Skip to content

Commit

Permalink
Fix tv_interval usage in process_perfdata
Browse files Browse the repository at this point in the history
Fix usage of Time::HiRes::tv_interval() where the second argument to
tv_interval should be omitted OR an array reference.

This fixes errors like these on Perl 5.26.3 and Time::HiRes 1.9758:

  tv_interval() 2nd argument should be an array reference at \
      /opt/monitor/op5/pnp/process_perfdata.pl line 221.
  ERROR: Executed command exits with return code '255'
  ERROR: Command line was '/opt/monitor/op5/pnp/process_perfdata.pl \
    -n --bulk /opt/monitor/var/spool/perfdata/service_perfdata.1626159482'

Signed-off-by: Aksel Sjögren <[email protected]>
  • Loading branch information
sjoegren committed Jul 13, 2021
1 parent 9dd8f72 commit e634155
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions scripts/process_perfdata.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,14 @@ if( ! defined($opt_gm) ){
sub main {
my $job = shift;
my $t0 = [gettimeofday];
my $t1;
my $rt;
my $lines = 0;
# Gearman Worker
if (defined $opt_gm) {
print_log( "Gearman Worker Job start", 1 );
%NAGIOS = parse_env($job->arg);
$lines = process_perfdata();
$t1 = [gettimeofday];
$rt = tv_interval $t0, $t1;
$rt = tv_interval($t0, [gettimeofday]);
$stats{runtime} += $rt;
$stats{rows}++;
if( ( int $stats{timet} / 60 ) < ( int time / 60 )){
Expand Down Expand Up @@ -218,7 +216,7 @@ sub main {
%NAGIOS = parse_env();
$lines = process_perfdata();
}
$rt = tv_interval $t0, $t1;
$rt = tv_interval($t0, [gettimeofday]);
$stats{runtime} = $rt;
$stats{rows} = $lines;
store_internals();
Expand Down

0 comments on commit e634155

Please sign in to comment.