diff --git a/README.md b/README.md index d0a432613..056aac6fe 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ +# centreon-plugins +“centreon-plugins” is a free and open source project to monitor systems. The project can be used with Centreon and all monitoring softwares compatible with Nagios plugins. -Read 'docs/user/guide.rst' for help or go to http://documentation.centreon.com/docs/centreon-plugins/en/latest/ +For more information or help, please read 'docs/user/guide.rst' or go to http://documentation.centreon.com/docs/centreon-plugins/en/latest/ diff --git a/apps/hddtemp/local/mode/temperature.pm b/apps/hddtemp/local/mode/temperature.pm index a33da6da5..92e29d20f 100644 --- a/apps/hddtemp/local/mode/temperature.pm +++ b/apps/hddtemp/local/mode/temperature.pm @@ -117,7 +117,7 @@ sub run { $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("'%s' temp is %s", $disk, $temp . '°' . $self->{option_results}->{unit})); } - $self->{output}->perfdata_add(label => $disk, unit => '°' .$self->{option_results}->{unit}, + $self->{output}->perfdata_add(label => $disk, unit => $self->{option_results}->{unit}, value => $temp, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/apps/pfsense/snmp/mode/runtime.pm b/apps/pfsense/snmp/mode/runtime.pm index b221ddb33..d0d92d084 100644 --- a/apps/pfsense/snmp/mode/runtime.pm +++ b/apps/pfsense/snmp/mode/runtime.pm @@ -86,8 +86,8 @@ sub run { if ($valueStatus == 1) { my $exit_code = $self->{perfdata}->threshold_check(value => $valueRuntime, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->perfdata_add(label => 'runtime', + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->perfdata_add(label => 'runtime', unit => 's', value => floor($valueRuntime / 100), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), @@ -97,7 +97,7 @@ sub run { defined($self->{option_results}->{seconds}) ? floor($valueRuntime / 100) . " seconds" : floor($valueRuntime / 86400 / 100) . " days" )); } else { - $self->{output}->perfdata_add(label => 'runtime', + $self->{output}->perfdata_add(label => 'runtime', unit => 's', value => 0, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/apps/protocols/http/mode/expectedcontent.pm b/apps/protocols/http/mode/expectedcontent.pm index 2ccbb6a6b..9e3083a81 100644 --- a/apps/protocols/http/mode/expectedcontent.pm +++ b/apps/protocols/http/mode/expectedcontent.pm @@ -1,35 +1,36 @@ ############################################################################### -# Copyright 2005-2013 MERETHIS +# Copyright 2005-2015 CENTREON # Centreon is developped by : Julien Mathis and Romain Le Merlus under # GPL Licence 2.0. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software # Foundation ; either version 2 of the License. -# +# # This program is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with +# +# You should have received a copy of the GNU General Public License along with # this program; if not, see . -# -# Linking this program statically or dynamically with other modules is making a -# combined work based on this program. Thus, the terms and conditions of the GNU +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU # General Public License cover the whole combination. -# -# As a special exception, the copyright holders of this program give MERETHIS -# permission to link this program with independent modules to produce an timeelapsedutable, -# regardless of the license terms of these independent modules, and to copy and -# distribute the resulting timeelapsedutable under terms of MERETHIS choice, provided that -# MERETHIS also meet, for each linked independent module, the terms and conditions -# of the license of that module. An independent module is a module which is not -# derived from this program. If you modify this program, you may extend this +# +# As a special exception, the copyright holders of this program give CENTREON +# permission to link this program with independent modules to produce an timeelapsedutable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting timeelapsedutable under terms of CENTREON choice, provided that +# CENTREON also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this # exception to your version of the program, but you are not obliged to do so. If you # do not wish to do so, delete this exception statement from your version. -# +# # For more information : contact@centreon.com -# Author : Simon BOMM +# Authors : Simon BOMM +# Mathieu Cinquin # # Based on De Bodt Lieven plugin #################################################################################### @@ -47,7 +48,7 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, @@ -62,6 +63,9 @@ sub new { "expected-string:s" => { name => 'expected_string' }, "timeout:s" => { name => 'timeout', default => '3' }, "ssl:s" => { name => 'ssl', }, + "cert-file:s" => { name => 'cert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, }); return $self; } @@ -86,13 +90,17 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option"); $self->{output}->option_exit(); } + if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) { + $self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used"); + $self->{output}->option_exit(); + } } sub run { my ($self, %options) = @_; if (!defined($self->{option_results}->{port})) { - $self->{option_results}->{port} = centreon::plugins::httplib::get_port($self); + $self->{option_results}->{port} = centreon::plugins::httplib::get_port($self); } my $webcontent = centreon::plugins::httplib::connect($self); @@ -163,6 +171,18 @@ Threshold for HTTP timeout Specify SSL version (example : 'sslv3', 'tlsv1'...) +=item B<--cert-file> + +Specify certificate to send to the webserver + +=item B<--cert-pwd> + +Specify certificate's password + +=item B<--cert-pkcs12> + +Specify type of certificate (PKCS12) + =item B<--expected-string> Specify String to check on the Webpage diff --git a/apps/protocols/http/mode/jsoncontent.pm b/apps/protocols/http/mode/jsoncontent.pm index a87e14d50..8f08afc5d 100644 --- a/apps/protocols/http/mode/jsoncontent.pm +++ b/apps/protocols/http/mode/jsoncontent.pm @@ -1,35 +1,36 @@ ############################################################################### -# Copyright 2005-2013 MERETHIS +# Copyright 2005-2015 CENTREON # Centreon is developped by : Julien Mathis and Romain Le Merlus under # GPL Licence 2.0. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software # Foundation ; either version 2 of the License. -# +# # This program is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with +# +# You should have received a copy of the GNU General Public License along with # this program; if not, see . -# -# Linking this program statically or dynamically with other modules is making a -# combined work based on this program. Thus, the terms and conditions of the GNU +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU # General Public License cover the whole combination. -# -# As a special exception, the copyright holders of this program give MERETHIS -# permission to link this program with independent modules to produce an timeelapsedutable, -# regardless of the license terms of these independent modules, and to copy and -# distribute the resulting timeelapsedutable under terms of MERETHIS choice, provided that -# MERETHIS also meet, for each linked independent module, the terms and conditions -# of the license of that module. An independent module is a module which is not -# derived from this program. If you modify this program, you may extend this +# +# As a special exception, the copyright holders of this program give CENTREON +# permission to link this program with independent modules to produce an timeelapsedutable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting timeelapsedutable under terms of CENTREON choice, provided that +# CENTREON also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this # exception to your version of the program, but you are not obliged to do so. If you # do not wish to do so, delete this exception statement from your version. -# +# # For more information : contact@centreon.com -# Author : Simon BOMM +# Authors : Simon BOMM +# Mathieu Cinquin # # Based on De Bodt Lieven plugin #################################################################################### @@ -50,7 +51,7 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { "data:s" => { name => 'data' }, @@ -68,7 +69,10 @@ sub new { "get-param:s@" => { name => 'get_param' }, "timeout:s" => { name => 'timeout', default => 10 }, "ssl:s" => { name => 'ssl', }, - + "cert-file:s" => { name => 'cert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + "warning-numeric:s" => { name => 'warning_numeric' }, "critical-numeric:s" => { name => 'critical_numeric' }, "warning-string:s" => { name => 'warning_string' }, @@ -129,6 +133,10 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option"); $self->{output}->option_exit(); } + if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) { + $self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used"); + $self->{output}->option_exit(); + } $self->{headers} = {}; if (defined($self->{option_results}->{header})) { foreach (@{$self->{option_results}->{header}}) { @@ -158,7 +166,7 @@ sub check_options { sub load_request { my ($self, %options) = @_; - + $self->{method} = 'GET'; if (defined($self->{option_results}->{data})) { local $/ = undef; @@ -176,7 +184,7 @@ sub load_request { sub display_output { my ($self, %options) = @_; - + foreach my $severity (('ok', 'warning', 'critical')) { next if (scalar(@{$self->{'values_' . $severity}}) == 0 && scalar(@{$self->{'values_string_' . $severity}}) == 0); my $format = $self->{option_results}->{'format_' . $severity}; @@ -197,7 +205,7 @@ sub display_output { sub lookup { my ($self, %options) = @_; my ($xpath, @values); - + my $json = JSON->new; my $content; eval { @@ -207,7 +215,7 @@ sub lookup { $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); $self->{output}->option_exit(); } - + foreach my $xpath_find (@{$self->{option_results}->{lookup}}) { eval { my $jpath = JSON::Path->new($xpath_find); @@ -217,7 +225,7 @@ sub lookup { $self->{output}->add_option_msg(short_msg => "Cannot lookup: $@"); $self->{output}->option_exit(); } - + $self->{output}->output_add(long_msg => "Lookup XPath $xpath_find:"); foreach my $value (@values) { $self->{count}++; @@ -225,26 +233,26 @@ sub lookup { push @{$self->{values}}, $value; } } - + if ($self->{option_results}->{threshold_value} eq 'count') { - my $exit = lc($self->{perfdata}->threshold_check(value => $self->{count}, + my $exit = lc($self->{perfdata}->threshold_check(value => $self->{count}, threshold => [ { label => 'critical-numeric', exit_litteral => 'critical' }, { label => 'warning-numeric', exit_litteral => 'warning' } ])); push @{$self->{'values_' . $exit}}, $self->{count}; $self->{'count_' . $exit}++; } - + $self->{output}->perfdata_add(label => 'count', value => $self->{count}, warning => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef, critical => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef, min => 0); - + my $count = 0; foreach my $value (@{$self->{values}}) { $count++; if ($value =~ /^[0-9.]+$/) { if ($self->{option_results}->{threshold_value} eq 'values') { - my $exit = lc($self->{perfdata}->threshold_check(value => $value, + my $exit = lc($self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical-numeric', exit_litteral => 'critical' }, { label => 'warning-numeric', exit_litteral => 'warning' } ])); push @{$self->{'values_' . $exit}}, $value; $self->{'count_' . $exit}++ @@ -254,10 +262,10 @@ sub lookup { warning => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef, critical => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef); } else { - if (defined($self->{option_results}->{critical_string}) && $self->{option_results}->{critical_string} ne '' && + if (defined($self->{option_results}->{critical_string}) && $self->{option_results}->{critical_string} ne '' && $value =~ /$self->{option_results}->{critical_string}/) { push @{$self->{values_string_critical}}, $value; - } elsif (defined($self->{option_results}->{warning_string}) && $self->{option_results}->{warning_string} ne '' && + } elsif (defined($self->{option_results}->{warning_string}) && $self->{option_results}->{warning_string} ne '' && $value =~ /$self->{option_results}->{warning_string}/) { push @{$self->{values_string_warning}}, $value; } else { @@ -265,7 +273,7 @@ sub lookup { } } } - + $self->display_output(); } @@ -273,12 +281,12 @@ sub run { my ($self, %options) = @_; if (!defined($self->{option_results}->{port})) { - $self->{option_results}->{port} = centreon::plugins::httplib::get_port($self); + $self->{option_results}->{port} = centreon::plugins::httplib::get_port($self); } $self->load_request(); - + my $timing0 = [gettimeofday]; - $self->{json_response} = centreon::plugins::httplib::connect($self, headers => $self->{headers}, method => $self->{method}, + $self->{json_response} = centreon::plugins::httplib::connect($self, headers => $self->{headers}, method => $self->{method}, query_form_get => $self->{get_params}, query_form_post => $self->{json_request}); my $timeelapsed = tv_interval ($timing0, [gettimeofday]); @@ -289,7 +297,7 @@ sub run { } else { $self->lookup(); } - + my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, threshold => [ { label => 'critical-time', exit_litteral => 'critical' }, { label => 'warning-time', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -303,7 +311,7 @@ sub run { warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-time'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-time'), min => 0); - + $self->{output}->display(); $self->{output}->exit(); } @@ -340,7 +348,7 @@ FORMAT OPTIONS: =item B<--format-ok> Output format (Default: '%{count} element(s) finded') -Can used: +Can used: '%{values}' = display all values (also text string) '%{values_ok}' = values from attributes and text node only (seperated by option values-separator) '%{values_warning}' and '%{values_critical}' @@ -442,6 +450,18 @@ Threshold for HTTP timeout (Default: 10) Specify SSL version (example : 'sslv3', 'tlsv1'...) +=item B<--cert-file> + +Specify certificate to send to the webserver + +=item B<--cert-pwd> + +Specify certificate's password + +=item B<--cert-pkcs12> + +Specify type of certificate (PKCS12) + =item B<--get-param> Set GET params (Multiple option. Example: --get-param='key=value') diff --git a/apps/protocols/http/mode/responsetime.pm b/apps/protocols/http/mode/responsetime.pm index e8d56f2c2..9775839ed 100644 --- a/apps/protocols/http/mode/responsetime.pm +++ b/apps/protocols/http/mode/responsetime.pm @@ -32,6 +32,7 @@ # Authors : Simon BOMM # Mathieu Cinquin # +# # Based on De Bodt Lieven plugin #################################################################################### diff --git a/apps/protocols/http/mode/soapcontent.pm b/apps/protocols/http/mode/soapcontent.pm index 9c3d93654..b52d75bfd 100644 --- a/apps/protocols/http/mode/soapcontent.pm +++ b/apps/protocols/http/mode/soapcontent.pm @@ -1,35 +1,36 @@ ############################################################################### -# Copyright 2005-2013 MERETHIS +# Copyright 2005-2015 CENTREON # Centreon is developped by : Julien Mathis and Romain Le Merlus under # GPL Licence 2.0. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software # Foundation ; either version 2 of the License. -# +# # This program is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with +# +# You should have received a copy of the GNU General Public License along with # this program; if not, see . -# -# Linking this program statically or dynamically with other modules is making a -# combined work based on this program. Thus, the terms and conditions of the GNU +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU # General Public License cover the whole combination. -# -# As a special exception, the copyright holders of this program give MERETHIS -# permission to link this program with independent modules to produce an timeelapsedutable, -# regardless of the license terms of these independent modules, and to copy and -# distribute the resulting timeelapsedutable under terms of MERETHIS choice, provided that -# MERETHIS also meet, for each linked independent module, the terms and conditions -# of the license of that module. An independent module is a module which is not -# derived from this program. If you modify this program, you may extend this +# +# As a special exception, the copyright holders of this program give CENTREON +# permission to link this program with independent modules to produce an timeelapsedutable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting timeelapsedutable under terms of CENTREON choice, provided that +# CENTREON also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this # exception to your version of the program, but you are not obliged to do so. If you # do not wish to do so, delete this exception statement from your version. -# +# # For more information : contact@centreon.com -# Author : Simon BOMM +# Authors : Simon BOMM +# Mathieu Cinquin # # Based on De Bodt Lieven plugin #################################################################################### @@ -49,7 +50,7 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { "service-soap:s" => { name => 'service_soap' }, @@ -67,7 +68,10 @@ sub new { "header:s@" => { name => 'header' }, "timeout:s" => { name => 'timeout', default => 10 }, "ssl:s" => { name => 'ssl', }, - + "cert-file:s" => { name => 'cert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + "warning-numeric:s" => { name => 'warning_numeric' }, "critical-numeric:s" => { name => 'critical_numeric' }, "warning-string:s" => { name => 'warning_string' }, @@ -136,6 +140,10 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option"); $self->{output}->option_exit(); } + if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) { + $self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used"); + $self->{output}->option_exit(); + } $self->{headers} = {}; if (defined($self->{option_results}->{header})) { foreach (@{$self->{option_results}->{header}}) { @@ -149,7 +157,7 @@ sub check_options { sub load_request { my ($self, %options) = @_; - + local $/ = undef; if (!open(FILE, "<", $self->{option_results}->{data})) { $self->{output}->output_add(severity => 'UNKNOWN', @@ -163,7 +171,7 @@ sub load_request { sub display_output { my ($self, %options) = @_; - + foreach my $severity (('ok', 'warning', 'critical')) { next if (scalar(@{$self->{'values_' . $severity}}) == 0 && scalar(@{$self->{'values_string_' . $severity}}) == 0); my $format = $self->{option_results}->{'format_' . $severity}; @@ -184,7 +192,7 @@ sub display_output { sub lookup { my ($self, %options) = @_; my ($xpath, $nodeset); - + eval { $xpath = XML::XPath->new(xml => $self->{soap_response}); }; @@ -192,7 +200,7 @@ sub lookup { $self->{output}->add_option_msg(short_msg => "Cannot load SOAP response"); $self->{output}->option_exit(); } - + foreach my $xpath_find (@{$self->{option_results}->{lookup}}) { eval { $nodeset = $xpath->find($xpath_find); @@ -201,7 +209,7 @@ sub lookup { $self->{output}->add_option_msg(short_msg => "Cannot lookup: $@"); $self->{output}->option_exit(); } - + $self->{output}->output_add(long_msg => "Lookup XPath $xpath_find:"); foreach my $node ($nodeset->get_nodelist()) { $self->{count}++; @@ -217,26 +225,26 @@ sub lookup { } } } - + if ($self->{option_results}->{threshold_value} eq 'count') { - my $exit = lc($self->{perfdata}->threshold_check(value => $self->{count}, + my $exit = lc($self->{perfdata}->threshold_check(value => $self->{count}, threshold => [ { label => 'critical-numeric', exit_litteral => 'critical' }, { label => 'warning-numeric', exit_litteral => 'warning' } ])); push @{$self->{'values_' . $exit}}, $self->{count}; $self->{'count_' . $exit}++; } - + $self->{output}->perfdata_add(label => 'count', value => $self->{count}, warning => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef, critical => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef, min => 0); - + my $count = 0; foreach my $value (@{$self->{values}}) { $count++; if ($value =~ /^[0-9.]+$/) { if ($self->{option_results}->{threshold_value} eq 'values') { - my $exit = lc($self->{perfdata}->threshold_check(value => $value, + my $exit = lc($self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical-numeric', exit_litteral => 'critical' }, { label => 'warning-numeric', exit_litteral => 'warning' } ])); push @{$self->{'values_' . $exit}}, $value; $self->{'count_' . $exit}++ @@ -246,10 +254,10 @@ sub lookup { warning => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef, critical => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef); } else { - if (defined($self->{option_results}->{critical_string}) && $self->{option_results}->{critical_string} ne '' && + if (defined($self->{option_results}->{critical_string}) && $self->{option_results}->{critical_string} ne '' && $value =~ /$self->{option_results}->{critical_string}/) { push @{$self->{values_string_critical}}, $value; - } elsif (defined($self->{option_results}->{warning_string}) && $self->{option_results}->{warning_string} ne '' && + } elsif (defined($self->{option_results}->{warning_string}) && $self->{option_results}->{warning_string} ne '' && $value =~ /$self->{option_results}->{warning_string}/) { push @{$self->{values_string_warning}}, $value; } else { @@ -257,7 +265,7 @@ sub lookup { } } } - + $self->display_output(); } @@ -265,7 +273,7 @@ sub run { my ($self, %options) = @_; if (!defined($self->{option_results}->{port})) { - $self->{option_results}->{port} = centreon::plugins::httplib::get_port($self); + $self->{option_results}->{port} = centreon::plugins::httplib::get_port($self); } $self->load_request(); @@ -280,7 +288,7 @@ sub run { } else { $self->lookup(); } - + my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, threshold => [ { label => 'critical-time', exit_litteral => 'critical' }, { label => 'warning-time', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -294,7 +302,7 @@ sub run { warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-time'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-time'), min => 0); - + $self->{output}->display(); $self->{output}->exit(); } @@ -306,7 +314,7 @@ __END__ =head1 MODE Check SOAP content. Send the soap request with option '--data'. Example: -centreon_plugins.pl --plugin=apps::protocols::http::plugin --mode=soap-content --service-soap='http://www.mysite.com/mysoapaction' +centreon_plugins.pl --plugin=apps::protocols::http::plugin --mode=soap-content --service-soap='http://www.mysite.com/mysoapaction' --header='Content-Type: text/xml;charset=UTF-8' --data='/home/user/soap_request.xml' --hostname='myws.site.com' --urlpath='/get/payment' --lookup='//numeric/text()' @@ -335,7 +343,7 @@ FORMAT OPTIONS: =item B<--format-ok> Output format (Default: '%{count} element(s) finded') -Can used: +Can used: '%{values}' = display all values (also text string) '%{values_ok}' = values from attributes and text node only (seperated by option values-separator) '%{values_warning}' and '%{values_critical}' @@ -437,6 +445,18 @@ Threshold for HTTP timeout (Default: 10) Specify SSL version (example : 'sslv3', 'tlsv1'...) +=item B<--cert-file> + +Specify certificate to send to the webserver + +=item B<--cert-pwd> + +Specify certificate's password + +=item B<--cert-pkcs12> + +Specify type of certificate (PKCS1 + =item B<--header> Set HTTP headers (Multiple option) diff --git a/apps/protocols/x509/mode/validity.pm b/apps/protocols/x509/mode/validity.pm index d8da96fcc..bdff05002 100644 --- a/apps/protocols/x509/mode/validity.pm +++ b/apps/protocols/x509/mode/validity.pm @@ -48,7 +48,7 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.2'; + $self->{version} = '1.3'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, @@ -221,11 +221,11 @@ Can be : 'expiration' or 'subject' or 'issuer' =item B<--warning-date> -Threshold warning in days (Days before expiration) +Threshold warning in days (Days before expiration, eg: '60:' for 60 days before) =item B<--critical-date> -Threshold critical in days (Days before expiration) +Threshold critical in days (Days before expiration, eg: '30:' for 30 days before) =item B<--subject> diff --git a/apps/tomcat/web/mode/memory.pm b/apps/tomcat/web/mode/memory.pm index 4b3b0ed53..2338af787 100644 --- a/apps/tomcat/web/mode/memory.pm +++ b/apps/tomcat/web/mode/memory.pm @@ -174,7 +174,7 @@ sub run { $self->{output}->option_exit(); } - my $exit = $self->{perfdata}->threshold_check(value => $memUsed_prct, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $memUsed_prct, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($memTotal_value, $memTotal_unit) = $self->{perfdata}->change_bytes(value => $memTotal); my ($memFree_value, $memFree_unit) = $self->{perfdata}->change_bytes(value => $memFree); @@ -186,7 +186,7 @@ sub run { short_msg => sprintf("Memory used %s (%.2f%%)", $memUsed_value . " " . $memUsed_unit, $memUsed_prct)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $memUsed, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $memTotal), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $memTotal), diff --git a/centreon/common/fastpath/mode/cpu.pm b/centreon/common/fastpath/mode/cpu.pm index 937cfc652..aada0e377 100644 --- a/centreon/common/fastpath/mode/cpu.pm +++ b/centreon/common/fastpath/mode/cpu.pm @@ -126,21 +126,18 @@ sub run { short_msg => sprintf("CPU Usage: %.2f%% (5sec), %.2f%% (1min), %.2f%% (5min)", $cpu5sec, $cpu1min, $cpu5min)); - $self->{output}->perfdata_add(label => "cpu_5s", + $self->{output}->perfdata_add(label => "cpu_5s", unit => '%', value => $cpu5sec, - unit => '%', warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5s'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_1m", + $self->{output}->perfdata_add(label => "cpu_1m", unit => '%', value => $cpu1min, - unit => '%', warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_5m", + $self->{output}->perfdata_add(label => "cpu_5m", unit => '%', value => $cpu5min, - unit => '%', warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), min => 0, max => 100); diff --git a/centreon/common/fastpath/mode/memory.pm b/centreon/common/fastpath/mode/memory.pm index c1e16160c..840c59ed8 100644 --- a/centreon/common/fastpath/mode/memory.pm +++ b/centreon/common/fastpath/mode/memory.pm @@ -99,9 +99,8 @@ sub run { $memory_available_value . " " . $memory_available_unit, $memory_free_value . " " . $memory_free_unit, $prct_free)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $memory_used, - unit => 'B', warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $memory_available, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $memory_available, cast_int => 1), min => 0, max => $memory_available); diff --git a/centreon/common/fortinet/fortigate/mode/cpu.pm b/centreon/common/fortinet/fortigate/mode/cpu.pm index cd78efcc1..a9c5d7862 100644 --- a/centreon/common/fortinet/fortigate/mode/cpu.pm +++ b/centreon/common/fortinet/fortigate/mode/cpu.pm @@ -92,7 +92,7 @@ sub cpu_ha { my $cpu_num = $1; $self->{output}->output_add(long_msg => sprintf("CPU master $cpu_num Usage is %.2f%%", $self->{result}->{$oid_fgHaStatsCpuUsage}->{$key})); - $self->{output}->perfdata_add(label => 'cpu_master' . $cpu_num, + $self->{output}->perfdata_add(label => 'cpu_master' . $cpu_num, unit => '%', value => sprintf("%.2f", $self->{result}->{$oid_fgHaStatsCpuUsage}->{$key}), min => 0, max => 100); } @@ -108,7 +108,7 @@ sub cpu_ha { 'master' : 'slave'; $self->{output}->output_add(long_msg => sprintf("CPU %s Usage is %.2f%%", $label, $self->{result}->{$oid_fgHaStatsCpuUsage}->{$key})); - $self->{output}->perfdata_add(label => 'cpu_' . $label, + $self->{output}->perfdata_add(label => 'cpu_' . $label, unit => '%', value => sprintf("%.2f", $self->{result}->{$oid_fgHaStatsCpuUsage}->{$key}), min => 0, max => 100); } @@ -144,7 +144,7 @@ sub run { $i++; $self->{output}->output_add(long_msg => sprintf("CPU $cpu_num Usage is %.2f%%", $self->{result}->{$oid_cpu}->{$key})); - $self->{output}->perfdata_add(label => 'cpu' . $cpu_num, + $self->{output}->perfdata_add(label => 'cpu' . $cpu_num, unit => '%', value => sprintf("%.2f", $self->{result}->{$oid_cpu}->{$key}), min => 0, max => 100); } @@ -154,7 +154,7 @@ sub run { threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("CPU(s) average usage is: %.2f%%", $avg_cpu)); - $self->{output}->perfdata_add(label => 'total_cpu_avg', + $self->{output}->perfdata_add(label => 'total_cpu_avg', unit => '%', value => sprintf("%.2f", $avg_cpu), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/centreon/plugins/httplib.pm b/centreon/plugins/httplib.pm index 46e91d4de..10d9772f4 100644 --- a/centreon/plugins/httplib.pm +++ b/centreon/plugins/httplib.pm @@ -30,7 +30,7 @@ # # For more information : contact@centreon.com # Authors : Simon BOMM -# Mathieu Cinquin +# Mathieu Cinquin # # Based on De Bodt Lieven plugin #################################################################################### @@ -39,7 +39,6 @@ package centreon::plugins::httplib; use strict; use warnings; - use LWP::UserAgent; use HTTP::Cookies; use URI; @@ -128,13 +127,13 @@ sub connect { } if (defined($self->{option_results}->{cert_pkcs12}) && $self->{option_results}->{cert_file} ne '' && $self->{option_results}->{cert_pwd} ne '') { - use Net::SSL; + eval "use Net::SSL"; die $@ if $@; $ENV{HTTPS_PKCS12_FILE} = $self->{option_results}->{cert_file}; $ENV{HTTPS_PKCS12_PASSWORD} = $self->{option_results}->{cert_pwd}; } if (defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pkcs12})) { - use Net::SSL; + eval "use Net::SSL"; die $@ if $@; $ENV{HTTPS_CERT_FILE} = $self->{option_results}->{cert_file}; } diff --git a/database/mysql/mode/databasessize.pm b/database/mysql/mode/databasessize.pm index a397f2922..bf9ea1c76 100644 --- a/database/mysql/mode/databasessize.pm +++ b/database/mysql/mode/databasessize.pm @@ -100,7 +100,7 @@ sub run { $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("DB '" . $$row[0] . "' size: %s%s", $value, $value_unit)); } - $self->{output}->perfdata_add(label => $$row[0] . '_size', + $self->{output}->perfdata_add(label => $$row[0] . '_size', unit => 'B', value => $$row[1], warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/database/mysql/mysqlcmd.pm b/database/mysql/mysqlcmd.pm index 6b7c90131..fdc3d6050 100644 --- a/database/mysql/mysqlcmd.pm +++ b/database/mysql/mysqlcmd.pm @@ -64,6 +64,7 @@ sub new { "port:s@" => { name => 'port' }, "username:s@" => { name => 'username' }, "password:s@" => { name => 'password' }, + "socket:s@" => { name => 'socket' }, "sql-errors-exit:s" => { name => 'sql_errors_exit', default => 'unknown' }, }); } @@ -78,6 +79,7 @@ sub new { $self->{host} = undef; $self->{port} = undef; + $self->{socket} = undef; $self->{username} = undef; $self->{password} = undef; @@ -118,6 +120,7 @@ sub check_options { $self->{host} = (defined($self->{option_results}->{host})) ? shift(@{$self->{option_results}->{host}}) : undef; $self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : undef; + $self->{socket} = (defined($self->{option_results}->{socket})) ? shift(@{$self->{option_results}->{socket}}) : undef; $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : undef; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : undef; $self->{sql_errors_exit} = $self->{option_results}->{sql_errors_exit}; @@ -138,6 +141,9 @@ sub check_options { if (defined($self->{password}) && $self->{password} ne '') { push @{$self->{args}}, "-p" . $self->{password}; } + if (defined($self->{socket}) && $self->{socket} ne '') { + push @{$self->{args}}, "--socket", $self->{socket}; + } if (scalar(@{$self->{option_results}->{host}}) == 0) { return 0; diff --git a/database/mysql/plugin.pm b/database/mysql/plugin.pm index d8293dbcf..46fa55833 100644 --- a/database/mysql/plugin.pm +++ b/database/mysql/plugin.pm @@ -73,6 +73,7 @@ sub init { arguments => { 'host:s@' => { name => 'db_host' }, 'port:s@' => { name => 'db_port' }, + 'socket:s@' => { name => 'db_socket' }, } ); $self->{options}->parse_options(); @@ -89,6 +90,10 @@ sub init { $self->{sqldefault}->{dbi}[$i]->{data_source} .= ';port=' . $options_result->{db_port}[$i]; $self->{sqldefault}->{mysqlcmd}[$i]->{port} = $options_result->{db_port}[$i]; } + if (defined($options_result->{db_socket}[$i])) { + $self->{sqldefault}->{dbi}[$i]->{data_source} .= ';mysql_socket=' . $options_result->{db_socket}[$i]; + $self->{sqldefault}->{mysqlcmd}[$i]->{socket} = $options_result->{db_socket}[$i]; + } } } diff --git a/database/oracle/mode/rmanbackupage.pm b/database/oracle/mode/rmanbackupage.pm index f972f099c..2bd42d0b8 100644 --- a/database/oracle/mode/rmanbackupage.pm +++ b/database/oracle/mode/rmanbackupage.pm @@ -39,7 +39,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use Time::HiRes; +use DateTime; sub new { my ($class, %options) = @_; @@ -51,13 +51,17 @@ sub new { { "skip-no-backup" => { name => 'skip_no_backup', }, "filter-type:s" => { name => 'filter_type', }, - "warning-db-incr:s" => { name => 'warning_db_incr', }, - "critical-db-incr:s" => { name => 'critical_db_incr', }, - "warning-db-full:s" => { name => 'warning_db_full', }, - "critical-db-full:s" => { name => 'critical_db_full', }, - "warning-archivelog:s" => { name => 'warning_archivelog', }, - "critical-archivelog:s" => { name => 'critical_archivelog', }, + "timezone:s" => { name => 'timezone', }, }); + foreach (('db incr', 'db full', 'archivelog', 'controlfile')) { + my $label = $_; + $label =~ s/ /-/g; + $options{options}->add_options(arguments => { + 'warning-' . $label . ':s' => { name => 'warning-' . $label }, + 'critical-' . $label . ':s' => { name => 'critical-' . $label }, + 'no-' . $label => { name => 'no-' . $label }, + }); + } return $self; } @@ -66,29 +70,19 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning_db_incr', value => $self->{option_results}->{warning_db_incr})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-db-incr threshold '" . $self->{option_results}->{warning_db_incr} . "'."); - $self->{output}->option_exit(); + foreach (('db incr', 'db full', 'archivelog', 'controlfile')) { + my $label = $_; + $label =~ s/ /-/g; + foreach my $threshold (('warning', 'critical')) { + if (($self->{perfdata}->threshold_validate(label => $threshold . '-' . $label, value => $self->{option_results}->{$threshold . '-' . $label})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong " . $threshold . '-' . $label . " threshold '" . $self->{option_results}->{warning_db_incr} . "'."); + $self->{output}->option_exit(); + } + } } - if (($self->{perfdata}->threshold_validate(label => 'critical_db_incr', value => $self->{option_results}->{critical_db_incr})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-db-incr threshold '" . $self->{option_results}->{critical_db_incr} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning_db_full', value => $self->{option_results}->{warning_db_full})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-db-full threshold '" . $self->{option_results}->{warning_db_full} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_db_full', value => $self->{option_results}->{critical_db_full})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-db-full threshold '" . $self->{option_results}->{critical_db_full} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning_archivelog', value => $self->{option_results}->{warning_archivelog})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-archivelog threshold '" . $self->{option_results}->{warning_archivelog} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_archivelog', value => $self->{option_results}->{critical_archivelog})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-archivelog threshold '" . $self->{option_results}->{critical_archivelog} . "'."); - $self->{output}->option_exit(); + + if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') { + $ENV{TZ} = $self->{option_results}->{timezone}; } } @@ -99,7 +93,7 @@ sub run { $self->{sql}->connect(); my $query = q{SELECT object_type, count(*) as num, - ((max(start_time) - date '1970-01-01')*24*60*60 - TO_NUMBER(SUBSTR(TZ_OFFSET(DBTIMEZONE),1,3))*3600 - TO_NUMBER(SUBSTR(TZ_OFFSET(DBTIMEZONE),1,1) || SUBSTR(TZ_OFFSET(DBTIMEZONE),5,2))*60) as last_time + ((max(start_time) - date '1970-01-01')*24*60*60) as last_time FROM v$rman_status WHERE operation='BACKUP' GROUP BY object_type}; @@ -110,46 +104,54 @@ sub run { short_msg => sprintf("Rman backup age are ok.")); my $count_backups = 0; - foreach my $row (@$result) { - my ($type, $count, $last_time) = @$row; - $last_time = sprintf("%i", $last_time); - next if (defined($self->{option_results}->{filter_type}) && $type !~ /$self->{option_results}->{filter_type}/); - $count_backups++; - my $now = sprintf("%i",time()); - my $backup_age = $now - $last_time; - my $backup_age_convert = centreon::plugins::misc::change_seconds(value => $backup_age); - my $type_perfdata = $type; - $type_perfdata =~ s/\s+/_/; - $self->{output}->output_add(long_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert)); - my $exit_code; - if ($type =~ /incr/i) { + foreach (('db incr', 'db full', 'archivelog', 'controlfile')) { + my $executed = 0; + my $label = $_; + $label =~ s/ /-/g; + foreach my $row (@$result) { + next if ($$row[0] !~ /$_/i); + + $count_backups++; + $executed = 1; + my ($type, $count, $last_time) = @$row; + next if (defined($self->{option_results}->{filter_type}) && $type !~ /$self->{option_results}->{filter_type}/); + + my @values = localtime($last_time); + my $dt = DateTime->new( + year => $values[5] + 1900, + month => $values[4] + 1, + day => $values[3], + hour => $values[2], + minute => $values[1], + second => $values[0], + time_zone => 'UTC', + ); + my $offset = $last_time - $dt->epoch; + $last_time = $last_time + $offset; + + my $backup_age = time() - $last_time; + + my $backup_age_convert = centreon::plugins::misc::change_seconds(value => $backup_age); + my $type_perfdata = $type; + $type_perfdata =~ s/ /_/g; + $self->{output}->output_add(long_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert)); $self->{output}->perfdata_add(label => sprintf('%s_backup_age',$type_perfdata), value => $backup_age, unit => 's', - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_db_incr'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_db_incr'), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $label), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $label), min => 0); - $exit_code = $self->{perfdata}->threshold_check(value => $backup_age, threshold => [ { label => 'critical_db_incr', 'exit_litteral' => 'critical' }, { label => 'warning_db_incr', exit_litteral => 'warning' } ]); - } elsif ($type =~ /full/i) { - $self->{output}->perfdata_add(label => sprintf('%s_backup_age',$type_perfdata), - value => $backup_age, - unit => 's', - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_db_full'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_db_full'), - min => 0); - $exit_code = $self->{perfdata}->threshold_check(value => $backup_age, threshold => [ { label => 'critical_db_full', 'exit_litteral' => 'critical' }, { label => 'warning_db_full', exit_litteral => 'warning' } ]); - } elsif ($type =~ /archive/i) { - $self->{output}->perfdata_add(label => sprintf('%s_backup_age',$type_perfdata), - value => $backup_age, - unit => 's', - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_archivelog'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_archivelog'), - min => 0); - $exit_code = $self->{perfdata}->threshold_check(value => $backup_age, threshold => [ { label => 'critical_archivelog', 'exit_litteral' => 'critical' }, { label => 'warning_archivelog', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $backup_age, threshold => [ { label => 'critical-' . $label, exit_litteral => 'critical' }, { label => 'warning-' . $label, exit_litteral => 'warning' } ]); + + if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert)); + } } - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert)); + + if ($executed == 0 && !defined($self->{option_results}->{'no-' . $label})) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Rman '%s' backups never executed", uc($_))); } } @@ -172,39 +174,34 @@ Check Oracle rman backup age. =over 8 -=item B<--warning-db-incr> +=item B<--warning-*> -Threshold warning of DB INCR backups in seconds. +Threshold warning in seconds. +Can be: 'db-incr', 'db-full', 'archivelog', 'controlfile'. -=item B<--critical-db-incr> +=item B<--critical-*> -Threshold critical of DB INCR backups in seconds. +Threshold critical in seconds. +Can be: 'db-incr', 'db-full', 'archivelog', 'controlfile'. -=item B<--warning-db-full> +=item B<--no-*> -Threshold warning of DB FULL backups in seconds. - -=item B<--critical-db-full> - -Threshold critical of DB FULL backups in seconds. - -=item B<--warning-archivelog> - -Threshold warning of ARCHIVELOG backups in seconds. - -=item B<--critical-archivelog> - -Threshold critical of ARCHIVELOG backups in seconds. +Skip error if never executed. +Can be: 'db-incr', 'db-full', 'archivelog', 'controlfile'. =item B<--filter-type> Filter backup type. (type can be : 'DB INCR', 'DB FULL', 'ARCHIVELOG') -=item B<--skip-bo-backup> +=item B<--skip-no-backup> Return ok if no backup found. +=item B<--timezone> + +Timezone of oracle server (If not set, we use current server execution timezone) + =back =cut diff --git a/database/oracle/mode/rmanbackupproblems.pm b/database/oracle/mode/rmanbackupproblems.pm index b94b314cf..9d07ba507 100644 --- a/database/oracle/mode/rmanbackupproblems.pm +++ b/database/oracle/mode/rmanbackupproblems.pm @@ -77,11 +77,11 @@ sub run { $self->{sql}->connect(); my $retention = $self->{option_results}->{retention}; - my $query = q{SELECT COUNT(*) FROM v$rman_status WHERE status != 'COMPLETED' AND status != 'RUNNING' AND start_time > sysdate-} . $retention; + my $query = q{SELECT COUNT(*) FROM v$rman_status WHERE operation = 'BACKUP' AND status != 'COMPLETED' AND status != 'RUNNING' AND start_time > sysdate-} . $retention; $self->{sql}->query(query => $query); my $rman_backup_problems = $self->{sql}->fetchrow_array(); - my $exit_code = $self->{perfdata}->threshold_check(value => $rman_backup_problems, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $rman_backup_problems, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("rman had %i problems during the last %i days", $rman_backup_problems, $self->{option_results}->{retention})); $self->{output}->perfdata_add(label => 'rman_backup_problems', diff --git a/database/oracle/mode/rmanonlinebackupage.pm b/database/oracle/mode/rmanonlinebackupage.pm index 29f790a06..b6d4d1d59 100644 --- a/database/oracle/mode/rmanonlinebackupage.pm +++ b/database/oracle/mode/rmanonlinebackupage.pm @@ -39,7 +39,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use Time::HiRes; +use DateTime; sub new { my ($class, %options) = @_; @@ -49,9 +49,9 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "skip-no-backup" => { name => 'skip_no_backup', }, "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, + "timezone:s" => { name => 'timezone', }, }); return $self; @@ -69,6 +69,10 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } + + if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') { + $ENV{TZ} = $self->{option_results}->{timezone}; + } } sub run { @@ -77,7 +81,7 @@ sub run { $self->{sql} = $options{sql}; $self->{sql}->connect(); - my $query = q{SELECT min(((time - date '1970-01-01') * 86400) - TO_NUMBER(SUBSTR(TZ_OFFSET(DBTIMEZONE),1,3))*3600 - TO_NUMBER(SUBSTR(TZ_OFFSET(DBTIMEZONE),1,1) || SUBSTR(TZ_OFFSET(DBTIMEZONE),5,2))*60 ) as last_time + my $query = q{SELECT min(((time - date '1970-01-01') * 86400)) as last_time FROM v$backup WHERE STATUS='ACTIVE' }; @@ -85,36 +89,35 @@ sub run { my $result = $self->{sql}->fetchall_arrayref(); $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("Rman online backup age are ok.")); + short_msg => sprintf("Backup online modes are ok.")); - my $count_backups = 0; foreach my $row (@$result) { next if (!defined($$row[0])); my $last_time = $$row[0]; - $last_time = sprintf("%i", $last_time); - $count_backups++; - my $now = sprintf("%i",time()); - my $backup_age = $now - $last_time; - my $backup_age_convert = centreon::plugins::misc::change_seconds(value => $backup_age); - $self->{output}->output_add(long_msg => sprintf("Last Rman online backup : %s", $backup_age_convert)); - $self->{output}->perfdata_add(label => 'online_backup_age', - value => $backup_age, - unit => 's', - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); - my $exit_code = $self->{perfdata}->threshold_check(value => $backup_age, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + my @values = localtime($last_time); + my $dt = DateTime->new( + year => $values[5] + 1900, + month => $values[4] + 1, + day => $values[3], + hour => $values[2], + minute => $values[1], + second => $values[0], + time_zone => 'UTC', + ); + my $offset = $last_time - $dt->epoch; + $last_time = $last_time + $offset; + + my $launched = time() - $last_time; + my $launched_convert = centreon::plugins::misc::change_seconds(value => $launched); + $self->{output}->output_add(long_msg => sprintf("backup online mode since %s (%s)", $launched_convert, locatime($last_time))); + my $exit_code = $self->{perfdata}->threshold_check(value => $launched, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Last Rman online backup : %s", $backup_age_convert)); + short_msg => sprintf("backup online mode since %s (%s)", $launched_convert, locatime($last_time))); } } - if (($count_backups == 0) && (!defined($self->{option_results}->{skip_no_backup}))) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Rman online backups never executed.")); - } - $self->{output}->display(); $self->{output}->exit(); } @@ -125,7 +128,7 @@ __END__ =head1 MODE -Check Oracle rman online backup age. +Check Oracle backup online mode. =over 8 @@ -137,9 +140,9 @@ Threshold warning in seconds. Threshold critical in seconds. -=item B<--skip-bo-backup> +=item B<--timezone> -Return ok if no backup found. +Timezone of oracle server (If not set, we use current server execution timezone) =back diff --git a/database/postgres/mode/connectiontime.pm b/database/postgres/mode/connectiontime.pm index d3e7c4a47..a60afae92 100644 --- a/database/postgres/mode/connectiontime.pm +++ b/database/postgres/mode/connectiontime.pm @@ -86,7 +86,7 @@ sub run { } else { my $milliseconds = $now2 - $now; $milliseconds = floor($milliseconds * 1000); - my $exit_code = $self->{perfdata}->threshold_check(value => $milliseconds, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $milliseconds, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("Connection established in %.3fs.", $milliseconds / 1000)); $self->{output}->perfdata_add(label => 'connection_time', unit => 'ms', diff --git a/database/postgres/mode/querytime.pm b/database/postgres/mode/querytime.pm index 1c0ee1fdd..f3504b99c 100644 --- a/database/postgres/mode/querytime.pm +++ b/database/postgres/mode/querytime.pm @@ -110,7 +110,7 @@ ORDER BY query_start, procpid DESC next; } - my $exit_code = $self->{perfdata}->threshold_check(value => $row->{seconds}, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $row->{seconds}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if ($self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { $self->{output}->output_add(long_msg => sprintf("Request from client '%s' too long (%d sec) on database '%s': %s", $row->{client_addr}, $row->{seconds}, $row->{datname}, $row->{current_query})); diff --git a/database/postgres/mode/tablespace.pm b/database/postgres/mode/tablespace.pm index 1c65cb797..f03d6215a 100644 --- a/database/postgres/mode/tablespace.pm +++ b/database/postgres/mode/tablespace.pm @@ -91,13 +91,14 @@ sub run { $self->{output}->output_add(severity => $exit_code, short_msg => sprintf('Tablespace "%s" size is %s %s',$self->{option_results}->{tablespace}, $value, $value_unit)); - $self->{output}->perfdata_add(label => $self->{option_results}->{tablespace}, + $self->{output}->perfdata_add(label => $self->{option_results}->{tablespace}, unit => 'B', value => $result, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0); } else { $self->{output}->output_add(severity => 'UNKNOWN', - short_msg => sprintf('Table space "%s" is unknown ...',$self->{option_results}->{tablespace})); + short_msg => sprintf('Table space "%s" is unknown ...', $self->{option_results}->{tablespace})); } $self->{output}->display(); diff --git a/network/alcatel/common/mode/flashmemory.pm b/network/alcatel/common/mode/flashmemory.pm index 47b9e0a06..25298a67a 100644 --- a/network/alcatel/common/mode/flashmemory.pm +++ b/network/alcatel/common/mode/flashmemory.pm @@ -115,7 +115,7 @@ sub run { $free_value . " " . $free_unit, $prct_free)); } - $self->{output}->perfdata_add(label => "used_" . $memory_name, + $self->{output}->perfdata_add(label => "used_" . $memory_name, unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/aruba/common/mode/memory.pm b/network/aruba/common/mode/memory.pm index 1a52f7c22..fcddfcffe 100644 --- a/network/aruba/common/mode/memory.pm +++ b/network/aruba/common/mode/memory.pm @@ -117,13 +117,13 @@ sub run { } if ($mode == 1) { - $self->{output}->perfdata_add(label => "used_" . $memory_name, + $self->{output}->perfdata_add(label => "used_" . $memory_name, unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), min => 0, max => $total_size); } else { - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/cisco/common/mode/memory.pm b/network/cisco/common/mode/memory.pm index 93747657f..dab782fec 100644 --- a/network/cisco/common/mode/memory.pm +++ b/network/cisco/common/mode/memory.pm @@ -112,7 +112,7 @@ sub check_table_memory { $free_value . " " . $free_unit, $prct_free)); } - $self->{output}->perfdata_add(label => "used_" . $memory_name, + $self->{output}->perfdata_add(label => "used_" . $memory_name, unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/hp/procurve/mode/memory.pm b/network/hp/procurve/mode/memory.pm index 5d72c78a6..40e6e9438 100644 --- a/network/hp/procurve/mode/memory.pm +++ b/network/hp/procurve/mode/memory.pm @@ -94,7 +94,7 @@ sub run { my $prct_used = $memory_used * 100 / $total_size; my $prct_free = 100 - $prct_used; - my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $memory_used); my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); @@ -111,7 +111,7 @@ sub run { $free_value . " " . $free_unit, $prct_free)); } - $self->{output}->perfdata_add(label => "used_" . $instance, + $self->{output}->perfdata_add(label => "used_" . $instance, unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/juniper/common/junos/mode/memoryrouting.pm b/network/juniper/common/junos/mode/memoryrouting.pm index 8b879333e..8e21a09af 100644 --- a/network/juniper/common/junos/mode/memoryrouting.pm +++ b/network/juniper/common/junos/mode/memoryrouting.pm @@ -134,7 +134,7 @@ sub run { my $extra_label = ''; $extra_label = '_' . $description if ($multiple == 1); - $self->{output}->perfdata_add(label => "used" . $extra_label, + $self->{output}->perfdata_add(label => "used" . $extra_label, unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/juniper/common/screenos/mode/cpu.pm b/network/juniper/common/screenos/mode/cpu.pm index 1bb27cc30..d311eca68 100644 --- a/network/juniper/common/screenos/mode/cpu.pm +++ b/network/juniper/common/screenos/mode/cpu.pm @@ -104,28 +104,28 @@ sub run { my $cpu15min = $result->{$oid_nsResCpuLast15Min}; my $exit1 = $self->{perfdata}->threshold_check(value => $cpu1min, - threshold => [ { label => 'crit1min', 'exit_litteral' => 'critical' }, { label => 'warn1min', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit1min', exit_litteral => 'critical' }, { label => 'warn1min', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $cpu5min, - threshold => [ { label => 'crit5min', 'exit_litteral' => 'critical' }, { label => 'warn5min', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit5min', exit_litteral => 'critical' }, { label => 'warn5min', exit_litteral => 'warning' } ]); my $exit3 = $self->{perfdata}->threshold_check(value => $cpu15min, - threshold => [ { label => 'crit15min', 'exit_litteral' => 'critical' }, { label => 'warn15min', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit15min', exit_litteral => 'critical' }, { label => 'warn15min', exit_litteral => 'warning' } ]); my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("CPU Usage: %.2f%% (1min), %.2f%% (5min), %.2f%% (15min)", $cpu1min, $cpu5min, $cpu15min)); - $self->{output}->perfdata_add(label => "cpu_1min", + $self->{output}->perfdata_add(label => "cpu_1min", unit => '%', value => $cpu1min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1min'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1min'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_5min", + $self->{output}->perfdata_add(label => "cpu_5min", unit => '%', value => $cpu5min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5min'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5min'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_15min", + $self->{output}->perfdata_add(label => "cpu_15min", unit => '%', value => $cpu15min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn15min'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit15min'), diff --git a/network/juniper/common/screenos/mode/memory.pm b/network/juniper/common/screenos/mode/memory.pm index af617da27..477332364 100644 --- a/network/juniper/common/screenos/mode/memory.pm +++ b/network/juniper/common/screenos/mode/memory.pm @@ -101,7 +101,7 @@ sub run { $free_value . " " . $free_unit, $prct_free, $frag_value . " " . $frag_unit, $prct_frag)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/juniper/ggsn/mode/globalstats.pm b/network/juniper/ggsn/mode/globalstats.pm index 9e7278a12..9534d2350 100644 --- a/network/juniper/ggsn/mode/globalstats.pm +++ b/network/juniper/ggsn/mode/globalstats.pm @@ -41,7 +41,6 @@ use strict; use warnings; use centreon::plugins::values; use centreon::plugins::statefile; -use Digest::MD5 qw(md5_hex); my $maps_counters = { '000_traffic-in' => { class => 'centreon::plugins::values', obj => undef, @@ -279,7 +278,7 @@ sub run { $self->manage_selection(); $self->{new_datas} = {}; - $self->{statefile_value}->read(statefile => "juniper_ggsn_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('.*'))); + $self->{statefile_value}->read(statefile => "juniper_ggsn_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); $self->{new_datas}->{last_timestamp} = time(); my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); @@ -377,10 +376,6 @@ Can be: 'traffic-in' (bps), 'traffic-out' (bps), 'drop-in' (%), 'drop-out' (%), 'attempted-self-deactivation-pdp', 'completed-activation-pdp', 'completed-update-pdp', 'completed-deactivation-pdp', 'completed-self-deactivation-pdp'. -=item B<--filter-name> - -Filter APN name (can be a regexp). - =back =cut diff --git a/network/radware/alteon/common/mode/cpu.pm b/network/radware/alteon/common/mode/cpu.pm index f0b0b01f2..c076d6ec9 100644 --- a/network/radware/alteon/common/mode/cpu.pm +++ b/network/radware/alteon/common/mode/cpu.pm @@ -115,17 +115,17 @@ sub run { short_msg => sprintf("MP CPU Usage: %.2f%% (1sec), %.2f%% (4sec), %.2f%% (64sec)", $cpu1sec, $cpu4sec, $cpu64sec)); - $self->{output}->perfdata_add(label => "cpu_1s", + $self->{output}->perfdata_add(label => "cpu_1s", unit => '%', value => $cpu1sec, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1s'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_4s", + $self->{output}->perfdata_add(label => "cpu_4s", unit => '%', value => $cpu4sec, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn4s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit4s'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_64s", + $self->{output}->perfdata_add(label => "cpu_64s", unit => '%', value => $cpu64sec, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn64s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit64s'), diff --git a/network/radware/alteon/common/mode/memory.pm b/network/radware/alteon/common/mode/memory.pm index b5adb471d..578945171 100644 --- a/network/radware/alteon/common/mode/memory.pm +++ b/network/radware/alteon/common/mode/memory.pm @@ -96,7 +96,7 @@ sub run { $used_value . " " . $used_unit, $prct_used, $free_value . " " . $free_unit, $prct_free)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/network/redback/snmp/mode/cpu.pm b/network/redback/snmp/mode/cpu.pm index 7b12efc9b..51e864c96 100644 --- a/network/redback/snmp/mode/cpu.pm +++ b/network/redback/snmp/mode/cpu.pm @@ -132,17 +132,17 @@ sub run { short_msg => sprintf("CPU: %.2f%% (5sec), %.2f%% (1min), %.2f%% (5min)", $cpu5sec, $cpu1min, $cpu5min)); - $self->{output}->perfdata_add(label => "cpu_5s", + $self->{output}->perfdata_add(label => "cpu_5s", unit => '%', value => $cpu5sec, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5s'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_1m", + $self->{output}->perfdata_add(label => "cpu_1m", unit => '%', value => $cpu1min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_5m", + $self->{output}->perfdata_add(label => "cpu_5m", unit => '%', value => $cpu5min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), diff --git a/network/ruggedcom/mode/memory.pm b/network/ruggedcom/mode/memory.pm index 3df91f14e..58b1e846f 100644 --- a/network/ruggedcom/mode/memory.pm +++ b/network/ruggedcom/mode/memory.pm @@ -93,7 +93,7 @@ sub run { $used_value . " " . $used_unit, $prct_used, $total_value . " " . $total_unit)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), diff --git a/network/stonesoft/mode/clusterload.pm b/network/stonesoft/snmp/mode/clusterload.pm similarity index 98% rename from network/stonesoft/mode/clusterload.pm rename to network/stonesoft/snmp/mode/clusterload.pm index 95702bc33..60340f27a 100644 --- a/network/stonesoft/mode/clusterload.pm +++ b/network/stonesoft/snmp/mode/clusterload.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::clusterload; +package network::stonesoft::snmp::mode::clusterload; use base qw(centreon::plugins::mode); diff --git a/network/stonesoft/mode/clusterstate.pm b/network/stonesoft/snmp/mode/clusterstate.pm similarity index 98% rename from network/stonesoft/mode/clusterstate.pm rename to network/stonesoft/snmp/mode/clusterstate.pm index b19d83593..3c9a3f9e7 100644 --- a/network/stonesoft/mode/clusterstate.pm +++ b/network/stonesoft/snmp/mode/clusterstate.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::clusterstate; +package network::stonesoft::snmp::mode::clusterstate; use base qw(centreon::plugins::mode); diff --git a/network/stonesoft/snmp/mode/connections.pm b/network/stonesoft/snmp/mode/connections.pm new file mode 100644 index 000000000..734eb3d5a --- /dev/null +++ b/network/stonesoft/snmp/mode/connections.pm @@ -0,0 +1,204 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::stonesoft::snmp::mode::connections; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; +use centreon::plugins::statefile; + +my $maps_counters = { + '000_connections' => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'fwConnNumber', diff => 1 }, + ], + output_template => 'Connections : %s', + perfdatas => [ + { label => 'connections', value => 'fwConnNumber_absolute', template => '%s', + unit => 'con', min => 0 }, + ], + } + }, + '001_rate-connections' => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'fwConnNumber', diff => 1 }, + ], + per_second => 1, + output_template => 'Rate Connections : %.2f /s', + perfdatas => [ + { label => 'rate_connections', value => 'fwConnNumber_per_second', template => '%.2f', + unit => 'con/s', min => 0 }, + ], + } + }, +}; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + $self->{statefile_value} = centreon::plugins::statefile->new(%options); + + foreach (keys %{$maps_counters}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + my $class = $maps_counters->{$_}->{class}; + $maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value}, + output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach (keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); + } + + $self->{statefile_value}->check_options(%options); +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); + + if ($self->{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + $self->manage_selection(); + + $self->{new_datas} = {}; + $self->{statefile_value}->read(statefile => "stonesoft_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); + $self->{new_datas}->{last_timestamp} = time(); + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->set(instance => 'global'); + + my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{global}, + new_datas => $self->{new_datas}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); + push @exits, $exit2; + + my $output = $maps_counters->{$_}->{obj}->output(); + $long_msg .= $long_msg_append . $output; + $long_msg_append = ', '; + + if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { + $short_msg .= $short_msg_append . $output; + $short_msg_append = ', '; + } + + $maps_counters->{$_}->{obj}->perfdata(); + } + + my $exit = $self->{output}->get_most_critical(status => [ @exits ]); + if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { + $self->{output}->output_add(severity => $exit, + short_msg => "$short_msg" + ); + } else { + $self->{output}->output_add(short_msg => "$long_msg"); + } + + $self->{statefile_value}->write(data => $self->{new_datas}); + $self->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_fwConnNumber = '.1.3.6.1.4.1.1369.5.2.1.4.0'; + $self->{results} = $self->{snmp}->get_leef(oids => [$oid_fwConnNumber], + nothing_quit => 1); + $self->{global} = { fwConnNumber => $self->{result}->{$oid_fwConnNumber} }; +} + +1; + +__END__ + +=head1 MODE + +Check firewall connections. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'connections', 'rate-connections'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'connections', 'rate-connections'. + +=back + +=cut diff --git a/network/stonesoft/mode/cpu.pm b/network/stonesoft/snmp/mode/cpu.pm similarity index 99% rename from network/stonesoft/mode/cpu.pm rename to network/stonesoft/snmp/mode/cpu.pm index ae2e8a24e..570838ae8 100644 --- a/network/stonesoft/mode/cpu.pm +++ b/network/stonesoft/snmp/mode/cpu.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::cpu; +package network::stonesoft::snmp::mode::cpu; use base qw(centreon::plugins::mode); diff --git a/network/stonesoft/mode/droppedpackets.pm b/network/stonesoft/snmp/mode/droppedpackets.pm similarity index 99% rename from network/stonesoft/mode/droppedpackets.pm rename to network/stonesoft/snmp/mode/droppedpackets.pm index 4376a7e8b..6b5229cea 100644 --- a/network/stonesoft/mode/droppedpackets.pm +++ b/network/stonesoft/snmp/mode/droppedpackets.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::droppedpackets; +package network::stonesoft::snmp::mode::droppedpackets; use base qw(centreon::plugins::mode); diff --git a/network/stonesoft/mode/memory.pm b/network/stonesoft/snmp/mode/memory.pm similarity index 97% rename from network/stonesoft/mode/memory.pm rename to network/stonesoft/snmp/mode/memory.pm index 9f1f4cdb9..6dfd58466 100644 --- a/network/stonesoft/mode/memory.pm +++ b/network/stonesoft/snmp/mode/memory.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::memory; +package network::stonesoft::snmp::mode::memory; use base qw(centreon::plugins::mode); @@ -132,13 +132,13 @@ sub run { $buffer_value . " " . $buffer_unit, $cached_value . " " . $cached_unit)); - $self->{output}->perfdata_add(label => "cached", + $self->{output}->perfdata_add(label => "cached", unit => 'B', value => $cached_used, min => 0); - $self->{output}->perfdata_add(label => "buffer", + $self->{output}->perfdata_add(label => "buffer", unit => 'B', value => $buffer_used, min => 0); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $nobuf_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), @@ -168,7 +168,7 @@ sub run { $swap_used_value . " " . $swap_used_unit, $prct_used, $swap_free_value . " " . $swap_free_unit, (100 - $prct_used))); - $self->{output}->perfdata_add(label => "swap", + $self->{output}->perfdata_add(label => "swap", unit => 'B', value => $swap_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-swap', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-swap', total => $total_size, cast_int => 1), diff --git a/network/stonesoft/mode/rejectedpackets.pm b/network/stonesoft/snmp/mode/rejectedpackets.pm similarity index 99% rename from network/stonesoft/mode/rejectedpackets.pm rename to network/stonesoft/snmp/mode/rejectedpackets.pm index 1aac66784..e17c3bd52 100644 --- a/network/stonesoft/mode/rejectedpackets.pm +++ b/network/stonesoft/snmp/mode/rejectedpackets.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::rejectedpackets; +package network::stonesoft::snmp::mode::rejectedpackets; use base qw(centreon::plugins::mode); diff --git a/network/stonesoft/mode/storage.pm b/network/stonesoft/snmp/mode/storage.pm similarity index 98% rename from network/stonesoft/mode/storage.pm rename to network/stonesoft/snmp/mode/storage.pm index 21aa4bfc8..2baa99f15 100644 --- a/network/stonesoft/mode/storage.pm +++ b/network/stonesoft/snmp/mode/storage.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::mode::storage; +package network::stonesoft::snmp::mode::storage; use base qw(centreon::plugins::mode); @@ -109,7 +109,7 @@ sub run { $threshold_value = $prct_used; $threshold_value = $prct_free if (defined($self->{option_results}->{free})); } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $total_size); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $total_used); diff --git a/network/stonesoft/plugin.pm b/network/stonesoft/snmp/plugin.pm similarity index 89% rename from network/stonesoft/plugin.pm rename to network/stonesoft/snmp/plugin.pm index 5c50b1731..500242119 100644 --- a/network/stonesoft/plugin.pm +++ b/network/stonesoft/snmp/plugin.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::stonesoft::plugin; +package network::stonesoft::snmp::plugin; use strict; use warnings; @@ -47,13 +47,14 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'memory' => 'network::stonesoft::mode::memory', - 'cpu' => 'network::stonesoft::mode::cpu', - 'storage' => 'network::stonesoft::mode::storage', - 'cluster-state' => 'network::stonesoft::mode::clusterstate', - 'cluster-load' => 'network::stonesoft::mode::clusterload', - 'rejected-packets' => 'network::stonesoft::mode::rejectedpackets', - 'dropped-packets' => 'network::stonesoft::mode::droppedpackets', + 'memory' => 'network::stonesoft::snmp::mode::memory', + 'cpu' => 'network::stonesoft::snmp::mode::cpu', + 'connections' => 'network::stonesoft::snmp::mode::connections', + 'storage' => 'network::stonesoft::snmp::mode::storage', + 'cluster-state' => 'network::stonesoft::snmp::mode::clusterstate', + 'cluster-load' => 'network::stonesoft::snmp::mode::clusterload', + 'rejected-packets' => 'network::stonesoft::snmp::mode::rejectedpackets', + 'dropped-packets' => 'network::stonesoft::snmp::mode::droppedpackets', 'traffic' => 'snmp_standard::mode::traffic', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', ); diff --git a/os/linux/local/mode/cpu.pm b/os/linux/local/mode/cpu.pm index 5eee43f49..c49ad1b60 100644 --- a/os/linux/local/mode/cpu.pm +++ b/os/linux/local/mode/cpu.pm @@ -146,7 +146,7 @@ sub run { if ($i > 0) { my $avg_cpu = $cpu / $i; my $exit_code = $self->{perfdata}->threshold_check(value => $avg_cpu, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("CPU(s) average usage is: %.2f%%", $avg_cpu)); $self->{output}->perfdata_add(label => 'total_cpu_avg', unit => '%', diff --git a/os/linux/local/mode/memory.pm b/os/linux/local/mode/memory.pm index 13655208d..e737c3f5d 100644 --- a/os/linux/local/mode/memory.pm +++ b/os/linux/local/mode/memory.pm @@ -124,13 +124,13 @@ sub run { $buffer_value . " " . $buffer_unit, $cached_value . " " . $cached_unit)); - $self->{output}->perfdata_add(label => "cached", + $self->{output}->perfdata_add(label => "cached", unit => 'B', value => $cached_used, min => 0); - $self->{output}->perfdata_add(label => "buffer", + $self->{output}->perfdata_add(label => "buffer", unit => 'B', value => $buffer_used, min => 0); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $nobuf_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/os/linux/local/mode/swap.pm b/os/linux/local/mode/swap.pm index 169d8dff1..48d40761c 100644 --- a/os/linux/local/mode/swap.pm +++ b/os/linux/local/mode/swap.pm @@ -133,7 +133,7 @@ sub run { $swap_used_value . " " . $swap_used_unit, $prct_used, $swap_free_value . " " . $swap_free_unit, (100 - $prct_used))); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $swap_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/os/linux/local/mode/uptime.pm b/os/linux/local/mode/uptime.pm index 9adc36d08..4c1282a25 100644 --- a/os/linux/local/mode/uptime.pm +++ b/os/linux/local/mode/uptime.pm @@ -101,8 +101,8 @@ sub run { } my $exit_code = $self->{perfdata}->threshold_check(value => floor($uptime), - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->perfdata_add(label => 'uptime', + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->perfdata_add(label => 'uptime', unit => 's', value => floor($uptime), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/os/windows/snmp/mode/memory.pm b/os/windows/snmp/mode/memory.pm index 57421f74d..31e45911a 100644 --- a/os/windows/snmp/mode/memory.pm +++ b/os/windows/snmp/mode/memory.pm @@ -117,7 +117,7 @@ sub run { $physical_used_value . " " . $physical_used_unit, $prct_used, $physical_free_value . " " . $physical_free_unit, 100 - $prct_used)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $physical_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), diff --git a/os/windows/snmp/mode/swap.pm b/os/windows/snmp/mode/swap.pm index 60b186650..facc2dfee 100644 --- a/os/windows/snmp/mode/swap.pm +++ b/os/windows/snmp/mode/swap.pm @@ -117,7 +117,7 @@ sub run { $swap_used_value . " " . $swap_used_unit, $prct_used, $swap_free_value . " " . $swap_free_unit, 100 - $prct_used)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $swap_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), diff --git a/snmp_standard/mode/memory.pm b/snmp_standard/mode/memory.pm index 28c7e2ead..e111325c9 100644 --- a/snmp_standard/mode/memory.pm +++ b/snmp_standard/mode/memory.pm @@ -120,7 +120,7 @@ sub run { my $total_size = $result->{$oid_memTotalReal} * 1024; my $prct_used = $nobuf_used * 100 / $total_size; - my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($nobuf_value, $nobuf_unit) = $self->{perfdata}->change_bytes(value => $nobuf_used); my ($buffer_value, $buffer_unit) = $self->{perfdata}->change_bytes(value => $buffer_used); @@ -134,13 +134,13 @@ sub run { $cached_value . " " . $cached_unit, $shared_value . " " . $shared_unit)); - $self->{output}->perfdata_add(label => "cached", + $self->{output}->perfdata_add(label => "cached", unit => 'B', value => $cached_used, min => 0); - $self->{output}->perfdata_add(label => "buffer", + $self->{output}->perfdata_add(label => "buffer", unit => 'B', value => $buffer_used, min => 0); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $nobuf_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), @@ -170,7 +170,7 @@ sub run { $swap_used_value . " " . $swap_used_unit, $prct_used, $swap_free_value . " " . $swap_free_unit, (100 - $prct_used))); - $self->{output}->perfdata_add(label => "swap", + $self->{output}->perfdata_add(label => "swap", unit => 'B', value => $swap_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-swap', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-swap', total => $total_size, cast_int => 1), diff --git a/snmp_standard/mode/swap.pm b/snmp_standard/mode/swap.pm index 032b37a3d..e06431c94 100644 --- a/snmp_standard/mode/swap.pm +++ b/snmp_standard/mode/swap.pm @@ -109,7 +109,7 @@ sub run { $swap_used_value . " " . $swap_used_unit, $prct_used, $swap_free_value . " " . $swap_free_unit, (100 - $prct_used))); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $swap_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), diff --git a/snmp_standard/mode/uptime.pm b/snmp_standard/mode/uptime.pm index 4c9e3febe..bcd857de5 100644 --- a/snmp_standard/mode/uptime.pm +++ b/snmp_standard/mode/uptime.pm @@ -96,8 +96,8 @@ sub run { } my $exit_code = $self->{perfdata}->threshold_check(value => floor($value / 100), - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->perfdata_add(label => 'uptime', + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->perfdata_add(label => 'uptime', unit => 's', value => floor($value / 100), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/storage/netapp/mode/filesys.pm b/storage/netapp/mode/filesys.pm index 9ad90abdd..956d09d08 100644 --- a/storage/netapp/mode/filesys.pm +++ b/storage/netapp/mode/filesys.pm @@ -204,7 +204,7 @@ sub run { $total_options{total} = $total_size; $total_options{cast_int} = 1; } - $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'o', + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', value => $value_perf, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', %total_options), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', %total_options), diff --git a/storage/panzura/snmp/mode/diskusagelocal.pm b/storage/panzura/snmp/mode/diskusagelocal.pm index d35be397c..c11a09c11 100644 --- a/storage/panzura/snmp/mode/diskusagelocal.pm +++ b/storage/panzura/snmp/mode/diskusagelocal.pm @@ -102,7 +102,7 @@ sub run { $used_value . " " . $used_unit, $prct_used, $free_value . " " . $free_unit, $prct_free)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/storage/panzura/snmp/mode/memory.pm b/storage/panzura/snmp/mode/memory.pm index 43fc25bb6..ed7a52726 100644 --- a/storage/panzura/snmp/mode/memory.pm +++ b/storage/panzura/snmp/mode/memory.pm @@ -103,7 +103,7 @@ sub run { $used_value . " " . $used_unit, $prct_used, $free_value . " " . $free_unit, $prct_free)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), diff --git a/storage/qnap/snmp/mode/memory.pm b/storage/qnap/snmp/mode/memory.pm index fbdbceed9..315e31680 100644 --- a/storage/qnap/snmp/mode/memory.pm +++ b/storage/qnap/snmp/mode/memory.pm @@ -117,7 +117,7 @@ sub run { $used_value . " " . $used_unit, $prct_used, $free_value . " " . $free_unit, $prct_free)); - $self->{output}->perfdata_add(label => "used", + $self->{output}->perfdata_add(label => "used", unit => 'B', value => int($memory_used), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),