|
|
| Author |
Message |
orjanb314
Joined: 01 Aug 2008 Posts: 6
|
Posted: Fri Aug 01, 2008 7:55 am Post subject: Help with script basics |
|
|
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] |
|
| Back to top |
|
 |
kramsay
Joined: 21 Jan 2005 Posts: 14
|
Posted: Sat Aug 02, 2008 3:57 pm Post subject: |
|
|
Your script can be tested from the command line using
#/usr/bin/perl "your_script_name"
Your script is fine. If you are getting an empty graph there is lots of help on this forum. Just search "empty graphs" |
|
| Back to top |
|
 |
orjanb314
Joined: 01 Aug 2008 Posts: 6
|
Posted: Wed Aug 06, 2008 2:22 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12186 Location: Muenster, Germany
|
Posted: Mon Aug 11, 2008 1:46 pm Post subject: |
|
|
Please see 1st link of my sig for help
Reinhard |
|
| Back to top |
|
 |
shull Cacti User
Joined: 24 Aug 2006 Posts: 54 Location: South Texas
|
Posted: Wed Aug 13, 2008 11:23 am Post subject: |
|
|
I have a site called 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 |
|
| Back to top |
|
 |
|