diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2007-11-23 20:41:19 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2007-11-23 20:41:19 +0000 |
commit | 59cf5402f37fc0fff3a9b41e3c7cc754ba3bfb04 (patch) | |
tree | 0e9a267507581e89e59253d907c3e5193a956718 | |
parent | 00b996c068fe17ff4c2271e44d91bd1a92f6aa76 (diff) | |
download | sitesummary-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-- | Makefile | 1 | ||||
-rw-r--r-- | agesinceseen-summary | 70 | ||||
-rw-r--r-- | debian/changelog | 7 |
3 files changed, 76 insertions, 2 deletions
@@ -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 |