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.
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.cf = "AVERAGE" rra.rows = 600 rra.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
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.
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:
Fill in the usual header data:
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:
|Internal Data Source Name||You must use the existing data source name of the rrd as retrieved in Chapter I. In this example, use external_ds1.|
|Minimum Value||Fill 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 Value||Fill 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 Type||Fill 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.|
|Heartbeat||Fill 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:
Repeat this for all other data sources of the example.rrd (use the New function of Data Source Items):
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:
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
and fill in the usual header data:
Now add the first Graph Item:
and fill in the usual Data:
Use the Legend Option as a time saver:
And add all other Graph Items like that:
to end up in
Of course you will use more meaningful input for Text Format. That's all for now.
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:
Fill in Description and Name as usual. To deactivate all checks, please check Disable Host and leave SNMP Community empty.
Please proceed to the next chapter now.
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.
Now select the Data Template from above:
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.:
The result is shown in the next image
Let's create a new Graph from Graph Management now.
Select the Selected Graph Template defined previously:
and Create. Now select all needed Data Source […] and Save:
The result is shown like:
Please select this Graph again and Turn on Graph Debug Mode to see