diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-04-30 12:56:11 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-04-30 12:56:11 +0200 |
commit | a57a24c2d68daa4d4561ed9035c863e574cdc70a (patch) | |
tree | b0cacb635d65e9f220748142080b832a43de7342 /lib/Travelynx/Command/munin.pm | |
parent | 99aa3a4a0d467fd83ba78096cf34113df797f0d8 (diff) |
add "active user count" munin command
Diffstat (limited to 'lib/Travelynx/Command/munin.pm')
-rw-r--r-- | lib/Travelynx/Command/munin.pm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/munin.pm b/lib/Travelynx/Command/munin.pm index a7ee9b1..110e058 100644 --- a/lib/Travelynx/Command/munin.pm +++ b/lib/Travelynx/Command/munin.pm @@ -21,6 +21,7 @@ sub run { my $db = $self->app->pg->db; my $now = DateTime->now( time_zone => 'Europe/Berlin' ); + my $active = $now->clone->subtract( months => 1 ); my $checkin_window_query = qq{select count(*) as count from journeys where checkin_time > to_timestamp(?);}; @@ -29,6 +30,17 @@ sub run { $db->select( 'users', 'count(*) as count', { status => 1 } ) ->hash->{count} ); query_to_munin( + 'active_user_count', + $db->select( + 'users', + 'count(*) as count', + { + status => 1, + last_seen => { '>', $active } + } + )->hash->{count} + ); + query_to_munin( 'checkins_24h', $db->query( $checkin_window_query, $now->subtract( hours => 24 )->epoch )->hash->{count} |