Hi,
I'm completely new to both cacti and perl scripting and I'm currently trying out some basics with using scripts to expand cactis data gathering capabilities.
I have followed a howto guide to graph the output of the following script, which is working now. This script pings the host supplied as input and graphs the round trip time.
#!/usr/bin/perl
$ping = `ping -c 1 $ARGV[0] | grep icmp_seq`;
$ping =~ m/(.*time=)(.*) (ms|usec)/;
print $2;
The next step I'm trying is to make a very simple script which only returns a constant value and the goal is that cacti makes a flat, constant value graph. This is the script I have made:
#!/usr/bin/perl
$test = 200;
print $test;
I just want to confirm that this script should in theory do the job so I'll know if it's the script or the setup of all the templates and stuff in cacti that is wrong. Because all I'm getting in the graph overview is an emtpy graph.[/img]
Help with script basics
Moderators: Developers, Moderators
I'm still having trouble with getting Cacti to graph a constant value returned by a script. I have made some progress though with this script:
#!/usr/bin/perl
$k = $ARGV[0];
print $k;
It simply returns the value supplied as input, and with this script I get the flat graph I was looking for. The only thing I can think of myself is the format the return value has. I'm used to Integer, double, string etc. from java and not used to the idea of variables in perl. But I guess Cacti should understand it anyway if I define a variable as $number = 200;
Because what it seems to me is that Cacti only understands the variable it has supplied itself and not the ones I try to give it from the script.
#!/usr/bin/perl
$k = $ARGV[0];
print $k;
It simply returns the value supplied as input, and with this script I get the flat graph I was looking for. The only thing I can think of myself is the format the return value has. I'm used to Integer, double, string etc. from java and not used to the idea of variables in perl. But I guess Cacti should understand it anyway if I define a variable as $number = 200;
Because what it seems to me is that Cacti only understands the variable it has supplied itself and not the ones I try to give it from the script.
I have a site called http://www.cactiexchange.com. There are some tools to help with scripting. Also, I will soon be adding some basic info about running and creating external scripts.
-Stephen
-Stephen
www.cactiexchange.com -- Hosted Tools for the Cacti Community:
Cacti Perl Tool
Cacti XML Tool
Search OID-to-Names
[url=http://www.google.com/search?num=100&hl=en&safe=off&domains=forums.cacti.net&q=cacti&sitesearch=forums.cacti.net]Cacti Forums Google Index -- Better than the main page version![/url]
Cacti Perl Tool
Cacti XML Tool
Search OID-to-Names
[url=http://www.google.com/search?num=100&hl=en&safe=off&domains=forums.cacti.net&q=cacti&sitesearch=forums.cacti.net]Cacti Forums Google Index -- Better than the main page version![/url]
Who is online
Users browsing this forum: No registered users and 3 guests