From 1dddd2fbc402baa697de907f77518ca5e357059d Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Tue, 20 Aug 2013 10:33:34 +0200 Subject: [PATCH 1/5] - 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 --- plugins/network/multiping | 76 ++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/plugins/network/multiping b/plugins/network/multiping index f5de8a7c..1fb56458 100755 --- a/plugins/network/multiping +++ b/plugins/network/multiping @@ -22,12 +22,12 @@ # # Parameters: # -# ping_args - Arguments to ping (default "-c 2 -w 1") -# ping_args2 - Arguments after the host name (required for Solaris) -# ping - Ping program to use -# 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). -# If not set, "hosts" elements will be used +# ping_args - Arguments to ping (default "-c 2 -w 1") +# ping_args2 - Arguments after the host name (required for Solaris) +# ping - Ping program to use +# 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). +# If not set, "hosts" elements will be used # # Arguments for Solaris: # 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} : ''; if ($#hosts != $#names) { - print "unequal amount of hosts and names\n"; - exit 1; + print "unequal amount of hosts and names\n"; + exit 1; } if ((exists $ARGV[0]) && ($ARGV[0] eq "autoconf")) { - my @ping = `$ping_cmd $ping_args $hosts[0] $ping_args2`; - chomp @ping; - my $ping = join(" ", @ping); - if ($ping =~ m@min/avg/max@) { - print "yes\n"; - exit 0; - } else { - print "no\n"; - exit 1; - } + my @ping = `$ping_cmd $ping_args $hosts[0] $ping_args2`; + chomp @ping; + my $ping = join(" ", @ping); + if ($ping =~ m@min/avg/max@) { + print "yes\n"; + exit 0; + } else { + print "no\n"; + exit 1; + } } if ((exists $ARGV[0]) && ($ARGV[0] eq "config")) { - print "graph_title Ping times\n"; - print "graph_args --base 1000 -o\n"; - print "graph_vlabel seconds\n"; - print "graph_category network\n"; - print "graph_info This graph shows ping RTT statistics.\n"; - for (my $site=1; $site<=$#hosts+1; $site++) { - print "site$site.label $names[$site-1]\n"; - print "site$site.info Ping RTT statistics for $hosts[$site-1].\n"; - print "site$site.draw LINE2\n"; - print "site${site}_packetloss.label $names[$site-1] packet loss\n"; - print "site${site}_packetloss.graph no\n"; - } + print "graph_title Ping times\n"; + print "graph_args --base 1000 -o\n"; + print "graph_vlabel seconds\n"; + print "graph_category network\n"; + print "graph_info This graph shows ping RTT statistics.\n"; + for (my $site=1; $site<=$#hosts+1; $site++) { + my $item = lc($hosts[$site-1]); + $item =~ s/\.//g; + print "$item.label $names[$site-1]\n"; + print "$item.info Ping RTT statistics for $hosts[$site-1].\n"; + print "$item.draw LINE2\n"; + print "${item}_packetloss.label $names[$site-1] packet loss\n"; + print "${item}_packetloss.graph no\n"; + } exit 0; } for (my $site=1; $site<=$#hosts+1; $site++) { - my $host = $hosts[$site-1]; - my @ping = `$ping_cmd $ping_args $host $ping_args2`; - chomp @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 "site".$site."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/); + my $item = lc($hosts[$site-1]); + $item =~ s/\.//g; + my $host = $hosts[$site-1]; + my @ping = `$ping_cmd $ping_args $host $ping_args2`; + chomp @ping; + 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/); } From 12d632ca62870ee3ea11a72b17cd8d9f88c576cd Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Tue, 20 Aug 2013 21:31:15 +0200 Subject: [PATCH 2/5] fping_ => Added file to monitor server/network availability --- plugins/network/fping_ | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 plugins/network/fping_ diff --git a/plugins/network/fping_ b/plugins/network/fping_ new file mode 100755 index 00000000..6fa39a56 --- /dev/null +++ b/plugins/network/fping_ @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Plugin to monitor a server/network availability. +# Author: Thomas VIAL +# +# Requirements: +# * fping +# + +target=`basename $0 | sed 's/^fping_//g'` +#target='dev.instalbu.ms' +#target='127.0.0.1' + +if [ "$1" = "config" ]; then + echo "graph_title ${target} availability" + echo "graph_args --upper-limit 100" + echo "graph_vlabel Availability" + echo "graph_category network" + # Success + echo "fping_${target}_success.label Reachable" + echo "fping_${target}_success.type GAUGE" + echo "fping_${target}_success.color 00CC00CC" + # Failure + echo "fping_${target}_failure.label Unreachable" + echo "fping_${target}_failure.type AREA" + echo "fping_${target}_failure.color ff0000" + exit 0 +fi + + + +fping -q $target +status=$? + +if [ $status -eq 0 ]; then + echo "fping_${target}_success.value 100" + echo "fping_${target}_failure.value 0" +else + echo "fping_${target}_success.value 0" + echo "fping_${target}_failure.value 100" +fi From 29be1c0078b71e29cd0a011d9072b31db80e0946 Mon Sep 17 00:00:00 2001 From: tomav Date: Tue, 20 Aug 2013 22:48:47 +0200 Subject: [PATCH 3/5] fping_ => Added informations and fixed a bug --- plugins/network/fping_ | 45 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/plugins/network/fping_ b/plugins/network/fping_ index 6fa39a56..d74bc8a2 100755 --- a/plugins/network/fping_ +++ b/plugins/network/fping_ @@ -1,41 +1,50 @@ #!/bin/sh # -# Plugin to monitor a server/network availability. -# Author: Thomas VIAL -# -# Requirements: +# Description : Plugin to monitor a server/network availability. +# Author : Thomas VIAL +# Usage : ln -s /path/to/fping_ /etc/munin/fping_www.google.com +# Explaination : Will graph connection to www.google.com +# Requirements : # * fping # target=`basename $0 | sed 's/^fping_//g'` -#target='dev.instalbu.ms' -#target='127.0.0.1' +item=`echo $target | sed -e 's/\.//g'` + +# +# Config +# if [ "$1" = "config" ]; then echo "graph_title ${target} availability" - echo "graph_args --upper-limit 100" + echo "graph_args -l 0 -u 100" echo "graph_vlabel Availability" echo "graph_category network" + echo "graph_info Displays Network Availability" # Success - echo "fping_${target}_success.label Reachable" - echo "fping_${target}_success.type GAUGE" - echo "fping_${target}_success.color 00CC00CC" + echo "fping_${item}_success.label Reachable" + #echo "fping_${item}_success.type GAUGE" + echo "fping_${item}_success.colour 00CC00CC" # Failure - echo "fping_${target}_failure.label Unreachable" - echo "fping_${target}_failure.type AREA" - echo "fping_${target}_failure.color ff0000" + echo "fping_${item}_failure.label Unreachable" + echo "fping_${item}_failure.type AREA" + echo "fping_${item}_failure.colour ff0000" exit 0 fi - +# +# Let's go! +# fping -q $target status=$? if [ $status -eq 0 ]; then - echo "fping_${target}_success.value 100" - echo "fping_${target}_failure.value 0" + # Success + echo "fping_${item}_success.value 100" + echo "fping_${item}_failure.value 0" else - echo "fping_${target}_success.value 0" - echo "fping_${target}_failure.value 100" + # Failure + echo "fping_${item}_success.value 0" + echo "fping_${item}_failure.value 100" fi From 5cbdd737f00769f3b21de24d126d73b42040175a Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Wed, 21 Aug 2013 12:03:09 +0200 Subject: [PATCH 4/5] fping_ => Improved display --- plugins/network/fping_ | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/network/fping_ b/plugins/network/fping_ index d74bc8a2..b4e038b6 100755 --- a/plugins/network/fping_ +++ b/plugins/network/fping_ @@ -2,6 +2,7 @@ # # Description : Plugin to monitor a server/network availability. # Author : Thomas VIAL +# Author URL : http://tvi.al # Usage : ln -s /path/to/fping_ /etc/munin/fping_www.google.com # Explaination : Will graph connection to www.google.com # Requirements : @@ -17,18 +18,18 @@ item=`echo $target | sed -e 's/\.//g'` if [ "$1" = "config" ]; then echo "graph_title ${target} availability" - echo "graph_args -l 0 -u 100" - echo "graph_vlabel 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" - # Success - echo "fping_${item}_success.label Reachable" - #echo "fping_${item}_success.type GAUGE" - echo "fping_${item}_success.colour 00CC00CC" # Failure - echo "fping_${item}_failure.label Unreachable" - echo "fping_${item}_failure.type AREA" - echo "fping_${item}_failure.colour ff0000" + 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 @@ -41,10 +42,10 @@ status=$? if [ $status -eq 0 ]; then # Success - echo "fping_${item}_success.value 100" - echo "fping_${item}_failure.value 0" + echo "success.value 100" + echo "failure.value 0" else # Failure - echo "fping_${item}_success.value 0" - echo "fping_${item}_failure.value 100" + echo "success.value 0" + echo "failure.value 100" fi From 5cfe8f9abfcbf5ddfc3d04d4c7bc525465855724 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Thu, 22 Aug 2013 23:53:28 +0200 Subject: [PATCH 5/5] fping_ => Fixed documentation --- plugins/network/fping_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/network/fping_ b/plugins/network/fping_ index b4e038b6..5741eb38 100755 --- a/plugins/network/fping_ +++ b/plugins/network/fping_ @@ -3,7 +3,7 @@ # Description : Plugin to monitor a server/network availability. # Author : Thomas VIAL # Author URL : http://tvi.al -# Usage : ln -s /path/to/fping_ /etc/munin/fping_www.google.com +# Usage : ln -s /path/to/fping_ /etc/munin/plugins/fping_www.google.com # Explaination : Will graph connection to www.google.com # Requirements : # * fping