aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmunin-plugin-agesinceseen15
1 files changed, 10 insertions, 5 deletions
diff --git a/munin-plugin-agesinceseen b/munin-plugin-agesinceseen
index 5740df5..86dfdf5 100755
--- a/munin-plugin-agesinceseen
+++ b/munin-plugin-agesinceseen
@@ -21,17 +21,23 @@ my %counts;
my %agegroups = get_age_groups();
my @order = map { $agegroups{$_}; } sort { $a <=> $b } keys %agegroups;
+sub label2key {
+ my $label = shift;
+ $label =~ s/[ >]+/_/g;
+ $label =~ s/^_+//;
+ return $label;
+}
+
if (!$ARGV[0]) {
for_all_hosts(\&handle_host);
for my $label (@order) {
- my $key = $label;
- $key =~ s/[ >]+/_/g;
+ my $key = label2key($label);
print "$key.value ", defined $counts{$label} ? $counts{$label} : 0 , "\n";
}
} elsif ($ARGV[0] eq "config") {
print "graph_title SiteSummary AgeSinceSeen\n";
- print "graph_order ", join(" ", map { s/ /_/g; $_; } @order), "\n";
+ print "graph_order ", join(" ", map { label2key($_); } @order), "\n";
print "graph_vlabel count\n";
print "graph_scale yes\n";
print "graph_args --base 1000 -l 0\n";
@@ -40,8 +46,7 @@ if (!$ARGV[0]) {
my $first = 1;
for my $label (@order) {
- my $key = $label;
- $key =~ s/[ >]+/_/g;
+ my $key = label2key($label);
if ($first) {
print "$key.draw AREA\n";
$first = 0;