From 366e5cca067a5e67d5a8868e6f8a7cb1c514465a Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 14 Sep 2015 11:27:37 +0200 Subject: [PATCH 01/68] Add EMC/Xtremio first checks --- .../emc/xtremio/restapi/custom/xtremioapi.pm | 231 ++++++++++++++++++ .../emc/xtremio/restapi/mode/clusterhealth.pm | 219 +++++++++++++++++ .../emc/xtremio/restapi/mode/ssdendurance.pm | 152 ++++++++++++ storage/emc/xtremio/restapi/mode/ssdiops.pm | 208 ++++++++++++++++ storage/emc/xtremio/restapi/mode/xenvscpu.pm | 153 ++++++++++++ .../emc/xtremio/restapi/mode/xenvsstate.pm | 190 ++++++++++++++ storage/emc/xtremio/restapi/plugin.pm | 58 +++++ 7 files changed, 1211 insertions(+) create mode 100644 storage/emc/xtremio/restapi/custom/xtremioapi.pm create mode 100644 storage/emc/xtremio/restapi/mode/clusterhealth.pm create mode 100644 storage/emc/xtremio/restapi/mode/ssdendurance.pm create mode 100644 storage/emc/xtremio/restapi/mode/ssdiops.pm create mode 100644 storage/emc/xtremio/restapi/mode/xenvscpu.pm create mode 100644 storage/emc/xtremio/restapi/mode/xenvsstate.pm create mode 100644 storage/emc/xtremio/restapi/plugin.pm diff --git a/storage/emc/xtremio/restapi/custom/xtremioapi.pm b/storage/emc/xtremio/restapi/custom/xtremioapi.pm new file mode 100644 index 000000000..b766cb827 --- /dev/null +++ b/storage/emc/xtremio/restapi/custom/xtremioapi.pm @@ -0,0 +1,231 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::custom::xtremioapi; + +use strict; +use warnings; +use centreon::plugins::http; +use JSON; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + # $options{options} = options object + # $options{output} = output object + # $options{exit_value} = integer + # $options{noptions} = integer + + if (!defined($options{output})) { + print "Class Custom: Need to specify 'output' argument.\n"; + exit 3; + } + if (!defined($options{options})) { + $options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument."); + $options{output}->option_exit(); + } + + if (!defined($options{noptions})) { + $options{options}->add_options(arguments => + { + "hostname:s@" => { name => 'hostname', }, + "xtremio-username:s@" => { name => 'xtremio_username', }, + "xtremio-password:s@" => { name => 'xtremio_password', }, + "proxyurl:s@" => { name => 'proxyurl', }, + "timeout:s@" => { name => 'timeout', }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(output => $self->{output}); + + return $self; + +} + +# Method to manage multiples +sub set_options { + my ($self, %options) = @_; + # options{options_result} + + $self->{option_results} = $options{option_results}; +} + +# Method to manage multiples +sub set_defaults { + my ($self, %options) = @_; + # options{default} + + # Manage default value + foreach (keys %{$options{default}}) { + if ($_ eq $self->{mode}) { + for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { + foreach my $opt (keys %{$options{default}->{$_}[$i]}) { + if (!defined($self->{option_results}->{$opt}[$i])) { + $self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt}; + } + } + } + } + } +} + +sub check_options { + my ($self, %options) = @_; +# # return 1 = ok still hostname +# # return 0 = no hostname left + + $self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef; + $self->{xtremio_username} = (defined($self->{option_results}->{xtremio_username})) ? shift(@{$self->{option_results}->{xtremio_username}}) : ''; + $self->{xtremio_password} = (defined($self->{option_results}->{xtremio_password})) ? shift(@{$self->{option_results}->{xtremio_password}}) : ''; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; + $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; + + if (!defined($self->{hostname})) { + $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); + $self->{output}->option_exit(); + } + + if (!defined($self->{xtremio_username}) || !defined($self->{xtremio_password})) { + $self->{output}->add_option_msg(short_msg => "Need to specify --xtremio-username and --xtremio-password options."); + $self->{output}->option_exit(); + } + + if (!defined($self->{hostname}) || + scalar(@{$self->{option_results}->{hostname}}) == 0) { + return 0; + } + return 1; +} + + +sub build_options_for_httplib { + my ($self, %options) = @_; + + $self->{option_results}->{hostname} = $self->{xtremio_username}.':'.$self->{xtremio_password}.'@'.$self->{hostname}; + $self->{option_results}->{timeout} = $self->{timeout}; + $self->{option_results}->{port} = 443; + $self->{option_results}->{proto} = 'https'; + $self->{option_results}->{proxyurl} = $self->{proxyurl}; +} + +sub settings { + my ($self, %options) = @_; + + $self->build_options_for_httplib(); + $self->{http}->set_options(%{$self->{option_results}}); +} + +sub get_items { + my ($self, %options) = @_; + + $self->settings(); + + if (defined($options{obj}) && $options{obj} ne '') { + $options{url} .= $options{obj} . '/'; + } + + my $response = $self->{http}->request(url_path => $options{url}); + my $decoded; + eval { + $decoded = decode_json($response); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->option_exit(); + } + + my @items; + foreach my $context (@{$decoded->{$options{obj}}}) { + push @items,$context->{name}; + } + + return @items; +} + +sub get_details { + my ($self, %options) = @_; + + $self->settings(); + + if ((defined($options{obj}) && $options{obj} ne '') && (defined($options{name}) && $options{name} ne '')) { + $options{url} .= $options{obj} . '/?name=' . $options{name} ; + } + + my $response = $self->{http}->request(url_path => $options{url}); + my $decoded; + eval { + $decoded = decode_json($response); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->option_exit(); + } + + return $decoded->{content}; + +} + +1; + +__END__ + +=head1 NAME + +XREMIO REST API + +=head1 SYNOPSIS + +Xtremio Rest API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +Xtremio hostname. + +=item B<--xtremio-username> + +Xtremio username. + +=item B<--xtremio-password> + +Xtremio password. + +=item B<--proxyurl> + +Proxy URL if any + +=item B<--timeout> + +Set HTTP timeout + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/storage/emc/xtremio/restapi/mode/clusterhealth.pm b/storage/emc/xtremio/restapi/mode/clusterhealth.pm new file mode 100644 index 000000000..a626c9520 --- /dev/null +++ b/storage/emc/xtremio/restapi/mode/clusterhealth.pm @@ -0,0 +1,219 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::mode::clusterhealth; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + 'consistency-state' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], + 'free-ud-ssd-space-level' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], + 'shared-memory-efficiency-level' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], + 'free-ud-ssd-space-level' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], + 'vaai-tp-limit-crossing' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], + 'shared-memory-in-use-ratio-level' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], + 'sys-health-state' => [ + ['healthy', 'OK'], + ['.*', 'CRITICAL'], + ], +}; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.1'; + $options{options}->add_options(arguments => + { + "filter:s@" => { name => 'filter' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{filter} = []; + foreach my $val (@{$self->{option_results}->{filter}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; + } + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + if (scalar(@values) < 3) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $instance, $status, $filter); + if (scalar(@values) == 3) { + ($section, $status, $filter) = @values; + $instance = '.*'; + } else { + ($section, $instance, $status, $filter) = @values; + } + if (!defined $thresholds->{$section}) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'."); + $self->{output}->option_exit(); + } + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; + } + + +} + +sub run { + my ($self, %options) = @_; + my $xtremio = $options{custom}; + + my $urlbase = '/api/json/types/'; + my @items = $xtremio->get_items(url => $urlbase, + obj => 'clusters'); + + my @sensors = ('consistency-state','shared-memory-efficiency-level','free-ud-ssd-space-level', + 'vaai-tp-limit-crossing', 'shared-memory-in-use-ratio-level', 'sys-health-state'); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'Health is OK'); + + foreach my $item (@items) { + next if ($self->check_filter(section => 'cluster', instance => $item)); + my $details = $xtremio->get_details(url => $urlbase, + obj => 'clusters', + name => $item); + + foreach my $sensor (@sensors) { + $self->{output}->output_add(long_msg => sprintf("Sensor '%s' state is '%s'", + $sensor, $details->{$sensor})); + + my $exit = $self->get_severity(section => $sensor, value => $details->{$sensor}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Sensor '%s' state is '%s'", + $sensor, $details->{$sensor})); + } + + } + + } + + $self->{output}->display(); + $self->{output}->exit(); + +} + +sub check_filter { + my ($self, %options) = @_; + + foreach (@{$self->{filter}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($options{instance}) && !defined($_->{instance})) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } + } + + return 0; +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i && + (!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) { + $status = $_->{status}; + return $status; + } + } + } + my $label = defined($options{label}) ? $options{label} : $options{section}; + foreach (@{$thresholds->{$label}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + + +1; + +__END__ + +=head1 MODE + +Check cluster health indicators ('consistency-state','shared-memory-efficiency-level','free-ud-ssd-space-level', 'vaai-tp-limit-crossing', 'shared-memory-in-use-ratio-level', 'sys-health-state'); + +=over 8 + +=item B<--filter> + +Filter some parts (comma seperated list) +Can also exclude specific instance: --filter=cluster,CLUSTER-NAME + +=item B<--threshold-overload> + +Overload a specific threshold, e.g --threshold-overload="consistency-state,Xtremio,CRITICAL,healthy" + +=back + +=cut diff --git a/storage/emc/xtremio/restapi/mode/ssdendurance.pm b/storage/emc/xtremio/restapi/mode/ssdendurance.pm new file mode 100644 index 000000000..d1ae7499a --- /dev/null +++ b/storage/emc/xtremio/restapi/mode/ssdendurance.pm @@ -0,0 +1,152 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::mode::ssdendurance; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.1'; + $options{options}->add_options(arguments => + { + "filter:s@" => { name => 'filter' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{filter} = []; + foreach my $val (@{$self->{option_results}->{filter}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; + } + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + +} + +sub run { + my ($self, %options) = @_; + my $xtremio = $options{custom}; + + my $urlbase = '/api/json/types/'; + my @items = $xtremio->get_items(url => $urlbase, + obj => 'ssds'); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All SSDs Endurance are OK'); + + foreach my $item (@items) { + next if ($self->check_filter(section => 'ssds', instance => $item)); + my $details = $xtremio->get_details(url => $urlbase, + obj => 'ssds', + name => $item); + + $self->{output}->output_add(long_msg => sprintf("SSD '%s' endurance remaining is %i%%", + $item, $details->{'percent-endurance-remaining'})); + + + my $exit = $self->{perfdata}->threshold_check(value => $details->{'percent-endurance-remaining'}, + threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); + + $self->{output}->perfdata_add(label => $item."_endurance", + value => $details->{'percent-endurance-remaining'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + + if ($exit ne 'ok') { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("SSD '%s' endurance is %i%%", + $item, $details->{'percent-endurance-remaining'})); + } + + } + + $self->{output}->display(); + $self->{output}->exit(); + +} + +sub check_filter { + my ($self, %options) = @_; + + foreach (@{$self->{filter}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($options{instance}) && !defined($_->{instance})) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } + } + + return 0; +} + +1; + +__END__ + +=head1 MODE + +Check SSDs endurance level (100% is the best value) + +=over 8 + +=item B<--filter> + +Filter some parts (comma seperated list) +Can also exclude specific instance: --filter=ssds,SSD-NAME-NUMBER + +=item B<--warning> + +Warning trigger for SSD endurance + +=item B<--critical> + +Critical trigger for SSD endurance + +=back + +=cut diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm new file mode 100644 index 000000000..5faaf70b8 --- /dev/null +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -0,0 +1,208 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::mode::ssdiops; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.1'; + $options{options}->add_options(arguments => + { + "filter:s@" => { name => 'filter' }, + "warning-read:s" => { name => 'warning_read' }, + "critical-read:s" => { name => 'critical_read' }, + "warning-write:s" => { name => 'warning_write' }, + "critical-write:s" => { name => 'critical_write' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{filter} = []; + foreach my $val (@{$self->{option_results}->{filter}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; + } + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + + if (($self->{perfdata}->threshold_validate(label => 'warning-read', value => $self->{option_results}->{warning_read})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-read threshold '" . $self->{option_results}->{warning_read} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-read', value => $self->{option_results}->{critical_read})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-read threshold '" . $self->{option_results}->{critical_read} . "'."); + $self->{output}->option_exit(); + } + + if (($self->{perfdata}->threshold_validate(label => 'warning-write', value => $self->{option_results}->{warning_write})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-write threshold '" . $self->{option_results}->{warning_write} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-write', value => $self->{option_results}->{critical_write})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-write threshold '" . $self->{option_results}->{critical_write} . "'."); + $self->{output}->option_exit(); + } + + +} + +sub run { + my ($self, %options) = @_; + my $xtremio = $options{custom}; + + my $urlbase = '/api/json/types/'; + my @items = $xtremio->get_items(url => $urlbase, + obj => 'ssds'); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All SSDs Iops are OK'); + + foreach my $item (@items) { + next if ($self->check_filter(section => 'ssds', instance => $item)); + my $details = $xtremio->get_details(url => $urlbase, + obj => 'ssds', + name => $item); + + $self->{output}->output_add(long_msg => sprintf("SSD '%s' IOPS : Global=%i Read=%i Write=%i", + $item, $details->{'iops'}, $details->{'rd-iops'}, $details->{'wr-iops'})); + + my $exit1 = $self->{perfdata}->threshold_check(value => $details->{'iops'}, + threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); + my $exit2 = $self->{perfdata}->threshold_check(value => $details->{'rd-iops'}, + threshold => [ { label => 'warning-read', 'exit_litteral' => 'warning' }, { label => 'critical-read', exit_litteral => 'critical' } ]); + my $exit3 = $self->{perfdata}->threshold_check(value => $details->{'wr-iops'}, + threshold => [ { label => 'warning-write', 'exit_litteral' => 'warning' }, { label => 'critical-write', exit_litteral => 'critical' } ]); + + my $exit = $self->{output}->get_most_critical(status => [$exit1, $exit2, $exit3]); + + $self->{output}->perfdata_add(label => $item."_iops", + value => $details->{'iops'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + + $self->{output}->perfdata_add(label => $item."_rd-iops", + value => $details->{'rd-iops'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_read'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_read'), + min => 0, max => 100); + + $self->{output}->perfdata_add(label => $item."_wr-iops", + value => $details->{'wr-iops'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_write'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_write'), + min => 0, max => 100); + + if ($exit ne 'ok') { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("SSD '%s' IOPS : Global=%i Read=%i Write=%i", + $item, $details->{'iops'}, $details->{'rd-iops'}, $details->{'wr-iops'})); + } + + } + + $self->{output}->display(); + $self->{output}->exit(); + +} + +sub check_filter { + my ($self, %options) = @_; + + foreach (@{$self->{filter}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($options{instance}) && !defined($_->{instance})) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } + } + + return 0; +} + +1; + +__END__ + +=head1 MODE + +Check IOPS (Global, Read, Write) on each SSDs + +=over 8 + +=item B<--filter> + +Filter some parts (comma seperated list) +Can also exclude specific instance: --filter=ssds,SSDS-Number + +=item B<--warning> + +Warning value on global IOPS + +=item B<--critical> + +Critical value on global IOPS + +=item B<--warning-read> + +Warning value on read IOPS + +=item B<--critical-read> + +Critical value on read IOPS + +=item B<--warning-write> + +Warning value on write IOPS + +=item B<--critical-write> + +Critical value on write IOPS + +=back + +=cut diff --git a/storage/emc/xtremio/restapi/mode/xenvscpu.pm b/storage/emc/xtremio/restapi/mode/xenvscpu.pm new file mode 100644 index 000000000..3c8454ad4 --- /dev/null +++ b/storage/emc/xtremio/restapi/mode/xenvscpu.pm @@ -0,0 +1,153 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::mode::xenvscpu; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.1'; + $options{options}->add_options(arguments => + { + "filter:s@" => { name => 'filter' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{filter} = []; + foreach my $val (@{$self->{option_results}->{filter}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; + } + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + +} + +sub run { + my ($self, %options) = @_; + my $xtremio = $options{custom}; + + my $urlbase = '/api/json/types/'; + my @items = $xtremio->get_items(url => $urlbase, + obj => 'xenvs'); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All Xenvs CPU Usage are OK'); + + foreach my $item (@items) { + next if ($self->check_filter(section => 'cpu', instance => $item)); + my $details = $xtremio->get_details(url => $urlbase, + obj => 'xenvs', + name => $item); + + $self->{output}->output_add(long_msg => sprintf("Xenvs '%s' CPU Usage is %i%%", + $item, + $details->{'cpu-usage'})); + + + my $exit = $self->{perfdata}->threshold_check(value => $details->{'cpu-usage'}, threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); + + $self->{output}->perfdata_add(label => 'cpu_'.$item, + value => $details->{'cpu-usage'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + + if ($exit ne 'ok') { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Xenvs '%s' cpu-Usage is %i%%", + $item, + $details->{'cpu-usage'})); + } + + } + + $self->{output}->display(); + $self->{output}->exit(); + +} + +sub check_filter { + my ($self, %options) = @_; + + foreach (@{$self->{filter}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($options{instance}) && !defined($_->{instance})) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } + } + + return 0; +} + +1; + +__END__ + +=head1 MODE + +Check Xenvs CPU usage + +=over 8 + +=item B<--filter> + +Filter some parts (comma seperated list) +Can also exclude specific instance: --filter=cpu,XENVS-NAME-NUMBER + +=item B<--warning> + +Value to trigger a warning alarm on CPU usage + +=item B<--critical> + +Value to trigger a critical alarm on CPU usage + +=back + +=cut diff --git a/storage/emc/xtremio/restapi/mode/xenvsstate.pm b/storage/emc/xtremio/restapi/mode/xenvsstate.pm new file mode 100644 index 000000000..9942f4650 --- /dev/null +++ b/storage/emc/xtremio/restapi/mode/xenvsstate.pm @@ -0,0 +1,190 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::mode::xenvsstate; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + xenvs_state => [ + ['active', 'OK'], + ['.*', 'CRITICAL'], + ], +}; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.1'; + $options{options}->add_options(arguments => + { + "filter:s@" => { name => 'filter' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{filter} = []; + foreach my $val (@{$self->{option_results}->{filter}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; + } + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + if (scalar(@values) < 3) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $instance, $status, $filter); + if (scalar(@values) == 3) { + ($section, $status, $filter) = @values; + $instance = '.*'; + } else { + ($section, $instance, $status, $filter) = @values; + } + if (!defined $thresholds->{$section}) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'."); + $self->{output}->option_exit(); + } + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; + } + +} + +sub run { + my ($self, %options) = @_; + my $xtremio = $options{custom}; + + my $urlbase = '/api/json/types/'; + my @items = $xtremio->get_items(url => $urlbase, + obj => 'xenvs'); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All Xenvs states are active'); + + foreach my $item (@items) { + next if ($self->check_filter(section => 'state', instance => $item)); + my $details = $xtremio->get_details(url => $urlbase, + obj => 'xenvs', + name => $item); + + $self->{output}->output_add(long_msg => sprintf("Xenvs '%s' state is '%s'", + $item, + $details->{'xenv-state'})); + + my $exit = $self->get_severity(section => 'xenvs_state', instance => $item, value => $details->{'xenv-state'}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Xenvs '%s' state is '%s'", + $item, $details->{'xenv-state'})); + } + + } + + $self->{output}->display(); + $self->{output}->exit(); + +} + +sub check_filter { + my ($self, %options) = @_; + + foreach (@{$self->{filter}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($options{instance}) && !defined($_->{instance})) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } + } + + return 0; +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i && + (!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) { + $status = $_->{status}; + return $status; + } + } + } + my $label = defined($options{label}) ? $options{label} : $options{section}; + foreach (@{$thresholds->{$label}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +1; + +__END__ + +=head1 MODE + +Check Xenvs state + +=over 8 + +=item B<--filter> + +Filter some parts (comma seperated list) +Can also exclude specific instance: --filter=device,cluster-1_xxxx + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='xenvs_state,CRITICAL,^(?!(ok)$)' + +=back + +=cut diff --git a/storage/emc/xtremio/restapi/plugin.pm b/storage/emc/xtremio/restapi/plugin.pm new file mode 100644 index 000000000..55e37a12a --- /dev/null +++ b/storage/emc/xtremio/restapi/plugin.pm @@ -0,0 +1,58 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::xtremio::restapi::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_custom); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + # $options->{options} = options object + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'xenvs-cpu' => 'storage::emc::xtremio::restapi::mode::xenvscpu', + 'xenvs-state' => 'storage::emc::xtremio::restapi::mode::xenvsstate', + 'ssds-endurance' => 'storage::emc::xtremio::restapi::mode::ssdendurance', + 'ssds-iops' => 'storage::emc::xtremio::restapi::mode::ssdiops', + 'cluster-health' => 'storage::emc::xtremio::restapi::mode::clusterhealth', + ); + + $self->{custom_modes}{xtremioapi} = 'storage::emc::xtremio::restapi::custom::xtremioapi'; + return $self; +} + +sub init { + my ($self, %options) = @_; + + $self->SUPER::init(%options); +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check EMC Xtremio through HTTP/REST API. From 64d6875b32989d498ed62d6ef1433b0c4089157c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 10:22:56 +0200 Subject: [PATCH 02/68] + Fix #167 : wrong output message --- network/extreme/snmp/mode/cpu.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/network/extreme/snmp/mode/cpu.pm b/network/extreme/snmp/mode/cpu.pm index 94311459b..bd8925471 100644 --- a/network/extreme/snmp/mode/cpu.pm +++ b/network/extreme/snmp/mode/cpu.pm @@ -48,7 +48,7 @@ my $maps_counters = { }, '002_30secs' => { set => { key_values => [ { name => 'extremeCpuMonitorSystemUtilization30secs' }, { name => 'num' }, ], - output_template => '10 seconds : %.2f %%', + output_template => '30 seconds : %.2f %%', perfdatas => [ { label => 'cpu_30secs', value => 'extremeCpuMonitorSystemUtilization30secs_absolute', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, @@ -57,7 +57,7 @@ my $maps_counters = { }, '003_1min' => { set => { key_values => [ { name => 'extremeCpuMonitorSystemUtilization1min' }, { name => 'num' }, ], - output_template => '10 seconds : %.2f %%', + output_template => '1 minute : %.2f %%', perfdatas => [ { label => 'cpu_1min', value => 'extremeCpuMonitorSystemUtilization1min_absolute', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, @@ -66,7 +66,7 @@ my $maps_counters = { }, '004_5min' => { set => { key_values => [ { name => 'extremeCpuMonitorSystemUtilization5mins' }, { name => 'num' }, ], - output_template => '10 seconds : %.2f %%', + output_template => '5 minutes : %.2f %%', perfdatas => [ { label => 'cpu_5min', value => 'extremeCpuMonitorSystemUtilization5mins_absolute', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, From 3dbbb1c8d5a04ebeb3b370bf90c8e40785d46c25 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 14:53:10 +0200 Subject: [PATCH 03/68] + Ref #125 : some typo fix --- .../emc/xtremio/restapi/mode/clusterhealth.pm | 3 -- .../emc/xtremio/restapi/mode/ssdendurance.pm | 34 ++++++++----------- storage/emc/xtremio/restapi/mode/ssdiops.pm | 27 +++++++-------- storage/emc/xtremio/restapi/mode/xenvscpu.pm | 16 ++++----- .../emc/xtremio/restapi/mode/xenvsstate.pm | 2 -- 5 files changed, 33 insertions(+), 49 deletions(-) diff --git a/storage/emc/xtremio/restapi/mode/clusterhealth.pm b/storage/emc/xtremio/restapi/mode/clusterhealth.pm index a626c9520..c9bceb96a 100644 --- a/storage/emc/xtremio/restapi/mode/clusterhealth.pm +++ b/storage/emc/xtremio/restapi/mode/clusterhealth.pm @@ -108,8 +108,6 @@ sub check_options { $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; } - - } sub run { @@ -149,7 +147,6 @@ sub run { $self->{output}->display(); $self->{output}->exit(); - } sub check_filter { diff --git a/storage/emc/xtremio/restapi/mode/ssdendurance.pm b/storage/emc/xtremio/restapi/mode/ssdendurance.pm index d1ae7499a..1e1680a28 100644 --- a/storage/emc/xtremio/restapi/mode/ssdendurance.pm +++ b/storage/emc/xtremio/restapi/mode/ssdendurance.pm @@ -33,9 +33,9 @@ sub new { $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "filter:s@" => { name => 'filter' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, + "filter:s@" => { name => 'filter' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); return $self; @@ -53,14 +53,13 @@ sub check_options { } if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); } - } sub run { @@ -85,21 +84,18 @@ sub run { my $exit = $self->{perfdata}->threshold_check(value => $details->{'percent-endurance-remaining'}, - threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); - - $self->{output}->perfdata_add(label => $item."_endurance", - value => $details->{'percent-endurance-remaining'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => 100); - - if ($exit ne 'ok') { + threshold => [ { label => 'warning', exit_litteral => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("SSD '%s' endurance is %i%%", $item, $details->{'percent-endurance-remaining'})); } - - } + $self->{output}->perfdata_add(label => $item . "_endurance", unit => '%', + value => $details->{'percent-endurance-remaining'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + } $self->{output}->display(); $self->{output}->exit(); diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm index 5faaf70b8..c019be0bc 100644 --- a/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -57,33 +57,30 @@ sub check_options { } if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'warning-read', value => $self->{option_results}->{warning_read})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-read threshold '" . $self->{option_results}->{warning_read} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning-read threshold '" . $self->{option_results}->{warning_read} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical-read', value => $self->{option_results}->{critical_read})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-read threshold '" . $self->{option_results}->{critical_read} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical-read threshold '" . $self->{option_results}->{critical_read} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warning-write', value => $self->{option_results}->{warning_write})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-write threshold '" . $self->{option_results}->{warning_write} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning-write threshold '" . $self->{option_results}->{warning_write} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical-write', value => $self->{option_results}->{critical_write})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-write threshold '" . $self->{option_results}->{critical_write} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical-write threshold '" . $self->{option_results}->{critical_write} . "'."); + $self->{output}->option_exit(); } - - } sub run { diff --git a/storage/emc/xtremio/restapi/mode/xenvscpu.pm b/storage/emc/xtremio/restapi/mode/xenvscpu.pm index 3c8454ad4..2ead76f0d 100644 --- a/storage/emc/xtremio/restapi/mode/xenvscpu.pm +++ b/storage/emc/xtremio/restapi/mode/xenvscpu.pm @@ -60,7 +60,6 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } - } sub run { @@ -86,20 +85,17 @@ sub run { my $exit = $self->{perfdata}->threshold_check(value => $details->{'cpu-usage'}, threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); - - $self->{output}->perfdata_add(label => 'cpu_'.$item, - value => $details->{'cpu-usage'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => 100); - - if ($exit ne 'ok') { + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Xenvs '%s' cpu-Usage is %i%%", $item, $details->{'cpu-usage'})); } - + $self->{output}->perfdata_add(label => 'cpu_' . $item, unit => '%', + value => $details->{'cpu-usage'}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); } $self->{output}->display(); diff --git a/storage/emc/xtremio/restapi/mode/xenvsstate.pm b/storage/emc/xtremio/restapi/mode/xenvsstate.pm index 9942f4650..2e9a959d4 100644 --- a/storage/emc/xtremio/restapi/mode/xenvsstate.pm +++ b/storage/emc/xtremio/restapi/mode/xenvsstate.pm @@ -84,7 +84,6 @@ sub check_options { $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; } - } sub run { @@ -119,7 +118,6 @@ sub run { $self->{output}->display(); $self->{output}->exit(); - } sub check_filter { From 930ced398e98321c497afcce6c8e73c08068433e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 15:23:27 +0200 Subject: [PATCH 04/68] + Ref #125 : enhance ssdiops --- storage/emc/xtremio/restapi/mode/ssdiops.pm | 270 ++++++++++---------- 1 file changed, 142 insertions(+), 128 deletions(-) diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm index c019be0bc..3cc5e739a 100644 --- a/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -24,141 +24,170 @@ use base qw(centreon::plugins::mode); use strict; use warnings; +use centreon::plugins::values; + +my $maps_counters = { + ssd => { + '000_global' => { set => { + key_values => [ { name => 'global_iops' }, { name => 'display' }, ], + output_template => 'Global IOPs : %.2f %%', + perfdatas => [ + { label => 'global_iops', value => 'global_iops_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + '001_read' => { set => { + key_values => [ { name => 'read_iops' }, { name => 'display' }, ], + output_template => 'Read IOPs : %.2f %%', + perfdatas => [ + { label => 'read_iops', value => 'read_iops_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + '002_write' => { set => { + key_values => [ { name => 'write_iops' }, { name => 'display' }, ], + output_template => 'Write IOPs : %.2f %%', + perfdatas => [ + { label => 'write_iops', value => 'global_iops_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + }, +}; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $self->{version} = '1.1'; + + $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "filter:s@" => { name => 'filter' }, - "warning-read:s" => { name => 'warning_read' }, - "critical-read:s" => { name => 'critical_read' }, - "warning-write:s" => { name => 'warning_write' }, - "critical-write:s" => { name => 'critical_write' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, + "filter-name:s" => { name => 'filter_name' }, }); + foreach my $key (('ssd')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - - $self->{filter} = []; - foreach my $val (@{$self->{option_results}->{filter}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; - } - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-read', value => $self->{option_results}->{warning_read})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-read threshold '" . $self->{option_results}->{warning_read} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-read', value => $self->{option_results}->{critical_read})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-read threshold '" . $self->{option_results}->{critical_read} . "'."); - $self->{output}->option_exit(); - } - - if (($self->{perfdata}->threshold_validate(label => 'warning-write', value => $self->{option_results}->{warning_write})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-write threshold '" . $self->{option_results}->{warning_write} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-write', value => $self->{option_results}->{critical_write})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-write threshold '" . $self->{option_results}->{critical_write} . "'."); - $self->{output}->option_exit(); + + foreach my $key (('ssd')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } } + + $self->{statefile_cache}->check_options(%options); } sub run { my ($self, %options) = @_; my $xtremio = $options{custom}; + + $self->manage_selection(); + + my $multiple = 1; + if (scalar(keys %{$self->{ssd}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All SSDs usages are ok'); + } + + foreach my $id (sort keys %{$self->{ssd}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits = (); + foreach (sort keys %{$maps_counters->{ssd}}) { + my $obj = $maps_counters->{ssd}->{$_}->{obj}; + $obj->set(instance => $id); + my ($value_check) = $obj->execute(values => $self->{ssd}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $obj->perfdata(extra_instance => $multiple); + } + + $self->{output}->output_add(long_msg => "SSD '" . $self->{ssd}->{$id}->{display} . "' Usage $long_msg"); + 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 => "SSD '" . $self->{ssd}->{$id}->{display} . "' Usage $short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "SSD '" . $self->{ssd}->{$id}->{display} . "' Usage $long_msg"); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{ssd} = {}; my $urlbase = '/api/json/types/'; my @items = $xtremio->get_items(url => $urlbase, obj => 'ssds'); - - $self->{output}->output_add(severity => 'OK', - short_msg => 'All SSDs Iops are OK'); - foreach my $item (@items) { - next if ($self->check_filter(section => 'ssds', instance => $item)); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $item !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $item . "': no matching name.", debug => 1); + next; + } + my $details = $xtremio->get_details(url => $urlbase, obj => 'ssds', name => $item); - - $self->{output}->output_add(long_msg => sprintf("SSD '%s' IOPS : Global=%i Read=%i Write=%i", - $item, $details->{'iops'}, $details->{'rd-iops'}, $details->{'wr-iops'})); - - my $exit1 = $self->{perfdata}->threshold_check(value => $details->{'iops'}, - threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $details->{'rd-iops'}, - threshold => [ { label => 'warning-read', 'exit_litteral' => 'warning' }, { label => 'critical-read', exit_litteral => 'critical' } ]); - my $exit3 = $self->{perfdata}->threshold_check(value => $details->{'wr-iops'}, - threshold => [ { label => 'warning-write', 'exit_litteral' => 'warning' }, { label => 'critical-write', exit_litteral => 'critical' } ]); - - my $exit = $self->{output}->get_most_critical(status => [$exit1, $exit2, $exit3]); - - $self->{output}->perfdata_add(label => $item."_iops", - value => $details->{'iops'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => 100); - - $self->{output}->perfdata_add(label => $item."_rd-iops", - value => $details->{'rd-iops'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_read'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_read'), - min => 0, max => 100); - - $self->{output}->perfdata_add(label => $item."_wr-iops", - value => $details->{'wr-iops'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_write'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_write'), - min => 0, max => 100); - - if ($exit ne 'ok') { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("SSD '%s' IOPS : Global=%i Read=%i Write=%i", - $item, $details->{'iops'}, $details->{'rd-iops'}, $details->{'wr-iops'})); - } - - } - - $self->{output}->display(); - $self->{output}->exit(); - -} - -sub check_filter { - my ($self, %options) = @_; - - foreach (@{$self->{filter}}) { - if ($options{section} =~ /$_->{filter}/) { - if (!defined($options{instance}) && !defined($_->{instance})) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } + + $self->{ssd}->{$item} = { display => $item, global_iops => $details->{iops}, + read_iops => $details->{'rd-iops'}, write_iops => $details->{'wr-iops'} }; } - return 0; + if (scalar(keys %{$self->{ssd}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } } 1; @@ -167,38 +196,23 @@ __END__ =head1 MODE -Check IOPS (Global, Read, Write) on each SSDs +Check IOPS (Global, Read, Write) on each SSDs. =over 8 -=item B<--filter> +=item B<--warning-*> -Filter some parts (comma seperated list) -Can also exclude specific instance: --filter=ssds,SSDS-Number +Threshold warning. +Can be: 'global' (%), 'read' (%), 'write' (%). -=item B<--warning> +=item B<--critical-*> -Warning value on global IOPS +Threshold critical. +Can be: 'global' (%), 'read' (%), 'write' (%). -=item B<--critical> +=item B<--filter-name> -Critical value on global IOPS - -=item B<--warning-read> - -Warning value on read IOPS - -=item B<--critical-read> - -Critical value on read IOPS - -=item B<--warning-write> - -Warning value on write IOPS - -=item B<--critical-write> - -Critical value on write IOPS +Filter SSD name (can be a regexp). =back From 30387a09eb3b67ab6505a928f0433707c280756c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 15:32:52 +0200 Subject: [PATCH 05/68] + Fix ssd-iops mode --- storage/emc/xtremio/restapi/mode/ssdiops.pm | 34 ++++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm index 3cc5e739a..0aa3bf0b5 100644 --- a/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -30,28 +30,28 @@ my $maps_counters = { ssd => { '000_global' => { set => { key_values => [ { name => 'global_iops' }, { name => 'display' }, ], - output_template => 'Global IOPs : %.2f %%', + output_template => 'Global IOPs : %s', perfdatas => [ - { label => 'global_iops', value => 'global_iops_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'global_iops', value => 'global_iops_absolute', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'num_absolute' }, ], } }, '001_read' => { set => { key_values => [ { name => 'read_iops' }, { name => 'display' }, ], - output_template => 'Read IOPs : %.2f %%', + output_template => 'Read IOPs : %s', perfdatas => [ - { label => 'read_iops', value => 'read_iops_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'read_iops', value => 'read_iops_absolute', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'num_absolute' }, ], } }, '002_write' => { set => { key_values => [ { name => 'write_iops' }, { name => 'display' }, ], - output_template => 'Write IOPs : %.2f %%', + output_template => 'Write IOPs : %s', perfdatas => [ - { label => 'write_iops', value => 'global_iops_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'write_iops', value => 'global_iops_absolute', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'num_absolute' }, ], } }, @@ -95,14 +95,12 @@ sub check_options { foreach (keys %{$maps_counters->{$key}}) { $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); } - } - - $self->{statefile_cache}->check_options(%options); + } } sub run { my ($self, %options) = @_; - my $xtremio = $options{custom}; + $self->{xtremio} = $options{custom}; $self->manage_selection(); @@ -167,8 +165,8 @@ sub manage_selection { $self->{ssd} = {}; my $urlbase = '/api/json/types/'; - my @items = $xtremio->get_items(url => $urlbase, - obj => 'ssds'); + my @items = $self->{xtremio}->get_items(url => $urlbase, + obj => 'ssds'); foreach my $item (@items) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $item !~ /$self->{option_results}->{filter_name}/) { @@ -176,9 +174,9 @@ sub manage_selection { next; } - my $details = $xtremio->get_details(url => $urlbase, - obj => 'ssds', - name => $item); + my $details = $self->{xtremio}->get_details(url => $urlbase, + obj => 'ssds', + name => $item); $self->{ssd}->{$item} = { display => $item, global_iops => $details->{iops}, read_iops => $details->{'rd-iops'}, write_iops => $details->{'wr-iops'} }; From 63703a0f7c00cd5991714426a4f18fb947420913 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 15:34:08 +0200 Subject: [PATCH 06/68] + Fix ssd-iops mode --- storage/emc/xtremio/restapi/mode/ssdiops.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm index 0aa3bf0b5..2c3e2d265 100644 --- a/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -33,7 +33,7 @@ my $maps_counters = { output_template => 'Global IOPs : %s', perfdatas => [ { label => 'global_iops', value => 'global_iops_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'num_absolute' }, + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, @@ -42,7 +42,7 @@ my $maps_counters = { output_template => 'Read IOPs : %s', perfdatas => [ { label => 'read_iops', value => 'read_iops_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'num_absolute' }, + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, @@ -51,7 +51,7 @@ my $maps_counters = { output_template => 'Write IOPs : %s', perfdatas => [ { label => 'write_iops', value => 'global_iops_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'num_absolute' }, + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, From c080f651b3a96ce646293238d417b070cf479767 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 15:35:20 +0200 Subject: [PATCH 07/68] + Fix ssd-iops (last) --- storage/emc/xtremio/restapi/mode/ssdiops.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm index 2c3e2d265..2096ffd0c 100644 --- a/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -50,7 +50,7 @@ my $maps_counters = { key_values => [ { name => 'write_iops' }, { name => 'display' }, ], output_template => 'Write IOPs : %s', perfdatas => [ - { label => 'write_iops', value => 'global_iops_absolute', template => '%s', + { label => 'write_iops', value => 'write_iops_absolute', template => '%s', min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } From 8da8362e1ac913a57d172fa98f9c9cf6f660ce30 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 15:44:17 +0200 Subject: [PATCH 08/68] + Enhance custom mode load: if there is only one custommode we load it (simple) --- centreon/plugins/script_custom.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/centreon/plugins/script_custom.pm b/centreon/plugins/script_custom.pm index 4ca7765f0..a40fc933f 100644 --- a/centreon/plugins/script_custom.pm +++ b/centreon/plugins/script_custom.pm @@ -66,6 +66,15 @@ sub new { return $self; } +sub load_custom_mode { + my ($self, %options) = @_; + + $self->is_custommode(custommode => $self->{custommode_name}); + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{custom_modes}{$self->{custommode_name}}, + error_msg => "Cannot load module --custommode."); + $self->{custommode_current} = $self->{custom_modes}{$self->{custommode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{custommode_name}); +} + sub init { my ($self, %options) = @_; # $options{version} = string version @@ -92,10 +101,10 @@ sub init { $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); if (defined($self->{custommode_name}) && $self->{custommode_name} ne '') { - $self->is_custommode(custommode => $self->{custommode_name}); - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{custom_modes}{$self->{custommode_name}}, - error_msg => "Cannot load module --custommode."); - $self->{custommode_current} = $self->{custom_modes}{$self->{custommode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{custommode_name}); + $self->load_custom_mode(); + } elsif (scalar(%{$self->{custom_modes}}) == 1) { + $self->{custommode_name} = keys(%{$self->{custom_modes}})[0]; + $self->load_custom_mode(); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--custommode'."); $self->{output}->option_exit(); From 82f3a65a7b71464d7ff0fd2ceb724c12bae176cc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 15:49:07 +0200 Subject: [PATCH 09/68] + fix custom mode choose (simple) --- centreon/plugins/script_custom.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon/plugins/script_custom.pm b/centreon/plugins/script_custom.pm index a40fc933f..9a6df7c66 100644 --- a/centreon/plugins/script_custom.pm +++ b/centreon/plugins/script_custom.pm @@ -102,8 +102,8 @@ sub init { if (defined($self->{custommode_name}) && $self->{custommode_name} ne '') { $self->load_custom_mode(); - } elsif (scalar(%{$self->{custom_modes}}) == 1) { - $self->{custommode_name} = keys(%{$self->{custom_modes}})[0]; + } elsif (scalar(keys %{$self->{custom_modes}}) == 1) { + $self->{custommode_name} = (keys(%{$self->{custom_modes}}))[0]; $self->load_custom_mode(); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--custommode'."); From 9cfa8076bfeb6748b2d61950d093119ee3d031ac Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 18 Sep 2015 16:11:46 +0200 Subject: [PATCH 10/68] + Ref #159 --- apps/protocols/bgp/4/mode/bgppeerstate.pm | 91 +++++++++++------------ 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/apps/protocols/bgp/4/mode/bgppeerstate.pm b/apps/protocols/bgp/4/mode/bgppeerstate.pm index 4c5604953..1cbbe37ec 100644 --- a/apps/protocols/bgp/4/mode/bgppeerstate.pm +++ b/apps/protocols/bgp/4/mode/bgppeerstate.pm @@ -50,29 +50,6 @@ my $thresholds = { ], }; -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -127,8 +104,7 @@ sub run { my $result = $self->{snmp}->get_table(oid => $oid_bgpPeerTable, nothing_quit => 1); - if (defined $self->{option_results}->{peer}) { - + if (defined($self->{option_results}->{peer})) { my $bgpPeerState = $result->{$oid_bgpPeerState . '.' . $self->{option_results}->{peer}}; my $bgpPeerAdminStatus = $result->{$oid_bgpPeerAdminStatus . '.' . $self->{option_results}->{peer}}; my $bgpPeerRemoteAs = $result->{$oid_bgpPeerRemoteAs . '.' . $self->{option_results}->{peer}}; @@ -136,29 +112,28 @@ sub run { my $bgpLocalInfos = $result->{$oid_bgpPeerLocalAddr . '.' . $self->{option_results}->{peer}} . ':' . $result->{$oid_bgpPeerLocalPort . '.' . $self->{option_results}->{peer}}; my $bgpRemoteInfos = $result->{$oid_bgpPeerRemoteAddr. '.' . $self->{option_results}->{peer}} . ':' . $result->{$oid_bgpPeerRemotePort . '.' . $self->{option_results}->{peer}}; - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("Peer %s AdminState=%s Connection=%s [Remote Addr:%s AS:%d] [Last Update %d s]", $self->{option_results}->{peer}, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState} , $bgpRemoteInfos, $bgpPeerRemoteAs, $bgpPeerInUpdateElpasedTime)); - + short_msg => sprintf("Peer %s AdminState=%s Connection=%s [Remote Addr:%s AS:%d] [Last Update %d s]", + $self->{option_results}->{peer}, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, + $bgpRemoteInfos, $bgpPeerRemoteAs, $bgpPeerInUpdateElpasedTime)); if ($bgpPeerAdminStatus < 2) { $self->{output}->output_add(severity => 'CRITICAL', short_msg => sprintf("Peer '%s' AdminState is '%s' Remote AS: %s Remote Addr: %s", $self->{option_results}->{peer}, $map_admin_state{$bgpPeerAdminStatus}, $bgpPeerRemoteAs, $bgpRemoteInfos) ); - } elsif ($bgpPeerState != 6) { + } else { my $exit = $self->get_severity(section => 'peers', value => $map_peer_state{$bgpPeerState}); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Peer %s AdminState=%s Connection=%s [Remote Addr:%s AS:%d] [Last Update %d s]", $self->{option_results}->{peer}, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, $bgpRemoteInfos, $bgpPeerRemoteAs, $bgpPeerInUpdateElpasedTime)); - - } - + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Peer %s AdminState=%s Connection=%s [Remote Addr:%s AS:%d] [Last Update %d s]", + $self->{option_results}->{peer}, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, $bgpRemoteInfos, $bgpPeerRemoteAs, $bgpPeerInUpdateElpasedTime)); + } + } } else { - $self->{output}->output_add(severity => 'OK', short_msg => sprintf("All BGP peers are in an OK state")); foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { - next if ($key !~ /^$oid_bgpPeerState\.(.*)$/); my $instance = $1; next if ($instance eq '0.0.0.0'); @@ -171,28 +146,50 @@ sub run { my $bgpRemoteInfos = $result->{$oid_bgpPeerRemoteAddr. '.' . $instance} . ':' . $result->{$oid_bgpPeerRemotePort . '.' . $instance}; if ($bgpPeerAdminStatus < 2) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Peer '%s' AdminState is '%s' Remote AS: %s Remote Addr: %s \n", + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Peer '%s' AdminState is '%s' Remote AS: %s Remote Addr: %s", $instance, $map_admin_state{$bgpPeerAdminStatus}, $bgpPeerRemoteAs, - $bgpRemoteInfos)); - } elsif ($bgpPeerState != 6) { + $bgpRemoteInfos)); + } else { my $exit = $self->get_severity(section => 'peers', value => $map_peer_state{$bgpPeerState}); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Peer %s AdminState=%s Connection=%s [Remote Addr:%s AS:%d] [Last Update %d s] \n", $instance, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, $bgpRemoteInfos, $bgpPeerRemoteAs, $bgpPeerInUpdateElpasedTime)); - + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Peer %s AdminState=%s Connection=%s [Remote Addr:%s AS:%d] [Last Update %d s]", + $instance, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, $bgpRemoteInfos, $bgpPeerRemoteAs, $bgpPeerInUpdateElpasedTime)); + } } - $self->{output}->output_add(long_msg => sprintf("Peer:%s Local:%s Remote:%s AS:%d AdminState:'%s' Connection:'%s' Last Update:%d sec \n", $instance, $bgpLocalInfos, $bgpRemoteInfos, $bgpPeerRemoteAs, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, $bgpPeerInUpdateElpasedTime)); - - + $self->{output}->output_add(long_msg => sprintf("Peer:%s Local:%s Remote:%s AS:%d AdminState:'%s' Connection:'%s' Last Update:%d sec", + $instance, $bgpLocalInfos, $bgpRemoteInfos, $bgpPeerRemoteAs, $map_admin_state{$bgpPeerAdminStatus}, $map_peer_state{$bgpPeerState}, $bgpPeerInUpdateElpasedTime)); } - } $self->{output}->display(); $self->{output}->exit(); } +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i) { + $status = $_->{status}; + return $status; + } + } + } + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + 1; __END__ From d825452bfcbfc442a926026aa09ea1505be27b5c Mon Sep 17 00:00:00 2001 From: Sims24 Date: Thu, 24 Sep 2015 16:11:01 +0200 Subject: [PATCH 11/68] Update hardware.pm, fix short output Wrong skip/total components display --- network/alcatel/common/mode/hardware.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/network/alcatel/common/mode/hardware.pm b/network/alcatel/common/mode/hardware.pm index 50cd3fe8e..182c0794e 100644 --- a/network/alcatel/common/mode/hardware.pm +++ b/network/alcatel/common/mode/hardware.pm @@ -118,7 +118,8 @@ sub component { # Skipping short msg when no components next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name}; + my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; $display_by_component_append = ', '; } @@ -199,4 +200,4 @@ If total (with skipped) is 0. (Default: 'critical' returns). =back -=cut \ No newline at end of file +=cut From 6b90ad23d511e46eeae8b037b64f4c3661ca0bb4 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 25 Sep 2015 15:21:45 +0200 Subject: [PATCH 12/68] Update sessions.pm Add failed sessions monitoring https://github.com/centreon/centreon-plugins/issues/158 --- .../juniper/common/screenos/mode/sessions.pm | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/network/juniper/common/screenos/mode/sessions.pm b/network/juniper/common/screenos/mode/sessions.pm index 50df6a763..d890eb21e 100644 --- a/network/juniper/common/screenos/mode/sessions.pm +++ b/network/juniper/common/screenos/mode/sessions.pm @@ -34,7 +34,9 @@ sub new { $options{options}->add_options(arguments => { "warning:s" => { name => 'warning', }, + "warning-failed:s" => { name => 'warning_failed', }, "critical:s" => { name => 'critical', }, + "critical-failed:s" => { name => 'critical_failed', }, }); return $self; @@ -52,6 +54,14 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } + if (($self->{perfdata}->threshold_validate(label => 'warning-failed', value => $self->{option_results}->{warning_failed})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-failed threshold '" . $self->{option_results}->{warning_failed} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-failed', value => $self->{option_results}->{critical_failed})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-failed threshold '" . $self->{option_results}->{critical_failed} . "'."); + $self->{output}->option_exit(); + } } sub run { @@ -61,26 +71,38 @@ sub run { my $oid_nsResSessAllocate = '.1.3.6.1.4.1.3224.16.3.2.0'; my $oid_nsResSessMaxium = '.1.3.6.1.4.1.3224.16.3.3.0'; + my $oid_nsResSessFailed = '.1.3.6.1.4.1.3224.16.3.4.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium], nothing_quit => 1); + my $result = $self->{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium, $oid_nsResSessFailed], nothing_quit => 1); my $spu_done = 0; my $cp_total = $result->{$oid_nsResSessMaxium}; my $cp_used = $result->{$oid_nsResSessAllocate}; - + my $cp_failed = $result->{oid_nsResSessAllocate}; my $prct_used = $cp_used * 100 / $cp_total; - + my $prct_failed = $cp_failed * 100 / $cp_total; $spu_done = 1; - my $exit_code = $self->{perfdata}->threshold_check(value => $prct_used, + + my $exit_used = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_failed = $self->{perfdata}->threshold_check(value => $prct_failed, + threshold => [ { label => 'critical-failed', 'exit_litteral' => 'critical' }, { label => 'warning-failed', exit_litteral => 'warning' } ]); + my $exit_code = $self->{output}->get_most_critical(status => [ $exit_failed, $exit_used ]); + $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("%.2f%% of the sessions limit reached (%d of max. %d)", $prct_used, $cp_used, $cp_total)); + $self->{output}->perfdata_add(label => 'sessions', value => $cp_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $cp_total, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $cp_total, cast_int => 1), min => 0, max => $cp_total); + $self->{output}->perfdata_add(label => 'sessions_failed', + value => $cp_failed, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-failed', total => $cp_total, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-failed', total => $cp_total, cast_int => 1), + min => 0, max => $cp_total); if ($spu_done == 0) { $self->{output}->add_option_msg(short_msg => "Cannot check sessions usage (no total values)."); @@ -95,19 +117,25 @@ sub run { __END__ -=head1 MODE - -Check Juniper sessions usage (NETSCREEN-RESOURCE-MIB). +Check Juniper sessions usage and failed sessions (NETSCREEN-RESOURCE-MIB). =over 8 =item B<--warning> -Threshold warning in percent. +Threshold warning (percentage). =item B<--critical> -Threshold critical in percent. +Threshold critical (percentage). + +=item B<--warning-failed> + +Threshold warning on failed sessions (percentage). + +=item B<--critical-failed> + +Threshold critical in failed sessions (percentage). =back From 345ed54ea5565c57ba3a301136c46d36ef22c901 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 28 Sep 2015 17:43:45 +0200 Subject: [PATCH 13/68] Create connections.pm Add a mode to check TCP Connections (Client, Server, and Active server connections) --- .../netscaler/common/mode/connections.pm | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 network/citrix/netscaler/common/mode/connections.pm diff --git a/network/citrix/netscaler/common/mode/connections.pm b/network/citrix/netscaler/common/mode/connections.pm new file mode 100644 index 000000000..888099a3a --- /dev/null +++ b/network/citrix/netscaler/common/mode/connections.pm @@ -0,0 +1,153 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::citrix::netscaler::common::mode::connections; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +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 => + { + "warning-server:s" => { name => 'warning_server' }, + "critical-server:s" => { name => 'critical_server' }, + "warning-active:s" => { name => 'warning_active' }, + "critical-active:s" => { name => 'critical_active' }, + "warning-client:s" => { name => 'warning_client' }, + "critical-client:s" => { name => 'critical_client' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning-server', value => $self->{option_results}->{warning_server})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-server threshold '" . $self->{option_results}->{warning_server} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-server', value => $self->{option_results}->{critical_server})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-server threshold '" . $self->{option_results}->{critical_server} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warning-active', value => $self->{option_results}->{warning_active})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-active threshold '" . $self->{option_results}->{warning_active} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-active', value => $self->{option_results}->{critical_active})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-active threshold '" . $self->{option_results}->{critical_active} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warning-client', value => $self->{option_results}->{warning_client})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-client threshold '" . $self->{option_results}->{warning_client} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-client', value => $self->{option_results}->{critical_client})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-client threshold '" . $self->{option_results}->{critical_client} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_tcpCurServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.1.0'; + my $oid_tcpCurClientConn = '.1.3.6.1.4.1.5951.4.1.1.46.2.0'; + my $oid_tcpActiveServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.8.0'; + my $result = $self->{snmp}->get_leef(oids => [$oid_tcpCurServerConn, $oid_tcpCurClientConn, $oid_tcpActiveServerConn ], nothing_quit => 1); + + my $exit_server = $self->{perfdata}->threshold_check(value => $result->{$oid_tcpCurServerConn}, + threshold => [ { label => 'critical-server', exit_litteral => 'critical' }, { label => 'warning-server', exit_litteral => 'warning' } ]); + my $exit_client = $self->{perfdata}->threshold_check(value => $result->{$oid_tcpCurClientConn}, + threshold => [ { label => 'critical-client', exit_litteral => 'critical' }, { label => 'warning-client', exit_litteral => 'warning' } ]); + my $exit_active = $self->{perfdata}->threshold_check(value => $result->{$oid_tcpActiveServerConn}, + threshold => [ { label => 'critical-active', exit_litteral => 'critical' }, { label => 'warning-active', exit_litteral => 'warning' } ]); + my $exit = $self->{output}->get_most_critical(status => [$exit_server, $exit_client, $exit_active]); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Connections: Client=%s Server=%s (activeServer=%s)", + $result->{$oid_tcpCurClientConn}, $result->{$oid_tcpCurServerConn}, $result->{$oid_tcpActiveServerConn})); + + $self->{output}->perfdata_add(label => "client", unit => 'con', + value => $result->{$oid_tcpCurClientConn}, + warning => $self->{option_results}->{warning_client}, + critical => $self->{option_results}->{critical_client}, + min => 0); + $self->{output}->perfdata_add(label => "server", unit => 'con', + value => $result->{$oid_tcpCurServerConn}, + warning => $self->{option_results}->{warning_server}, + critical => $self->{option_results}->{critical_server}, + min => 0); + $self->{output}->perfdata_add(label => "activeServer", unit => 'con', + value => $result->{$oid_tcpActiveServerConn}, + warning => $self->{option_results}->{warning_active}, + critical => $self->{option_results}->{critical_active}, + min => 0); + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check connections usage (Client, Server, ActiveServer) (NS-ROOT-MIBv2). + +=over 8 + +=item B<--warning-server> + +Warning on number of server TCP connections + +=item B<--critical-server> + +Critical on number of server TCP connections + +=item B<--warning-client> + +Warning on number of client TCP connections + +=item B<--critical-client> + +Critical on number of client TCP connections + +=item B<--warning-active> + +Warning on number of server Active TCP connections + +=item B<--critical-active> + +Critical on number of server Active TCP connections + +=back + +=cut From 88096be0793fb28007970c07b15784825ccf0a97 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 28 Sep 2015 17:44:34 +0200 Subject: [PATCH 14/68] Update plugin.pm Add connections mode ref --- network/citrix/netscaler/mpx8000/plugin.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/network/citrix/netscaler/mpx8000/plugin.pm b/network/citrix/netscaler/mpx8000/plugin.pm index 960a164c3..4cb21ae51 100644 --- a/network/citrix/netscaler/mpx8000/plugin.pm +++ b/network/citrix/netscaler/mpx8000/plugin.pm @@ -42,6 +42,7 @@ sub new { 'list-vservers' => 'network::citrix::netscaler::common::mode::listvservers', 'vserver-status' => 'network::citrix::netscaler::common::mode::vserverstatus', 'memory' => 'network::citrix::netscaler::common::mode::memory', + 'connections' => 'network::citrix::netscaler::common::mode::connections', ); return $self; From 8dfc31e9369b00217668e27c45571956f060ad67 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 30 Sep 2015 13:56:12 +0200 Subject: [PATCH 15/68] + enhance a little --- cloud/aws/custom/awscli.pm | 27 +++++-------- cloud/aws/mode/cloudwatch.pm | 13 +++--- cloud/aws/mode/instancestate.pm | 70 ++++++++++++++++---------------- cloud/aws/mode/list.pm | 71 ++++++++++++++------------------- 4 files changed, 80 insertions(+), 101 deletions(-) diff --git a/cloud/aws/custom/awscli.pm b/cloud/aws/custom/awscli.pm index 3e43ea54b..4ed939bbe 100644 --- a/cloud/aws/custom/awscli.pm +++ b/cloud/aws/custom/awscli.pm @@ -23,7 +23,6 @@ package cloud::aws::custom::awscli; use strict; use warnings; use JSON; -use Data::Dumper; use centreon::plugins::misc; sub new { @@ -53,15 +52,10 @@ sub new { "sudo" => { name => 'sudo' }, } ); } - $options{options}->add_help( - package => __PACKAGE__, - sections => 'AWSCLI OPTIONS', - once => 1 - ); + $options{options}->add_help(package => __PACKAGE__, sections => 'AWSCLI OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - return $self; } @@ -78,8 +72,6 @@ sub set_options { sub set_defaults { my ( $self, %options ) = @_; - # options{default} - # Manage default value foreach ( keys %{ $options{default} } ) { if ( $_ eq $self->{mode} ) { @@ -96,30 +88,30 @@ sub set_defaults { } sub check_options { - my ( $self, %options ) = @_; + my ($self, %options) = @_; return 0; } sub execReq { - my ( $self, $options ) = @_; + my ($self, $options) = @_; my $jsoncontent; - if ( !defined( $options->{output} ) ) { + if (!defined($options->{output})) { $options->{output} = 'json'; } my $json = JSON->new; my $json_encoded = $options->{command} . " " . $options->{subcommand}; - if ( defined( $self->{option_results}->{region} ) ) { + if (defined($self->{option_results}->{region})) { $json_encoded = $json_encoded . " --region '". $self->{option_results}->{region} . "'"; } - if ( defined( $options->{json} ) ) { + if (defined($options->{json})) { $json_encoded = $json_encoded . " --cli-input-json '" . $json->encode( $options->{json} ) . "'"; } $self->{option_results}->{timeout} = 30; - if ( $options->{output} eq 'text' ) { + if ($options->{output} eq 'text') { $self->{stdout} = centreon::plugins::misc::execute( output => $self->{output}, options => $self->{option_results}, @@ -130,8 +122,7 @@ sub execReq { ); my @return = split /\n/, $self->{stdout}; $jsoncontent = $json->encode( [@return] ); - } - else { + } else { $jsoncontent = centreon::plugins::misc::execute( output => $self->{output}, options => $self->{option_results}, @@ -141,7 +132,7 @@ sub execReq { command_options => $json_encoded ); } - if ( $? > 0 ) { + if ($? > 0) { $self->{output}->add_option_msg( short_msg => "Cannot run aws" ); $self->{output}->option_exit(); } diff --git a/cloud/aws/mode/cloudwatch.pm b/cloud/aws/mode/cloudwatch.pm index 43c5fef6e..a92ac3ef4 100644 --- a/cloud/aws/mode/cloudwatch.pm +++ b/cloud/aws/mode/cloudwatch.pm @@ -25,18 +25,17 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; -use Data::Dumper; use POSIX; use JSON; use Module::Load; my $CloudwatchMetrics = { - 'cpu' => "cloud::aws::mode::metrics::ec2instancecpu", - 'traffic' => "cloud::aws::mode::metrics::ec2instancenetwork", - 'cpucreditusage' => "cloud::aws::mode::metrics::ec2instancecpucreditusage", - 'cpucreditbalance' => "cloud::aws::mode::metrics::ec2instancecpucreditbalance", - 'bucketsize' => "cloud::aws::mode::metrics::s3bucketsize", - 'rdscpu' => "cloud::aws::mode::metrics::rdsinstancecpu", + cpu => "cloud::aws::mode::metrics::ec2instancecpu", + traffic' => "cloud::aws::mode::metrics::ec2instancenetwork", + cpucreditusage => "cloud::aws::mode::metrics::ec2instancecpucreditusage", + cpucreditbalance => "cloud::aws::mode::metrics::ec2instancecpucreditbalance", + bucketsize => "cloud::aws::mode::metrics::s3bucketsize", + rdscpu => "cloud::aws::mode::metrics::rdsinstancecpu", }; my $StatisticsType = "Average,Minimum,Maximum,Sum,SampleCount"; diff --git a/cloud/aws/mode/instancestate.pm b/cloud/aws/mode/instancestate.pm index b7304a607..966d68565 100644 --- a/cloud/aws/mode/instancestate.pm +++ b/cloud/aws/mode/instancestate.pm @@ -51,7 +51,7 @@ sub new { $options{options}->add_options( arguments => { - "state:s" => { name => 'state', default => 'all' }, + "state:s" => { name => 'state', default => 'all' }, "no-includeallinstances" => { name => 'includeallinstances' }, "exclude:s" => { name => 'exclude' }, "instanceid:s" => { name => 'instanceid' } @@ -62,45 +62,43 @@ sub new { } sub check_options { - my ( $self, %options ) = @_; + my ($self, %options) = @_; $self->SUPER::init(%options); } sub manage_selection { - my ( $self, %options ) = @_; + my ($self, %options) = @_; - my ( @result, $awsapi ); + my (@result, $awsapi); # Getting some parameters # includeallinstances - if ( defined( $self->{option_results}->{includeallinstances} ) ) { - $self->{option_results}->{includeallinstances} = JSON::false; - } - else { + if (defined($self->{option_results}->{includeallinstances})) { + $self->{option_results}->{includeallinstances} = JSON::false; + } else { $self->{option_results}->{includeallinstances} = JSON::true; } # states - if ( $self->{option_results}->{state} eq 'all' ) { - @{ $self->{option_results}->{statetab} } = keys(%EC2_instance_states); - } - else { - @{ $self->{option_results}->{statetab} } = split( /,/, $self->{option_results}->{state} ); - foreach my $curstate ( @{ $self->{option_results}->{statetab} } ) { - if ( !grep { /^$curstate$/ } keys(%EC2_instance_states) ) { - $self->{output}->add_option_msg( severity => 'UNKNOWN', short_msg => "The state doesn't exist." ); + if ($self->{option_results}->{state} eq 'all') { + @{$self->{option_results}->{statetab} } = keys %EC2_instance_states; + } else { + @{$self->{option_results}->{statetab}} = split /,/, $self->{option_results}->{state}; + foreach my $curstate (@{$self->{option_results}->{statetab}}) { + if (!grep { /^$curstate$/ } keys(%EC2_instance_states)) { + $self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "The state doesn't exist."); $self->{output}->option_exit(); } } } # exclusions - if ( defined( $self->{option_results}->{exclude} ) ) { - my @excludetab = split( /,/, $self->{option_results}->{exclude} ); + if (defined($self->{option_results}->{exclude})) { + my @excludetab = split /,/, $self->{option_results}->{exclude}; my %array1 = map { $_ => 1 } @excludetab; - @{ $self->{option_results}->{statetab} } = grep { not $array1{$_} } @{ $self->{option_results}->{statetab} }; + @{$self->{option_results}->{statetab}} = grep { not $array1{$_} } @{$self->{option_results}->{statetab}}; } - my $states = join(',',@{ $self->{option_results}->{statetab} }); + my $states = join(',',@{$self->{option_results}->{statetab}}); # Getting data from AWS # Building JSON @@ -114,9 +112,9 @@ sub manage_selection { }], }; # InstanceIds - if ( defined( $self->{option_results}->{instanceid} ) ) { - my @InstanceIds = split(/,/,$self->{option_results}->{instanceid}); - @{$apiRequest->{json}{'InstanceIds'}} = @InstanceIds; + if (defined($self->{option_results}->{instanceid})) { + my @InstanceIds = split(/,/, $self->{option_results}->{instanceid}); + @{$apiRequest->{json}{InstanceIds}} = @InstanceIds; } # Requesting API @@ -124,22 +122,22 @@ sub manage_selection { $self->{command_return} = $awsapi->execReq($apiRequest); # Compute data - $self->{option_results}->{instancecount}->{'total'} = '0'; - foreach my $curstate ( @{ $self->{option_results}->{statetab} } ) { - $self->{option_results}->{instancecount}->{$curstate} = '0'; + $self->{option_results}->{instancecount}->{total} = 0; + foreach my $curstate (@{$self->{option_results}->{statetab}}) { + $self->{option_results}->{instancecount}->{$curstate} = 0; } - foreach my $l ( @{ $self->{command_return}->{InstanceStatuses} } ) { - $self->{result}->{instance}->{ $l->{InstanceId} } = $l->{InstanceState}->{Name}; + foreach my $l (@{$self->{command_return}->{InstanceStatuses}}) { + $self->{result}->{instance}->{$l->{InstanceId}} = $l->{InstanceState}->{Name}; # long output for each instance - $self->{output}->output_add( long_msg => "'" . $l->{InstanceId} . "' [state = " . $l->{InstanceState}->{Name} . ']' ); + $self->{output}->output_add(long_msg => "'" . $l->{InstanceId} . "' [state = " . $l->{InstanceState}->{Name} . ']'); - foreach my $curstate ( @{ $self->{option_results}->{statetab} } ) { - if ( $l->{InstanceState}->{Name} eq $curstate ) { + foreach my $curstate (@{$self->{option_results}->{statetab}}) { + if ($l->{InstanceState}->{Name} eq $curstate) { $self->{option_results}->{instancecount}->{$curstate}++; } } - $self->{option_results}->{instancecount}->{'total'}++; + $self->{option_results}->{instancecount}->{total}++; } } @@ -158,16 +156,16 @@ sub run { value => $self->{option_results}->{instancecount}->{'total'}, ); - foreach my $curstate ( @{ $self->{option_results}->{statetab} } ) { + foreach my $curstate (@{$self->{option_results}->{statetab}}) { $self->{output}->perfdata_add( label => $curstate, value => $self->{option_results}->{instancecount}->{$curstate}, ); # Most critical state - if ( $self->{option_results}->{instancecount}->{$curstate} != '0' ) { + if ($self->{option_results}->{instancecount}->{$curstate} != 0) { $exit_code = $EC2_instance_states{$curstate}; - $exit_code = $self->{output}->get_most_critical( status => [ $exit_code, $old_status ] ); + $exit_code = $self->{output}->get_most_critical(status => [ $exit_code, $old_status ]); $old_status = $exit_code; } } @@ -175,7 +173,7 @@ sub run { # Output message $self->{output}->output_add( severity => $exit_code, - short_msg => sprintf( "Total instances: %s", $self->{option_results}->{instancecount}->{'total'} ) + short_msg => sprintf("Total instances: %s", $self->{option_results}->{instancecount}->{total}) ); $self->{output}->display(); diff --git a/cloud/aws/mode/list.pm b/cloud/aws/mode/list.pm index a1eb79835..38da746c7 100644 --- a/cloud/aws/mode/list.pm +++ b/cloud/aws/mode/list.pm @@ -51,29 +51,24 @@ sub new { } sub check_options { - my ( $self, %options ) = @_; + my ($self, %options) = @_; $self->SUPER::init(%options); } sub api_request { - my ( $self, %options ) = @_; + my ($self, %options) = @_; - @{ $self->{option_results}->{servicetab} } = - split( /,/, $self->{option_results}->{service} ); - foreach my $service ( @{ $self->{option_results}->{servicetab} } ) { - $self->{result}->{count}->{$service} = '0'; - if ( $service eq 'EC2' ) { + @{$self->{option_results}->{servicetab}} = split( /,/, $self->{option_results}->{service} ); + foreach my $service (@{$self->{option_results}->{servicetab}}) { + $self->{result}->{count}->{$service} = 0; + if ($service eq 'EC2') { $self->EC2(%options); - } - elsif ( $service eq 'S3' ) { + } elsif ($service eq 'S3') { $self->S3(%options); - } - elsif ( $service eq 'RDS' ) { + } elsif ($service eq 'RDS') { $self->RDS(%options); - } - else { - $self->{output}->add_option_msg( - short_msg => "Service $service doesn't exists" ); + } else { + $self->{output}->add_option_msg(short_msg => "Service $service doesn't exists" ); $self->{output}->option_exit(); } } @@ -103,16 +98,16 @@ sub EC2 { $self->{command_return} = $awsapi->execReq($apiRequest); # Compute data - foreach my $instance ( @{ $self->{command_return}->{Reservations} } ) { - foreach my $tags ( @{ $instance->{Instances}[0]->{Tags} } ) { - if ( $tags->{Key} eq 'Name' ) { + foreach my $instance (@{$self->{command_return}->{Reservations}}) { + foreach my $tags (@{$instance->{Instances}[0]->{Tags}}) { + if ($tags->{Key} eq 'Name') { $instance->{Instances}[0]->{Name} = $tags->{Value}; } } - $self->{result}->{'EC2'}->{ $instance->{Instances}[0]->{InstanceId} } = + $self->{result}->{'EC2'}->{$instance->{Instances}[0]->{InstanceId}} = { - 'State' => $instance->{Instances}[0]->{State}->{Name}, - 'Name' => $instance->{Instances}[0]->{Name} + State => $instance->{Instances}[0]->{State}->{Name}, + Name => $instance->{Instances}[0]->{Name} }; $self->{result}->{count}->{'EC2'}++; @@ -134,16 +129,16 @@ sub S3 { $self->{command_return} = $awsapi->execReq($apiRequest); # Exec command - foreach my $line ( @{ $self->{command_return} } ) { - my ( $date, $time, $name ) = split( / /, $line ); + foreach my $line (@{$self->{command_return}}) { + my ($date, $time, $name) = split / /, $line; my $creationdate = $date . " " . $time; - push( @buckets, { Name => $name, CreationDate => $creationdate } ); + push(@buckets, { Name => $name, CreationDate => $creationdate }); } # Compute data foreach my $bucket (@buckets) { $self->{result}->{'S3'}->{ $bucket->{Name} } = - { 'Creation date' => $bucket->{CreationDate} }; + { Creation date => $bucket->{CreationDate} }; $self->{result}->{count}->{'S3'}++; } } @@ -161,12 +156,12 @@ sub RDS { $self->{command_return} = $awsapi->execReq($apiRequest); # Compute data - foreach my $dbinstance ( @{ $self->{command_return}->{DBInstances} } ) { - $self->{result}->{'RDS'}->{ $dbinstance->{DBInstanceIdentifier} } = { - 'State' => $dbinstance->{DBInstanceStatus}, - 'Name' => $dbinstance->{DBInstanceIdentifier} + foreach my $dbinstance (@{$self->{command_return}->{DBInstances}}) { + $self->{result}->{'RDS'}->{$dbinstance->{DBInstanceIdentifier}} = { + State => $dbinstance->{DBInstanceStatus}, + Name => $dbinstance->{DBInstanceIdentifier} }; - $self->{result}->{count}->{'RDS'}++; + $self->{result}->{count}->{RDS}++; } } @@ -181,9 +176,8 @@ sub disco_show { my ( $self, %options ) = @_; $self->api_request(%options); - - foreach my $service ( @Disco_service_tab ) { - foreach my $device ( keys %{ $self->{result}->{$service} } ) { + foreach my $service (@Disco_service_tab) { + foreach my $device (keys %{$self->{result}->{$service}}) { $self->{output}->add_disco_entry( name => $self->{result}->{$service}->{$device}->{Name}, id => $device, @@ -200,14 +194,11 @@ sub run { $self->api_request(%options); # Send formated data to Centreon - foreach my $service ( @{ $self->{option_results}->{servicetab} } ) { - $self->{output} - ->output_add( long_msg => sprintf( "AWS service: %s", $service ) ); - foreach my $device ( keys %{ $self->{result}->{$service} } ) { + foreach my $service (@{$self->{option_results}->{servicetab}}) { + $self->{output}->output_add(long_msg => sprintf("AWS service: %s", $service)); + foreach my $device (keys %{$self->{result}->{$service}}) { my $output = $device . " ["; - foreach my $value ( - sort( keys %{ $self->{result}->{$service}->{$device} } ) ) - { + foreach my $value (sort(keys %{$self->{result}->{$service}->{$device}})) { $output = $output . $value . " = " From ab82d369a71471ee2d07c172e22c696bb81ef916 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 30 Sep 2015 14:19:28 +0200 Subject: [PATCH 16/68] Update errpt.pm Little typo - unfinished sentence may be a copy/paste --- os/aix/local/mode/errpt.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/os/aix/local/mode/errpt.pm b/os/aix/local/mode/errpt.pm index d81522a55..0308c1a26 100644 --- a/os/aix/local/mode/errpt.pm +++ b/os/aix/local/mode/errpt.pm @@ -225,8 +225,6 @@ Print error description in output. Filter resource (can use a regexp). -Set - =back =cut From 9cf494e5d1269c42003a52a2d23d5c7a9fab2b3b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 30 Sep 2015 14:22:25 +0200 Subject: [PATCH 17/68] + enhance mode --- .../netscaler/common/mode/connections.pm | 196 +++++++++++------- .../juniper/common/screenos/mode/sessions.pm | 6 +- 2 files changed, 120 insertions(+), 82 deletions(-) diff --git a/network/citrix/netscaler/common/mode/connections.pm b/network/citrix/netscaler/common/mode/connections.pm index 888099a3a..91e250130 100644 --- a/network/citrix/netscaler/common/mode/connections.pm +++ b/network/citrix/netscaler/common/mode/connections.pm @@ -24,6 +24,39 @@ use base qw(centreon::plugins::mode); use strict; use warnings; +use centreon::plugins::values; + +my $maps_counters = { + global => { + '000_active' => { set => { + key_values => [ { name => 'active' } ], + output_template => 'Active Server TCP connections : %s', + perfdatas => [ + { label => 'active_server', value => 'active_absolute', template => '%s', + unit => 'con', min => 0 }, + ], + } + }, + '001_server' => { set => { + key_values => [ { name => 'server' } ], + output_template => 'Server TCP connections : %s', + perfdatas => [ + { label => 'server', value => 'server_absolute', template => '%s', + unit => 'con', min => 0 }, + ], + } + }, + '002_client' => { set => { + key_values => [ { name => 'client' } ], + output_template => 'Client TCP connections : %s', + perfdatas => [ + { label => 'client', value => 'client_absolute', template => '%s', + unit => 'con', min => 0 }, + ], + } + }, + }, +}; sub new { my ($class, %options) = @_; @@ -33,13 +66,24 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning-server:s" => { name => 'warning_server' }, - "critical-server:s" => { name => 'critical_server' }, - "warning-active:s" => { name => 'warning_active' }, - "critical-active:s" => { name => 'critical_active' }, - "warning-client:s" => { name => 'warning_client' }, - "critical-client:s" => { name => 'critical_client' }, }); + + foreach my $key (('global')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, + perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + return $self; } @@ -47,73 +91,79 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning-server', value => $self->{option_results}->{warning_server})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-server threshold '" . $self->{option_results}->{warning_server} . "'."); - $self->{output}->option_exit(); + foreach my $key (('global')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } } - if (($self->{perfdata}->threshold_validate(label => 'critical-server', value => $self->{option_results}->{critical_server})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-server threshold '" . $self->{option_results}->{critical_server} . "'."); - $self->{output}->option_exit(); +} + +sub run_global { + my ($self, %options) = @_; + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters->{global}}) { + my $obj = $maps_counters->{global}->{$_}->{obj}; + + $obj->set(instance => 'global'); + + my ($value_check) = $obj->execute(values => $self->{global}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $obj->perfdata(); } - if (($self->{perfdata}->threshold_validate(label => 'warning-active', value => $self->{option_results}->{warning_active})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-active threshold '" . $self->{option_results}->{warning_active} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-active', value => $self->{option_results}->{critical_active})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-active threshold '" . $self->{option_results}->{critical_active} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-client', value => $self->{option_results}->{warning_client})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-client threshold '" . $self->{option_results}->{warning_client} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-client', value => $self->{option_results}->{critical_client})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-client threshold '" . $self->{option_results}->{critical_client} . "'."); - $self->{output}->option_exit(); + + 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"); } } sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + $self->run_global(); + + $self->{output}->display(); + $self->{output}->exit(); +} +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = { client => 0, server => 0, active => 0 }; my $oid_tcpCurServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.1.0'; my $oid_tcpCurClientConn = '.1.3.6.1.4.1.5951.4.1.1.46.2.0'; my $oid_tcpActiveServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.8.0'; my $result = $self->{snmp}->get_leef(oids => [$oid_tcpCurServerConn, $oid_tcpCurClientConn, $oid_tcpActiveServerConn ], nothing_quit => 1); - - my $exit_server = $self->{perfdata}->threshold_check(value => $result->{$oid_tcpCurServerConn}, - threshold => [ { label => 'critical-server', exit_litteral => 'critical' }, { label => 'warning-server', exit_litteral => 'warning' } ]); - my $exit_client = $self->{perfdata}->threshold_check(value => $result->{$oid_tcpCurClientConn}, - threshold => [ { label => 'critical-client', exit_litteral => 'critical' }, { label => 'warning-client', exit_litteral => 'warning' } ]); - my $exit_active = $self->{perfdata}->threshold_check(value => $result->{$oid_tcpActiveServerConn}, - threshold => [ { label => 'critical-active', exit_litteral => 'critical' }, { label => 'warning-active', exit_litteral => 'warning' } ]); - my $exit = $self->{output}->get_most_critical(status => [$exit_server, $exit_client, $exit_active]); - - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Connections: Client=%s Server=%s (activeServer=%s)", - $result->{$oid_tcpCurClientConn}, $result->{$oid_tcpCurServerConn}, $result->{$oid_tcpActiveServerConn})); - - $self->{output}->perfdata_add(label => "client", unit => 'con', - value => $result->{$oid_tcpCurClientConn}, - warning => $self->{option_results}->{warning_client}, - critical => $self->{option_results}->{critical_client}, - min => 0); - $self->{output}->perfdata_add(label => "server", unit => 'con', - value => $result->{$oid_tcpCurServerConn}, - warning => $self->{option_results}->{warning_server}, - critical => $self->{option_results}->{critical_server}, - min => 0); - $self->{output}->perfdata_add(label => "activeServer", unit => 'con', - value => $result->{$oid_tcpActiveServerConn}, - warning => $self->{option_results}->{warning_active}, - critical => $self->{option_results}->{critical_active}, - min => 0); - $self->{output}->display(); - $self->{output}->exit(); + $self->{global}->{client} = $result->{$oid_tcpCurClientConn}; + $self->{global}->{server} = $result->{$oid_tcpCurServerConn}; + $self->{global}->{active} = $result->{$oid_tcpActiveServerConn}; } - + 1; __END__ @@ -124,30 +174,16 @@ Check connections usage (Client, Server, ActiveServer) (NS-ROOT-MIBv2). =over 8 -=item B<--warning-server> +=item B<--warning-*> -Warning on number of server TCP connections +Threshold warning. +Can be: 'server', 'active', 'client'. -=item B<--critical-server> +=item B<--critical-*> -Critical on number of server TCP connections - -=item B<--warning-client> - -Warning on number of client TCP connections - -=item B<--critical-client> - -Critical on number of client TCP connections - -=item B<--warning-active> - -Warning on number of server Active TCP connections - -=item B<--critical-active> - -Critical on number of server Active TCP connections +Threshold critical. +Can be: 'server', 'active', 'client'. =back -=cut +=cut \ No newline at end of file diff --git a/network/juniper/common/screenos/mode/sessions.pm b/network/juniper/common/screenos/mode/sessions.pm index d890eb21e..9ee4e8f73 100644 --- a/network/juniper/common/screenos/mode/sessions.pm +++ b/network/juniper/common/screenos/mode/sessions.pm @@ -87,11 +87,13 @@ sub run { threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my $exit_failed = $self->{perfdata}->threshold_check(value => $prct_failed, threshold => [ { label => 'critical-failed', 'exit_litteral' => 'critical' }, { label => 'warning-failed', exit_litteral => 'warning' } ]); - my $exit_code = $self->{output}->get_most_critical(status => [ $exit_failed, $exit_used ]); - $self->{output}->output_add(severity => $exit_code, + $self->{output}->output_add(severity => $exit_used, short_msg => sprintf("%.2f%% of the sessions limit reached (%d of max. %d)", $prct_used, $cp_used, $cp_total)); + $self->{output}->output_add(severity => $exit_failed, + short_msg => sprintf("%.2f%% of failed sessions (%d of max. %d)", + $prct_failed, $cp_failed, $cp_total)); $self->{output}->perfdata_add(label => 'sessions', value => $cp_used, From feb8231e9b4a2d8073f8e1db560de77c1692fe52 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 30 Sep 2015 17:06:38 +0200 Subject: [PATCH 18/68] +add verbose mode to print error content If everything ok we get "Error state: NoError Error code: 0" If something went bad then "Error state: Error code: " --- storage/ibm/TS3100/mode/globalstatus.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/ibm/TS3100/mode/globalstatus.pm b/storage/ibm/TS3100/mode/globalstatus.pm index c75b97cac..4ddf6fd21 100644 --- a/storage/ibm/TS3100/mode/globalstatus.pm +++ b/storage/ibm/TS3100/mode/globalstatus.pm @@ -88,12 +88,15 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; + my $oid_ibm3100FaultError = '.1.3.6.1.4.1.2.6.210.3.1.1.22.1'; + my $oid_ibm3100FaultDesc = '.1.3.6.1.4.1.2.6.210.3.1.1.24.1'; my $oid_ibm3100StatusGlobalStatus = '.1.3.6.1.4.1.2.6.210.2.1.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3100StatusGlobalStatus], nothing_quit => 1); + my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3100StatusGlobalStatus, $oid_ibm3100FaultError, $oid_ibm3100FaultDesc], nothing_quit => 1); $self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3100StatusGlobalStatus}), short_msg => sprintf("Overall global status is '%s'.", ${$states{$result->{$oid_ibm3100StatusGlobalStatus}}}[0])); + $self->{output}->output_add(long_msg => sprintf("Error state: %s Error code: %i", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError})); $self->{output}->display(); $self->{output}->exit(); @@ -117,4 +120,4 @@ Example: --threshold-overload='(unknown|non critical)=critical' =back =cut - \ No newline at end of file + From 22f7fc4566b8eccce0083814503fc8dcae06219c Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 30 Sep 2015 17:12:20 +0200 Subject: [PATCH 19/68] +add verbose mode to globalstatus.pm Get error code and error description in output to explain global status OID return code --- storage/ibm/TS3200/mode/globalstatus.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/storage/ibm/TS3200/mode/globalstatus.pm b/storage/ibm/TS3200/mode/globalstatus.pm index 78e14ac80..7fc400f31 100644 --- a/storage/ibm/TS3200/mode/globalstatus.pm +++ b/storage/ibm/TS3200/mode/globalstatus.pm @@ -87,14 +87,16 @@ sub run { my ($self, %options) = @_; # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; - + + my $oid_ibm3100FaultError = '.1.3.6.1.4.1.2.6.211.3.1.1.22.1'; + my $oid_ibm3100FaultDesc = '.1.3.6.1.4.1.2.6.211.3.1.1.24.1'; my $oid_ibm3200StatusGlobalStatus = '.1.3.6.1.4.1.2.6.211.2.1.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus], nothing_quit => 1); + my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus, $oid_ibm3100FaultError, $oid_ibm3100FaultDesc], nothing_quit => 1); $self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3200StatusGlobalStatus}), short_msg => sprintf("Overall global status is '%s'.", ${$states{$result->{$oid_ibm3200StatusGlobalStatus}}}[0])); - + $self->{output}->output_add(long_msg => sprintf("Error state: %s Error code: %i", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError})); $self->{output}->display(); $self->{output}->exit(); } @@ -117,4 +119,4 @@ Example: --threshold-overload='(unknown|non critical)=critical' =back =cut - \ No newline at end of file + From ac1a3e56771bf96d350933824e2c7ec91e008c4f Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 30 Sep 2015 17:27:32 +0200 Subject: [PATCH 20/68] Update globalstatus.pm protect in sprintf --- storage/ibm/TS3100/mode/globalstatus.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/ibm/TS3100/mode/globalstatus.pm b/storage/ibm/TS3100/mode/globalstatus.pm index 4ddf6fd21..a59855519 100644 --- a/storage/ibm/TS3100/mode/globalstatus.pm +++ b/storage/ibm/TS3100/mode/globalstatus.pm @@ -96,7 +96,7 @@ sub run { $self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3100StatusGlobalStatus}), short_msg => sprintf("Overall global status is '%s'.", ${$states{$result->{$oid_ibm3100StatusGlobalStatus}}}[0])); - $self->{output}->output_add(long_msg => sprintf("Error state: %s Error code: %i", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError})); + $self->{output}->output_add(long_msg => sprintf("Error state: '%s' Error code: '%i'", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError})); $self->{output}->display(); $self->{output}->exit(); From a60bc739af5ad7ebd1505786d6744277dc684fde Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 30 Sep 2015 17:28:24 +0200 Subject: [PATCH 21/68] Update globalstatus.pm fix copy/paste dumb things --- storage/ibm/TS3200/mode/globalstatus.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/ibm/TS3200/mode/globalstatus.pm b/storage/ibm/TS3200/mode/globalstatus.pm index 7fc400f31..98bad6d97 100644 --- a/storage/ibm/TS3200/mode/globalstatus.pm +++ b/storage/ibm/TS3200/mode/globalstatus.pm @@ -88,15 +88,15 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; - my $oid_ibm3100FaultError = '.1.3.6.1.4.1.2.6.211.3.1.1.22.1'; - my $oid_ibm3100FaultDesc = '.1.3.6.1.4.1.2.6.211.3.1.1.24.1'; + my $oid_ibm3200FaultError = '.1.3.6.1.4.1.2.6.211.3.1.1.22.1'; + my $oid_ibm3200FaultDesc = '.1.3.6.1.4.1.2.6.211.3.1.1.24.1'; my $oid_ibm3200StatusGlobalStatus = '.1.3.6.1.4.1.2.6.211.2.1.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus, $oid_ibm3100FaultError, $oid_ibm3100FaultDesc], nothing_quit => 1); + my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus, $oid_ibm3200FaultError, $oid_ibm3200FaultDesc], nothing_quit => 1); $self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3200StatusGlobalStatus}), short_msg => sprintf("Overall global status is '%s'.", ${$states{$result->{$oid_ibm3200StatusGlobalStatus}}}[0])); - $self->{output}->output_add(long_msg => sprintf("Error state: %s Error code: %i", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError})); + $self->{output}->output_add(long_msg => sprintf("Error state: '%s' Error code: '%i'", $result->{$oid_ibm3200FaultDesc}, $result->{$oid_ibm3200FaultError})); $self->{output}->display(); $self->{output}->exit(); } From 6404243fa1a9a787d0e258c3045f27cdc625c98d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 30 Sep 2015 17:36:24 +0200 Subject: [PATCH 22/68] + revert code --- storage/ibm/TS3100/mode/globalstatus.pm | 5 +---- storage/ibm/TS3200/mode/globalstatus.pm | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/storage/ibm/TS3100/mode/globalstatus.pm b/storage/ibm/TS3100/mode/globalstatus.pm index a59855519..a56a6d665 100644 --- a/storage/ibm/TS3100/mode/globalstatus.pm +++ b/storage/ibm/TS3100/mode/globalstatus.pm @@ -88,15 +88,12 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; - my $oid_ibm3100FaultError = '.1.3.6.1.4.1.2.6.210.3.1.1.22.1'; - my $oid_ibm3100FaultDesc = '.1.3.6.1.4.1.2.6.210.3.1.1.24.1'; my $oid_ibm3100StatusGlobalStatus = '.1.3.6.1.4.1.2.6.210.2.1.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3100StatusGlobalStatus, $oid_ibm3100FaultError, $oid_ibm3100FaultDesc], nothing_quit => 1); + my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3100StatusGlobalStatus], nothing_quit => 1); $self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3100StatusGlobalStatus}), short_msg => sprintf("Overall global status is '%s'.", ${$states{$result->{$oid_ibm3100StatusGlobalStatus}}}[0])); - $self->{output}->output_add(long_msg => sprintf("Error state: '%s' Error code: '%i'", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError})); $self->{output}->display(); $self->{output}->exit(); diff --git a/storage/ibm/TS3200/mode/globalstatus.pm b/storage/ibm/TS3200/mode/globalstatus.pm index 98bad6d97..1f4a916d8 100644 --- a/storage/ibm/TS3200/mode/globalstatus.pm +++ b/storage/ibm/TS3200/mode/globalstatus.pm @@ -88,15 +88,12 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; - my $oid_ibm3200FaultError = '.1.3.6.1.4.1.2.6.211.3.1.1.22.1'; - my $oid_ibm3200FaultDesc = '.1.3.6.1.4.1.2.6.211.3.1.1.24.1'; my $oid_ibm3200StatusGlobalStatus = '.1.3.6.1.4.1.2.6.211.2.1.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus, $oid_ibm3200FaultError, $oid_ibm3200FaultDesc], nothing_quit => 1); + my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus], nothing_quit => 1); $self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3200StatusGlobalStatus}), short_msg => sprintf("Overall global status is '%s'.", ${$states{$result->{$oid_ibm3200StatusGlobalStatus}}}[0])); - $self->{output}->output_add(long_msg => sprintf("Error state: '%s' Error code: '%i'", $result->{$oid_ibm3200FaultDesc}, $result->{$oid_ibm3200FaultError})); $self->{output}->display(); $self->{output}->exit(); } From ef5f5c298ce165387b73cc86007e17794c043b4d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Oct 2015 10:01:18 +0200 Subject: [PATCH 23/68] + Fix #170 --- .../common/cisco/standard/snmp/mode/cpu.pm | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/cpu.pm b/centreon/common/cisco/standard/snmp/mode/cpu.pm index 6ecaa5c09..a4870c11c 100644 --- a/centreon/common/cisco/standard/snmp/mode/cpu.pm +++ b/centreon/common/cisco/standard/snmp/mode/cpu.pm @@ -73,6 +73,26 @@ sub check_options { } } +sub check_nexus_cpu { + my ($self, %options) = @_; + + if (!defined($self->{results}->{$options{oid}}->{$options{oid} . '.0'})) { + return 0; + } + + my $cpu = $self->{results}->{$options{oid}}->{$options{oid} . '.0'}; + my $exit = $self->{perfdata}->threshold_check(value => $cpu, + threshold => [ { label => 'crit5m', exit_litteral => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU Usage : %s %%", $cpu)); + $self->{output}->perfdata_add(label => "cpu", unit => '%', + value => $cpu, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), + min => 0, max => 100); + return 1; +} + sub check_table_cpu { my ($self, %options) = @_; @@ -113,21 +133,21 @@ sub check_table_cpu { } if (defined($cpu5sec)) { - $self->{output}->perfdata_add(label => "cpu_" . $instance . "_5s", + $self->{output}->perfdata_add(label => "cpu_" . $instance . "_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); } if (defined($cpu1min)) { - $self->{output}->perfdata_add(label => "cpu_" . $instance . "_1m", + $self->{output}->perfdata_add(label => "cpu_" . $instance . "_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); } if (defined($cpu5min)) { - $self->{output}->perfdata_add(label => "cpu_" . $instance . "_5m", + $self->{output}->perfdata_add(label => "cpu_" . $instance . "_5m", unit => '%', value => $cpu5min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), @@ -157,14 +177,18 @@ sub run { my $oid_busyPer = '.1.3.6.1.4.1.9.2.1.56'; # .0 in reality my $oid_avgBusy1 = '.1.3.6.1.4.1.9.2.1.57'; # .0 in reality my $oid_avgBusy5 = '.1.3.6.1.4.1.9.2.1.58'; # .0 in reality + # Cisco Nexus + my $oid_cseSysCPUUtilization = '.1.3.6.1.4.1.9.9.305.1.1.1'; # .0 in reality $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_cpmCPUTotalEntry, start => $oid_cpmCPUTotal5sec, end => $oid_cpmCPUTotal5minRev }, { oid => $oid_lcpu, - start => $oid_busyPer, end => $oid_avgBusy5 }], - nothing_quit => 1); + start => $oid_busyPer, end => $oid_avgBusy5 }, + { oid => $oid_cseSysCPUUtilization }, + ], + nothing_quit => 1); $self->{output}->output_add(severity => 'OK', short_msg => 'All CPUs are ok.'); @@ -173,8 +197,10 @@ sub run { && !$self->check_table_cpu(entry => $oid_cpmCPUTotalEntry, sec5 => $oid_cpmCPUTotal5sec, min1 => $oid_cpmCPUTotal1min, min5 => $oid_cpmCPUTotal5min) && !$self->check_table_cpu(entry => $oid_lcpu, sec5 => $oid_busyPer, min1 => $oid_avgBusy1, min5 => $oid_avgBusy5) ) { - $self->{output}->output_add(severity => 'UNKNOWN', - short_msg => sprintf("Cannot find CPU informations.")); + if (!$self->check_nexus_cpu(oid => $oid_cseSysCPUUtilization)) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => sprintf("Cannot find CPU informations.")); + } } $self->{output}->display(); @@ -187,17 +213,19 @@ __END__ =head1 MODE -Check cpu usage (CISCO-PROCESS-MIB). +Check cpu usage (CISCO-PROCESS-MIB and CISCO-SYSTEM-EXT-MIB). =over 8 =item B<--warning> Threshold warning in percent (5s,1min,5min). +Used 5min threshold when you have only 'cpu' metric. =item B<--critical> Threshold critical in percent (5s,1min,5min). +Used 5min threshold when you have only 'cpu' metric. =back From 792a6c5450aafee8d0489fb14793374b103c124c Mon Sep 17 00:00:00 2001 From: Bertrand Cournaud Date: Thu, 1 Oct 2015 13:24:05 +0200 Subject: [PATCH 24/68] + Update map 4 plugin with new mbeans name --- apps/centreon/map/jmx/mode/eventqueue.pm | 8 ++++---- apps/centreon/map/jmx/mode/eventstatistics.pm | 8 ++++---- apps/centreon/map/jmx/mode/gates.pm | 8 ++++---- apps/centreon/map/jmx/mode/sessions.pm | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/centreon/map/jmx/mode/eventqueue.pm b/apps/centreon/map/jmx/mode/eventqueue.pm index ecab5277e..9cd6a8e00 100644 --- a/apps/centreon/map/jmx/mode/eventqueue.pm +++ b/apps/centreon/map/jmx/mode/eventqueue.pm @@ -59,20 +59,20 @@ sub run { $self->{connector} = $options{custom}; $self->{request} = [ - { mbean => "com.merethis.studio:name=statistics,type=session" } + { mbean => "com.centreon.studio:name=statistics,type=session" } ]; my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 0); - my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.merethis.studio:name=statistics,type=session"}->{AverageEventQueueSize}, + my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.centreon.studio:name=statistics,type=session"}->{AverageEventQueueSize}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Average event queue size : %d", - $result->{"com.merethis.studio:name=statistics,type=session"}->{AverageEventQueueSize})); + $result->{"com.centreon.studio:name=statistics,type=session"}->{AverageEventQueueSize})); $self->{output}->perfdata_add(label => 'events', - value => $result->{"com.merethis.studio:name=statistics,type=session"}->{AverageEventQueueSize}, + value => $result->{"com.centreon.studio:name=statistics,type=session"}->{AverageEventQueueSize}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); diff --git a/apps/centreon/map/jmx/mode/eventstatistics.pm b/apps/centreon/map/jmx/mode/eventstatistics.pm index 80ce73119..494fb186d 100644 --- a/apps/centreon/map/jmx/mode/eventstatistics.pm +++ b/apps/centreon/map/jmx/mode/eventstatistics.pm @@ -78,7 +78,7 @@ sub run { $self->{connector} = $options{custom}; $self->{request} = [ - { mbean => "com.merethis.studio:name=statistics,type=whatsup" } + { mbean => "com.centreon.studio.map:name=statistics,type=whatsup" } ]; my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 0); @@ -94,10 +94,10 @@ sub run { } foreach my $type ('EventCount', 'EventTypeCreate', 'EventTypeUpdate', 'EventTypeRemove') { - $new_datas->{$type} = $result->{"com.merethis.studio:name=statistics,type=whatsup"}->{$type}->{andIncrement}; + $new_datas->{$type} = $result->{"com.centreon.studio.map:name=statistics,type=whatsup"}->{$type}->{andIncrement}; my $old_val = $self->{statefile_cache}->get(name => $type); - next if (!defined($old_val) || $result->{"com.merethis.studio:name=statistics,type=whatsup"}->{$type}->{andIncrement} < $old_val); - my $value = int(($result->{"com.merethis.studio:name=statistics,type=whatsup"}->{$type}->{andIncrement} - $old_val) / ($new_datas->{last_timestamp} - $old_timestamp)); + next if (!defined($old_val) || $result->{"com.centreon.studio.map:name=statistics,type=whatsup"}->{$type}->{andIncrement} < $old_val); + my $value = int(($result->{"com.centreon.studio.map:name=statistics,type=whatsup"}->{$type}->{andIncrement} - $old_val) / ($new_datas->{last_timestamp} - $old_timestamp)); $self->{output}->perfdata_add(label => $type, value => $value, diff --git a/apps/centreon/map/jmx/mode/gates.pm b/apps/centreon/map/jmx/mode/gates.pm index f9346482b..27d855c15 100644 --- a/apps/centreon/map/jmx/mode/gates.pm +++ b/apps/centreon/map/jmx/mode/gates.pm @@ -59,22 +59,22 @@ sub run { $self->{connector} = $options{custom}; $self->{request} = [ - { mbean => "com.merethis.map:name=BusinessGate,type=repo" } + { mbean => "com.centreon.studio.map:name=BusinessGate,type=repo" } ]; my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); - my $gates = $result->{"com.merethis.map:name=BusinessGate,type=repo"}->{LoadedModelCount}; + my $gates = $result->{"com.centreon.studio.map:name=BusinessGate,type=repo"}->{LoadedModelCount}; my $exit = $self->{perfdata}->threshold_check(value => $gates, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Business gates opened : %d", - $result->{"com.merethis.map:name=BusinessGate,type=repo"}->{LoadedModelCount})); + $result->{"com.centreon.studio.map:name=BusinessGate,type=repo"}->{LoadedModelCount})); $self->{output}->perfdata_add(label => 'gates', - value => $result->{"com.merethis.map:name=BusinessGate,type=repo"}->{LoadedModelCount}, + value => $result->{"com.centreon.studio.map:name=BusinessGate,type=repo"}->{LoadedModelCount}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); diff --git a/apps/centreon/map/jmx/mode/sessions.pm b/apps/centreon/map/jmx/mode/sessions.pm index 70749bb51..443bde899 100644 --- a/apps/centreon/map/jmx/mode/sessions.pm +++ b/apps/centreon/map/jmx/mode/sessions.pm @@ -59,20 +59,20 @@ sub run { $self->{connector} = $options{custom}; $self->{request} = [ - { mbean => "com.merethis.studio:name=statistics,type=session" } + { mbean => "com.centreon.studio:name=statistics,type=session" } ]; my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 0); - my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.merethis.studio:name=statistics,type=session"}->{SessionCount}, + my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.centreon.studio:name=statistics,type=session"}->{SessionCount}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Current sessions : %d", - $result->{"com.merethis.studio:name=statistics,type=session"}->{SessionCount})); + $result->{"com.centreon.studio:name=statistics,type=session"}->{SessionCount})); $self->{output}->perfdata_add(label => 'sessions', - value => $result->{"com.merethis.studio:name=statistics,type=session"}->{SessionCount}, + value => $result->{"com.centreon.studio:name=statistics,type=session"}->{SessionCount}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); From 683a4f9d8d62ca9838eb17338446295b9fbdff12 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Oct 2015 17:17:47 +0200 Subject: [PATCH 25/68] + fix cloudwatch --- cloud/aws/mode/cloudwatch.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/aws/mode/cloudwatch.pm b/cloud/aws/mode/cloudwatch.pm index a92ac3ef4..a89f91b27 100644 --- a/cloud/aws/mode/cloudwatch.pm +++ b/cloud/aws/mode/cloudwatch.pm @@ -31,7 +31,7 @@ use Module::Load; my $CloudwatchMetrics = { cpu => "cloud::aws::mode::metrics::ec2instancecpu", - traffic' => "cloud::aws::mode::metrics::ec2instancenetwork", + traffic => "cloud::aws::mode::metrics::ec2instancenetwork", cpucreditusage => "cloud::aws::mode::metrics::ec2instancecpucreditusage", cpucreditbalance => "cloud::aws::mode::metrics::ec2instancecpucreditbalance", bucketsize => "cloud::aws::mode::metrics::s3bucketsize", From a00a1d3a1fabafba5976063eafea98b29ef6f8ae Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 5 Oct 2015 11:37:34 +0200 Subject: [PATCH 26/68] + add mode for biztalk (wip) --- apps/biztalk/sql/mode/rlocationdisabled.pm | 132 +++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 apps/biztalk/sql/mode/rlocationdisabled.pm diff --git a/apps/biztalk/sql/mode/rlocationdisabled.pm b/apps/biztalk/sql/mode/rlocationdisabled.pm new file mode 100644 index 000000000..12d10e16a --- /dev/null +++ b/apps/biztalk/sql/mode/rlocationdisabled.pm @@ -0,0 +1,132 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::biztalk::sql::mode::rlocationdisabled; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +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 => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "filter-location:s" => { name => 'filter_location' }, + "filter-application:s" => { name => 'filter_application' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical}. "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + + my $query = q{ + SELECT RL.Name, RL.Disabled, APP.nvcName + FROM BizTalkMgmtDb.dbo.adm_ReceiveLocation AS RL WITH(NOLOCK) + INNER JOIN BizTalkMgmtDb.dbo.bts_receiveport AS RP WITH(NOLOCK) + ON RL.ReceivePortId = RP.nID + INNER JOIN BizTalkMgmtDb.dbo.bts_application AS APP WITH(NOLOCK) + ON RP.nApplicationID = APP.nID WHERE RL.[Disabled] = -1 + }; + $self->{sql}->connect(); + $self->{sql}->query(query => $query); + + my $count = 0; + while ((my $row = $self->{sql}->fetchrow_hashref())) { + if (defined($self->{option_results}->{filter_location}) && $self->{option_results}->{filter_location} ne '' && + $row->{Name} !~ /$self->{option_results}->{filter_location}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $row->{Name} . "': no matching filter location.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '' && + $row->{nvcName} !~ /$self->{option_results}->{filter_application}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $row->{nvcName} . "': no matching filter application.", debug => 1); + next; + } + $self->{output}->output_add(long_msg => "'" . $row->{Name} . "' of application '" . $row->{nvcName} . "'"); + $count++; + } + + my $exit = $self->{perfdata}->threshold_check(value => $count, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%d receive locations are disabled", $count)); + $self->{output}->perfdata_add(label => 'count', + value => $count, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check the number of biztalk received locations disabled. +The mode should be used with mssql plugin and dyn-mode option. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=item B<--filter-location> + +Filter by location (regexp can be used). + +=item B<--filter-application> + +Filter by application (regexp can be used). + +=back + +=cut From 4bb3ae1960c7f8d096b688d4ac4edbdf09aff7d2 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 5 Oct 2015 12:12:53 +0200 Subject: [PATCH 27/68] +Few fix on plugin help Add error-id option description Specify verbose instead of description (didn't work) --- os/aix/local/mode/errpt.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/os/aix/local/mode/errpt.pm b/os/aix/local/mode/errpt.pm index 0308c1a26..b5d20c7d2 100644 --- a/os/aix/local/mode/errpt.pm +++ b/os/aix/local/mode/errpt.pm @@ -213,13 +213,17 @@ Filter error type separated by a coma (INFO, PEND, PERF, PERM, TEMP, UNKN). Filter error class ('H' for hardware, 'S' for software, '0' for errlogger, 'U' for undetermined). +=item B<--error-id> + +Filter specific error code + =item B<--retention> Retention time of errors in seconds. -=item B<--description> +=item B<--verbose> -Print error description in output. +Print error description in long output. [ Error 'CODE' Date: Timestamp ResourceName: RsrcName Description: Desc ] =item B<--filter-resource> From fab1f5bec1447b706bab4131fd0faac03314da9a Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 5 Oct 2015 12:48:47 +0200 Subject: [PATCH 28/68] +Add error-id inclusion/exclustion management Mapping between --error-id and --exclude-id options and errpt AIX options -j and -k --- os/aix/local/mode/errpt.pm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/os/aix/local/mode/errpt.pm b/os/aix/local/mode/errpt.pm index b5d20c7d2..dd2b0c278 100644 --- a/os/aix/local/mode/errpt.pm +++ b/os/aix/local/mode/errpt.pm @@ -46,10 +46,12 @@ sub new { "command-options:s" => { name => 'command_options', default => '' }, "error-type:s" => { name => 'error_type' }, "error-class:s" => { name => 'error_class' }, + "error-id:s" => { name => 'error_id' }, "retention:s" => { name => 'retention' }, "timezone:s" => { name => 'timezone' }, "description" => { name => 'description' }, - "filter-resource:s" => { name => 'filter_resource' }, + "filter-resource:s" => { name => 'filter_resource' }, + "exclude-id:s" => { name => 'exclude_id' }, }); $self->{result} = {}; return $self; @@ -58,6 +60,11 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + + if (defined($self->{option_results}->{exclude_id}) && defined($self->{option_results}->{error_id})) { + $self->{output}->add_option_msg(short_msg => "Please use --error-id OR --exclude-id, these options are mutually exclusives"); + $self->{output}->option_exit(); + } } sub manage_selection { @@ -70,6 +77,12 @@ sub manage_selection { if (defined($self->{option_results}->{error_class})){ $extra_options .= ' -d '.$self->{option_results}->{error_class}; } + if (defined($self->{option_results}->{error_id}) && $self->{option_results}->{error_id} ne ''){ + $extra_options.= ' -j '.$self->{option_results}->{error_id}; + } + if (defined($self->{option_results}->{exclude_id}) && $self->{option_results}->{exclude_id} ne ''){ + $extra_options.= ' -k '.$self->{option_results}->{exclude_id}; + } if (defined($self->{option_results}->{retention}) && $self->{option_results}->{retention} ne ''){ my $retention = time() - $self->{option_results}->{retention}; if (defined($self->{option_results}->{timezone})){ @@ -215,7 +228,7 @@ Filter error class ('H' for hardware, 'S' for software, '0' for errlogger, 'U' f =item B<--error-id> -Filter specific error code +Filter specific error code (can be a comma separated list). =item B<--retention> @@ -229,6 +242,10 @@ Print error description in long output. [ Error 'CODE' Date: Timestamp ResourceN Filter resource (can use a regexp). +=item B<--exclude-id> + +Filter on specific error code (can be a comma separated list). + =back =cut From 98b127848c9778300b0c5bdcfe3d400cc57b22a9 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 5 Oct 2015 13:00:15 +0200 Subject: [PATCH 29/68] +Fix bug "unitialized value in sprintf" Probably here since retention management has been introduced. Now it's better --- os/aix/local/mode/errpt.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/aix/local/mode/errpt.pm b/os/aix/local/mode/errpt.pm index dd2b0c278..de064cf27 100644 --- a/os/aix/local/mode/errpt.pm +++ b/os/aix/local/mode/errpt.pm @@ -139,7 +139,7 @@ sub run { $self->manage_selection(); $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("No error found since %s seconds%s.", $extra_message)); + short_msg => sprintf("No error found%s.", $extra_message)); my $total_error = 0; foreach my $errpt_error (sort(keys %{$self->{result}})) { From a4644f2cf9611825c566868f7b791f4b780b7862 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 5 Oct 2015 16:00:26 +0200 Subject: [PATCH 30/68] +add filter-id like we do for filter-resource Useful if we do not want to set a long comma separated list of id, just a pattern --- os/aix/local/mode/errpt.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os/aix/local/mode/errpt.pm b/os/aix/local/mode/errpt.pm index de064cf27..12b4e7be6 100644 --- a/os/aix/local/mode/errpt.pm +++ b/os/aix/local/mode/errpt.pm @@ -51,6 +51,7 @@ sub new { "timezone:s" => { name => 'timezone' }, "description" => { name => 'description' }, "filter-resource:s" => { name => 'filter_resource' }, + "filter-id:s" => { name => 'filter_id' }, "exclude-id:s" => { name => 'exclude_id' }, }); $self->{result} = {}; @@ -151,7 +152,8 @@ sub run { next if (defined($self->{option_results}->{filter_resource}) && $self->{option_results}->{filter_resource} ne '' && $resource_name !~ /$self->{option_results}->{filter_resource}/); - + next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' && + $identifier !~ /$self->{option_results}->{filter_id}/); $total_error++; if (defined($self->{option_results}->{description})) { $self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier, @@ -242,6 +244,10 @@ Print error description in long output. [ Error 'CODE' Date: Timestamp ResourceN Filter resource (can use a regexp). +=item B<--filter-id> + +Filter error code (can use a regexp). + =item B<--exclude-id> Filter on specific error code (can be a comma separated list). From fd94931ea9241fc936485f0c1a1ab93c3a8d0fdd Mon Sep 17 00:00:00 2001 From: Sims24 Date: Tue, 6 Oct 2015 10:44:57 +0200 Subject: [PATCH 31/68] Create offset.pm +Add first work on NTP offset mode https://github.com/centreon/centreon-plugins/issues/81 --- apps/protocols/ntp/mode/offset.pm | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 apps/protocols/ntp/mode/offset.pm diff --git a/apps/protocols/ntp/mode/offset.pm b/apps/protocols/ntp/mode/offset.pm new file mode 100644 index 000000000..120962516 --- /dev/null +++ b/apps/protocols/ntp/mode/offset.pm @@ -0,0 +1,127 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::protocols::ntp::mode::offset; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Net::NTP; + +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 => + { + "ntp-host:s" => { name => 'ntp_host' }, + "port:s" => { name => 'port', default => 123 }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout', default => 30 }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{ntp_host})) { + $self->{output}->add_option_msg(short_msg => "Please set the ntp_host option"); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + + my %ntp; + eval { + $Net::NTP::TIMEOUT = $self->{option_results}->{timeout}; + %ntp = get_ntp_response($self->{option_results}->{ntp_host}, $self->{option_results}->{port}); + }; + if ($@) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => "Couldn't connect to ntp server: " . $@); + $self->{output}->display(); + $self->{output}->exit(); + } + + my $localtime = time(); + my $offset = ($ntp{'Receive Timestamp'} - $ntp{'Originate Timestamp'}) + ($ntp{'Transmit Timestamp'} - $localtime) / 2); + + my $exit = $self->{perfdata}->threshold_check(value => $offset, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Response time %.3fs", $offset)); + $self->{output}->perfdata_add(label => "time", + value => sprintf('%.3f', $offset), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check Ntp server response. + +=over 8 + +=item B<--ntp_host> + +Ntp server address or FQDN + +=item B<--port> + +Port used (Default: 123) + +=item B<--timeout> + +Threshold for NTP timeout + +=item B<--warning> + +Threshold warning in seconds + +=item B<--critical> + +Threshold critical in seconds + +=back + +=cut From 55b9cc39d7c2d0261f59222792165c3f9225d559 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 6 Oct 2015 14:04:23 +0200 Subject: [PATCH 32/68] + add plugin for digi portserver TS --- network/digi/portserverts/snmp/mode/cpu.pm | 100 +++++++++ network/digi/portserverts/snmp/mode/memory.pm | 204 ++++++++++++++++++ network/digi/portserverts/snmp/plugin.pm | 52 +++++ 3 files changed, 356 insertions(+) create mode 100644 network/digi/portserverts/snmp/mode/cpu.pm create mode 100644 network/digi/portserverts/snmp/mode/memory.pm create mode 100644 network/digi/portserverts/snmp/plugin.pm diff --git a/network/digi/portserverts/snmp/mode/cpu.pm b/network/digi/portserverts/snmp/mode/cpu.pm new file mode 100644 index 000000000..00929cd18 --- /dev/null +++ b/network/digi/portserverts/snmp/mode/cpu.pm @@ -0,0 +1,100 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::digi::portserverts::snmp::mode::cpu; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +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 => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + # Between 0 and 255 (don't know why you can value over 100) + my $oid_processorCurrentUtilization = '.1.3.6.1.4.1.332.11.5.3.3.21.11.0'; + my $result = $self->{snmp}->get_leef(oids => [$oid_processorCurrentUtilization], nothing_quit => 1); + + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_processorCurrentUtilization}, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU Usage : %.2f", $result->{$oid_processorCurrentUtilization})); + $self->{output}->perfdata_add(label => "cpu", + value => $result->{$oid_processorCurrentUtilization}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check current processor usage. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut + \ No newline at end of file diff --git a/network/digi/portserverts/snmp/mode/memory.pm b/network/digi/portserverts/snmp/mode/memory.pm new file mode 100644 index 000000000..b04a2172c --- /dev/null +++ b/network/digi/portserverts/snmp/mode/memory.pm @@ -0,0 +1,204 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::digi::portserverts::snmp::mode::memory; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $maps_counters = { + global => { + '000_usage' => { set => { + key_values => [ { name => 'free' }, { name => 'total' } ], + closure_custom_calc => \&custom_usage_calc, + closure_custom_output => \&custom_usage_output, + closure_custom_perfdata => \&custom_usage_perfdata, + closure_custom_threshold_check => \&custom_usage_threshold, + } + }, + }, +}; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add(label => 'used', unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + my $msg = sprintf("Memory Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_total'} - $options{new_datas}->{$self->{instance} . '_free'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'}; + $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 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 => + { + }); + + foreach my $key (('global')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach my $key (('global')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + + foreach (sort keys %{$maps_counters->{global}}) { + my $obj = $maps_counters->{global}->{$_}->{obj}; + + use Data::Dumper; + Data::Dumper::Dumper($obj); + $obj->set(instance => 'global'); + + my ($value_check) = $obj->execute(values => $self->{global}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $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->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_memoryTotalMemory = '.1.3.6.1.4.1.332.11.5.3.3.22.11.0'; + my $oid_memoryAvailable = '.1.3.6.1.4.1.332.11.5.3.3.22.12.0'; + my $result = $self->{snmp}->get_leef(oids => [$oid_memoryTotalMemory, $oid_memoryAvailable], + nothing_quit => 1); + $self->{global} = { free => $result->{$oid_memoryAvailable}, total => $result->{$oid_memoryTotalMemory} }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage. + +=over 8 + +=item B<--warning-usage> + +Threshold warning (in percent). + +=item B<--critical-usage> + +Threshold critical (in percent). + +=back + +=cut \ No newline at end of file diff --git a/network/digi/portserverts/snmp/plugin.pm b/network/digi/portserverts/snmp/plugin.pm new file mode 100644 index 000000000..bb2442365 --- /dev/null +++ b/network/digi/portserverts/snmp/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::digi::portserverts::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + # $options->{options} = options object + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'network::digi::portserverts::snmp::mode::cpu', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::digi::portserverts::snmp::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Digi PortServer TS equipments in SNMP. + +=cut From 09ca75f92e8a19c661da49eb0e04c5bc01c6a8e7 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Thu, 8 Oct 2015 10:23:35 +0200 Subject: [PATCH 33/68] Update sessions.pm My bad, fix dumb copy/paste and typo --- network/juniper/common/screenos/mode/sessions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/juniper/common/screenos/mode/sessions.pm b/network/juniper/common/screenos/mode/sessions.pm index 9ee4e8f73..b529e1922 100644 --- a/network/juniper/common/screenos/mode/sessions.pm +++ b/network/juniper/common/screenos/mode/sessions.pm @@ -78,7 +78,7 @@ sub run { my $spu_done = 0; my $cp_total = $result->{$oid_nsResSessMaxium}; my $cp_used = $result->{$oid_nsResSessAllocate}; - my $cp_failed = $result->{oid_nsResSessAllocate}; + my $cp_failed = $result->{$oid_nsResSessFailed}; my $prct_used = $cp_used * 100 / $cp_total; my $prct_failed = $cp_failed * 100 / $cp_total; $spu_done = 1; From 269a94937f3ed4f95bb0ce1042b3b10081def407 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 9 Oct 2015 11:53:03 +0200 Subject: [PATCH 34/68] + Fix aruba users mode --- centreon/common/aruba/snmp/mode/apusers.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/common/aruba/snmp/mode/apusers.pm b/centreon/common/aruba/snmp/mode/apusers.pm index 621e99e34..1e5933fb4 100644 --- a/centreon/common/aruba/snmp/mode/apusers.pm +++ b/centreon/common/aruba/snmp/mode/apusers.pm @@ -396,7 +396,7 @@ sub manage_selection { my $total_timeticks = 0; foreach my $oid (keys %{$self->{results}->{$oid_wlsxUserEntry}}) { - $oid =~ /^$mapping->{nUserAuthenticationMethod}->{oid}\.(.*)$/; + next if ($oid !~ /^$mapping->{nUserAuthenticationMethod}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxUserEntry}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{nUserApBSSID}->{oid}}, instance => $instance); From 04ebdc58379b72d7bcb9a2eb843707cd10bdc258 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 9 Oct 2015 14:54:50 +0200 Subject: [PATCH 35/68] + Fix #186 --- apps/protocols/ldap/mode/search.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/protocols/ldap/mode/search.pm b/apps/protocols/ldap/mode/search.pm index a295d65d2..fbbcc94b7 100644 --- a/apps/protocols/ldap/mode/search.pm +++ b/apps/protocols/ldap/mode/search.pm @@ -98,8 +98,12 @@ sub run { $self->{output}->perfdata_add(label => "time", unit => 's', value => sprintf('%.3f', $timeelapsed), + min => 0); + $self->{output}->perfdata_add(label => "entries", + value => $num_entries, 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); $self->{output}->display(); $self->{output}->exit(); From bd3a2bfca80618d1caa854c555c13ed5aa739335 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 9 Oct 2015 15:31:52 +0200 Subject: [PATCH 36/68] + fix problem with predective failure --- .../snmp/mode/components/cachebattery.pm | 1 + .../openmanage/snmp/mode/components/connector.pm | 3 ++- .../dell/openmanage/snmp/mode/components/cpu.pm | 3 ++- .../snmp/mode/components/physicaldisk.pm | 15 +++++++++------ .../dell/openmanage/snmp/mode/components/psu.pm | 3 ++- network/f5/bigip/mode/virtualserverstatus.pm | 1 - 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm b/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm index 0b74c11ca..a453fda48 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm @@ -93,6 +93,7 @@ sub check { my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{batteryPredictedCapicity}->{oid}}, instance => $instance); my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{batteryLearnState}->{oid}}, instance => $instance); $result4->{batteryLearnState} = defined($result4->{batteryLearnState}) ? $result4->{batteryLearnState} : '-'; + $result3->{batteryPredictedCapicity} = defined($result3->{batteryPredictedCapicity}) ? $result3->{batteryPredictedCapicity} : '-'; next if ($self->check_exclude(section => 'cachebattery', instance => $instance)); diff --git a/hardware/server/dell/openmanage/snmp/mode/components/connector.pm b/hardware/server/dell/openmanage/snmp/mode/components/connector.pm index 9a56d7d27..34eede51f 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/connector.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/connector.pm @@ -83,7 +83,8 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_channelEntry}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{channelComponentStatus}->{oid}}, instance => $instance); my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{channelBusType}->{oid}}, instance => $instance); - + $result3->{channelBusType} = defined($result3->{channelBusType}) ? $result3->{channelBusType} : '-'; + next if ($self->check_exclude(section => 'connector', instance => $instance)); $self->{components}->{connector}->{total}++; diff --git a/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm b/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm index 2a8bce470..28dc2eb23 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm @@ -85,7 +85,8 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Cpu '%s' status is '%s' [instance: %s, manufacturer name: %s, brand name: %s, state: %s, speed: %s]", $instance, $result->{processorDeviceStatus}, $instance, - $result2->{processorDeviceManufacturerName}, $result4->{processorDeviceBrandName}, + $result2->{processorDeviceManufacturerName}, + defined($result4->{processorDeviceBrandName}) ? $result4->{processorDeviceBrandName} : '-', $result2->{processorDeviceStatusState}, $result3->{processorDeviceCurrentSpeed} )); my $exit = $self->get_severity(section => 'cpu', value => $result->{processorDeviceStatus}); diff --git a/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm b/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm index b956ae89a..f5a812909 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm @@ -107,7 +107,8 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Physical Disk '%s' status is '%s' [instance: %s, state: %s, spare state: %s, smart alert: %s]", $result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}, $instance, - $result2->{arrayDiskState}, $result3->{arrayDiskSpareState}, $result5->{arrayDiskSmartAlertIndication} + $result2->{arrayDiskState}, $result3->{arrayDiskSpareState}, + defined($result5->{arrayDiskSmartAlertIndication}) ? $result5->{arrayDiskSmartAlertIndication} : '-' )); my $exit = $self->get_severity(section => 'physicaldisk', value => $result4->{arrayDiskComponentStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -116,11 +117,13 @@ sub check { $result->{arrayDiskName}, $result4->{arrayDiskComponentStatus})); } - $exit = $self->get_severity(section => 'physicaldisk_smartalert', value => $result5->{arrayDiskSmartAlertIndication}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("physical disk '%s' has received a predictive failure alert", - $result->{arrayDiskName})); + if (defined($result5->{arrayDiskSmartAlertIndication})) { + $exit = $self->get_severity(section => 'physicaldisk_smartalert', value => $result5->{arrayDiskSmartAlertIndication}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("physical disk '%s' has received a predictive failure alert", + $result->{arrayDiskName})); + } } } } diff --git a/hardware/server/dell/openmanage/snmp/mode/components/psu.pm b/hardware/server/dell/openmanage/snmp/mode/components/psu.pm index 276d22528..18aaf5856 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/psu.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/psu.pm @@ -100,7 +100,8 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance: %s, location: %s, type: %s, output watts: %s, state: %s, configuration error: %s]", $instance, $result->{powerSupplyStatus}, $instance, - $result->{powerSupplyLocationName}, $result->{powerSupplyType}, $result->{powerSupplyOutputWatts}, + $result->{powerSupplyLocationName}, $result->{powerSupplyType}, + defined($result->{powerSupplyOutputWatts}) ? $result->{powerSupplyOutputWatts} : '-', $result2->{powerSupplySensorState}, $result2->{powerSupplyConfigurationErrorType} )); my $exit = $self->get_severity(section => 'psu', value => $result->{powerSupplyStatus}); diff --git a/network/f5/bigip/mode/virtualserverstatus.pm b/network/f5/bigip/mode/virtualserverstatus.pm index 86c5116fd..390af87c1 100644 --- a/network/f5/bigip/mode/virtualserverstatus.pm +++ b/network/f5/bigip/mode/virtualserverstatus.pm @@ -52,7 +52,6 @@ my $maps_counters = { }, }; - sub custom_threshold_output { my ($self, %options) = @_; From 05d7921c7a534b4d314ae4264983683db5274096 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 12 Oct 2015 14:47:18 +0200 Subject: [PATCH 37/68] +add offset reference in plugin.pm Add a line for offset mode --- apps/protocols/ntp/plugin.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/protocols/ntp/plugin.pm b/apps/protocols/ntp/plugin.pm index 9147f005e..6b659809e 100644 --- a/apps/protocols/ntp/plugin.pm +++ b/apps/protocols/ntp/plugin.pm @@ -32,7 +32,8 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'response-time' => 'apps::protocols::ntp::mode::responsetime', + 'response-time' => 'apps::protocols::ntp::mode::responsetime', + 'offset' => 'apps::protocols::ntp::mode::offset', ); return $self; From bf3c4995d131043943d62ad74f1d816115498e47 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 12 Oct 2015 14:50:18 +0200 Subject: [PATCH 38/68] +fix copy/paste in output and add verbose message --- apps/protocols/ntp/mode/offset.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/protocols/ntp/mode/offset.pm b/apps/protocols/ntp/mode/offset.pm index 120962516..0c53f0766 100644 --- a/apps/protocols/ntp/mode/offset.pm +++ b/apps/protocols/ntp/mode/offset.pm @@ -82,7 +82,9 @@ sub run { my $exit = $self->{perfdata}->threshold_check(value => $offset, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Response time %.3fs", $offset)); + short_msg => sprintf("Offset: %.3fs", $offset)); + $self->{output}->output_add(long_msg => sprintf("Host has %.5fs with its time server reference %s", $offset, $self->{option_results}->{ntp_host})); + $self->{output}->perfdata_add(label => "time", value => sprintf('%.3f', $offset), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), @@ -120,7 +122,7 @@ Threshold warning in seconds =item B<--critical> -Threshold critical in seconds +Threshold critical in seconds (e.g @10:10 means CRITICAL if offset is not between -10 and +10 seconds) =back From 69b47cece223ed496eabe43a6271ce15aa5da0b3 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 12 Oct 2015 14:50:56 +0200 Subject: [PATCH 39/68] +complete long output ... --- apps/protocols/ntp/mode/offset.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/protocols/ntp/mode/offset.pm b/apps/protocols/ntp/mode/offset.pm index 0c53f0766..998006944 100644 --- a/apps/protocols/ntp/mode/offset.pm +++ b/apps/protocols/ntp/mode/offset.pm @@ -83,7 +83,7 @@ sub run { threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Offset: %.3fs", $offset)); - $self->{output}->output_add(long_msg => sprintf("Host has %.5fs with its time server reference %s", $offset, $self->{option_results}->{ntp_host})); + $self->{output}->output_add(long_msg => sprintf("Host has an offset of %.5fs with its time server reference %s", $offset, $self->{option_results}->{ntp_host})); $self->{output}->perfdata_add(label => "time", value => sprintf('%.3f', $offset), From 046b4bc711323600d71e5b127502fde7948e7360 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Oct 2015 13:59:05 +0200 Subject: [PATCH 40/68] + Fix #190 --- snmp_standard/mode/diskio.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snmp_standard/mode/diskio.pm b/snmp_standard/mode/diskio.pm index 76d1c1746..953b69c31 100644 --- a/snmp_standard/mode/diskio.pm +++ b/snmp_standard/mode/diskio.pm @@ -340,7 +340,7 @@ sub manage_selection { $oid =~ /\.(\d+)$/; my $instance = $1; my $filter_name = $self->{results}->{$oid_diskIODevice}->{$oid}; - if (!defined($self->{option_results}->{device})) { + if (!defined($self->{option_results}->{device}) || $self->{option_results}->{device} eq '') { $self->add_result(instance => $instance); next; } From 5af32a3ac600bcbb594bea81ef5f762f884c9b82 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Oct 2015 14:32:41 +0200 Subject: [PATCH 41/68] + fix option name --- apps/protocols/ntp/mode/offset.pm | 8 ++++---- apps/protocols/ntp/plugin.pm | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/protocols/ntp/mode/offset.pm b/apps/protocols/ntp/mode/offset.pm index 998006944..6314e96b2 100644 --- a/apps/protocols/ntp/mode/offset.pm +++ b/apps/protocols/ntp/mode/offset.pm @@ -56,7 +56,7 @@ sub check_options { $self->{output}->option_exit(); } if (!defined($self->{option_results}->{ntp_host})) { - $self->{output}->add_option_msg(short_msg => "Please set the ntp_host option"); + $self->{output}->add_option_msg(short_msg => "Please set the ntp-host option"); $self->{output}->option_exit(); } } @@ -80,12 +80,12 @@ sub run { my $offset = ($ntp{'Receive Timestamp'} - $ntp{'Originate Timestamp'}) + ($ntp{'Transmit Timestamp'} - $localtime) / 2); my $exit = $self->{perfdata}->threshold_check(value => $offset, - 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, short_msg => sprintf("Offset: %.3fs", $offset)); $self->{output}->output_add(long_msg => sprintf("Host has an offset of %.5fs with its time server reference %s", $offset, $self->{option_results}->{ntp_host})); - $self->{output}->perfdata_add(label => "time", + $self->{output}->perfdata_add(label => "time", unit => 's', value => sprintf('%.3f', $offset), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); @@ -104,7 +104,7 @@ Check Ntp server response. =over 8 -=item B<--ntp_host> +=item B<--ntp-host> Ntp server address or FQDN diff --git a/apps/protocols/ntp/plugin.pm b/apps/protocols/ntp/plugin.pm index 6b659809e..650aff220 100644 --- a/apps/protocols/ntp/plugin.pm +++ b/apps/protocols/ntp/plugin.pm @@ -32,8 +32,8 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'response-time' => 'apps::protocols::ntp::mode::responsetime', - 'offset' => 'apps::protocols::ntp::mode::offset', + 'response-time' => 'apps::protocols::ntp::mode::responsetime', + 'offset' => 'apps::protocols::ntp::mode::offset', ); return $self; From c5aed031f093ad4a9883322ef333ece76443266a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 16 Oct 2015 00:21:30 +0200 Subject: [PATCH 42/68] + Fix #185 --- cloud/aws/mode/list.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud/aws/mode/list.pm b/cloud/aws/mode/list.pm index 38da746c7..82173e297 100644 --- a/cloud/aws/mode/list.pm +++ b/cloud/aws/mode/list.pm @@ -138,7 +138,7 @@ sub S3 { # Compute data foreach my $bucket (@buckets) { $self->{result}->{'S3'}->{ $bucket->{Name} } = - { Creation date => $bucket->{CreationDate} }; + { 'Creation date' => $bucket->{CreationDate} }; $self->{result}->{count}->{'S3'}++; } } @@ -166,7 +166,7 @@ sub RDS { } sub disco_format { - my ( $self, %options ) = @_; + my ($self, %options) = @_; my $names = [ 'name', 'id', 'state', 'service' ]; $self->{output}->add_disco_format( elements => $names ); From fad7a157e60de758febf6acf29595f9893fa50c2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 16 Oct 2015 00:23:58 +0200 Subject: [PATCH 43/68] + Fix #188 --- snmp_standard/plugin.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snmp_standard/plugin.pm b/snmp_standard/plugin.pm index ccb417939..ea21277bf 100644 --- a/snmp_standard/plugin.pm +++ b/snmp_standard/plugin.pm @@ -35,6 +35,7 @@ sub new { 'numeric-value' => 'snmp_standard::mode::numericvalue', 'string-value' => 'snmp_standard::mode::stringvalue', 'dynamic-command' => 'snmp_standard::mode::dynamiccommand', + 'uptime' => 'snmp_standard::mode::uptime', ); return $self; @@ -46,6 +47,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check SNMP values (string, numeric or execute commands). +Check SNMP values (string, numeric or execute commands) or standard (uptime). =cut From f3062f55ecbae83317c52a880c79e5a0521072bd Mon Sep 17 00:00:00 2001 From: RymRabehi Date: Tue, 20 Oct 2015 16:53:12 +0200 Subject: [PATCH 44/68] Update diskio.pm --- snmp_standard/mode/diskio.pm | 108 ++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 14 deletions(-) diff --git a/snmp_standard/mode/diskio.pm b/snmp_standard/mode/diskio.pm index 953b69c31..263cddd74 100644 --- a/snmp_standard/mode/diskio.pm +++ b/snmp_standard/mode/diskio.pm @@ -115,6 +115,29 @@ my $maps_counters = { unit => 'iops', min => 0 }, ], } + }, + }, + sum => { + '000_sum-read-write' => { set => { + key_values => [ { name => 'sum_read_write', diff => 1 } ], + per_second => 1, + output_template => 'R+W I/O : %s %s/s', output_error_template => "R+W I/O : %s", + output_change_bytes => 1, + perfdatas => [ + { label => 'sum_read_write', value => 'sum_read_write_per_second', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + '001_sum-read-write-iops' => { set => { + key_values => [ { name => 'sum_read_write_iops', diff => 1 } ], + per_second => 1, + output_template => 'R+W IOPs : %.2f', output_error_template => "R+W IOPs : %s", + perfdatas => [ + { label => 'total_read_write_iops', value => 'total_read_write_iops_per_second', template => '%.2f', + unit => 'iops', min => 0 }, + ], + } }, }, }; @@ -141,8 +164,8 @@ sub new { $self->{device_id_selected} = {}; $self->{statefile_value} = centreon::plugins::statefile->new(%options); - - foreach my $key (('total', 'disk')) { + + foreach my $key (('total', 'disk', 'sum')) { foreach (keys %{$maps_counters->{$key}}) { my ($id, $name) = split /_/; if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { @@ -165,7 +188,7 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - foreach my $key (('total', 'disk')) { + foreach my $key (('total', 'disk', 'sum')) { foreach (keys %{$maps_counters->{$key}}) { $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); } @@ -182,7 +205,7 @@ sub check_total { foreach (sort keys %{$maps_counters->{total}}) { my $obj = $maps_counters->{total}->{$_}->{obj}; $obj->set(instance => 'global'); - + my ($value_check) = $obj->execute(values => $self->{global}, new_datas => $self->{new_datas}); @@ -192,8 +215,8 @@ sub check_total { next; } my $exit2 = $obj->threshold_check(); - push @exits, $exit2; - + push @exits, $exit2; + my $output = $obj->output(); $long_msg .= $long_msg_append . $output; $long_msg_append = ', '; @@ -207,12 +230,57 @@ sub check_total { } 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 => "Total $short_msg" + $self->{output}->output_add(severity => $exit, + short_msg => "All devices [$short_msg]" ); } else { - $self->{output}->output_add(short_msg => "Total $long_msg"); + $self->{output}->output_add(short_msg => "All devices [$long_msg]"); + } +} + +sub check_sum { + my ($self, %options) = @_; + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits = (); + foreach (sort keys %{$maps_counters->{sum}}) { + my $obj = $maps_counters->{sum}->{$_}->{obj}; + $obj->set(instance => 'sum'); + + my ($value_check) = $obj->execute(values => $self->{sum_global}, + new_datas => $self->{new_datas}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $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 => "Server overall [$short_msg]" + ); + } else { + $self->{output}->output_add(short_msg => "Server overall [$long_msg]"); } } @@ -241,6 +309,7 @@ sub run { if ($multiple == 1) { $self->check_total(); + $self->check_sum(); $self->{output}->output_add(severity => 'OK', short_msg => 'All devices are ok.'); } @@ -250,7 +319,7 @@ sub run { my @exits; foreach (sort keys %{$maps_counters->{disk}}) { my $obj = $maps_counters->{disk}->{$_}->{obj}; - + $obj->set(instance => $id); my ($value_check) = $obj->execute(values => $self->{device_id_selected}->{$id}, new_datas => $self->{new_datas}); @@ -287,7 +356,8 @@ sub run { $self->{output}->output_add(short_msg => "Device '" . $self->{device_id_selected}->{$id}->{display} . "' $long_msg"); } } - + + $self->{statefile_value}->write(data => $self->{new_datas}); $self->{output}->display(); $self->{output}->exit(); @@ -314,12 +384,20 @@ sub add_result { $self->{device_id_selected}->{$options{instance}}->{write_iops} = $self->{results}->{$oid_diskIOWrites}->{$oid_diskIOWrites . '.' . $options{instance}}; $self->{global}->{total_write_iops} += $self->{device_id_selected}->{$options{instance}}->{write_iops}; } + + if ($self->{global}->{total_read} && $self->{global}->{total_write}) { + $self->{sum_global}->{sum_read_write} = $self->{global}->{total_read} + $self->{global}->{total_write}; + } + if ($self->{global}->{total_read_iops} && $self->{global}->{total_write_iops}) { + $self->{sum_global}->{sum_read_write_iops} = $self->{global}->{total_read_iops} + $self->{global}->{total_write_iops}; + } } sub manage_selection { my ($self, %options) = @_; $self->{global} = { total_read => 0, total_write => 0, total_read_iops => 0, total_write_iops => 0 }; + $self->{sum_global} = { sum_read_write => 0, sum_read_write_iops => 0 }; $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_diskIODevice }, { oid => $oid_diskIOReads }, @@ -340,7 +418,7 @@ sub manage_selection { $oid =~ /\.(\d+)$/; my $instance = $1; my $filter_name = $self->{results}->{$oid_diskIODevice}->{$oid}; - if (!defined($self->{option_results}->{device}) || $self->{option_results}->{device} eq '') { + if (!defined($self->{option_results}->{device})) { $self->add_result(instance => $instance); next; } @@ -400,13 +478,15 @@ Check read/write I/O disks (bytes per secondes, IOPs). Threshold warning. Can be: 'read', 'write', 'read-iops', 'write-iops', -'total-read', 'total-write', 'total-read-iops', 'total-write-iops'. +'total-read', 'total-write', 'total-read-iops', 'total-write-iops', +'sum-read-write', 'sum-read-write-iops'. =item B<--critical-*> Threshold critical. Can be: 'read', 'write', 'read-iops', 'write-iops', -'total-read', 'total-write', 'total-read-iops', 'total-write-iops'. +'total-read', 'total-write', 'total-read-iops', 'total-write-iops', +'sum-read-write', 'sum-read-write-iops'. =item B<--device> From 2839b1efbe9ee7a1556baee32814add3c4b2878e Mon Sep 17 00:00:00 2001 From: RymRabehi Date: Tue, 20 Oct 2015 17:18:32 +0200 Subject: [PATCH 45/68] Update diskio.pm --- snmp_standard/mode/diskio.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snmp_standard/mode/diskio.pm b/snmp_standard/mode/diskio.pm index 263cddd74..c25171535 100644 --- a/snmp_standard/mode/diskio.pm +++ b/snmp_standard/mode/diskio.pm @@ -134,7 +134,7 @@ my $maps_counters = { per_second => 1, output_template => 'R+W IOPs : %.2f', output_error_template => "R+W IOPs : %s", perfdatas => [ - { label => 'total_read_write_iops', value => 'total_read_write_iops_per_second', template => '%.2f', + { label => 'sum_read_write_iops', value => 'sum_read_write_iops_per_second', template => '%.2f', unit => 'iops', min => 0 }, ], } From 5e198d22ee1deeb55ef95c77d2f4a48e84f6ced8 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 22 Oct 2015 11:42:57 +0200 Subject: [PATCH 46/68] + Fix indentation --- snmp_standard/mode/diskio.pm | 44 ++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/snmp_standard/mode/diskio.pm b/snmp_standard/mode/diskio.pm index c25171535..ad93f7ea9 100644 --- a/snmp_standard/mode/diskio.pm +++ b/snmp_standard/mode/diskio.pm @@ -118,17 +118,17 @@ my $maps_counters = { }, }, sum => { - '000_sum-read-write' => { set => { - key_values => [ { name => 'sum_read_write', diff => 1 } ], - per_second => 1, - output_template => 'R+W I/O : %s %s/s', output_error_template => "R+W I/O : %s", - output_change_bytes => 1, - perfdatas => [ - { label => 'sum_read_write', value => 'sum_read_write_per_second', template => '%d', - unit => 'B/s', min => 0 }, - ], - } - }, + '000_sum-read-write' => { set => { + key_values => [ { name => 'sum_read_write', diff => 1 } ], + per_second => 1, + output_template => 'R+W I/O : %s %s/s', output_error_template => "R+W I/O : %s", + output_change_bytes => 1, + perfdatas => [ + { label => 'sum_read_write', value => 'sum_read_write_per_second', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, '001_sum-read-write-iops' => { set => { key_values => [ { name => 'sum_read_write_iops', diff => 1 } ], per_second => 1, @@ -205,7 +205,7 @@ sub check_total { foreach (sort keys %{$maps_counters->{total}}) { my $obj = $maps_counters->{total}->{$_}->{obj}; $obj->set(instance => 'global'); - + my ($value_check) = $obj->execute(values => $self->{global}, new_datas => $self->{new_datas}); @@ -215,7 +215,7 @@ sub check_total { next; } my $exit2 = $obj->threshold_check(); - push @exits, $exit2; + push @exits, $exit2; my $output = $obj->output(); $long_msg .= $long_msg_append . $output; @@ -230,7 +230,6 @@ sub check_total { } 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 => "All devices [$short_msg]" @@ -259,12 +258,11 @@ sub check_sum { } my $exit2 = $obj->threshold_check(); push @exits, $exit2; - + my $output = $obj->output(); - - $long_msg .= $long_msg_append . $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 = ', '; @@ -274,7 +272,6 @@ sub check_sum { } 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 => "Server overall [$short_msg]" @@ -286,7 +283,6 @@ sub check_sum { 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(); @@ -309,7 +305,7 @@ sub run { if ($multiple == 1) { $self->check_total(); - $self->check_sum(); + $self->check_sum(); $self->{output}->output_add(severity => 'OK', short_msg => 'All devices are ok.'); } @@ -386,10 +382,10 @@ sub add_result { } if ($self->{global}->{total_read} && $self->{global}->{total_write}) { - $self->{sum_global}->{sum_read_write} = $self->{global}->{total_read} + $self->{global}->{total_write}; + $self->{sum_global}->{sum_read_write} = $self->{global}->{total_read} + $self->{global}->{total_write}; } if ($self->{global}->{total_read_iops} && $self->{global}->{total_write_iops}) { - $self->{sum_global}->{sum_read_write_iops} = $self->{global}->{total_read_iops} + $self->{global}->{total_write_iops}; + $self->{sum_global}->{sum_read_write_iops} = $self->{global}->{total_read_iops} + $self->{global}->{total_write_iops}; } } @@ -418,7 +414,7 @@ sub manage_selection { $oid =~ /\.(\d+)$/; my $instance = $1; my $filter_name = $self->{results}->{$oid_diskIODevice}->{$oid}; - if (!defined($self->{option_results}->{device})) { + if (!defined($self->{option_results}->{device}) || $self->{option_results}->{device} eq '') { $self->add_result(instance => $instance); next; } From 392ae07b2a4d9a92355125eae7d24dc416a273c7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 22 Oct 2015 14:49:19 +0200 Subject: [PATCH 47/68] + Add nimble plugin --- storage/nimble/snmp/mode/globalstats.pm | 264 ++++++++++++++++++++++++ storage/nimble/snmp/mode/volumeusage.pm | 259 +++++++++++++++++++++++ storage/nimble/snmp/plugin.pm | 49 +++++ 3 files changed, 572 insertions(+) create mode 100644 storage/nimble/snmp/mode/globalstats.pm create mode 100644 storage/nimble/snmp/mode/volumeusage.pm create mode 100644 storage/nimble/snmp/plugin.pm diff --git a/storage/nimble/snmp/mode/globalstats.pm b/storage/nimble/snmp/mode/globalstats.pm new file mode 100644 index 000000000..636013b7f --- /dev/null +++ b/storage/nimble/snmp/mode/globalstats.pm @@ -0,0 +1,264 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::nimble::snmp::mode::globalstats; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use centreon::plugins::values; +use centreon::plugins::statefile; + +my $maps_counters = { + global => { + '000_read' => { set => { + key_values => [ { name => 'read', diff => 1 } ], + per_second => 1, + output_template => 'Read I/O : %s %s/s', output_error_template => "Read I/O : %s", + output_change_bytes => 1, + perfdatas => [ + { label => 'read', value => 'read_per_second', template => '%d', + unit => 'B/s' }, + ], + } + }, + '001_write' => { set => { + key_values => [ { name => 'write', diff => 1 } ], + per_second => 1, + output_template => 'Write I/O : %s %s/s', output_error_template => "Write I/O : %s", + output_change_bytes => 1, + perfdatas => [ + { label => 'write', value => 'write_per_second', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + '002_read-iops' => { set => { + key_values => [ { name => 'read_iops', diff => 1 } ], + per_second => 1, + output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", + perfdatas => [ + { label => 'read_iops', value => 'read_iops_per_second', template => '%.2f', + unit => 'iops', min => 0 }, + ], + } + }, + '003_write-iops' => { set => { + key_values => [ { name => 'write_iops', diff => 1 } ], + per_second => 1, + output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", + perfdatas => [ + { label => 'write_iops', value => 'write_iops_per_second', template => '%.2f', + unit => 'iops', min => 0 }, + ], + } + }, + '004_read-time' => { set => { + key_values => [ { name => 'read_time', diff => 1 } ], + output_template => 'Read Time : %.3f s', output_error_template => "Read Time : %s", + perfdatas => [ + { label => 'read_time', value => 'read_time_absolute', template => '%.3f', + unit => 's', min => 0 }, + ], + } + }, + '005_write-time' => { set => { + key_values => [ { name => 'write_time', diff => 1 } ], + output_template => 'Write Time : %.3f s', output_error_template => "Write Time : %s", + perfdatas => [ + { label => 'write_time', value => 'write_time_absolute', template => '%.3f', + unit => '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 => + { + "filter-counters:s" => { name => 'filter_counters' }, + }); + $self->{statefile_value} = centreon::plugins::statefile->new(%options); + + foreach my $key (('global')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value}, + output => $self->{output}, + perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach my $key (('global')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } + } + + $self->{statefile_value}->check_options(%options); +} + +sub run_global { + my ($self, %options) = @_; + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters->{global}}) { + if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' && + $_ !~ /$self->{option_results}->{filter_counters}/) { + $self->{output}->output_add(long_msg => "skipping counter $_", debug => 1); + next; + } + + my $obj = $maps_counters->{global}->{$_}->{obj}; + + $obj->set(instance => 'global'); + + my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, + values => $self->{global}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $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"); + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + + $self->{new_datas} = {}; + $self->{statefile_value}->read(statefile => $self->{cache_name}); + $self->{new_datas}->{last_timestamp} = time(); + + $self->run_global(); + + $self->{statefile_value}->write(data => $self->{new_datas}); + $self->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + + if ($options{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "nimble_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + $self->{global} = {}; + my $oid_globalStats = '.1.3.6.1.4.1.37447.1.3'; + my $oid_ioReads = '.1.3.6.1.4.1.37447.1.3.2.0'; + my $oid_ioReadBytes = '.1.3.6.1.4.1.37447.1.3.8.0'; + my $oid_ioReadTimeMicrosec = '.1.3.6.1.4.1.37447.1.3.6.0'; + my $oid_ioWrites = '.1.3.6.1.4.1.37447.1.3.4.0'; + my $oid_ioWriteBytes = '.1.3.6.1.4.1.37447.1.3.10.0'; + my $oid_ioWriteTimeMicrosec = '.1.3.6.1.4.1.37447.1.3.7.0'; + my $result = $options{snmp}->get_table(oid => $oid_globalStats, + nothing_quit => 1); + $self->{global}->{read} = defined($result->{$oid_ioReadBytes}) ? $result->{$oid_ioReadBytes} : undef; + $self->{global}->{read_iops} = defined($result->{$oid_ioReads}) ? $result->{$oid_ioReads} : undef; + $self->{global}->{read_time} = defined($result->{$oid_ioReadTimeMicrosec}) ? $result->{$oid_ioReadTimeMicrosec} / 1000000 : undef; + $self->{global}->{write} = defined($result->{$oid_ioWriteBytes}) ? $result->{$oid_ioWriteBytes} : undef; + $self->{global}->{write_iops} = defined($result->{$oid_ioWrites}) ? $result->{$oid_ioWrites} : undef; + $self->{global}->{write_time} = defined($result->{$oid_ioWriteTimeMicrosec}) ? $result->{$oid_ioWriteTimeMicrosec} / 1000000: undef; +} + +1; + +__END__ + +=head1 MODE + +Check global statistics of storage. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'read', 'read-iops', 'write', 'write-iops', +'read-time', 'write-time'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'read', 'read-iops', 'write', 'write-iops', +'read-time', 'write-time'. + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='-iops$' + +=back + +=cut diff --git a/storage/nimble/snmp/mode/volumeusage.pm b/storage/nimble/snmp/mode/volumeusage.pm new file mode 100644 index 000000000..d2f59bbad --- /dev/null +++ b/storage/nimble/snmp/mode/volumeusage.pm @@ -0,0 +1,259 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::nimble::snmp::mode::volumeusage; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $instance_mode; + +my $maps_counters = { + vol => { + '000_usage' => { + set => { + key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ], + closure_custom_calc => \&custom_usage_calc, + closure_custom_output => \&custom_usage_output, + closure_custom_perfdata => \&custom_usage_perfdata, + closure_custom_threshold_check => \&custom_usage_threshold, + }, + }, + } +}; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $extra_label = ''; + if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { + $extra_label .= '_' . $self->{result_values}->{display}; + } + $self->{output}->perfdata_add(label => 'used' . $extra_label, unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; + $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 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 => + { + "filter-name:s" => { name => 'filter_name' }, + }); + + foreach my $key (('vol')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach my $key (('vol')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } + } + $instance_mode = $self; +} + +sub run_instances { + my ($self, %options) = @_; + + my $multiple = 1; + if (scalar(keys %{$self->{vol}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All volume usages are ok'); + } + + foreach my $id (sort keys %{$self->{vol}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits = (); + foreach (sort keys %{$maps_counters->{vol}}) { + my $obj = $maps_counters->{vol}->{$_}->{obj}; + $obj->set(instance => $id); + + my ($value_check) = $obj->execute(values => $self->{vol}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $obj->perfdata(extra_instance => $multiple); + } + + $self->{output}->output_add(long_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg"); + 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 => "Volume '$self->{vol}->{$id}->{display}' $short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg"); + } + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + $self->run_instances(); + + $self->{output}->display(); + $self->{output}->exit(); +} + +my $mapping = { + volName => { oid => '.1.3.6.1.4.1.37447.1.2.1.3' }, + volSizeLow => { oid => '.1.3.6.1.4.1.37447.1.2.1.4' }, # seems in MB + volSizeHigh => { oid => '.1.3.6.1.4.1.37447.1.2.1.5' }, # seems in MB + volUsageLow => { oid => '.1.3.6.1.4.1.37447.1.2.1.6' }, # seems in MB + volUsageHigh => { oid => '.1.3.6.1.4.1.37447.1.2.1.7' }, # seems in MB +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_volEntry = '.1.3.6.1.4.1.37447.1.2.1'; + my $results = $options{snmp}->get_table(oid => $oid_volEntry, nothing_quit => 1); + $self->{vol} = {}; + foreach my $oid (keys %{$results}) { + next if ($oid !~ /^$mapping->{volName}->{oid}\.(.*)/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{volName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $result->{volName} . "': no matching vserver name.", debug => 1); + next; + } + + my $total = (($result->{volSizeHigh} << 32) + $result->{volSizeLow}) * 1024 * 1024; + my $used = (($result->{volUsageHigh} << 32) + $result->{volUsageLow}) * 1024 * 1024; + $self->{vol}->{$instance} = { display => $result->{volName}, used => $used, total => $total }; + } + + if (scalar(keys %{$self->{vol}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check volume usages. + +=over 8 + +=item B<--filter-name> + +Filter by name (regexp can be used). + +=item B<--warning-usage> + +Threshold warning (in percent). + +=item B<--critical-usage> + +Threshold critical (in percent). + +=back + +=cut diff --git a/storage/nimble/snmp/plugin.pm b/storage/nimble/snmp/plugin.pm new file mode 100644 index 000000000..1d7d9bfd3 --- /dev/null +++ b/storage/nimble/snmp/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::nimble::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'volume-usage' => 'storage::nimble::snmp::mode::volumeusage', + 'global-stats' => 'storage::nimble::snmp::mode::globalstats', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check nimble storage in SNMP. + +=cut From 2c4019306c925afc2c43c2e40432f7fbc302c990 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 30 Oct 2015 17:13:05 +0100 Subject: [PATCH 48/68] + add some option for connector 2.1.0 --- apps/vmware/connector/custom/connector.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/vmware/connector/custom/connector.pm b/apps/vmware/connector/custom/connector.pm index 4b560ad06..fb9dde9d2 100644 --- a/apps/vmware/connector/custom/connector.pm +++ b/apps/vmware/connector/custom/connector.pm @@ -54,7 +54,9 @@ sub new { "vsphere-username:s@" => { name => 'vsphere_username' }, "vsphere-password:s@" => { name => 'vsphere_password' }, "container:s@" => { name => 'container' }, - "timeout:s@" => { name => 'timeout' }, + "timeout:s@" => { name => 'timeout' }, + "sampling-period:s@" => { name => 'sampling_period' }, + "time-shift:s@" => { name => 'time_shift' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'CONNECTOR OPTIONS', once => 1); @@ -105,7 +107,9 @@ sub check_options { $self->{vsphere_address} = (defined($self->{option_results}->{vsphere_address})) ? shift(@{$self->{option_results}->{vsphere_address}}) : undef; $self->{vsphere_username} = (defined($self->{option_results}->{vsphere_username})) ? shift(@{$self->{option_results}->{vsphere_username}}) : undef; $self->{vsphere_password} = (defined($self->{option_results}->{vsphere_password})) ? shift(@{$self->{option_results}->{vsphere_password}}) : undef; - + $self->{sampling_period} = (defined($self->{option_results}->{sampling_period})) ? shift(@{$self->{option_results}->{sampling_period}}) : undef; + $self->{time_shift} = (defined($self->{option_results}->{sampling_period})) ? shift(@{$self->{option_results}->{time_shift}}) : 0; + $self->{connector_port} = 5700 if ($self->{connector_port} eq ''); $self->{container} = 'default' if ($self->{container} eq ''); if (!defined($self->{connector_hostname}) || $self->{connector_hostname} eq '') { @@ -198,6 +202,8 @@ sub run { $self->{json_send}->{vsphere_address} = $self->{vsphere_address}; $self->{json_send}->{vsphere_username} = $self->{vsphere_username}; $self->{json_send}->{vsphere_password} = $self->{vsphere_password}; + $self->{json_send}->{sampling_period} = $self->{sampling_period}; + $self->{json_send}->{time_shift} = $self->{time_shift}; # Init my $context = zmq_init(); @@ -288,6 +294,15 @@ Password of vpshere/ESX connection (with --vsphere-address). Set global execution timeout (Default: 50) +=item B<--sampling-period> + +Choose the sampling period (can change the default sampling for counters). +Should be not different than 300 or 20. + +=item B<--time-shift> + +Can shift the time. We the following option you can average X counters values (default: 0). + =back =head1 DESCRIPTION From cdb24e8744302601f5d999f074c10a43636c06d6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 4 Nov 2015 10:16:27 +0100 Subject: [PATCH 49/68] + Change oracle backup age request --- database/oracle/mode/rmanbackupage.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/database/oracle/mode/rmanbackupage.pm b/database/oracle/mode/rmanbackupage.pm index 55b1f4785..aee605963 100644 --- a/database/oracle/mode/rmanbackupage.pm +++ b/database/oracle/mode/rmanbackupage.pm @@ -85,13 +85,12 @@ sub run { $self->{sql}->connect(); my $query; if (defined($self->{option_results}->{incremental_level})) { - $query = q{SELECT v$rman_status.object_type, + $query = q{SELECT v$rman_status.object_type, ((max(v$rman_status.start_time) - date '1970-01-01')*24*60*60) as last_time, - NVL(v$backup_set_details.incremental_level, 0) - FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_recid = v$backup_set_details.session_recid - WHERE operation='BACKUP' - GROUP BY object_type, incremental_level ORDER BY last_time DESC - }; + v$backup_set_details.incremental_level, + FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_stamp = v$backup_set_details.session_stamp + WHERE operation='BACKUP' and v$backup_set_details.incremental_level is not Null + GROUP BY object_type, incremental_level}; } else { $query = q{SELECT object_type, ((max(start_time) - date '1970-01-01')*24*60*60) as last_time From c8c31b18c2f319c5fc89b6343b86a41cf1ae7124 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 4 Nov 2015 11:12:52 +0100 Subject: [PATCH 50/68] + Enhance cisco wlc mode: manage when it's in slave mode --- centreon/common/airespace/snmp/mode/apstatus.pm | 14 +++++++++----- centreon/common/airespace/snmp/mode/apusers.pm | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/centreon/common/airespace/snmp/mode/apstatus.pm b/centreon/common/airespace/snmp/mode/apstatus.pm index 53f421367..c3e230234 100644 --- a/centreon/common/airespace/snmp/mode/apstatus.pm +++ b/centreon/common/airespace/snmp/mode/apstatus.pm @@ -161,7 +161,7 @@ sub run { $self->manage_selection(); my $multiple = 1; - if (scalar(keys %{$self->{ap_selected}}) == 1) { + if (scalar(keys %{$self->{ap_selected}}) <= 1) { $multiple = 0; } @@ -234,15 +234,19 @@ my $mapping3 = { bsnAPAdminStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => \%map_admin_status }, }; +my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3'; + sub manage_selection { my ($self, %options) = @_; $self->{ap_selected} = {}; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{bsnAPName}->{oid} }, + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel }, + { oid => $mapping->{bsnAPName}->{oid} }, { oid => $mapping2->{bsnAPOperationStatus}->{oid} }, { oid => $mapping3->{bsnAPAdminStatus}->{oid} }, ], nothing_quit => 1); + $self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}); foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnAPName}->{oid} }}) { $oid =~ /^$mapping->{bsnAPName}->{oid}\.(.*)$/; my $instance = $1; @@ -251,7 +255,7 @@ sub manage_selection { my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnAPAdminStatus}->{oid} }, instance => $instance); if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $result->{bsnAPName} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "Skipping '" . $result->{bsnAPName} . "': no matching filter."); + $self->{output}->output_add(long_msg => "Skipping '" . $result->{bsnAPName} . "': no matching filter.", debug => 1); next; } @@ -260,8 +264,8 @@ sub manage_selection { } if (scalar(keys %{$self->{ap_selected}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "No entry found."); - $self->{output}->option_exit(); + $self->{output}->output_add(severity => 'OK', + short_msg => 'No AP associated (can be: slave wireless controller or your filter)'); } } diff --git a/centreon/common/airespace/snmp/mode/apusers.pm b/centreon/common/airespace/snmp/mode/apusers.pm index b7ec0e16e..63834926b 100644 --- a/centreon/common/airespace/snmp/mode/apusers.pm +++ b/centreon/common/airespace/snmp/mode/apusers.pm @@ -221,16 +221,20 @@ my $mapping2 = { bsnMobileStationSsid => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.7' }, }; +my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3'; + sub manage_selection { my ($self, %options) = @_; $self->{global} = { total => 0, total_idle => 0, total_aaapending => 0, total_authenticated => 0, total_associated => 0, total_powersave => 0, total_disassociated => 0, total_tobedeleted => 0, total_probing => 0, total_blacklisted => 0}; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{bsnMobileStationStatus}->{oid} }, + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel }, + { oid => $mapping->{bsnMobileStationStatus}->{oid} }, { oid => $mapping2->{bsnMobileStationSsid}->{oid} }, ], nothing_quit => 1); + $self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}); foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnMobileStationStatus}->{oid} }}) { $oid =~ /^$mapping->{bsnMobileStationStatus}->{oid}\.(.*)$/; my $instance = $1; From 27a6be829c7f72f43ce20b5bf8c96ae50a1dac9e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 4 Nov 2015 15:05:41 +0100 Subject: [PATCH 51/68] + fix rman incremental backup age --- database/oracle/mode/rmanbackupage.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/database/oracle/mode/rmanbackupage.pm b/database/oracle/mode/rmanbackupage.pm index aee605963..01cb955e8 100644 --- a/database/oracle/mode/rmanbackupage.pm +++ b/database/oracle/mode/rmanbackupage.pm @@ -87,10 +87,11 @@ sub run { if (defined($self->{option_results}->{incremental_level})) { $query = q{SELECT v$rman_status.object_type, ((max(v$rman_status.start_time) - date '1970-01-01')*24*60*60) as last_time, - v$backup_set_details.incremental_level, - FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_stamp = v$backup_set_details.session_stamp - WHERE operation='BACKUP' and v$backup_set_details.incremental_level is not Null - GROUP BY object_type, incremental_level}; + v$backup_set_details.incremental_level + FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_recid = v$backup_set_details.session_recid + WHERE operation='BACKUP' + GROUP BY object_type, incremental_level ORDER BY last_time DESC + }; } else { $query = q{SELECT object_type, ((max(start_time) - date '1970-01-01')*24*60*60) as last_time @@ -114,7 +115,8 @@ sub run { next if (defined($already_checked->{$$row[0]})); - if (defined($self->{option_results}->{incremental_level})) { + if (defined($self->{option_results}->{incremental_level})) { + next if (!defined($$row[2])); # skip null incremental # db incr with incremental level 0 = DB FULL if (/db full/ && $$row[0] =~ /db incr/i && defined($$row[2]) && $$row[2] == 0) { # it's a full. we get $$row[0] = 'DB FULL'; From b498c8ee5efd88c9b74efb0903b914ff58fdf5d4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 4 Nov 2015 16:02:37 +0100 Subject: [PATCH 52/68] + Revert request (need to work on it) --- database/oracle/mode/rmanbackupage.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/oracle/mode/rmanbackupage.pm b/database/oracle/mode/rmanbackupage.pm index 01cb955e8..fef424a8f 100644 --- a/database/oracle/mode/rmanbackupage.pm +++ b/database/oracle/mode/rmanbackupage.pm @@ -87,7 +87,7 @@ sub run { if (defined($self->{option_results}->{incremental_level})) { $query = q{SELECT v$rman_status.object_type, ((max(v$rman_status.start_time) - date '1970-01-01')*24*60*60) as last_time, - v$backup_set_details.incremental_level + NVL(v$backup_set_details.incremental_level, 0) FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_recid = v$backup_set_details.session_recid WHERE operation='BACKUP' GROUP BY object_type, incremental_level ORDER BY last_time DESC @@ -116,7 +116,6 @@ sub run { next if (defined($already_checked->{$$row[0]})); if (defined($self->{option_results}->{incremental_level})) { - next if (!defined($$row[2])); # skip null incremental # db incr with incremental level 0 = DB FULL if (/db full/ && $$row[0] =~ /db incr/i && defined($$row[2]) && $$row[2] == 0) { # it's a full. we get $$row[0] = 'DB FULL'; From 2cdd7ae29416302a86b1e1a3e90a577f63ec09c5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 6 Nov 2015 11:31:05 +0100 Subject: [PATCH 53/68] + Protect to avoid errors on checking h3c hardware on wrong hardware --- network/h3c/snmp/mode/components/default.pm | 1 + network/h3c/snmp/mode/components/fan.pm | 1 + network/h3c/snmp/mode/components/psu.pm | 1 + network/h3c/snmp/mode/components/sensor.pm | 1 + 4 files changed, 4 insertions(+) diff --git a/network/h3c/snmp/mode/components/default.pm b/network/h3c/snmp/mode/components/default.pm index 325208b3c..6be93e67d 100644 --- a/network/h3c/snmp/mode/components/default.pm +++ b/network/h3c/snmp/mode/components/default.pm @@ -57,6 +57,7 @@ sub check { foreach my $instance (sort $self->get_instance_class(class => { $options{component_class} => 1 })) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); + next if (!defined($result->{EntityExtErrorStatus})); next if ($self->check_exclude(section => $options{component}, instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => $options{component}, instance => $instance); diff --git a/network/h3c/snmp/mode/components/fan.pm b/network/h3c/snmp/mode/components/fan.pm index 352d70cf8..a4e2b1cfb 100644 --- a/network/h3c/snmp/mode/components/fan.pm +++ b/network/h3c/snmp/mode/components/fan.pm @@ -45,6 +45,7 @@ sub check { foreach my $instance (sort $self->get_instance_class(class => { 7 => 1 })) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); + next if (!defined($result->{EntityExtErrorStatus})); next if ($self->check_exclude(section => 'fan', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'fan', instance => $instance); diff --git a/network/h3c/snmp/mode/components/psu.pm b/network/h3c/snmp/mode/components/psu.pm index d89fd0dd1..aa963bf58 100644 --- a/network/h3c/snmp/mode/components/psu.pm +++ b/network/h3c/snmp/mode/components/psu.pm @@ -45,6 +45,7 @@ sub check { foreach my $instance (sort $self->get_instance_class(class => { 6 => 1 }) ) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); + next if (!defined($result->{EntityExtErrorStatus})); next if ($self->check_exclude(section => 'psu', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'psu', instance => $instance); diff --git a/network/h3c/snmp/mode/components/sensor.pm b/network/h3c/snmp/mode/components/sensor.pm index 542dcb4fd..f6f5735c5 100644 --- a/network/h3c/snmp/mode/components/sensor.pm +++ b/network/h3c/snmp/mode/components/sensor.pm @@ -58,6 +58,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance); + next if (!defined($result->{EntityExtErrorStatus})); next if ($self->check_exclude(section => 'sensor', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'sensor', instance => $instance); From 1ceded94bec73e2a3f4bb67c898d0bc96ecde24c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 6 Nov 2015 13:44:47 +0100 Subject: [PATCH 54/68] + add 3com plugin (WIP) --- network/3com/snmp/mode/cpu.pm | 229 ++++++++++++++++++++++++++++ network/3com/snmp/mode/memory.pm | 250 +++++++++++++++++++++++++++++++ network/3com/snmp/plugin.pm | 51 +++++++ 3 files changed, 530 insertions(+) create mode 100644 network/3com/snmp/mode/cpu.pm create mode 100644 network/3com/snmp/mode/memory.pm create mode 100644 network/3com/snmp/plugin.pm diff --git a/network/3com/snmp/mode/cpu.pm b/network/3com/snmp/mode/cpu.pm new file mode 100644 index 000000000..8804ac90b --- /dev/null +++ b/network/3com/snmp/mode/cpu.pm @@ -0,0 +1,229 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::3com::snmp::mode::cpu; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $instance_mode; + +my $maps_counters = { + cpu => { + '000_5s' => { + set => { + key_values => [ { name => 'display' }, { name => 'usage_5s' } ], + output_template => '%s %% (5sec)', output_error_template => "%s (5sec)", + perfdatas => [ + { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%d', + unit => '%', min => 0, max => 100 }, + ], + }, + }, + '001_1m' => { + set => { + key_values => [ { name => 'display' }, { name => 'usage_1m' } ], + output_template => '%s %% (1m)', output_error_template => "%s (1min)", + perfdatas => [ + { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%d', + unit => '%', min => 0, max => 100 }, + ], + }, + }, + '002_5m' => { + set => { + key_values => [ { name => 'display' }, { name => 'usage_5m' } ], + output_template => '%s %% (5min)', output_error_template => "%s (5min)", + perfdatas => [ + { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%d', + unit => '%', min => 0, max => 100 }, + ], + }, + }, + } +}; + +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 => + { + }); + + foreach my $key (('cpu')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach my $key (('cpu')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } + } + $instance_mode = $self; +} + +sub run_instances { + my ($self, %options) = @_; + + my $multiple = 1; + if (scalar(keys %{$self->{cpu}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All CPU usages are ok'); + } + + foreach my $id (sort keys %{$self->{cpu}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits = (); + foreach (sort keys %{$maps_counters->{cpu}}) { + my $obj = $maps_counters->{cpu}->{$_}->{obj}; + $obj->set(instance => $id); + + my ($value_check) = $obj->execute(values => $self->{cpu}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $obj->perfdata(extra_instance => $multiple); + } + + my $prefix = ''; + if ($multiple == 1) { + $prefix = sprintf("CPU '%s' ", $self->{cpu}->{$id}->{display}); + } + $self->{output}->output_add(long_msg => "${prefix}$long_msg"); + 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 => "${prefix}$short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "${prefix}$long_msg"); + } + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + $self->run_instances(); + + $self->{output}->display(); + $self->{output}->exit(); +} + +my $mapping = { + hwCpuCostRate => { oid => '.1.3.6.1.4.1.43.45.1.6.1.1.1.2' }, + hwCpuCostRatePer1Min => { oid => '.1.3.6.1.4.1.43.45.1.6.1.1.1.3' }, + hwCpuCostRatePer5Min => { oid => '.1.3.6.1.4.1.43.45.1.6.1.1.1.4' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + # a3com-huawei-splat-devm.mib + my $oid_hwCpuEntry = '.1.3.6.1.4.1.43.45.1.6.1.1.1'; + my $results = $options{snmp}->get_table(oid => $oid_hwCpuEntry, nothing_quit => 1); + $self->{cpu} = {}; + foreach my $oid (keys %{$results}) { + next if ($oid !~ /^$mapping->{hwMemSize}->{oid}\.(.*)/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + + $self->{cpu}->{$instance} = { display => $instance, + usage_5s => $result->{hwCpuCostRate}, + usage_1m => $result->{hwCpuCostRatePer1Min}, + usage_5m => $result->{hwCpuCostRatePer5Min}, + }; + } + + if (scalar(keys %{$self->{cpu}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check cpu usages. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: '5s', '1m', '5m'. + +=item B<--critical-*> + +Threshold critical. +Can be: '5s', '1m', '5m'. + +=back + +=cut diff --git a/network/3com/snmp/mode/memory.pm b/network/3com/snmp/mode/memory.pm new file mode 100644 index 000000000..d0e92264b --- /dev/null +++ b/network/3com/snmp/mode/memory.pm @@ -0,0 +1,250 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::3com::snmp::mode::memory; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $instance_mode; + +my $maps_counters = { + mem => { + '000_usage' => { + set => { + key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ], + closure_custom_calc => \&custom_usage_calc, + closure_custom_output => \&custom_usage_output, + closure_custom_perfdata => \&custom_usage_perfdata, + closure_custom_threshold_check => \&custom_usage_threshold, + }, + }, + } +}; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $extra_label = ''; + if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { + $extra_label .= '_' . $self->{result_values}->{display}; + } + $self->{output}->perfdata_add(label => 'used' . $extra_label, unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; + $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 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 => + { + }); + + foreach my $key (('mem')) { + foreach (keys %{$maps_counters->{$key}}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); + } + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach my $key (('mem')) { + foreach (keys %{$maps_counters->{$key}}) { + $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); + } + } + $instance_mode = $self; +} + +sub run_instances { + my ($self, %options) = @_; + + my $multiple = 1; + if (scalar(keys %{$self->{mem}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All memory usages are ok'); + } + + foreach my $id (sort keys %{$self->{mem}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits = (); + foreach (sort keys %{$maps_counters->{mem}}) { + my $obj = $maps_counters->{mem}->{$_}->{obj}; + $obj->set(instance => $id); + + my ($value_check) = $obj->execute(values => $self->{mem}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $obj->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $obj->threshold_check(); + push @exits, $exit2; + + my $output = $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 = ', '; + } + + $obj->perfdata(extra_instance => $multiple); + } + + my $prefix = ''; + if ($multiple == 1) { + $prefix = sprintf("Memory '%s' ", $self->{mem}->{$id}->{display}); + } + $self->{output}->output_add(long_msg => "${prefix}$long_msg"); + 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 => "${prefix}$short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "${prefix}$long_msg"); + } + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + $self->run_instances(); + + $self->{output}->display(); + $self->{output}->exit(); +} + +my $mapping = { + hwMemSize => { oid => '.1.3.6.1.4.1.43.45.1.6.1.2.1.1.2' }, + hwMemFree => { oid => '.1.3.6.1.4.1.43.45.1.6.1.2.1.1.3' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + # a3com-huawei-splat-devm.mib + my $oid_hwMemEntry = '.1.3.6.1.4.1.43.45.1.6.1.2.1.1'; + my $results = $options{snmp}->get_table(oid => $oid_hwMemEntry, nothing_quit => 1); + $self->{mem} = {}; + foreach my $oid (keys %{$results}) { + next if ($oid !~ /^$mapping->{hwMemSize}->{oid}\.(.*)/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + + my $total = $result->{hwMemSize}; + my $used = $result->{hwMemSize} - $result->{hwMemFree}; + $self->{mem}->{$instance} = { display => $instance, used => $used, total => $total }; + } + + if (scalar(keys %{$self->{mem}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check memory usages. + +=over 8 + +=item B<--warning-usage> + +Threshold warning (in percent). + +=item B<--critical-usage> + +Threshold critical (in percent). + +=back + +=cut diff --git a/network/3com/snmp/plugin.pm b/network/3com/snmp/plugin.pm new file mode 100644 index 000000000..2a591a9d3 --- /dev/null +++ b/network/3com/snmp/plugin.pm @@ -0,0 +1,51 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::3com::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'network::3com::snmp::mode::cpu', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::3com::snmp::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check 3com equipment (old legacy. Maybe you should use 'network::h3c' plugin) in SNMP. + +=cut From af60854ad81e25cff108ace8a4aa6ef223dbe680 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 6 Nov 2015 13:48:53 +0100 Subject: [PATCH 55/68] + fix cpu 3com --- network/3com/snmp/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/3com/snmp/mode/cpu.pm b/network/3com/snmp/mode/cpu.pm index 8804ac90b..1f38a6da6 100644 --- a/network/3com/snmp/mode/cpu.pm +++ b/network/3com/snmp/mode/cpu.pm @@ -187,7 +187,7 @@ sub manage_selection { my $results = $options{snmp}->get_table(oid => $oid_hwCpuEntry, nothing_quit => 1); $self->{cpu} = {}; foreach my $oid (keys %{$results}) { - next if ($oid !~ /^$mapping->{hwMemSize}->{oid}\.(.*)/); + next if ($oid !~ /^$mapping->{hwCpuCostRatePer5Min}->{oid}\.(.*)/); my $instance = $1; my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); From 439e4f3236785a37881356066ecc66fc122d6141 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 6 Nov 2015 13:54:40 +0100 Subject: [PATCH 56/68] + 3com: change order --- network/3com/snmp/mode/cpu.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/network/3com/snmp/mode/cpu.pm b/network/3com/snmp/mode/cpu.pm index 1f38a6da6..06e535f03 100644 --- a/network/3com/snmp/mode/cpu.pm +++ b/network/3com/snmp/mode/cpu.pm @@ -32,7 +32,7 @@ my $maps_counters = { cpu => { '000_5s' => { set => { - key_values => [ { name => 'display' }, { name => 'usage_5s' } ], + key_values => [ { name => 'usage_5s' }, { name => 'display' } ], output_template => '%s %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%d', @@ -42,7 +42,7 @@ my $maps_counters = { }, '001_1m' => { set => { - key_values => [ { name => 'display' }, { name => 'usage_1m' } ], + key_values => [ { name => 'usage_1m' }, { name => 'display' } ], output_template => '%s %% (1m)', output_error_template => "%s (1min)", perfdatas => [ { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%d', @@ -52,7 +52,7 @@ my $maps_counters = { }, '002_5m' => { set => { - key_values => [ { name => 'display' }, { name => 'usage_5m' } ], + key_values => [ { name => 'usage_5m' }, { name => 'display' } ], output_template => '%s %% (5min)', output_error_template => "%s (5min)", perfdatas => [ { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%d', From aa4785bd518a1e083c987c722ad4ebd006f623e7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 6 Nov 2015 14:06:02 +0100 Subject: [PATCH 57/68] + Correct hardware bluecoat --- network/bluecoat/snmp/mode/components/disk.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/bluecoat/snmp/mode/components/disk.pm b/network/bluecoat/snmp/mode/components/disk.pm index c8f429993..bf0127b44 100644 --- a/network/bluecoat/snmp/mode/components/disk.pm +++ b/network/bluecoat/snmp/mode/components/disk.pm @@ -61,7 +61,7 @@ sub check { my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_deviceDiskValueEntry}, instance => $instance); - next if ($result->{deviceDiskStatus} !~ /notpresent/i && + next if ($result->{deviceDiskStatus} =~ /notpresent/i && $self->absent_problem(section => 'disk', instance => $instance)); next if ($self->check_filter(section => 'disk', instance => $instance)); $self->{components}->{disk}->{total}++; @@ -72,7 +72,7 @@ sub check { my $exit = $self->get_severity(section => 'disk', value => $result->{deviceDiskStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Sensor '%s' operational status is %s", + short_msg => sprintf("Disk '%s' status is %s", $result->{deviceDiskSerialN}, $result->{deviceDiskStatus})); } } From 702ebf47237b038bb83926038a8f00c1717fba0c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 6 Nov 2015 14:08:01 +0100 Subject: [PATCH 58/68] + add hardware mode 3com --- network/3com/snmp/mode/components/fan.pm | 74 ++++++ network/3com/snmp/mode/components/psu.pm | 74 ++++++ network/3com/snmp/mode/cpu.pm | 4 +- network/3com/snmp/mode/hardware.pm | 275 +++++++++++++++++++++++ network/3com/snmp/plugin.pm | 1 + 5 files changed, 426 insertions(+), 2 deletions(-) create mode 100644 network/3com/snmp/mode/components/fan.pm create mode 100644 network/3com/snmp/mode/components/psu.pm create mode 100644 network/3com/snmp/mode/hardware.pm diff --git a/network/3com/snmp/mode/components/fan.pm b/network/3com/snmp/mode/components/fan.pm new file mode 100644 index 000000000..0c91df2cf --- /dev/null +++ b/network/3com/snmp/mode/components/fan.pm @@ -0,0 +1,74 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::3com::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'active', + 2 => 'deactive', + 3 => 'not-install', + 4 => 'unsupport', +); + +# In MIB 'a3com-huawei-splat-devm' +my $mapping = { + hwDevMFanStatus => { oid => '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2', map => \%map_status }, +}; +my $oid_hwdevMFanStatusEntry = '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_hwdevMFanStatusEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fans"); + $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hwdevMFanStatusEntry}})) { + next if ($oid !~ /^$mapping->{hwDevMFanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hwdevMFanStatusEntry}, instance => $instance); + + next if ($result->{hwDevMFanStatus} =~ /not-install/i && + $self->absent_problem(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance: %s]", + $instance, $result->{hwDevMFanStatus}, + $instance)); + my $exit = $self->get_severity(section => 'fan', value => $result->{hwDevMFanStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' status is %s", + $instance, $result->{hwDevMFanStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/3com/snmp/mode/components/psu.pm b/network/3com/snmp/mode/components/psu.pm new file mode 100644 index 000000000..9fda71e7b --- /dev/null +++ b/network/3com/snmp/mode/components/psu.pm @@ -0,0 +1,74 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::3com::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'active', + 2 => 'deactive', + 3 => 'not-install', + 4 => 'unsupport', +); + +# In MIB 'a3com-huawei-splat-devm' +my $mapping = { + hwDevMPowerStatus => { oid => '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2', map => \%map_status }, +}; +my $oid_hwdevMPowerStatusEntry = '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_hwdevMPowerStatusEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hwdevMPowerStatusEntry}})) { + next if ($oid !~ /^$mapping->{hwDevMPowerStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hwdevMPowerStatusEntry}, instance => $instance); + + next if ($result->{hwDevMPowerStatus} =~ /not-install/i && + $self->absent_problem(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance: %s]", + $instance, $result->{hwDevMPowerStatus}, + $instance)); + my $exit = $self->get_severity(section => 'psu', value => $result->{hwDevMPowerStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supply '%s' status is %s", + $instance, $result->{hwDevMPowerStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/3com/snmp/mode/cpu.pm b/network/3com/snmp/mode/cpu.pm index 06e535f03..71e7df6fe 100644 --- a/network/3com/snmp/mode/cpu.pm +++ b/network/3com/snmp/mode/cpu.pm @@ -145,9 +145,9 @@ sub run_instances { $obj->perfdata(extra_instance => $multiple); } - my $prefix = ''; + my $prefix = "CPU Usage "; if ($multiple == 1) { - $prefix = sprintf("CPU '%s' ", $self->{cpu}->{$id}->{display}); + $prefix = sprintf("CPU '%s' Usage ", $self->{cpu}->{$id}->{display}); } $self->{output}->output_add(long_msg => "${prefix}$long_msg"); my $exit = $self->{output}->get_most_critical(status => [ @exits ]); diff --git a/network/3com/snmp/mode/hardware.pm b/network/3com/snmp/mode/hardware.pm new file mode 100644 index 000000000..a4bb080b3 --- /dev/null +++ b/network/3com/snmp/mode/hardware.pm @@ -0,0 +1,275 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::3com::snmp::mode::hardware; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +my $thresholds = { + fan => [ + ['active', 'OK'], + ['deactive', 'CRITICAL'], + ['not-install', 'OK'], + ['unsupport', 'WARNING'], + ], + psu => [ + ['active', 'OK'], + ['deactive', 'CRITICAL'], + ['not-install', 'OK'], + ['unsupport', 'WARNING'], + ], +}; + +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 => + { + "filter:s@" => { name => 'filter' }, + "absent-problem:s@" => { name => 'absent_problem' }, + "component:s" => { name => 'component', default => '.*' }, + "no-component:s" => { name => 'no_component' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + $self->{components} = {}; + $self->{no_components} = undef; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (defined($self->{option_results}->{no_component})) { + if ($self->{option_results}->{no_component} ne '') { + $self->{no_components} = $self->{option_results}->{no_component}; + } else { + $self->{no_components} = 'critical'; + } + } + + $self->{filter} = []; + foreach my $val (@{$self->{option_results}->{filter}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; + } + + $self->{absent_problem} = []; + foreach my $val (@{$self->{option_results}->{absent_problem}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + push @{$self->{absent_problem}}, { filter => $values[0], instance => $values[1] }; + } + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + next if (!defined($val) || $val eq ''); + my @values = split (/,/, $val); + if (scalar(@values) < 3) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $instance, $status, $filter); + if (scalar(@values) == 3) { + ($section, $status, $filter) = @values; + $instance = '.*'; + } else { + ($section, $instance, $status, $filter) = @values; + } + if ($section !~ /^psu|fan$/) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'."); + $self->{output}->option_exit(); + } + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance }; + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + my $snmp_request = []; + my @components = ('psu', 'fan'); + foreach (@components) { + if (/$self->{option_results}->{component}/) { + my $mod_name = "network::3com::snmp::mode::components::$_"; + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, + error_msg => "Cannot load module '$mod_name'."); + my $func = $mod_name->can('load'); + $func->(request => $snmp_request); + } + } + + if (scalar(@{$snmp_request}) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } + $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); + + foreach (@components) { + if (/$self->{option_results}->{component}/) { + my $mod_name = "network::3com::snmp::mode::components::$_"; + my $func = $mod_name->can('check'); + $func->($self); + } + } + + my $total_components = 0; + my $display_by_component = ''; + my $display_by_component_append = ''; + foreach my $comp (sort(keys %{$self->{components}})) { + # Skipping short msg when no components + next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); + $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; + $display_by_component_append = ', '; + } + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All %s components are ok [%s].", + $total_components, + $display_by_component) + ); + + if (defined($self->{option_results}->{no_component}) && $total_components == 0) { + $self->{output}->output_add(severity => $self->{no_components}, + short_msg => 'No components are checked.'); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub absent_problem { + my ($self, %options) = @_; + + foreach (@{$self->{absent_problem}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($_->{instance}) || $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Component '%s' instance '%s' is not present", + $options{section}, $options{instance})); + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); + $self->{components}->{$options{section}}->{skip}++; + return 1; + } + } + } + + return 0; +} + +sub check_filter { + my ($self, %options) = @_; + + foreach (@{$self->{filter}}) { + if ($options{section} =~ /$_->{filter}/) { + if (!defined($options{instance}) && !defined($_->{instance})) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } + } + + return 0; +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i && + (!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) { + $status = $_->{status}; + return $status; + } + } + } + my $label = defined($options{label}) ? $options{label} : $options{section}; + foreach (@{$thresholds->{$label}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware (Power Supply, Fan). + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'fan', 'psu'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan) +Can also exclude specific instance: --filter=fan,1 + +=item B<--absent-problem> + +Return an error if an entity is not 'present' (default is skipping) (comma seperated list) +Can be specific or global: --absent-problem=fan,2 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='fan,CRITICAL,^(?!(active)$)' + +=back + +=cut \ No newline at end of file diff --git a/network/3com/snmp/plugin.pm b/network/3com/snmp/plugin.pm index 2a591a9d3..132c0a2ff 100644 --- a/network/3com/snmp/plugin.pm +++ b/network/3com/snmp/plugin.pm @@ -32,6 +32,7 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( 'cpu' => 'network::3com::snmp::mode::cpu', + 'hardware' => 'network::3com::snmp::mode::hardware', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'memory' => 'network::3com::snmp::mode::memory', From e02b164e2f558f8223c92a40954f58f1882f1e3d Mon Sep 17 00:00:00 2001 From: Shini31 Date: Fri, 6 Nov 2015 17:59:49 +0100 Subject: [PATCH 59/68] Fix #203 - fix typo for issuername and subjectname in help --- apps/protocols/x509/mode/validity.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/protocols/x509/mode/validity.pm b/apps/protocols/x509/mode/validity.pm index c4c124ebb..754aa220e 100644 --- a/apps/protocols/x509/mode/validity.pm +++ b/apps/protocols/x509/mode/validity.pm @@ -208,11 +208,11 @@ Threshold warning in days (Days before expiration, eg: '60:' for 60 days before) Threshold critical in days (Days before expiration, eg: '30:' for 30 days before) -=item B<--subject> +=item B<--subjectname> Subject Name pattern -=item B<--issuer> +=item B<--issuername> Issuer Name pattern From fca3e08804a6c441d58a688ab7002113e288a7c1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 10 Nov 2015 10:44:19 +0100 Subject: [PATCH 60/68] + Set sanity mode by default --- centreon/plugins/script_custom.pm | 6 ++---- centreon/plugins/script_simple.pm | 6 ++---- centreon/plugins/script_snmp.pm | 6 ++---- centreon/plugins/script_sql.pm | 6 ++---- centreon/plugins/script_wsman.pm | 6 ++---- docs/en/user/guide.rst | 9 --------- docs/fr/user/guide.rst | 9 --------- 7 files changed, 10 insertions(+), 38 deletions(-) diff --git a/centreon/plugins/script_custom.pm b/centreon/plugins/script_custom.pm index 9a6df7c66..0a42f05ac 100644 --- a/centreon/plugins/script_custom.pm +++ b/centreon/plugins/script_custom.pm @@ -42,7 +42,7 @@ sub new { 'custommode:s' => { name => 'custommode_name' }, 'list-custommode' => { name => 'list_custommode' }, 'multiple' => { name => 'multiple' }, - 'sanity-options' => { name => 'sanity_options' }, + 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it } ); $self->{version} = '1.0'; @@ -93,9 +93,7 @@ sub init { if (defined($self->{list_custommode})) { $self->list_custommode(); } - if (defined($self->{sanity_options})) { - $self->{options}->set_sanity(); - } + $self->{options}->set_sanity(); # Output HELP $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); diff --git a/centreon/plugins/script_simple.pm b/centreon/plugins/script_simple.pm index fa6543593..ae6d97caa 100644 --- a/centreon/plugins/script_simple.pm +++ b/centreon/plugins/script_simple.pm @@ -39,7 +39,7 @@ sub new { 'dyn-mode:s' => { name => 'dynmode_name' }, 'list-mode' => { name => 'list_mode' }, 'mode-version:s' => { name => 'mode_version' }, - 'sanity-options' => { name => 'sanity_options' }, + 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it } ); $self->{version} = '1.0'; @@ -74,9 +74,7 @@ sub init { if (defined($self->{list_mode})) { $self->list_mode(); } - if (defined($self->{sanity_options})) { - $self->{options}->set_sanity(); - } + $self->{options}->set_sanity(); # Output HELP $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); diff --git a/centreon/plugins/script_snmp.pm b/centreon/plugins/script_snmp.pm index 7c8cfbaaa..17653b9ac 100644 --- a/centreon/plugins/script_snmp.pm +++ b/centreon/plugins/script_snmp.pm @@ -41,7 +41,7 @@ sub new { 'dyn-mode:s' => { name => 'dynmode_name' }, 'list-mode' => { name => 'list_mode' }, 'mode-version:s' => { name => 'mode_version' }, - 'sanity-options' => { name => 'sanity_options' }, + 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it } ); $self->{version} = '1.0'; @@ -76,9 +76,7 @@ sub init { if (defined($self->{list_mode})) { $self->list_mode(); } - if (defined($self->{sanity_options})) { - $self->{options}->set_sanity(); - } + $self->{options}->set_sanity(); # Output HELP $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); diff --git a/centreon/plugins/script_sql.pm b/centreon/plugins/script_sql.pm index 7a21220f0..da585de01 100644 --- a/centreon/plugins/script_sql.pm +++ b/centreon/plugins/script_sql.pm @@ -43,7 +43,7 @@ sub new { 'sqlmode:s' => { name => 'sqlmode_name', default => 'dbi' }, 'list-sqlmode' => { name => 'list_sqlmode' }, 'multiple' => { name => 'multiple' }, - 'sanity-options' => { name => 'sanity_options' }, + 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it } ); $self->{version} = '1.0'; @@ -85,9 +85,7 @@ sub init { if (defined($self->{list_sqlmode})) { $self->list_sqlmode(); } - if (defined($self->{sanity_options})) { - $self->{options}->set_sanity(); - } + $self->{options}->set_sanity(); # Output HELP $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); diff --git a/centreon/plugins/script_wsman.pm b/centreon/plugins/script_wsman.pm index d7f38d0c5..0243f4ae7 100644 --- a/centreon/plugins/script_wsman.pm +++ b/centreon/plugins/script_wsman.pm @@ -41,7 +41,7 @@ sub new { 'dyn-mode:s' => { name => 'dynmode_name' }, 'list-mode' => { name => 'list_mode' }, 'mode-version:s' => { name => 'mode_version' }, - 'sanity-options' => { name => 'sanity_options' }, + 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it } ); $self->{version} = '1.0'; @@ -76,9 +76,7 @@ sub init { if (defined($self->{list_mode})) { $self->list_mode(); } - if (defined($self->{sanity_options})) { - $self->{options}->set_sanity(); - } + $self->{options}->set_sanity(); # Output HELP $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); diff --git a/docs/en/user/guide.rst b/docs/en/user/guide.rst index 96191a3e7..60ff97ab4 100644 --- a/docs/en/user/guide.rst +++ b/docs/en/user/guide.rst @@ -557,15 +557,6 @@ The mapping between 'snmpwalk' options and "centreon-plugins" options: Miscellaneous ------------- -I use an option but it doesn't seem to work -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Before opening a ticket on the github, please use the option ``--sanity-options``. It checks if you have misspell an option: -:: - - $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=traffic --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --interface='.*' --name --regex --verbose --skip --skip-speed0 --sanity-options - Unknown option: regex - I get the error: "UNKNOWN: Need to specify '--custommode'." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/fr/user/guide.rst b/docs/fr/user/guide.rst index dc1701fb3..df9d7da3b 100644 --- a/docs/fr/user/guide.rst +++ b/docs/fr/user/guide.rst @@ -557,15 +557,6 @@ L'association entre les options 'snmpwalk' et les options "centreon-plugins" : Divers ------ -J'utilise une options mais il semblerait qu'elle ne fonctionne pas -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Avant d'ouvrir un ticket sur github, utilisez l'option ``--sanity-options``. Cela vérifie si vous avez mal orthographié une option : -:: - - $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=traffic --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --interface='.*' --name --regex --verbose --skip --skip-speed0 --sanity-options - Unknown option: regex - J'ai l'erreur: "UNKNOWN: Need to specify '--custommode'." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From af71ac763e5516169025e135ddaad63ad6654be0 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 10 Nov 2015 10:45:59 +0100 Subject: [PATCH 61/68] + Remove sanity option in help --- centreon/plugins/script_custom.pm | 4 ---- centreon/plugins/script_simple.pm | 4 ---- centreon/plugins/script_snmp.pm | 4 ---- centreon/plugins/script_sql.pm | 4 ---- centreon/plugins/script_wsman.pm | 4 ---- 5 files changed, 20 deletions(-) diff --git a/centreon/plugins/script_custom.pm b/centreon/plugins/script_custom.pm index 0a42f05ac..38650e334 100644 --- a/centreon/plugins/script_custom.pm +++ b/centreon/plugins/script_custom.pm @@ -262,10 +262,6 @@ Check minimal version of mode. If not, unknown error. Display plugin version. -=item B<--sanity-options> - -Check unknown options (for debug purpose). - =item B<--custommode> Choose a custom mode. diff --git a/centreon/plugins/script_simple.pm b/centreon/plugins/script_simple.pm index ae6d97caa..5a6a994e8 100644 --- a/centreon/plugins/script_simple.pm +++ b/centreon/plugins/script_simple.pm @@ -198,10 +198,6 @@ Check minimal version of mode. If not, unknown error. Display plugin version. -=item B<--sanity-options> - -Check unknown options (for debug purpose). - =back =head1 DESCRIPTION diff --git a/centreon/plugins/script_snmp.pm b/centreon/plugins/script_snmp.pm index 17653b9ac..2a4567629 100644 --- a/centreon/plugins/script_snmp.pm +++ b/centreon/plugins/script_snmp.pm @@ -206,10 +206,6 @@ Check minimal version of mode. If not, unknown error. Display plugin version. -=item B<--sanity-options> - -Check unknown options (for debug purpose). - =back =head1 DESCRIPTION diff --git a/centreon/plugins/script_sql.pm b/centreon/plugins/script_sql.pm index da585de01..c82cf1778 100644 --- a/centreon/plugins/script_sql.pm +++ b/centreon/plugins/script_sql.pm @@ -259,10 +259,6 @@ Check minimal version of mode. If not, unknown error. Display plugin version. -=item B<--sanity-options> - -Check unknown options (for debug purpose). - =item B<--sqlmode> Choose a sql mode (Default: "dbi"). diff --git a/centreon/plugins/script_wsman.pm b/centreon/plugins/script_wsman.pm index 0243f4ae7..789747149 100644 --- a/centreon/plugins/script_wsman.pm +++ b/centreon/plugins/script_wsman.pm @@ -202,10 +202,6 @@ Check minimal version of mode. If not, unknown error. Display plugin version. -=item B<--sanity-options> - -Check unknown options (for debug purpose). - =back =head1 DESCRIPTION From 89c8f254c550c00ee4f125a42be89380f92d957c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 10 Nov 2015 11:16:11 +0100 Subject: [PATCH 62/68] + Add global version --- centreon/plugins/script.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/centreon/plugins/script.pm b/centreon/plugins/script.pm index 81df96169..7cf310f13 100644 --- a/centreon/plugins/script.pm +++ b/centreon/plugins/script.pm @@ -29,7 +29,9 @@ use FindBin; use Pod::Usage; use Pod::Find qw(pod_where); -my %handlers = ('DIE' => {}); +my %handlers = (DIE => {}); + +my $global_version = 20151110; sub new { my $class = shift; @@ -242,6 +244,10 @@ sub run { $self->{output}->option_exit(); } if (!defined($self->{plugin}) || $self->{plugin} eq '') { + if (defined($self->{version})) { + $self->{output}->add_option_msg(short_msg => "Global Version: " . $global_version); + $self->{output}->option_exit(nolabel => 1); + } $self->{output}->add_option_msg(short_msg => "Need to specify '--plugin' option."); $self->{output}->option_exit(); } @@ -285,7 +291,7 @@ Print available plugins. =item B<--version> -Print plugin version. +Print global version. =item B<--help> From d6314d70937c52d6b927852e6aa82d5eb8650db4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 12 Nov 2015 21:34:56 +0100 Subject: [PATCH 63/68] Fix #205 --- .../cisco/standard/snmp/mode/components/voltage.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/components/voltage.pm b/centreon/common/cisco/standard/snmp/mode/components/voltage.pm index 0b8cddeb1..33530f526 100644 --- a/centreon/common/cisco/standard/snmp/mode/components/voltage.pm +++ b/centreon/common/cisco/standard/snmp/mode/components/voltage.pm @@ -72,11 +72,13 @@ sub check { short_msg => sprintf("Voltage '%s' status is %s", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState})); } - + + $result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000; my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageStatusValue}); if ($checked == 0) { my $warn_th = undef; - my $crit_th = $result->{ciscoEnvMonVoltageThresholdLow} . ':' . $result->{ciscoEnvMonVoltageThresholdHigh}; + my $crit_th = (defined($result->{ciscoEnvMonVoltageThresholdLow}) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdLow}) : 0) . ':' . + (defined($result->{ciscoEnvMonVoltageThresholdHigh}) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdHigh}) : ''); $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); @@ -84,10 +86,10 @@ sub check { } if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("Voltage '%s' is %s V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue})); + short_msg => sprintf("Voltage '%s' is %.3f V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue})); } $self->{output}->perfdata_add(label => "voltage_" . $result->{ciscoEnvMonVoltageStatusDescr}, unit => 'V', - value => $result->{ciscoEnvMonVoltageStatusValue}, + value => sprintf("%.3f", $result->{ciscoEnvMonVoltageStatusValue}), warning => $warn, critical => $crit); } From 81f1ce5c307f56d9b9fa8ca2754982540652eb85 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 12 Nov 2015 21:40:34 +0100 Subject: [PATCH 64/68] + Fix aruba '--warning-snr' --- centreon/common/aruba/snmp/mode/apconnections.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon/common/aruba/snmp/mode/apconnections.pm b/centreon/common/aruba/snmp/mode/apconnections.pm index 3db216373..ebb58bb18 100644 --- a/centreon/common/aruba/snmp/mode/apconnections.pm +++ b/centreon/common/aruba/snmp/mode/apconnections.pm @@ -55,11 +55,11 @@ my $maps_counters = { ], } }, - '003_nsr' => { set => { + '003_snr' => { set => { key_values => [ { name => 'apSignalToNoiseRatio' }, { name => 'bssid' }, ], output_template => 'Signal to noise ratio : %d', perfdatas => [ - { label => 'nsr', value => 'apSignalToNoiseRatio_absolute', template => '%d', + { label => 'snr', value => 'apSignalToNoiseRatio_absolute', template => '%d', label_extra_instance => 1, instance_use => 'bssid_absolute' }, ], } From 8bc02e668baee84a4150755e4cb8ca8b91b52683 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 19 Nov 2015 11:42:10 +0100 Subject: [PATCH 65/68] + Enhance bladecenter to check pureflex (WIP) --- .../snmp/mode/components/ambient.pm | 31 +++++-- .../bladecenter/snmp/mode/components/blade.pm | 2 +- .../snmp/mode/components/chassisfan.pm | 86 ++++++++++++++++++ .../snmp/mode/components/chassisstatus.pm | 2 +- .../snmp/mode/components/fanpack.pm | 91 +++++++++++++++++++ .../snmp/mode/components/powermodule.pm | 2 +- .../snmp/mode/components/switchmodule.pm | 70 ++++++++++++++ .../snmp/mode/components/systemhealth.pm | 2 +- .../ibm/bladecenter/snmp/mode/hardware.pm | 31 +++++-- .../server/ibm/bladecenter/snmp/plugin.pm | 2 +- 10 files changed, 300 insertions(+), 19 deletions(-) create mode 100644 hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm create mode 100644 hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm create mode 100644 hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm index d30d61822..6725026a0 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm @@ -23,18 +23,26 @@ package hardware::server::ibm::bladecenter::snmp::mode::components::ambient; use strict; use warnings; -# In MIB 'mmblade.mib' + my $oid_temperature = '.1.3.6.1.4.1.2.3.51.2.2.1'; +my $oid_end = '.1.3.6.1.4.1.2.3.51.2.2.1.5'; +my $oid_rearLEDCardTempMax = '.1.3.6.1.4.1.2.3.51.2.2.1.5.3.0'; +# In MIB 'mmblade.mib' and 'cme.mib' my $oids = { - mm => '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0', - frontpanel => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0', - frontpanel2 => '.1.3.6.1.4.1.2.3.51.2.2.1.5.2.0', + bladecenter => { + mm => '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0', + frontpanel => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0', + frontpanel2 => '.1.3.6.1.4.1.2.3.51.2.2.1.5.2.0', + }, + pureflex => { + ambient => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0', # rearLEDCardTempAvg + } }; sub load { my (%options) = @_; - push @{$options{request}}, { oid => $oid_temperature }; + push @{$options{request}}, { oid => $oid_temperature, end => $oid_end }; } sub check { @@ -44,9 +52,16 @@ sub check { $self->{components}->{ambient} = {name => 'ambient', total => 0, skip => 0}; return if ($self->check_exclude(section => 'ambient')); - foreach my $temp (('mm', 'frontpanel', 'frontpanel2')) { - if (!defined($self->{results}->{$oid_temperature}->{$oids->{$temp}}) || - $self->{results}->{$oid_temperature}->{$oids->{$temp}} !~ /([0-9\.]+)/) { + my @sensors = ('mm', 'frontpanel', 'frontpanel2'); + my $label = 'bladecenter'; + if (defined()) { + @sensors = ('ambient'); + $label = 'pureflex'; + } + + foreach my $temp (@values) { + if (!defined($self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}}) || + $self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}} !~ /([0-9\.]+)/) { $self->{output}->output_add(long_msg => sprintf("skip ambient '%s': no values", $temp)); next; diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm index ee0b5e5c6..db7fc2399 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm @@ -48,7 +48,7 @@ my %map_blade_power_state = ( 4 => 'hibernate', ); -# In MIB 'CPQSTDEQ-MIB.mib' +# In MIB 'mmblade.mib' and 'cme.mib' my $mapping = { bladeId => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2' }, bladeExists => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3', map => \%map_blade_exists }, diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm new file mode 100644 index 000000000..c92ddd188 --- /dev/null +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm @@ -0,0 +1,86 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::ibm::bladecenter::snmp::mode::components::chassisfan; + +use strict; +use warnings; + +my %map_state = ( + 0 => 'unknown', + 1 => 'good', + 2 => 'warning', + 3 => 'bad', +); + +# In MIB 'mmblade.mib' and 'cme.mib' +my $mapping = { + chassisFanState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.3.50.1.4', map => \%map_state }, + chassisFanSpeedRPM => { oid => '.1.3.6.1.4.1.2.3.51.2.2.3.50.1.5' }, +}; +my $oid_chassisFansEntry = '.1.3.6.1.4.1.2.3.51.2.2.3.50.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_chassisFansEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking chassis fan"); + $self->{components}->{chassisfan} = {name => 'chassis fan', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'chassisfan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_chassisFansEntry}})) { + next if ($oid !~ /^$mapping->{chassisFanState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_chassisFansEntry}, instance => $instance); + + next if ($self->check_exclude(section => 'chassisfan', instance => $instance)); + $self->{components}->{chassisfan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Chassis fan '%s' is %d rpm [status: %s, instance: %s]", + $instance, $result->{fanPackAverageSpeedRPM}, $result->{chassisFanState}, + $instance)); + my $exit = $self->get_severity(section => 'chassisfan', value => $result->{chassisFanState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Chassis fan '%s' status is %s", + $instance, $result->{chassisFanState})); + } + + if (defined($result->{chassisFanSpeedRPM}) && $result->{chassisFanSpeedRPM} =~ /[0-9]/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassisfan', instance => $instance, value => $result->{chassisFanSpeedRPM}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Chassis fan '%s' speed is %s rpm", $instance, $result->{chassisFanSpeedRPM})); + } + $self->{output}->perfdata_add(label => "chassisfan_" . $instance, unit => 'rpm', + value => $result->{chassisFanSpeedRPM}, + warning => $warn, + critical => $crit, + min => 0); + } + } +} + +1; \ No newline at end of file diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm index 3a2537aae..db8b4a56a 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm @@ -23,7 +23,7 @@ package hardware::server::ibm::bladecenter::snmp::mode::components::chassisstatu use strict; use warnings; -# In MIB 'mmblade.mib' +# In MIB 'mmblade.mib' and 'cme.mib' my $oid_mmBistAndChassisStatus = '.1.3.6.1.4.1.2.3.51.2.2.5.2'; my $oid_bistLogicalNetworkLink = '.1.3.6.1.4.1.2.3.51.2.2.5.2.30.0'; my $oids = { diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm new file mode 100644 index 000000000..6f6b075ff --- /dev/null +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm @@ -0,0 +1,91 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::ibm::bladecenter::snmp::mode::components::fanpack; + +use strict; +use warnings; + +my %map_state = ( + 0 => 'unknown', + 1 => 'good', + 2 => 'warning', + 3 => 'bad', +); + +# In MIB 'mmblade.mib' and 'cme.mib' +my $mapping = { + fanPackExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.2' }, + fanPackState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.3', map => \%map_state }, + fanPackAverageSpeedRPM => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.6' }, +}; +my $oid_fanPackEntry = '.1.3.6.1.4.1.2.3.51.2.2.6.1.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_fanPackEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fanpack"); + $self->{components}->{fanpack} = {name => 'fanpacks', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'fanpack')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanPackEntry}})) { + next if ($oid !~ /^$mapping->{fanPackState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanPackEntry}, instance => $instance); + + if ($result->{fanPackExists} == 1) { + $self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits"); + next; + } + next if ($self->check_exclude(section => 'fanpack', instance => $instance)); + $self->{components}->{fanpack}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %d rpm [status: %s, instance: %s]", + $instance, $result->{fanPackAverageSpeedRPM}, $result->{fanPackState}, + $instance)); + my $exit = $self->get_severity(section => 'fanpack', value => $result->{fanPackState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fanpack '%s' status is %s", + $instance, $result->{fanPackState})); + } + + if (defined($result->{fanPackAverageSpeedRPM}) && $result->{fanPackAverageSpeedRPM} =~ /[0-9]/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fanpack', instance => $instance, value => $result->{fanPackAverageSpeedRPM}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Fanpack '%s' speed is %s rpm", $instance, $result->{fanPackAverageSpeedRPM})); + } + $self->{output}->perfdata_add(label => "fanpack_" . $instance, unit => 'rpm', + value => $result->{fanPackAverageSpeedRPM}, + warning => $warn, + critical => $crit, + min => 0); + } + } +} + +1; \ No newline at end of file diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm index 577608191..dd4fd6135 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm @@ -35,7 +35,7 @@ my %map_pw_exists = ( 1 => 'true', ); -# In MIB 'CPQSTDEQ-MIB.mib' +# In MIB 'mmblade.mib' and 'cme.mib' my $mapping = { powerModuleExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.2', map => \%map_pw_exists }, powerModuleState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3', map => \%map_pw_state }, diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm new file mode 100644 index 000000000..d48dac789 --- /dev/null +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm @@ -0,0 +1,70 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::server::ibm::bladecenter::snmp::mode::components::switchmodule; + +use strict; +use warnings; + +my %map_state = ( + 0 => 'unknown', + 1 => 'good', + 2 => 'warning', + 3 => 'bad', +); + +# In MIB 'mmblade.mib' and 'cme.mib' +my $mapping = { + smHealthState => { oid => '.1.3.6.1.4.1.2.3.51.2.22.3.1.1.1.15', map => \%map_state }, +}; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $mapping->{smHealthState}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking switch module"); + $self->{components}->{switchmodule} = {name => 'switch modules', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'switchmodule')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{smHealthState}->{oid}}})) { + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{smHealthState}->{oid}}, instance => $instance); + + next if ($self->check_exclude(section => 'switchmodule', instance => $instance)); + $self->{components}->{switchmodule}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Switch module '%s' status is %s [instance: %s]", + $instance, $result->{smHealthState}, + $instance)); + my $exit = $self->get_severity(section => 'switchmodule', value => $result->{smHealthState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Switch module '%s' status is %s", + $instance, $result->{smHealthState})); + } + } +} + +1; \ No newline at end of file diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm index 88097db74..4f4958292 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm @@ -23,7 +23,7 @@ package hardware::server::ibm::bladecenter::snmp::mode::components::systemhealth use strict; use warnings; -# In MIB 'mmblade.mib' +# In MIB 'mmblade.mib' and 'cme.mib' my $oid_systemHealthStat = '.1.3.6.1.4.1.2.3.51.2.2.7.1'; my %map_systemhealth_state = ( diff --git a/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm b/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm index 8faa14976..1d939c6e7 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm @@ -42,12 +42,30 @@ my $thresholds = { ['warning', 'WARNING'], ['notAvailable', 'UNKNOWN'], ], - blower => [ + fanpack => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], + chassisfan => [ ['unknown', 'UNKNOWN'], ['good', 'OK'], ['warning', 'WARNING'], ['bad', 'CRITICAL'], ], + blower => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], + switchmodule => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['bad', 'CRITICAL'], + ], blowerctrl => [ ['unknown', 'UNKNOWN'], ['operational', 'OK'], @@ -132,8 +150,8 @@ sub check_options { $self->{output}->option_exit(); } my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(blower|ambient)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: blower or ambient)."); + if ($section !~ /(blower|ambient|fanpack|chassisfan)/) { + $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: blower, fanpack, chassisfan or ambient)."); $self->{output}->option_exit(); } my $position = 0; @@ -156,7 +174,7 @@ sub run { $self->{snmp} = $options{snmp}; my $snmp_request = []; - my @components = ('ambient', 'powermodule', 'blade', 'blower', 'systemhealth', 'chassisstatus'); + my @components = ('ambient', 'powermodule', 'blade', 'blower', 'fanpack', 'chassisfan', 'systemhealth', 'chassisstatus', 'switchmodule'); foreach (@components) { if (/$self->{option_results}->{component}/) { my $mod_name = "hardware::server::ibm::bladecenter::snmp::mode::components::$_"; @@ -289,14 +307,15 @@ __END__ =head1 MODE -Check Hardware (Ambient temperatures, Blowers, Power modules, Blades, System Health, Chassis status). +Check Hardware (Ambient temperatures, Blowers, Power modules, Blades, System Health, Chassis status, Fanpack). =over 8 =item B<--component> Which component to check (Default: 'all'). -Can be: 'ambient', 'powermodule', 'blower', 'blade', 'systemhealth', 'chassisstatus'. +Can be: 'ambient', 'powermodule', 'fanpack', 'chassisfan', +'blower', 'blade', 'systemhealth', 'chassisstatus', 'switchmodule'. =item B<--exclude> diff --git a/hardware/server/ibm/bladecenter/snmp/plugin.pm b/hardware/server/ibm/bladecenter/snmp/plugin.pm index 324ec3c75..0842efad6 100644 --- a/hardware/server/ibm/bladecenter/snmp/plugin.pm +++ b/hardware/server/ibm/bladecenter/snmp/plugin.pm @@ -44,6 +44,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check IBM Chassis BladeCenter (H, HT, T) in SNMP. +Check IBM Chassis BladeCenter (H, HT, T, Pureflex) in SNMP. =cut From d21cfb3e3c5db2d4c76ef16371094721be166233 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 19 Nov 2015 14:20:58 +0100 Subject: [PATCH 66/68] + Correct bladecenter IBM --- .../ibm/bladecenter/snmp/mode/components/ambient.pm | 2 +- .../ibm/bladecenter/snmp/mode/components/blade.pm | 6 ++++-- .../ibm/bladecenter/snmp/mode/components/chassisfan.pm | 4 ++-- .../ibm/bladecenter/snmp/mode/components/fanpack.pm | 10 +++++++--- .../bladecenter/snmp/mode/components/switchmodule.pm | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm index 6725026a0..5c2970d7c 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm @@ -59,7 +59,7 @@ sub check { $label = 'pureflex'; } - foreach my $temp (@values) { + foreach my $temp (@sensors) { if (!defined($self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}}) || $self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}} !~ /([0-9\.]+)/) { $self->{output}->output_add(long_msg => sprintf("skip ambient '%s': no values", diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm index db7fc2399..29ab7b611 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm @@ -77,8 +77,10 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeSystemStatusEntry}, instance => $instance); next if ($self->check_exclude(section => 'blade', instance => $result->{bladeId})); - next if ($result->{bladeExists} =~ /No/i && - $self->absent_problem(section => 'blade', instance => $result->{bladeId})); + if ($result->{bladeExists} =~ /No/i) { + $self->{output}->output_add(long_msg => "skipping blade '" . $instance . "' : not exits"); + next; + } $self->{components}->{blade}->{total}++; if ($result->{bladePowerState} =~ /off/) { diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm index c92ddd188..a3c90d7a2 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm @@ -58,8 +58,8 @@ sub check { next if ($self->check_exclude(section => 'chassisfan', instance => $instance)); $self->{components}->{chassisfan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Chassis fan '%s' is %d rpm [status: %s, instance: %s]", - $instance, $result->{fanPackAverageSpeedRPM}, $result->{chassisFanState}, + $self->{output}->output_add(long_msg => sprintf("Chassis fan '%s' is %s rpm [status: %s, instance: %s]", + $instance, $result->{chassisFanSpeedRPM}, $result->{chassisFanState}, $instance)); my $exit = $self->get_severity(section => 'chassisfan', value => $result->{chassisFanState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm index 6f6b075ff..79605c75a 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm @@ -29,10 +29,14 @@ my %map_state = ( 2 => 'warning', 3 => 'bad', ); +my %map_exists = ( + 0 => 'false', + 1 => 'true', +); # In MIB 'mmblade.mib' and 'cme.mib' my $mapping = { - fanPackExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.2' }, + fanPackExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.2', map => \%map_exists }, fanPackState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.3', map => \%map_state }, fanPackAverageSpeedRPM => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.6' }, }; @@ -56,14 +60,14 @@ sub check { my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanPackEntry}, instance => $instance); - if ($result->{fanPackExists} == 1) { + if ($result->{fanPackExists} =~ /No/i) { $self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits"); next; } next if ($self->check_exclude(section => 'fanpack', instance => $instance)); $self->{components}->{fanpack}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %d rpm [status: %s, instance: %s]", + $self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %s rpm [status: %s, instance: %s]", $instance, $result->{fanPackAverageSpeedRPM}, $result->{fanPackState}, $instance)); my $exit = $self->get_severity(section => 'fanpack', value => $result->{fanPackState}); diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm index d48dac789..3d6c6b3f2 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm @@ -49,6 +49,7 @@ sub check { return if ($self->check_exclude(section => 'switchmodule')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{smHealthState}->{oid}}})) { + $oid =~ /^$mapping->{smHealthState}->{oid}\.(.*)/; my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{smHealthState}->{oid}}, instance => $instance); From df0710715fc4d2f210af83b69fe192e40687cd16 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 19 Nov 2015 14:25:14 +0100 Subject: [PATCH 67/68] + Correct bladecenter IBM --- hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm | 2 +- hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm index 29ab7b611..2f020405a 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm @@ -77,7 +77,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeSystemStatusEntry}, instance => $instance); next if ($self->check_exclude(section => 'blade', instance => $result->{bladeId})); - if ($result->{bladeExists} =~ /No/i) { + if ($result->{bladeExists} =~ /false/i) { $self->{output}->output_add(long_msg => "skipping blade '" . $instance . "' : not exits"); next; } diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm index 79605c75a..918cd655a 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm @@ -60,7 +60,7 @@ sub check { my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanPackEntry}, instance => $instance); - if ($result->{fanPackExists} =~ /No/i) { + if ($result->{fanPackExists} =~ /false/i) { $self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits"); next; } From eecc69a63fb3e295792a7f04dc9abacb19732bc7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 19 Nov 2015 14:29:04 +0100 Subject: [PATCH 68/68] + Fixed ibm bladecenter plugin --- hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm index 5c2970d7c..eabf896d3 100644 --- a/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm +++ b/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm @@ -54,7 +54,7 @@ sub check { my @sensors = ('mm', 'frontpanel', 'frontpanel2'); my $label = 'bladecenter'; - if (defined()) { + if (defined($self->{results}->{$oid_temperature}->{$oid_rearLEDCardTempMax})) { @sensors = ('ambient'); $label = 'pureflex'; }