diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2008-06-07 10:10:22 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2008-06-07 10:10:22 +0000 |
commit | 72de6a9cfbbe42e785cf817be2aa207a5b45cca6 (patch) | |
tree | 2858af6738fd9e993ccb51d96ed72ae7d9e5f909 /munin-plugin | |
parent | 00d16d08cc735c3f4a2f00ba3a10b9d84d607410 (diff) | |
download | sitesummary-72de6a9cfbbe42e785cf817be2aa207a5b45cca6.tar.gz sitesummary-72de6a9cfbbe42e785cf817be2aa207a5b45cca6.tar.bz2 sitesummary-72de6a9cfbbe42e785cf817be2aa207a5b45cca6.tar.xz |
* Add munin plugin to graph sites based on an idea from Narvik.
Diffstat (limited to 'munin-plugin')
-rwxr-xr-x | munin-plugin | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/munin-plugin b/munin-plugin new file mode 100755 index 0000000..0034e20 --- /dev/null +++ b/munin-plugin @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# +# Generate list of nodes to load from /etc/munin/munin.conf to check +# all the machines reporting to sitesummary. + +use strict; +use warnings; + +use SiteSummary; + +my %sitelabels; + +if (!defined $ARGV[0]) { + for_all_hosts(\&handle_host); + for my $sitelabel (sort keys %sitelabels) { + print "$sitelabel.value ", $sitelabels{$sitelabel}, "\n"; + } +} elsif ($ARGV[0] eq "config") { + for_all_hosts(\&handle_host); + print "graph_title SiteSummary History\n"; + print "graph_order " . join(" ", sort keys %sitelabels), "\n"; + print "graph_vlabel count\n"; + print "graph_scale yes\n"; + print "graph_height 400\n"; + print "graph_category SiteSummary\n"; + + my $first = 1; + for my $sitelabel (sort keys %sitelabels) { + print "$sitelabel.label $sitelabel\n"; + if ($first) { + print "$sitelabel.draw AREA\n" + } else { + print "$sitelabel.draw STACK\n" + } + $first = 0; + } +} elsif ($ARGV[0] eq "autoconf") { + # This module is only available when the sitesummary collector is + # installed too, thus we always answer yes. + print "yes\n"; + exit 0; +} + +sub handle_host { + my $hostid = shift; + for my $site (get_site($hostid)) { + $site = "NoSite" unless defined $site; + $site =~ s/[^a-zA-Z_]/_/g; + $sitelabels{$site}++; + } +} + +exit 0; |