1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

- Fixed key that was based on $index and no unique name (when you changed a url, old stats were kept)

- Indentation changed to soft tabs
This commit is contained in:
Thomas VIAL 2013-08-20 10:33:34 +02:00
parent 9ec552e04e
commit 1dddd2fbc4

View file

@ -22,12 +22,12 @@
# #
# Parameters: # Parameters:
# #
# ping_args - Arguments to ping (default "-c 2 -w 1") # ping_args - Arguments to ping (default "-c 2 -w 1")
# ping_args2 - Arguments after the host name (required for Solaris) # ping_args2 - Arguments after the host name (required for Solaris)
# ping - Ping program to use # ping - Ping program to use
# hosts - List of comma-separated hosts to ping (IP address or FQDN) # hosts - List of comma-separated hosts to ping (IP address or FQDN)
# names - Friendly display name of each host given in the "hosts" parameter (comma-separated list). # names - Friendly display name of each host given in the "hosts" parameter (comma-separated list).
# If not set, "hosts" elements will be used # If not set, "hosts" elements will be used
# #
# Arguments for Solaris: # Arguments for Solaris:
# ping_args -s # ping_args -s
@ -58,45 +58,49 @@ my $ping_args = exists $ENV{ping_args} ? $ENV{ping_args} : '-c 2 -w 1';
my $ping_args2 = exists $ENV{ping_args2} ? $ENV{ping_args2} : ''; my $ping_args2 = exists $ENV{ping_args2} ? $ENV{ping_args2} : '';
if ($#hosts != $#names) { if ($#hosts != $#names) {
print "unequal amount of hosts and names\n"; print "unequal amount of hosts and names\n";
exit 1; exit 1;
} }
if ((exists $ARGV[0]) && ($ARGV[0] eq "autoconf")) { if ((exists $ARGV[0]) && ($ARGV[0] eq "autoconf")) {
my @ping = `$ping_cmd $ping_args $hosts[0] $ping_args2`; my @ping = `$ping_cmd $ping_args $hosts[0] $ping_args2`;
chomp @ping; chomp @ping;
my $ping = join(" ", @ping); my $ping = join(" ", @ping);
if ($ping =~ m@min/avg/max@) { if ($ping =~ m@min/avg/max@) {
print "yes\n"; print "yes\n";
exit 0; exit 0;
} else { } else {
print "no\n"; print "no\n";
exit 1; exit 1;
} }
} }
if ((exists $ARGV[0]) && ($ARGV[0] eq "config")) { if ((exists $ARGV[0]) && ($ARGV[0] eq "config")) {
print "graph_title Ping times\n"; print "graph_title Ping times\n";
print "graph_args --base 1000 -o\n"; print "graph_args --base 1000 -o\n";
print "graph_vlabel seconds\n"; print "graph_vlabel seconds\n";
print "graph_category network\n"; print "graph_category network\n";
print "graph_info This graph shows ping RTT statistics.\n"; print "graph_info This graph shows ping RTT statistics.\n";
for (my $site=1; $site<=$#hosts+1; $site++) { for (my $site=1; $site<=$#hosts+1; $site++) {
print "site$site.label $names[$site-1]\n"; my $item = lc($hosts[$site-1]);
print "site$site.info Ping RTT statistics for $hosts[$site-1].\n"; $item =~ s/\.//g;
print "site$site.draw LINE2\n"; print "$item.label $names[$site-1]\n";
print "site${site}_packetloss.label $names[$site-1] packet loss\n"; print "$item.info Ping RTT statistics for $hosts[$site-1].\n";
print "site${site}_packetloss.graph no\n"; print "$item.draw LINE2\n";
} print "${item}_packetloss.label $names[$site-1] packet loss\n";
print "${item}_packetloss.graph no\n";
}
exit 0; exit 0;
} }
for (my $site=1; $site<=$#hosts+1; $site++) { for (my $site=1; $site<=$#hosts+1; $site++) {
my $host = $hosts[$site-1]; my $item = lc($hosts[$site-1]);
my @ping = `$ping_cmd $ping_args $host $ping_args2`; $item =~ s/\.//g;
chomp @ping; my $host = $hosts[$site-1];
my $ping = join(" ", @ping); my @ping = `$ping_cmd $ping_args $host $ping_args2`;
print "site".$site.".value ".($1 / 1000)."\n" if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@); chomp @ping;
print "site".$site."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/); my $ping = join(" ", @ping);
print $item.".value ".($1 / 1000)."\n" if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
print $item."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/);
} }