From 2a3fdf768b269de08fa1f4a0e1fe50c26e6a1c43 Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Thu, 16 May 2019 15:15:03 +0200 Subject: [PATCH] expose events as method; name variables more consistently --- modules/util/Util/Monitoring.pm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/util/Util/Monitoring.pm b/modules/util/Util/Monitoring.pm index 254c575..3c2cc4f 100644 --- a/modules/util/Util/Monitoring.pm +++ b/modules/util/Util/Monitoring.pm @@ -189,6 +189,15 @@ sub setup_ref $ref; } +sub event +{ + my $mon= shift; + my $ev= shift; + + my $events= $mon->{_events}; + + my $event_id= $events->insert($ev); +} =head1 FILE SYSTEM METHODS =cut @@ -205,7 +214,7 @@ sub mon_fs # $filesystems->df('h'); # print "filesystems: ", Dumper ($filesystems); - my $worst_status= -1; + my $worst_status_code= -1; my $worst_msg= 'unknown'; my $now= time (); @@ -220,7 +229,7 @@ sub mon_fs # TODO: # * calculate a proper nagios status code - # * update $worst_status accordingly + # * update $worst_status_code accordingly my @cmp= (); @@ -240,13 +249,13 @@ sub mon_fs push (@cmp, $res_i); } - my ($nagios_status, $nagios_msg)= compare_levels(@cmp); - ($worst_status, $worst_msg)= compare_levels([$worst_status, $worst_msg], [$nagios_status, $nagios_msg]); + my ($nagios_status_code, $nagios_msg)= compare_levels(@cmp); + ($worst_status_code, $worst_msg)= compare_levels([$worst_status_code, $worst_msg], [$nagios_status_code, $nagios_msg]); my $rc= $moni->update({ 'resource' => $x_fs->{'mp'} }, { 'resource' => $x_fs->{'mp'}, 'e' => $now, 'ts' => DateTime->from_epoch('epoch' => $now), - 'nagios_status' => $nagios_status[$nagios_status], - 'nagios_status_code' => $nagios_status, + 'nagios_status' => $nagios_status[$nagios_status_code], + 'nagios_status_code' => $nagios_status_code, 'nagios_msg' => $nagios_msg, 'val' => $x_fs->{'k'}->{'used'}, 'par' => $x_fs @@ -264,7 +273,7 @@ sub mon_fs 'e' => $now, # 'ts' => $ts, # 'ts' => $ts->iso8601(), - 'worst_status' => $nagios_status[$worst_status], + 'worst_status' => $nagios_status[$worst_status_code], 'worst_msg' => $worst_msg }; @@ -351,6 +360,10 @@ sub setup_default_collection =head1 GENERIC STATUS FUNCTIONS +=head2 get_fs_level + +return filling level of a filesystem in percent + =cut sub get_fs_level -- GitLab