summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Filion <lelutin@gmail.com>2012-10-17 14:49:15 -0400
committerMicah Anderson <micah@riseup.net>2013-02-27 17:01:55 -0500
commit27f0c77945444e14d77866fcd497eb21ecc662e4 (patch)
treed3a49d17900be0ea83f17bde8375f0b059fbe689
parentcfb91ce97243e743f5af0c417851aa730ab96f41 (diff)
Fix munin plugins
the basic path for nagiosstats is wrong/hardcoded. that binary comes in with the nagios3 package in Debian. set the default value to the right path under Debian and make it possible to override the path with an environment variable. Signed-off-by: Gabriel Filion <lelutin@gmail.com>
-rw-r--r--files/munin/nagios_hosts10
-rw-r--r--files/munin/nagios_perf8
-rw-r--r--files/munin/nagios_svc12
-rw-r--r--manifests/munin.pp41
4 files changed, 37 insertions, 34 deletions
diff --git a/files/munin/nagios_hosts b/files/munin/nagios_hosts
index fa8f9dc..3fa00f1 100644
--- a/files/munin/nagios_hosts
+++ b/files/munin/nagios_hosts
@@ -1,5 +1,9 @@
#!/bin/bash
+if [ -z "$nag_stats_binary" ]; then
+ nag_stats_binary=/usr/sbin/nagios3stats
+fi
+
if [ "$1" = "config" ]; then
echo 'graph_title Nagios host stats'
echo 'graph_args --base 1000 -l 0'
@@ -20,9 +24,9 @@ if [ "$1" = "config" ]; then
fi
echo -n 'up.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMHSTUP
+$nag_stats_binary --mrtg --data NUMHSTUP
echo -n 'down.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMHSTDOWN
+$nag_stats_binary --mrtg --data NUMHSTDOWN
echo -n 'unr.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMHSTUNR
+$nag_stats_binary --mrtg --data NUMHSTUNR
diff --git a/files/munin/nagios_perf b/files/munin/nagios_perf
index 35fd9cd..609d62f 100644
--- a/files/munin/nagios_perf
+++ b/files/munin/nagios_perf
@@ -1,5 +1,9 @@
#!/bin/bash
+if [ -z "$nag_stats_binary" ]; then
+ nag_stats_binary=/usr/sbin/nagios3stats
+fi
+
NAME=$(basename $0)
TYPE=${NAME##nagios_perf_}
@@ -30,5 +34,5 @@ if [ "$1" = "config" ]; then
exit 0
fi
-echo "act_lat_$TYPE_ABBR.value " $(/usr/local/sbin/nagiostats --mrtg --data AVGACT${TYPE_ABBR}LAT)
-echo "act_ext_$TYPE_ABBR.value " $(/usr/local/sbin/nagiostats --mrtg --data AVGACT${TYPE_ABBR}EXT)
+echo "act_lat_$TYPE_ABBR.value " $($nag_stats_binary --mrtg --data AVGACT${TYPE_ABBR}LAT)
+echo "act_ext_$TYPE_ABBR.value " $($nag_stats_binary --mrtg --data AVGACT${TYPE_ABBR}EXT)
diff --git a/files/munin/nagios_svc b/files/munin/nagios_svc
index 0a9a9bf..97c8bfc 100644
--- a/files/munin/nagios_svc
+++ b/files/munin/nagios_svc
@@ -1,5 +1,9 @@
#!/bin/bash
+if [ -z "$nag_stats_binary" ]; then
+ nag_stats_binary=/usr/sbin/nagios3stats
+fi
+
if [ "$1" = "config" ]; then
echo 'graph_title Nagios service stats'
echo 'graph_args --base 1000 -l 0'
@@ -23,11 +27,11 @@ if [ "$1" = "config" ]; then
fi
echo -n 'ok.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMSVCOK
+$nag_stats_binary --mrtg --data NUMSVCOK
echo -n 'warn.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMSVCWARN
+$nag_stats_binary --mrtg --data NUMSVCWARN
echo -n 'crit.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMSVCCRIT
+$nag_stats_binary --mrtg --data NUMSVCCRIT
echo -n 'unkn.value '
-/usr/local/sbin/nagiostats --mrtg --data NUMSVCUNKN
+$nag_stats_binary --mrtg --data NUMSVCUNKN
diff --git a/manifests/munin.pp b/manifests/munin.pp
index 92a389f..dc5cc4c 100644
--- a/manifests/munin.pp
+++ b/manifests/munin.pp
@@ -1,28 +1,19 @@
-class nagios::munin inherits munin::plugins::base {
+class nagios::munin {
+ include munin::plugins::base
- munin::plugin::deploy {
- nagios_hosts:
- source => 'nagios/munin/nagios_hosts',
- config => 'user root';
- nagios_svc:
- source => 'nagios/munin/nagios_svc',
- config => 'user root';
- nagios_perf_hosts:
- source => 'nagios/munin/nagios_perf',
- config => 'user root';
- nagios_perf_svc:
- source => 'nagios/munin/nagios_perf',
- config => 'user root';
- }
-
- exec { 'munin_nagios2stats_link':
- command => 'ln -s /usr/sbin/nagios2stats /usr/local/sbin/nagiostats',
- onlyif => ["test ! -e /usr/local/sbin/nagiostats", "test -e /usr/sbin/nagios2stats"],
- }
-
- exec { 'munin_nagios3stats_link':
- command => 'ln -s /usr/sbin/nagios3stats /usr/local/sbin/nagiostats',
- onlyif => ["test ! -e /usr/local/sbin/nagiostats", "test -e /usr/sbin/nagios3stats"],
- }
+ munin::plugin::deploy {
+ 'nagios_hosts':
+ source => 'nagios/munin/nagios_hosts',
+ config => 'user nagios';
+ 'nagios_svc':
+ source => 'nagios/munin/nagios_svc',
+ config => 'user nagios';
+ 'nagios_perf_hosts':
+ source => 'nagios/munin/nagios_perf',
+ config => 'user nagios';
+ 'nagios_perf_svc':
+ source => 'nagios/munin/nagios_perf',
+ config => 'user nagios';
+ }
}