diff options
Diffstat (limited to 'munin-plugin')
-rwxr-xr-x | munin-plugin | 18 |
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}++; } } |