aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--debian/changelog2
-rwxr-xr-xmunin-plugin18
-rwxr-xr-xmunin-plugin-agesinceseen10
3 files changed, 20 insertions, 10 deletions
diff --git a/debian/changelog b/debian/changelog
index 701cffb..dd7cae0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ sitesummary (0.0.59) UNRELEASED; urgency=low
Petter Reinholdtsen.
* Introduce new agesinceseen group 120-180 to have one limit that
match the removal limit (120 days).
+ * Adjust site count munin plugin to use original site as label and
+ only remove illegal characters for the munin key.
* Adjust sitesummary postinst to only try to enable nagios
autoconfig if /etc/default/nagios3 exist.
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}++;
}
}
diff --git a/munin-plugin-agesinceseen b/munin-plugin-agesinceseen
index 86dfdf5..750ffba 100755
--- a/munin-plugin-agesinceseen
+++ b/munin-plugin-agesinceseen
@@ -23,7 +23,7 @@ my @order = map { $agegroups{$_}; } sort { $a <=> $b } keys %agegroups;
sub label2key {
my $label = shift;
- $label =~ s/[ >]+/_/g;
+ $label =~ s/[^a-xA-Z_]+/_/g;
$label =~ s/^_+//;
return $label;
}
@@ -32,7 +32,7 @@ if (!$ARGV[0]) {
for_all_hosts(\&handle_host);
for my $label (@order) {
- my $key = label2key($label);
+ my $key = label2key($label);
print "$key.value ", defined $counts{$label} ? $counts{$label} : 0 , "\n";
}
} elsif ($ARGV[0] eq "config") {
@@ -46,14 +46,14 @@ if (!$ARGV[0]) {
my $first = 1;
for my $label (@order) {
- my $key = label2key($label);
+ my $key = label2key($label);
if ($first) {
print "$key.draw AREA\n";
- $first = 0;
+ $first = 0;
} else {
print "$key.draw STACK\n";
}
- print "$key.label $label\n";
+ print "$key.label $label\n";
}
} elsif ($ARGV[0] eq "autoconf") {
# This module is only available when the sitesummary collector is