mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-26 10:58:12 +00:00
commit
11691dfd85
2 changed files with 91 additions and 36 deletions
51
plugins/network/fping_
Executable file
51
plugins/network/fping_
Executable file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Description : Plugin to monitor a server/network availability.
|
||||||
|
# Author : Thomas VIAL
|
||||||
|
# Author URL : http://tvi.al
|
||||||
|
# Usage : ln -s /path/to/fping_ /etc/munin/plugins/fping_www.google.com
|
||||||
|
# Explaination : Will graph connection to www.google.com
|
||||||
|
# Requirements :
|
||||||
|
# * fping
|
||||||
|
#
|
||||||
|
|
||||||
|
target=`basename $0 | sed 's/^fping_//g'`
|
||||||
|
item=`echo $target | sed -e 's/\.//g'`
|
||||||
|
|
||||||
|
#
|
||||||
|
# Config
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "$1" = "config" ]; then
|
||||||
|
echo "graph_title ${target} availability"
|
||||||
|
echo "graph_args --base 1000 -r -l 0 -u 100"
|
||||||
|
echo "graph_vlabel Availability in %"
|
||||||
|
echo "graph_category network"
|
||||||
|
echo "graph_info Displays Network Availability"
|
||||||
|
# Failure
|
||||||
|
echo "failure.label Unreachable"
|
||||||
|
echo "failure.draw AREA"
|
||||||
|
echo "failure.colour ff0000"
|
||||||
|
# Success
|
||||||
|
echo "success.label Reachable"
|
||||||
|
echo "success.draw STACK"
|
||||||
|
echo "success.colour 00CC00CC"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Let's go!
|
||||||
|
#
|
||||||
|
|
||||||
|
fping -q $target
|
||||||
|
status=$?
|
||||||
|
|
||||||
|
if [ $status -eq 0 ]; then
|
||||||
|
# Success
|
||||||
|
echo "success.value 100"
|
||||||
|
echo "failure.value 0"
|
||||||
|
else
|
||||||
|
# Failure
|
||||||
|
echo "success.value 0"
|
||||||
|
echo "failure.value 100"
|
||||||
|
fi
|
|
@ -82,21 +82,25 @@ if ((exists $ARGV[0]) && ($ARGV[0] eq "config")) {
|
||||||
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 $item = lc($hosts[$site-1]);
|
||||||
|
$item =~ s/\.//g;
|
||||||
my $host = $hosts[$site-1];
|
my $host = $hosts[$site-1];
|
||||||
my @ping = `$ping_cmd $ping_args $host $ping_args2`;
|
my @ping = `$ping_cmd $ping_args $host $ping_args2`;
|
||||||
chomp @ping;
|
chomp @ping;
|
||||||
my $ping = join(" ", @ping);
|
my $ping = join(" ", @ping);
|
||||||
print "site".$site.".value ".($1 / 1000)."\n" if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
|
print $item.".value ".($1 / 1000)."\n" if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
|
||||||
print "site".$site."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/);
|
print $item."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue