Cacti and rrdtool

Cacti is a great tool. I use it for collecting and graphing all kinds of data about my servers and networks. But after using it for so many years, I’ve learned its weaknesses. It is quite easy to make a mistake setting up Cacti that you later come to regret – and cannot fix. Before using Cacti to graph real data, you need to understand how it works.

This is the first in a series of related blog posts about Cacti.

Underneath the pretty pretty wrapper, Cacti uses rrdtool to store and graph data. If you really want to understand rrdtool itself, read the tutorial and man pages. In a nutshell, rrdtool stores data in round-robin archives, and can output that data in graphical form.

Cacti uses rrdtool for three things. It:

  1. Creates data sources by using “rrdtool create” to create a new RRD file.
  2. Stores collected data by using the “rrdtool update” command to add new data rows to round-robin archives in RRD files.
  3. Graphs collected data by using the “rrdtool graph” command to generate a PNG file and display it to the user.

You can see these steps in Cacti. Under “Management” -> “Graph Management”, select a graph. Then click on “Turn on graph debug mode” to see the exact rrdtool command line Cacti will use to output a graph to the user.

Likewise, you can “Turn on data source debug mode” to see the command Cacti uses to update data sources. To see how a data source is created, set Cacti logging to “debug” before creating it. The output will appear in the Cacti log.

The first thing to do when debugging a “Why isn’t my graph appearing”* problem is to try the above steps. If an error message wasn’t printed with the debug output, try to paste the command line into the terminal as the Cacti user. This is usually Apache’s user, such as “www-data” on Debian.

* Safety tip for new users: be patient. It takes at least two polling cycles (2 or 10 minutes, depending on your setup) before most graphs appear in Cacti.

On Debian or Ubuntu systems, Cacti stores RRD files in /var/lib/cacti/rrd/. You can run manual rrdtool commands here to examine the RRD structure (rrdtool info), to dump the raw data (rrdtool dump) or graph it (rrdtool graph).

Tags: ,

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">