aboutsummaryrefslogtreecommitdiffstats
path: root/agesinceseen-summary
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2010-01-26 14:46:04 +0000
committerPetter Reinholdtsen <pere@hungry.com>2010-01-26 14:46:04 +0000
commit359e65ff3ea2dfa5500da27bc67eef841dfff9cc (patch)
treeea2e136e23db8674e51bf753936a0e77c8db6510 /agesinceseen-summary
parente63982416dd7d7f0a9d412033d574b72622434eb (diff)
downloadsitesummary-359e65ff3ea2dfa5500da27bc67eef841dfff9cc.tar.gz
sitesummary-359e65ff3ea2dfa5500da27bc67eef841dfff9cc.tar.bz2
sitesummary-359e65ff3ea2dfa5500da27bc67eef841dfff9cc.tar.xz
Rewritten new munin module to use SiteSummary.pm.
Diffstat (limited to 'agesinceseen-summary')
-rw-r--r--agesinceseen-summary24
1 files changed, 3 insertions, 21 deletions
diff --git a/agesinceseen-summary b/agesinceseen-summary
index 0347393..ddfd7ff 100644
--- a/agesinceseen-summary
+++ b/agesinceseen-summary
@@ -6,17 +6,6 @@ use warnings;
use SiteSummary;
use Getopt::Std;
-my %agegroup =
- (
- 0 => '>0 days',
- 3 => '>3 days',
- 7 => '>one week',
- 14 => '>14 days',
- 30 => '>30 days',
- 90 => '>90 days',
- 180 => '>180 days',
-);
-
my %agedist;
my %opts;
@@ -37,15 +26,7 @@ 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;
- }
- }
+ my $thisgroup = get_age_group($hostid);
if (defined $thisgroup) {
if (exists $agedist{$thisgroup}) {
push @{$agedist{$thisgroup}}, $hostid ;
@@ -57,8 +38,9 @@ sub handle_host {
sub print_summary {
printf(" %-20s %5s\n", "age", "count");
+ my %agegroups = get_age_groups();
for my $group (sort { $a <=> $b; } keys %agedist) {
- printf(" %-20s %5d\n", $agegroup{$group}, scalar @{$agedist{$group}});
+ printf(" %-20s %5d\n", $agegroups{$group}, scalar @{$agedist{$group}});
if (exists $opts{l}) {
for my $hostid (sort @{$agedist{$group}}) {
my $hostname = get_hostname($hostid);