aboutsummaryrefslogtreecommitdiffstats
path: root/munin-plugin
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2010-01-27 11:08:58 +0000
committerPetter Reinholdtsen <pere@hungry.com>2010-01-27 11:08:58 +0000
commitfb284a96d0b6334eff78d503d28422b00053d70e (patch)
tree12bbddf1e926c3fb244eeac4f3319249c366e03e /munin-plugin
parentbe7419d972d8ba82e95f35d35e547b67468bc704 (diff)
downloadsitesummary-fb284a96d0b6334eff78d503d28422b00053d70e.tar.gz
sitesummary-fb284a96d0b6334eff78d503d28422b00053d70e.tar.bz2
sitesummary-fb284a96d0b6334eff78d503d28422b00053d70e.tar.xz
Adjust site count munin plugin to use original site as label and
only remove illegal characters for the munin key.
Diffstat (limited to 'munin-plugin')
-rwxr-xr-xmunin-plugin18
1 files changed, 13 insertions, 5 deletions
diff --git a/munin-plugin b/munin-plugin
index f0c111b..8e59139 100755
--- a/munin-plugin
+++ b/munin-plugin
@@ -18,7 +18,8 @@ if (!$ARGV[0]) {
# List values in the opposit order of the configuration order, to
# try to get the same order on the graphs and the values.
for my $sitelabel (sort { $b cmp $a } keys %sitelabels) {
- print "$sitelabel.value ", $sitelabels{$sitelabel}, "\n";
+ my $key = label2key($sitelabel);
+ print "$key.value ", $sitelabels{$sitelabel}, "\n";
}
} elsif ($ARGV[0] eq "config") {
for_all_hosts(\&handle_host);
@@ -31,11 +32,12 @@ if (!$ARGV[0]) {
my $first = 1;
for my $sitelabel (sort keys %sitelabels) {
- print "$sitelabel.label $sitelabel\n";
+ my $key = label2key($sitelabel);
+ print "$key.label $sitelabel\n";
if ($first) {
- print "$sitelabel.draw AREA\n";
+ print "$key.draw AREA\n";
} else {
- print "$sitelabel.draw STACK\n";
+ print "$key.draw STACK\n";
}
$first = 0;
}
@@ -46,11 +48,17 @@ if (!$ARGV[0]) {
exit 0;
}
+sub label2key {
+ my $label = shift;
+ $label =~ s/[^a-xA-Z_]+/_/g;
+ $label =~ s/^_+//;
+ return $label;
+}
+
sub handle_host {
my $hostid = shift;
for my $site (get_site($hostid)) {
$site = "SiteMissing" unless defined $site;
- $site =~ s/[^a-zA-Z_]/_/g;
$sitelabels{$site}++;
}
}