ping RTT and packet loss script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

kurowsky
Cacti User
Posts: 52
Joined: Wed Feb 04, 2004 4:43 pm
Location: Richmond, VA.

Post by kurowsky »

Yeah, I didn't really explain my problem well.
When I run the script manually it works perfectly.

I created a data input method, which all seems correct:
-script/command
-correct path: perl <path_cacti>/scripts/rtt.pl <count> <host>
- two input fields: count and host
-four output fields: min, avg, max and loss

My data template seems correct:
-data input method is correct
-have four data source items corresponding to the above output fields

I believe my graph template is correct too.
I applied the graph template to the host template (cisco router)

I create the graph, and after five minutes debug says it's okay but no data is being displayed (-1.#J) which I know is okay at first.
Wait 10 to 15 minutes and still nothing.
So I checked the rra file and the rrd for this item has been created but not updated.

It's the only one out of 504 that is not being updated.
I don't understand what I may be missing. It should be getting updated even if I'm sending wrong data or no data.( I think )

It is the only script that I'm running though.

Does that help?
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

maybe you can try to run php.exe c:\inetpub\wwwroot\cacti\cmd.php at the dos command so you can see what values the script is returning. If it says:

Code: Select all

MULTI command: perl c:\apache\htdocs\cacti/scripts/pingavg.pl 195.130.130.4 2, output: min:93 avg:138 max:183 loss:0
MULTI expansion: found fieldid: 37, found rrdname: min, value: 93
MULTI expansion: found fieldid: 38, found rrdname: avg, value: 138
MULTI expansion: found fieldid: 39, found rrdname: max, value: 183
MULTI expansion: found fieldid: 40, found rrdname: loss, value: 0
update c:\Apache\htdocs\cacti/rra/localhost_loss_20.rrd --template min:avg:max:loss N:93:138:183:0
you know the problem must be at the graph template or something else

Maybe try: rrdtool fetch yourdb.rdd AVERAGE and see the output
fhelsley
Posts: 3
Joined: Wed Feb 25, 2004 12:46 pm
Location: Austin, TX

Redhat 9 / Perl script

Post by fhelsley »

what I cannot figure out is that on Redhat 9 the last line of ping stats are in the form of:

4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 0.442/0.450/0.467/0.018 ms

This causes NONE of the scripts to work, since looking for a value next to min, avg, etc.. does not produce any results. The loss works because it is next to the percent sign...

Am I missing something?
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

you have to change the regular expression to look for the slashes /
starkie

Post by starkie »

Their seems to be a few windows scripts here. I can get mine to work when I run it via comamnd line, but i cant get it to graph??

How do I do it??

#!/usr/bin/perl

$host = $ARGV[1];
$pingcount = $ARGV[0];

$ping = `ping -n $pingcount $host`;

# starts some variables

$min;
$max;
$avg;
$loss;

# check for the minimum value

$ping =~ /Minimum = (\d*)/;
$min = $1;

# check for the maximum value

$ping =~ /Maximum = (.*)ms,/;
$max = $1;

# check for the average value

$ping =~ /(Averag|Gemiddeld)e = (.*)ms/;
$avg = $2;

# check for the % sign inside parens and grab it's value
$ping =~ /(\d*)%/;
$loss = $1;

#print the values
print "min:$min avg:$avg";
boots
Cacti User
Posts: 55
Joined: Wed Jan 07, 2004 4:59 am
Location: Melbourne Australia

Post by boots »

Could someone post their working copy of the script and any templates known to work on Windows?

That would be greatly appreciated!!!!
Guest

Post by Guest »

ThyReX wrote:Here is the one i use:
.....
use it like your script: latence.pl <count> <host>
and it return somethink like:

Code: Select all

min:10.766 avg:17.067 max:60.479 dev:14.497 loss:0
....
thx to my friend TiChou for helping :)
Hi. I want to make this skript work, so when I run at console i see it working. But i read some howto's and do not understand some things ^(. Can someone tell me please what should i do step by step to run any script i wrote on this example with ping?

Thank you!
Altex

Post by Altex »

P.S.sorry, it was my last post

I can add new method in "Data Input Methods" with my own script or this one. But i see it is not enough. Is it possible to make new graph with this script (or any script) without adding new query in "Data Queries"?
Altex

Please help?

Post by Altex »

Please help me? I can easily write my own script but i can't make it work with cacti, because i do not well understand that to do exactly. Can you show me just one example?

Thank you, i hope you find some minutes to tell me or just give me a link to another article.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests