aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2007-11-23 20:41:19 +0000
committerPetter Reinholdtsen <pere@hungry.com>2007-11-23 20:41:19 +0000
commit59cf5402f37fc0fff3a9b41e3c7cc754ba3bfb04 (patch)
tree0e9a267507581e89e59253d907c3e5193a956718
parent00b996c068fe17ff4c2271e44d91bd1a92f6aa76 (diff)
downloadsitesummary-59cf5402f37fc0fff3a9b41e3c7cc754ba3bfb04.tar.gz
sitesummary-59cf5402f37fc0fff3a9b41e3c7cc754ba3bfb04.tar.bz2
sitesummary-59cf5402f37fc0fff3a9b41e3c7cc754ba3bfb04.tar.xz
* New script agesinceseen-summary, listing the hosts that have
failed to submit a report in the last few days. It support -l to list the individual hosts.
-rw-r--r--Makefile1
-rw-r--r--agesinceseen-summary70
-rw-r--r--debian/changelog7
3 files changed, 76 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index e88ad73..026d0fc 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@ COLLECTORS = \
collect.d/siteinfo
SUMMARYSCRIPTS = \
+ agesinceseen-summary \
site-summary \
hostclass-summary \
kernelversion-summary \
diff --git a/agesinceseen-summary b/agesinceseen-summary
new file mode 100644
index 0000000..4bfed75
--- /dev/null
+++ b/agesinceseen-summary
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use SiteSummary;
+use Getopt::Std;
+
+my %agegroup =
+ (
+ 3 => '>3 days',
+ 7 => '>one week',
+ 14 => '>14 days',
+ 30 => '>30 days',
+ 90 => '>90 days',
+);
+
+my %agedist;
+my %opts;
+
+sub usage {
+ my $retval = shift;
+ print <<EOF;
+Usage: $0 [-l]
+ -l list hosts with the given age
+EOF
+ exit $retval;
+}
+
+getopt("l", \%opts) || usage(1);
+
+for_all_hosts(\&handle_host);
+
+print_summary();
+
+sub handle_host {
+ my $hostid = shift;
+ my $topdir = get_filepath_current($hostid, "/");
+ my $age = (time() - (stat($topdir))[9]) / (60 * 60 * 24);
+
+ my $thisgroup;
+ for my $group (sort { $a <=> $b; } keys %agegroup) {
+ if ($age > $group) {
+ $thisgroup = $group;
+ }
+ }
+ if (defined $thisgroup) {
+ if (exists $agedist{$thisgroup}) {
+ push @{$agedist{$thisgroup}}, $hostid ;
+ } else {
+ $agedist{$thisgroup} = [$hostid];
+ }
+ }
+}
+
+sub print_summary {
+ printf(" %-20s %5s\n", "hostclass", "count");
+ for my $group (sort { $a <=> $b; } keys %agedist) {
+ printf(" %-20s %5d\n", $agegroup{$group}, scalar @{$agedist{$group}});
+ if (exists $opts{l}) {
+ for my $hostid (@{$agedist{$group}}) {
+ my $hostname = get_hostname($hostid);
+ my $site = get_site($hostid) || "";
+ my $sitegroup = get_sitegroup($hostid) || "";
+ printf " %s %s/%s %s\n", $hostname, $site, $sitegroup, $hostid;
+ }
+ print "\n";
+ }
+ }
+}
diff --git a/debian/changelog b/debian/changelog
index 96d04c8..db32d91 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,12 @@
-sitesummary (0.0.31) UNRELEASED; urgency=low
+summary (0.0.31) UNRELEASED; urgency=low
* Add -l option to kernelversion-summary, to get it to list the
individual hosts with the given kernel version.
+ * New script agesinceseen-summary, listing the hosts that have
+ failed to submit a report in the last few days. It support -l to
+ list the individual hosts.
- -- Petter Reinholdtsen <pere@debian.org> Fri, 23 Nov 2007 21:02:44 +0100
+ -- Petter Reinholdtsen <pere@debian.org> Fri, 23 Nov 2007 21:40:00 +0100
sitesummary (0.0.30) unstable; urgency=low