How to use output from a script in Cacti Filed Under: Networks
Introduction
This is a quick tutorial explaining how to use the output from a script with input and output variables and create some graphs.
If you need any examples of how to write the actual script to use in cacti please drop some comments in this post and I will write it.
Get the script ready
First you will need to have an script that have the output in this kind of format:
something:{data} somethingelse:{data}
for example inOctets:121242 outOctets:23912123
Creating a data input
After the script is installed in the Cacti server we need to create a new data input method to let Cacti now where is the script and the parameters needed.
For this go to the Data Input Methods in the menu to your left and click on Add.
For Input type you need to select “Script/Command”
For Input String type the path to your script and specify the parameters that you need to input using <> for each parameter.
An example of this could be:
perl <path_cacti>/scripts/randomScript -h <hostname> -c <community>
In this example <path_cacti> is a recognised variable that point to the actual path where cacti is installed.
After that create in create and then fill the input and output fields.
Create a data source
After we have told cacti how to use the script we need to create now a data source so we can draw graphs later on.
So now go to Data sources in the menu and add a new one.
When you create the new data source the host part is used to point to which host (under devices) the data source belongs to.
After that, fill the appropriate fields. In the data input field select the data input we created before. The data sources part is relating to the output of the script that is going to be used to draw the graphs. In custom data input the data to pass to the script (this will be the data you will pass to the parameters you put between <>).
Create a graph
The last step now is to create the graph. To do this go to Graph Management and add a new one. If the data you are using has already a template you could use then select the appropriate template. If you cannot use any templates here are some tips on how to create the fields on the graph.
- Don’t forget to select the title of the graph and the vertical label
- Edit the lower and upper limit values appropiately
- After you save those items create the graph items. GRPRINT is used for the legend, LAST is the current value and AVERAGE is the average value
After the graph is created just add it to your graph tree if is not there and you are done.
Tags: cacti, graphs, output script, Perl
- Permalink
- Alberto Diaz
- 26 Jul 2008 9:53 AM
- Comments (1)
February 4th, 2014 at 14:14
SitId,BytesIn,BytesOut,BytesTotal,SLA,TimeStamp
14800001,9444766,1503521,10948287,2048_512,”2014-01-02 16:00:00″
14800001,8381526,2617620,10999146,2048_512,”2014-01-02 17:00:00″
14800001,4075591,1142685,5218276,2048_512,”2014-01-02 18:00:00″
14800001,13520049,4557420,18077469,2048_512,”2014-01-02 19:00:00″
14800001,28304445,5351989,33656434,2048_512,”2014-01-02 20:00:00″
14800002,4221533,465132,4686665,2048_512,”2014-01-02 21:00:00″
14800003,10285231,923910,11209141,2048_512,”2014-01-03 05:00:00″
14800001,10543785,2027684,12571469,2048_5