From 84b2ad9b476a615a8ebc8795fffd86be7a29a08d Mon Sep 17 00:00:00 2001 From: Sergey Ivanov <seriv@cs.umd.edu> Date: Tue, 28 Apr 2020 07:33:34 -0400 Subject: [PATCH] Increase precision --- resources/check_resmon_metric | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/check_resmon_metric b/resources/check_resmon_metric index 88ee30f..615792a 100755 --- a/resources/check_resmon_metric +++ b/resources/check_resmon_metric @@ -320,6 +320,7 @@ eval { my $ref; # Make the HTTP request my $res = $ua->request($t); + my $now_after = Time::HiRes::time(); die "could not fetch http://$host:$port$url - " . $res->status_line ."\n" unless($res && $res->is_success); # Parse the xml @@ -340,9 +341,9 @@ eval { if($age) { my $last_update; if ($module eq 'System::Time' && $check eq 'now') { - $last_update = Time::HiRes::time() - $ref->{ResmonResult}->[$idx]->{metric}->{now}->{content}; + $last_update = $now_after - $ref->{ResmonResult}->[$idx]->{metric}->{now}->{content}; } else { - $last_update = Time::HiRes::time() - $ref->{ResmonResult}->[$idx]->{last_update}->[0]; + $last_update = $now_after - $ref->{ResmonResult}->[$idx]->{last_update}->[0]; } if ($age < abs($last_update)){ $state = "CRITICAL"; -- GitLab