Multiple output fields from a script
Moderators: Developers, Moderators
Multiple output fields from a script
What is the correct way for a perl script to return multiple output fields? I've successfully created a Data Input Method with a SINGLE output field and was able to use that in a Data Source and Graph. However whenever I try to add another output field neither show up properly on the graph. Or rather they just show with no values. I can't seem to figure out how to debug what I'm doing wrong.
- kwabbernoot
- Cacti User
- Posts: 99
- Joined: Mon Oct 13, 2003 4:11 am
- Location: Zottegem, Belgium
Multiple output fields
Hi,
You have to make sure that your output is generated in a way that cacti can compare your output to the info created in the "Output Fields" of the "Data Input Methods". Maybe the easiest is to explain it using an example.
I use the Nagios agent and plugins to retrieve information from my Win2K machines. The check is performed by a perl script that generates output. In this example I check the number of anonymous and non-anonymous users of the IIS server.
The perl script:
This script generates output like e.g. "iis_anony:10 iis_nanony:2" (without quotes)
Now the Data Input Method for this script looks like:
This way cacti knows that the output of the script points to the output field "iis_anony", the info after ":" and that the output field "iis_nanony", to the info after ":" of the output iis_nanony.
Hope this helps,
You have to make sure that your output is generated in a way that cacti can compare your output to the info created in the "Output Fields" of the "Data Input Methods". Maybe the easiest is to explain it using an example.
I use the Nagios agent and plugins to retrieve information from my Win2K machines. The check is performed by a perl script that generates output. In this example I check the number of anonymous and non-anonymous users of the IIS server.
The perl script:
Code: Select all
#!/usr/bin/perl
$anony = `/usr/lib/nagios/plugins/check_nt -H $ARGV[0] -p 20000 -v COUNTER -l "\\Web Service(_Total)\\Current Anonymous Users"`;
chomp $anony;
$non_anony = `/usr/lib/nagios/plugins/check_nt -H $ARGV[0] -p 20000 -v COUNTER -l "\\Web Service(_Total)\\Current NonAnonymous Users"`;
chomp $non_anony;
print "iis_anony:$anony iis_nanony:$non_anony\n";
Now the Data Input Method for this script looks like:
Code: Select all
Name: MS Win - IIS Users
Input Type: Script/Command
Input string: perl <path_cacti>/scripts/check_nt_iis_users.pl <ip>
Input Fields
Name: ip (in detail this points to the cacti hostname)
Output Fields
Name: iis_anony
Friendly Name: Anonymous Users
Update RRA: Selected
Name: iis_nanony
Friendly Name: Non Anonymous Users
Update RRA: Selected
Hope this helps,
Well almost
Well, seems it worked fine for 2 variables but when I tried to add a 3rd it didn't work. So looks to be back to the drawing board.
Although I didn't seem to find any errors I found that the rrd file just did not contain the new variable. I used "rrdtool info" to look at the rdd file and it had no clue about the new variable.
I'll mess around a bit more but seems this might be the breaking point for Cacti.
Although I didn't seem to find any errors I found that the rrd file just did not contain the new variable. I used "rrdtool info" to look at the rdd file and it had no clue about the new variable.
I'll mess around a bit more but seems this might be the breaking point for Cacti.
- kwabbernoot
- Cacti User
- Posts: 99
- Joined: Mon Oct 13, 2003 4:11 am
- Location: Zottegem, Belgium
new output
Hi,
If you alter the data input method and modify your graph and data source you have to delete the old source and graph and recreate them. They will not update to the new data source by themself.
I have data inputs of 4 and even more and they all work fine.
Also verify that your Data Template points to the correct Data Input Method value.
Regards,
If you alter the data input method and modify your graph and data source you have to delete the old source and graph and recreate them. They will not update to the new data source by themself.
I have data inputs of 4 and even more and they all work fine.
Also verify that your Data Template points to the correct Data Input Method value.
Regards,
Actually I found that updates made through the Cacti web reference often do not get reflected in the .rrd file. So what I do now is delete the .rrd file just before making any changes to a data source. I believe it then creates the .rrd file on the next processing run.
Applying this method allowed me to add as many data outputs as I wanted.
Applying this method allowed me to add as many data outputs as I wanted.
Who is online
Users browsing this forum: No registered users and 1 guest