From e2b1981f930873f580d93cb57c278d6d9274055e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 10 Feb 2023 10:10:48 +0200 Subject: add ideas --- src/guprecords.raku | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/guprecords.raku b/src/guprecords.raku index 6c17bc7..629a6e0 100644 --- a/src/guprecords.raku +++ b/src/guprecords.raku @@ -42,7 +42,7 @@ class Aggregate { } class Aggregator { - has %.aggregates = { hostname => {}, os => {}, uname => {}, major => {} } + has %.aggregates = { hostname => {}, os => {}, uname => {}, os-major => {} } method aggregate(IO::Path :$file is readonly) { my Str $hostname = $file.IO.basename.split('.').first; @@ -51,22 +51,26 @@ class Aggregator { for $file.IO.lines { my Str ($uptime, $boot-time, $os) = .trim.split(':'); my Str $uname = $os.split(' ').first; - my Str $major = "{$uname} {$os.split(' ')[1].split('.').first}..."; + my Str $os-major = "$uname {$os.split(' ')[1].split('.').first}..."; %!aggregates{$os} //= Aggregate.new; %!aggregates{$uname} //= Aggregate.new; - %!aggregates{$major} //= Aggregate.new; + %!aggregates{$os-major} //= Aggregate.new; for %!aggregates{$hostname}, %!aggregates{$os}, %!aggregates{$uname}, - %!aggregates{$major} { + %!aggregates{$os-major} { .aggregate(:$uptime, :$boot-time); } } } } +# TODO: +# --category switch (hostname, os, os-major, uname...) +# --stats switch (record count, total uptime, total downtime, total time/lifespan, +# individual uptime, individual downtime) sub MAIN( Str $in-dir = './stats', Str $sort-by = 'uptime'; -- cgit v1.2.3