Modified Ping routine compensating for micro seconds [Split]

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

Moderators: Developers, Moderators

Post Reply
mszarek
Posts: 3
Joined: Wed Feb 08, 2006 2:39 am

How to ged rid of unit letters?

Post by mszarek »

Hi,

First of all I want to admin that I didn't check all archives to find answer regarding my question. Forgive me that - I just don't have enough time for playing with Cacti and forums.

I have found post http://forums.cacti.net/about8168.html explaining the meaning of letters next to values on graphs.
But tell me please if one can get rid of this letters and force Cacti to display more "reader friendly" values in form of: 0.234 (instead of 234 m).
I would like to get such markings for example in my ping latency graphs.

Thank you in advance for any kind of help!

Greetings
**** MARCIN SZAREK <mszarek@cutthisout.gmail.com> ****
** There are only 10 types of people in this world; **
** those who understand binary and those who don't. **
User avatar
N3NCY
Cacti User
Posts: 260
Joined: Thu Sep 22, 2005 7:50 pm
Location: Landenberg, PA
Contact:

Post by N3NCY »

I don't know how to make is get rid of the letters either.
PINGs under one (1) msec never displayed correctly for me.
I made my ping script always round up to 1 if less than 1ms
Example:
.407us becomes 1ms
I don't care about microseconds, milliseconds is close enough for me!

Here is what my UNIX - Ping Host: cacti/scripts/ping.pl looks like now:

Code: Select all

#!/usr/bin/perl 

open(PROCESS, "ping -c 1 $ARGV[0] | grep icmp_seq |");
$ping = <PROCESS>;
close(PROCESS);
$ping =~ m/(.*time=)(.*) (ms|usec)/; 

$output = $2;
chop ($output);
chop ($output);
chop ($output);
chop ($output);

if ( $output =~ 0 ) { $output = $output + 1 };

print $output;
Attachments
A chart that now shows a 1ms average on this very close (extreme low PING) device instead of .012u - Looks nicer and makes more sense (to me anyway).
A chart that now shows a 1ms average on this very close (extreme low PING) device instead of .012u - Looks nicer and makes more sense (to me anyway).
PING-chart.gif (8.21 KiB) Viewed 6701 times
Thank you,

Ernie
http://www.NMSWorld.com
[b]Dual Zeon Dual Core 2.6Ghz / 8GB RAM / 4x15k RPM SATA RAID5[/b]
[b]Cacti Version[/b] - 0.8.7b
[b]Poller Type[/b] - cactid 0.8.7 with Boost v1.7
[b]Server Info[/b] - FreeBSD 7.0-RELEASE
[b]Web Server[/b] - Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8g DAV/2 PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8
[b]PHP[/b] - 5.2.6
[b]MySQL[/b] - 5.0.51b Mod: poller_output ENGINE = MEMORY
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.4.1
[b]Plugins[/b] - Host Info (hostinfo - v0.2), Update Checker (update - v0.3), Network Tools (tools - v0.2), FlowView (flowview - v0.3), Read-only Devices Tab (devices - v0.4), Network Discovery (discovery - v0.8.3), Syslog Monitoring (syslog - v0.5.2), Thresholds (thold - v0.3.9), Device Monitoring (monitor - v0.8.2), PHP Network Weathermap (weathermap - v0.941), SuperLinks (superlinks - v0.72), Report Creator (reports - v0.1b)
tgk
Posts: 28
Joined: Sat Mar 11, 2006 10:46 pm

Get rid of letters

Post by tgk »

To get rid of the letters (milli, Kilo, etc), just create a new GPRINT (Graph Management/GPRINT Presets), that looks like this:

Code: Select all

%8.2lf
(without the final %s that the "Normal" preset has)

... and then just apply that preset to your labels in the Graph Template.
Yesser
Posts: 5
Joined: Tue Mar 14, 2006 2:23 pm

I need help

Post by Yesser »

Hi:
I have a doubt about the meaning of some results.
How can I interpret the result of a chart about errors and discards in a router's interface?
Is something like this:

Errors in Current: 0.00 Averange: 545.88 u Maximum: 94.0 m
Discards out Current: 9.33 m Averange: 2.30 m Maximum: 236.0 m

I hope you can help me...
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

Using a GPRINT preset to remove the letters works fine for the legend - but is there any way of disabling it for the Y-axis value? I've got a load average graph where I'd like the axis display to be prevented from turning into 500m - 750m, and displayed as 0.5 to 0.75.
new-to-linux
Posts: 9
Joined: Thu Jun 29, 2006 2:03 pm

Thanks N3NCY works great except for one small problem

Post by new-to-linux »

Thanks N3NCY

I added you code which work great for devices under 1 millisecond but for the normal Wan devices they stopped graphing. Any ideas.

Once again thanks for your help
User avatar
N3NCY
Cacti User
Posts: 260
Joined: Thu Sep 22, 2005 7:50 pm
Location: Landenberg, PA
Contact:

Post by N3NCY »

Try running the script from the command line like:
./ping.pl devicename
or
./ping.pl WANipAddress

Show me the output.

You may need to make your script executable via
chmod +x ping.pl
Thank you,

Ernie
http://www.NMSWorld.com
[b]Dual Zeon Dual Core 2.6Ghz / 8GB RAM / 4x15k RPM SATA RAID5[/b]
[b]Cacti Version[/b] - 0.8.7b
[b]Poller Type[/b] - cactid 0.8.7 with Boost v1.7
[b]Server Info[/b] - FreeBSD 7.0-RELEASE
[b]Web Server[/b] - Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8g DAV/2 PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8
[b]PHP[/b] - 5.2.6
[b]MySQL[/b] - 5.0.51b Mod: poller_output ENGINE = MEMORY
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.4.1
[b]Plugins[/b] - Host Info (hostinfo - v0.2), Update Checker (update - v0.3), Network Tools (tools - v0.2), FlowView (flowview - v0.3), Read-only Devices Tab (devices - v0.4), Network Discovery (discovery - v0.8.3), Syslog Monitoring (syslog - v0.5.2), Thresholds (thold - v0.3.9), Device Monitoring (monitor - v0.8.2), PHP Network Weathermap (weathermap - v0.941), SuperLinks (superlinks - v0.72), Report Creator (reports - v0.1b)
new-to-linux
Posts: 9
Joined: Thu Jun 29, 2006 2:03 pm

command line results

Post by new-to-linux »

Hi N3NCY

I tried this with no luck. I made ping.pl executable via command line and ran it but it does not show me the results it just goes back to the shell line.

Sorry I could not work out how to paste a picture into post.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

This is not a discussion to have on a sticky thread.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
pdestefanis
Posts: 9
Joined: Tue Dec 19, 2006 11:39 am

Post by pdestefanis »

That script won't work if you need to graph host that are about 1ms and below 1ms.
The problem lays in that you remove the last four characters, and in some cases ping will return something like "3.78" (meaning miliseconds) and thus you'll end up with an empty return string.

You can change it to:

#!/usr/bin/perl

open(PROCESS, "ping -c 1 $ARGV[0] | grep icmp_seq |");
$ping = <PROCESS>;
close(PROCESS);
$ping =~ m/(.*time=)(.*) (ms|usec)/;

$output = $2;

if ( $output =~ 0 ) { $output = $output + 1 };

print $output;

Wich is not a nice hack, since all it does is adding 1ms when the RTT is < 1ms. Horrible as it is, it will work with both.

A nicer approach will be to check if the first digit is 0 (as in 0.234 ms) and the how many digits you have after your decimal, and get rid of those and add 1... I don't have the time, though)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest