Cacti (home)ForumsDocumentation

Externally Updated RRDs

Cacti itself provides a very flexible and fast data gatherer, but situations may occur, where this is not what you want. Assuming, that there already is some rrd file filled by other means, question arises how to use this with cacti's flexible rrdtool front-end administration facilities.

Sometimes people call this feature “Importing external rrds” to cacti. But what I'm going to explain is not an automated function. It will require some manual interaction.

Of course, the webserver must have at least read access to the required rrd file(s). For sake of easiness, I'll assume the file to be located in cacti's default ./rra/ directory. In my examples, this file is called example.rrd.

Get rrdtool info

First task is to get information about the data sources used in the rrd file. This is done using rrdtool info <rrd file>:

rrdtool info ./rra/external.rrd
filename = "/var/www/html/cacti/rra/external.rrd"
rrd_version = "0003"
step = 300
last_update = 1140957748
ds[external_ds1].type = "GAUGE"
ds[external_ds1].minimal_heartbeat = 600
ds[external_ds1].min = 0.0000000000e+00
ds[external_ds1].max = 5.0000000000e+02
ds[external_ds1].last_ds = "UNKN"
ds[external_ds1].value = 4.4510209500e+02
ds[external_ds1].unknown_sec = 0
ds[external_ds2].type = "GAUGE"
ds[external_ds2].minimal_heartbeat = 600
ds[external_ds2].min = 0.0000000000e+00
ds[external_ds2].max = 5.0000000000e+02
ds[external_ds2].last_ds = "UNKN"
ds[external_ds2].value = 7.4183682500e+02
ds[external_ds2].unknown_sec = 0
ds[external_ds3].type = "GAUGE"
ds[external_ds3].minimal_heartbeat = 600
ds[external_ds3].min = 0.0000000000e+00
ds[external_ds3].max = 5.0000000000e+02
ds[external_ds3].last_ds = "UNKN"
ds[external_ds3].value = 1.0385715550e+03
ds[external_ds3].unknown_sec = 0
rra[0].cf = "AVERAGE"
rra[0].rows = 600
rra[0].pdp_per_row = 1
(... more to follow ...)

From the ds[…..] statements, the names of the ds' are taken. In this case the data sources are named

  • external_ds1,
  • external_ds2,
  • external_ds3

respectively. While this is not that a meaningful name, it should show you the principles when dealing with multi-ds rrds. Alongside with this, it is good to know the ds[…].type, ds[…].min and ds[…].max for correct definition of the data sources. In this case, all data sources are of type GAUGE. This will not affect data gathering nor graphing, but to me it seems to be advantageous to create the correct data sources. All other paramaters (step, heartbeat, xff, rra[..].rows) are assumed to be standard settings.

Create the Data Template

The Data Template will tell cacti, how the data is stored within the rrd file. This is the way to tell cacti about all data sources and their properties. The purpose is twofold:

  • tell cacti, how to create the correct rrd file with all parameters
  • store the name of the data sources for later use with Graph Templates

While the first goal is not needed in this context, the second one is crucial. So lets define a new Data Template. Goto Data Templates and Add a new one:

dt-01

Fill in the usual header data:

dt-02

If you want to associate this to a certain host, you may use |host_description| as a placeholder as usual. As this external.rrd file is updated externally, you must set the Data Input Method to None. Select the Associated RRA's as they will define the Detailed Graph Views (usually Daily, Weekly, Monthly, Yearly). And you'll have to uncheck the Data Source Active checkbox. This will prevent cacti from actually gathering data for this Data Template. Now add the first Data Source:

dt-03

Internal Data Source NameYou must use the existing data source name of the rrd as retrieved in Chapter I. In this example, use external_ds1.
Minimum ValueFill in the ds[…].min value from rrdtool info above. In this case, use 0. This is not really needed, but for sake of consistency I recommend this.
Maximum ValueFill in the ds[…].max value from rrdtool info above. In this case, use 500. This is not really needed, but for sake of consistency I recommend this.
Data Source TypeFill in the ds[…].type value from rrdtool info above. In this case, use GAUGE. This is not really needed, but for sake of consistency I recommend this.
HeartbeatFill in the ds[…].minimal_heartbeat value from rrdtool info above. In this case, use 600. This is not really needed, but for sake of consistency I recommend this.

Now Create to see:

dt-04

Repeat this for all other data sources of the example.rrd (use the New function of Data Source Items):

dt-05

You will have noticed, that no Custom Data is given as defined by the Data Input Method set to NONE. You'll see the result as:

dt-06

That's it.

Create the Graph Template

The Graph template will tell cacti, what Data Sources should be shown on the Graph. This is very straightforward; simply use the Data Sources as defined in Chapter II and use all the Graph magic cacti provides. So Add a new Graph Template

gt-01

and fill in the usual header data:

gt-02

Now add the first Graph Item:

gt-03

and fill in the usual Data:

gt-04

Use the Legend Option as a time saver:

gt-05

And add all other Graph Items like that:

gt-06

gt-07

to end up in

gt-08

Of course you will use more meaningful input for Text Format. That's all for now.

Prepare the Host

Now its time for the Host to be prepared. You have the choice between two different approaches

  • the Host already exists (perhaps you're polling some other data from this host) and the status is up
  • the Host does not yet exist in cacti's tables and shall never been polled for other data by cacti's own poller

The first approach does not need any additional changes to the Devices list. The second approch will be more common. You will need a Host entry in the Devices list even for this host. So we will create kind of a dummy entry. Please goto the Devices list and Add a new one:

ho-01

Fill in Description and Name as usual. To deactivate all checks, please check Disable Host and leave SNMP Community empty.

ho-02

Create

ho-03

Please proceed to the next chapter now.

Creating the Data Sources

Usually, you would create the Data Sources and Graphs automagically using Create Graphs for this Host. But using this approach, cacti would enumerate and generate the needed rrd file(s) on its own. That's not wanted now. Our task is: make cacti generate all Data Sources stuff but accept our external.rrd file name. This is accomplished by adding the Data Sources manually from the Data Sources list. In this case, there's no difference whether you're going to use an already existing host or the kind of host we generated in the previous chapter.

ds-01

Now select the Data Template from above:

ds-02

and Create. You will be prompted to fill in the full path to your external.rrd file. If this resides in cacti's default ./rra directory, you may use <path_rra> for this. Remember, that the web server must have at least read access to that file.:

ds-03

The result is shown in the next image

ds-04

Create the new Graph

Let's create a new Graph from Graph Management now.

gm-01

Select the Selected Graph Template defined previously:

gm-02

and Create. Now select all needed Data Source […] and Save:

gm-03

The result is shown like:

gm-04

Please select this Graph again and Turn on Graph Debug Mode to see

gm-05






Personal Tools