From c71014e0674e602baa66617f72f621fe1c10d61e Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Mon, 10 Nov 2014 14:51:04 +0100 Subject: [PATCH] fixes refs #5643 --- .../database/mssql/mode/backupage.pm | 5 ----- .../database/mssql/mode/failedjobs.pm | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/centreon-plugins/database/mssql/mode/backupage.pm b/centreon-plugins/database/mssql/mode/backupage.pm index 66e3a54fb..042d185c3 100644 --- a/centreon-plugins/database/mssql/mode/backupage.pm +++ b/centreon-plugins/database/mssql/mode/backupage.pm @@ -42,11 +42,6 @@ use warnings; use Time::HiRes; use Time::Local; -my %states = ( - 0 => 'failed', - 1 => 'success', -); - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon-plugins/database/mssql/mode/failedjobs.pm b/centreon-plugins/database/mssql/mode/failedjobs.pm index a477b4fea..98a2cce58 100644 --- a/centreon-plugins/database/mssql/mode/failedjobs.pm +++ b/centreon-plugins/database/mssql/mode/failedjobs.pm @@ -55,6 +55,8 @@ sub new { { "filter-job:s" => { name => 'filter_job', }, "skip" => { name => 'skip', }, + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', }, }); return $self; @@ -97,14 +99,16 @@ sub run { $self->{output}->output_add(long_msg => sprintf("Job '%s' status %s [Date : %s] [Runtime : %ss]", $job_name, $states{$run_status}, $run_date, $run_time)); if ($run_status == 0) { $count_failed++; - $self->{output}->output_add(severity => 'Critical', - short_msg => sprintf("Job '%s' status %s", $job_name, $states{$run_status})); } } + my $exit_code = $self->{perfdata}->threshold_check(value => $count_failed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if(!defined($self->{option_results}->{skip}) && $count == 0) { $self->{output}->output_add(severity => 'Unknown', short_msg => "No job found."); + } elsif (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("%d failed job(s)", $count_failed)); } $self->{output}->perfdata_add(label => 'failed_jobs', @@ -134,6 +138,14 @@ Filter job. Skip error if no job found. +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + =back =cut