Windows Ping Script!

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

Moderators: Moderators, Developers

Author
Message
Misora
Posts: 7
Joined: Thu Jul 14, 2005 2:35 pm

Windows Ping Script!

#1 Post by Misora » Fri Jul 15, 2005 3:57 am

Several people seem to be looking for a windows ping script so I finally have written one. Actually, I just started using cacti yesterday and stayed up a large portion of last night getting it to work. At about 4 am I decided to write a windows ping script and finished it up the latter part of today, there were some things I had to work out.

Details: It uses tping (a windows application) to send out 6 pings, which time out after 400 ms (you're welcome to change these values in the script). It returns average rtt within two decimal points of accuracy. It also returns packet loss and uses a slight modification of the graph from this thread: http://forums.cacti.net/viewtopic.php?t=6900

Tping can be found here (if you're interested, I already included it in the zip): http://sourceforge.net/projects/tping/
If you did download tping, I can only promise that version 1.11 will parse correctly.

This has only been tested on cacti 0.8.6f, and needs the patch from this thread for the php script server: http://forums.cacti.net/viewtopic.php?t=8494

Install Instructions:

1. Open the tping.zip archive, unzip the php file into [Cacti Directory]\scripts.
2. Unzip tping.exe into c:\windows (or your windows directory).
3. Make sure your files have been pached for the script server bug.
4. Import the xml into cacti.
5. Choose any device and add the 'Network - Ping' graph. You can choose a hostname or ip address at this point.
6. Wait two cycles (600 seconds) for the graph to update.
7. Yay, you're done.
Attachments
tping.zip
(27.91 KiB) Downloaded 8541 times
cacti_graph_template_network_ping.xml
(21.94 KiB) Downloaded 8063 times

Misora
Posts: 7
Joined: Thu Jul 14, 2005 2:35 pm

#2 Post by Misora » Fri Jul 15, 2005 4:00 am

Example Picture.
Attachments
googleping.png
Ping times to google after a short bit of testing.
googleping.png (25.51 KiB) Viewed 74548 times

georger_br
Cacti User
Posts: 63
Joined: Mon Jul 04, 2005 10:12 am
Location: Brazil

Re: Windows Ping Script!

#3 Post by georger_br » Fri Jul 15, 2005 6:43 am

Misora, fantastic work! I just tried it on my Apache 1.3.27/PHP 4.3.11/MySQL 4.1.11/Cacti 0.8.6f + script server patch Windows 2000 server and it works great!
Just in case somebody doesn't know what patch needs to be applied, please refer to the following topic:
http://forums.cacti.net/viewtopic.php?p=37099

Georger
Misora wrote:Several people seem to be looking for a windows ping script so I finally have written one. Actually, I just started using cacti yesterday and stayed up a large portion of last night getting it to work. At about 4 am I decided to write a windows ping script and finished it up the latter part of today, there were some things I had to work out.

Details: It uses tping (a windows application) to send out 6 pings, which time out after 400 ms (you're welcome to change these values in the script). It returns average rtt within two decimal points of accuracy. It also returns packet loss and uses a slight modification of the graph from this thread: http://forums.cacti.net/viewtopic.php?t=6900

Tping can be found here (if you're interested, I already included it in the zip): http://sourceforge.net/projects/tping/
If you did download tping, I can only promise that version 1.11 will parse correctly.

This has only been tested on cacti 0.8.6f, and needs the patch from this thread for the php script server: http://forums.cacti.net/viewtopic.php?t=8494

Install Instructions:

1. Open the tping.zip archive, unzip the php file into [Cacti Directory]\scripts.
2. Unzip tping.exe into c:\windows (or your windows directory).
3. Make sure your files have been pached for the script server bug.
4. Import the xml into cacti.
5. Choose any device and add the 'Network - Ping' graph. You can choose a hostname or ip address at this point.
6. Wait two cycles (600 seconds) for the graph to update.
7. Yay, you're done.

flipflap
Cacti User
Posts: 142
Joined: Sat Jul 09, 2005 3:13 pm

#4 Post by flipflap » Fri Jul 15, 2005 7:11 am

guys i just did all that but can't get any graph. i ran it manually this is what i get.

C:\Inetpub\wwwroot\cacti\scripts>php ss_tping.php ss_tping 4.2.2.2
Windows Socket Unable to Resolve Host ss_tping
AV: PL:

i got a winnt box | cacti 8.6f | cactid 8.6e | php504 | rrdtool 1049 | mysql4112a

georger_br
Cacti User
Posts: 63
Joined: Mon Jul 04, 2005 10:12 am
Location: Brazil

#5 Post by georger_br » Fri Jul 15, 2005 7:32 am

This is not how it's supposed to be used - that PHP file belogs in the /scripts directory, and tping.exe should go to, say, C:\WINNT\SYSTEM32. You should also allow the poller script to run twice in order to get some data. By the way, why are you using Cactid? Many hosts? I use cmd.php and it works just fine.
Do EXACTLY as Misora instructs and all should be fine. Regards,

Georger
flipflap wrote:guys i just did all that but can't get any graph. i ran it manually this is what i get.

C:\Inetpub\wwwroot\cacti\scripts>php ss_tping.php ss_tping 4.2.2.2
Windows Socket Unable to Resolve Host ss_tping
AV: PL:

i got a winnt box | cacti 8.6f | cactid 8.6e | php504 | rrdtool 1049 | mysql4112a

flipflap
Cacti User
Posts: 142
Joined: Sat Jul 09, 2005 3:13 pm

#6 Post by flipflap » Fri Jul 15, 2005 7:48 am

the php script is in the cacti scripts directory also tping is in the WINNT directory. that's the problem i just did exactly what he said but can't get any graphs. this is killing me need help badly. maybe i'm jinxed :(. BTW i use cmp.php i just installed cactid as an alternate poller just in case. HELP!!!!

flipflap
Cacti User
Posts: 142
Joined: Sat Jul 09, 2005 3:13 pm

#7 Post by flipflap » Fri Jul 15, 2005 7:49 am

i got this on the input string

<path_cacti>/scripts/ss_tping.php ss_tping <hostname>

is that correct?

georger_br
Cacti User
Posts: 63
Joined: Mon Jul 04, 2005 10:12 am
Location: Brazil

#8 Post by georger_br » Fri Jul 15, 2005 8:28 am

Yes, it is.
How did you create your graph? After installing tping, the script server fix and graph template, I created mine like this:

1. Click Devices. Click the device for which you want to create the ping graph.
2. Click Create Graphs for this Host.
3. On Graph Templates, pick Network - Ping and click the "create" button.
4. On the Legend Text field, type some description, e.g. "ADSL Router". On the Hostname / IP field, type the IP address of your device, e.g. "192.168.1.254". It goes without saying that you shouldn't use quotes when filling the fields. Click the "create" button.
5. Click Graph Management - your graph should be there. Click it - it probably doesn't contain a graph yet, but after two polls it will. Be patient.

Hope this helps. Regards,

Georger
flipflap wrote:i got this on the input string

<path_cacti>/scripts/ss_tping.php ss_tping <hostname>

is that correct?

flipflap
Cacti User
Posts: 142
Joined: Sat Jul 09, 2005 3:13 pm

#9 Post by flipflap » Fri Jul 15, 2005 8:38 am

got it working now. just deleted the network-ping data query or something and installed it again. thanks for the great tool

Who's your momma now?!?!?!?! or daddy!!??? :wink:

georger_br
Cacti User
Posts: 63
Joined: Mon Jul 04, 2005 10:12 am
Location: Brazil

#10 Post by georger_br » Fri Jul 15, 2005 9:35 am

What kind of question is that? I was trying to help you.
I explained in such great detail because, looking at your previous posts, you look like a novice in LAMP applications. Furthermore, I'm not trying to help you exclusively - many other people will read this topic and at least one of them will save some time following my advice.

Georger
flipflap wrote:got it working now. just deleted the network-ping data query or something and installed it again. thanks for the great tool

Who's your momma now?!?!?!?! or daddy!!??? :wink:

flipflap
Cacti User
Posts: 142
Joined: Sat Jul 09, 2005 3:13 pm

#11 Post by flipflap » Fri Jul 15, 2005 9:53 am

hey i meant that as a complement to you and the guys who did this script. like saying you're the man. i meant no disrespect. sorry if you interpret things that way :( .

ok to be more direct. thanks you for taking some time off to help a novice guy like me. hope that helps :D

fas73
Posts: 5
Joined: Fri Jul 15, 2005 6:35 am

#12 Post by fas73 » Fri Jul 15, 2005 12:55 pm

Misora,

Thanks for a great addon. I've tested it on some long-delay (satellite) links and I noticed that I always got a yellow color on the graph for the first ping to be lost or so (?). To avoid this adjusted the default 400ms timeout to 1000ms, but then I think i ran into some problems with my overall graphing. My question is, since we're pushing out 6 pings, what happens let's say when this long-delay link is down? Do we need to wait for 6 x timeout? Could the 6 pings have been pushed out simultaneously instead? Maybe with smaller packets? Well.. I guess this is maybe up to me to tune in but I was just curious to know if you had any considerations about this.

Thanks,

Misora
Posts: 7
Joined: Thu Jul 14, 2005 2:35 pm

#13 Post by Misora » Fri Jul 15, 2005 3:46 pm

You can take a look at the tping options if you wish to change them. The php script is rather easy to change...

You'll see this in the script:

Code: Select all

$output = shell_exec("tping.exe -n 6 -l 64 -w 400 " . $target);
This is using the default delay. Tping does not have a preloading option like linux, however you can set something like...

Code: Select all

$output = shell_exec("tping.exe -n 7 -l 64 -d 0 -z 1 -w 400 " . $target);
This will set delay between pings to 0. It will send out 7 pings total at 64 bytes. Also, it will ignore the first ping in the calculation and will wait 400 ms for time-out.

Hopefully this helps,
Misora

skuzbucket
Posts: 16
Joined: Thu Jul 14, 2005 8:55 am

???

#14 Post by skuzbucket » Mon Jul 18, 2005 10:17 am

getting this error even after following all your directions:

ERROR: Not enough arguments

Ideas?

jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

#15 Post by jas0420 » Mon Jul 18, 2005 8:15 pm

Great stuff Misora... Worked like a champ. Thanks for sharing!

Jason

Post Reply