Multiple output fields from a script

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
timcacti
Posts: 5
Joined: Wed Dec 17, 2003 11:25 pm

Multiple output fields from a script

Post by timcacti »

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.
User avatar
kwabbernoot
Cacti User
Posts: 99
Joined: Mon Oct 13, 2003 4:11 am
Location: Zottegem, Belgium

Multiple output fields

Post by kwabbernoot »

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:

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";
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:

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
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,
timcacti
Posts: 5
Joined: Wed Dec 17, 2003 11:25 pm

Post by timcacti »

Fantastic, finally someone with an answer to this one.

Thanks, this works wonders. I can now go and define tons of stuff for my graphs without creating a million separate Data Input Methods.

Finally, I almost gave up on Cacti!!
timcacti
Posts: 5
Joined: Wed Dec 17, 2003 11:25 pm

Well almost

Post by timcacti »

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.
User avatar
kwabbernoot
Cacti User
Posts: 99
Joined: Mon Oct 13, 2003 4:11 am
Location: Zottegem, Belgium

new output

Post by kwabbernoot »

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,
timcacti
Posts: 5
Joined: Wed Dec 17, 2003 11:25 pm

Post by timcacti »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests