Fix 1382
This commit is contained in:
parent
60122659dc
commit
42c5ba7df9
|
@ -25,6 +25,7 @@ use base qw(centreon::plugins::mode);
|
|||
use strict;
|
||||
use warnings;
|
||||
use Time::Local;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my %states = (
|
||||
0 => 'failed',
|
||||
|
@ -127,24 +128,24 @@ sub run {
|
|||
if (defined($$row[2])) {
|
||||
my $run_duration_padding = sprintf("%06d", $$row[2]);
|
||||
my ($hour_duration, $minute_duration, $second_duration) = $run_duration_padding =~ /(\d{2})(\d{2})(\d{2})$/;
|
||||
$run_duration = ($hour_duration * 3600 + $minute_duration * 60 + $second_duration) / 60;
|
||||
$run_duration = ($hour_duration * 3600 + $minute_duration * 60 + $second_duration);
|
||||
} else {
|
||||
my $start_time = timelocal($second,$minute,$hour,$day,$month-1,$year);
|
||||
$run_duration = (time() - $start_time) / 60;
|
||||
$run_duration = (time() - $start_time);
|
||||
}
|
||||
|
||||
if ($run_status == 0) {
|
||||
$count_failed++;
|
||||
push (@job_failed, $job_name);
|
||||
} else {
|
||||
my $exit_code1 = $self->{perfdata}->threshold_check(value => $run_duration, threshold => [ { label => 'critical-duration', exit_litteral => 'critical' }, { label => 'warning-duration', exit_litteral => 'warning' } ]);
|
||||
my $exit_code1 = $self->{perfdata}->threshold_check(value => $run_duration / 60, threshold => [ { label => 'critical-duration', exit_litteral => 'critical' }, { label => 'warning-duration', exit_litteral => 'warning' } ]);
|
||||
if (!$self->{output}->is_status(value => $exit_code1, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit_code1,
|
||||
short_msg => sprintf("Job '%s' duration : %d minutes", $job_name, $run_duration));
|
||||
short_msg => sprintf("Job '%s' duration : %s", $job_name, centreon::plugins::misc::change_seconds(value => $run_duration)));
|
||||
}
|
||||
}
|
||||
$self->{output}->output_add(long_msg => sprintf("Job '%s' status %s [Runtime : %s %s] [Duration : %d minutes]",
|
||||
$job_name, $states{$run_status}, defined($year) ? $year . '-' . $month . '-' . $day : '', $hour . ':' . $minute . ':' . $second, $run_duration));
|
||||
$self->{output}->output_add(long_msg => sprintf("Job '%s' status %s [Runtime : %s %s] [Duration : %s]",
|
||||
$job_name, $states{$run_status}, defined($year) ? $year . '-' . $month . '-' . $day : '', $hour . ':' . $minute . ':' . $second, centreon::plugins::misc::change_seconds(value => $run_duration)));
|
||||
}
|
||||
|
||||
my $exit_code2 = $self->{perfdata}->threshold_check(value => $count_failed, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
|
Loading…
Reference in New Issue