diff --git a/centreon-plugins/README.md b/centreon-plugins/README.md index f9ca13ec2..f52fb7712 100644 --- a/centreon-plugins/README.md +++ b/centreon-plugins/README.md @@ -27,7 +27,7 @@ It seems that 'os::linux::snmp::plugin' is the good one. So i verify with the op Plugin Description: Check Linux operating systems in SNMP. -It's exactly what i need. Now i'll the option ``--list-mode`` to know what can i do with it: +It's exactly what i need. Now i'll add the option ``--list-mode`` to know what can i do with it: $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --list-mode ... diff --git a/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm b/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm index 284d7ea30..cf747ac3c 100644 --- a/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm +++ b/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/activedirectory/local/mode/netdom.pm b/centreon-plugins/apps/activedirectory/local/mode/netdom.pm index 07b5a48ab..5059eefd4 100644 --- a/centreon-plugins/apps/activedirectory/local/mode/netdom.pm +++ b/centreon-plugins/apps/activedirectory/local/mode/netdom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/activedirectory/local/plugin.pm b/centreon-plugins/apps/activedirectory/local/plugin.pm index 25c230928..b78e18018 100644 --- a/centreon-plugins/apps/activedirectory/local/plugin.pm +++ b/centreon-plugins/apps/activedirectory/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/activedirectory/wsman/mode/dcdiag.pm b/centreon-plugins/apps/activedirectory/wsman/mode/dcdiag.pm index 0c5cd43fd..3996d4fbc 100644 --- a/centreon-plugins/apps/activedirectory/wsman/mode/dcdiag.pm +++ b/centreon-plugins/apps/activedirectory/wsman/mode/dcdiag.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/activedirectory/wsman/plugin.pm b/centreon-plugins/apps/activedirectory/wsman/plugin.pm index f02336cf6..a04c98062 100644 --- a/centreon-plugins/apps/activedirectory/wsman/plugin.pm +++ b/centreon-plugins/apps/activedirectory/wsman/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/apache/serverstatus/mode/cpuload.pm b/centreon-plugins/apps/apache/serverstatus/mode/cpuload.pm index c17664b50..df0a4f44d 100644 --- a/centreon-plugins/apps/apache/serverstatus/mode/cpuload.pm +++ b/centreon-plugins/apps/apache/serverstatus/mode/cpuload.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apache/serverstatus/mode/requests.pm b/centreon-plugins/apps/apache/serverstatus/mode/requests.pm index b167b4d30..8ab2a2928 100644 --- a/centreon-plugins/apps/apache/serverstatus/mode/requests.pm +++ b/centreon-plugins/apps/apache/serverstatus/mode/requests.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apache/serverstatus/mode/responsetime.pm b/centreon-plugins/apps/apache/serverstatus/mode/responsetime.pm index 1cd608c45..72e44c706 100644 --- a/centreon-plugins/apps/apache/serverstatus/mode/responsetime.pm +++ b/centreon-plugins/apps/apache/serverstatus/mode/responsetime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm b/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm index 6e1cfa38c..6caa7a169 100644 --- a/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm +++ b/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -360,14 +360,14 @@ Threshold for HTTP timeout Threshold unit (Default: '%'. Can be: '%' or 'absolute') -=item B<--warning> +=item B<--warning-*> Warning threshold. Can be: 'busy', 'free', 'waiting', 'starting', 'reading', 'sending', 'keepalive', 'dns-lookup', 'closing', 'logging', 'gracefuly-finished', 'idle-cleanup-worker'. -=item B<--critical> +=item B<--critical-*> Critical threshold. Can be: 'busy', 'free', 'waiting', 'starting', 'reading', diff --git a/centreon-plugins/apps/apache/serverstatus/mode/workers.pm b/centreon-plugins/apps/apache/serverstatus/mode/workers.pm index 37e97675e..92625bd30 100644 --- a/centreon-plugins/apps/apache/serverstatus/mode/workers.pm +++ b/centreon-plugins/apps/apache/serverstatus/mode/workers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apache/serverstatus/plugin.pm b/centreon-plugins/apps/apache/serverstatus/plugin.pm index 76be02374..620407bf4 100644 --- a/centreon-plugins/apps/apache/serverstatus/plugin.pm +++ b/centreon-plugins/apps/apache/serverstatus/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/apcupsd/local/mode/batterycharge.pm b/centreon-plugins/apps/apcupsd/local/mode/batterycharge.pm index 00604eff7..dc191ad87 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/batterycharge.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/batterycharge.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/batteryvoltage.pm b/centreon-plugins/apps/apcupsd/local/mode/batteryvoltage.pm index d43d99244..fe6afc5cc 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/batteryvoltage.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/batteryvoltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/libgetdata.pm b/centreon-plugins/apps/apcupsd/local/mode/libgetdata.pm index 2bd300877..a3710515f 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/libgetdata.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/libgetdata.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -41,7 +41,7 @@ sub getdata { my ($value); #print $stdout; foreach (split(/\n/, $stdout)) { - if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal)/i) { + if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C Internal|F Internal|C|F)/i) { $valueok = "1"; $value = $1; #print $value; diff --git a/centreon-plugins/apps/apcupsd/local/mode/linefrequency.pm b/centreon-plugins/apps/apcupsd/local/mode/linefrequency.pm index 18e2ddcbd..e3d961a43 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/linefrequency.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/linefrequency.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/linevoltage.pm b/centreon-plugins/apps/apcupsd/local/mode/linevoltage.pm index 5c414cd1d..08fb59a4e 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/linevoltage.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/linevoltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/loadpercentage.pm b/centreon-plugins/apps/apcupsd/local/mode/loadpercentage.pm index 74081b806..c278ea011 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/loadpercentage.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/loadpercentage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/outputvoltage.pm b/centreon-plugins/apps/apcupsd/local/mode/outputvoltage.pm index b22a1622e..5ec59e5b6 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/outputvoltage.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/outputvoltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/temperature.pm b/centreon-plugins/apps/apcupsd/local/mode/temperature.pm index c591fe8c1..11aa4e54f 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/temperature.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/mode/timeleft.pm b/centreon-plugins/apps/apcupsd/local/mode/timeleft.pm index 97945f7ed..39789d43d 100644 --- a/centreon-plugins/apps/apcupsd/local/mode/timeleft.pm +++ b/centreon-plugins/apps/apcupsd/local/mode/timeleft.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/apcupsd/local/plugin.pm b/centreon-plugins/apps/apcupsd/local/plugin.pm index 920c68b42..a653bd346 100644 --- a/centreon-plugins/apps/apcupsd/local/plugin.pm +++ b/centreon-plugins/apps/apcupsd/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -82,7 +82,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/backup/netbackup/local/mode/dedupstatus.pm b/centreon-plugins/apps/backup/netbackup/local/mode/dedupstatus.pm new file mode 100644 index 000000000..3baa279e6 --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/mode/dedupstatus.pm @@ -0,0 +1,267 @@ +# +# Copyright 2016 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::backup::netbackup::local::mode::dedupstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg = 'status : ' . $self->{result_values}->{status}; + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'pool', type => 1, cb_prefix_output => 'prefix_pool_output', message_multiple => 'All dedup status are ok' } + ]; + + $self->{maps_counters}->{pool} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + { label => 'usage', set => { + key_values => [ { name => 'usage' }, { name => 'display' } ], + output_template => 'Use: %s %%', + perfdatas => [ + { label => 'used', value => 'usage_absolute', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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 => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'nbdevquery' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-listdv -U -stype PureDisk' }, + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_pool_output { + my ($self, %options) = @_; + + return "Disk pool name '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->{pool} = {}; + #Disk Pool Name : NBU-MASTER-DP + #Disk Type : PureDisk + #Disk Volume Name : PureDiskVolume + #Disk Media ID : @aaaah + #Total Capacity (GB) : 9777.56 + #Free Space (GB) : 837.72 + #Use% : 91 + #Status : UP + #Flag : ReadOnWrite + #Flag : AdminUp + #Flag : InternalUp + while ($stdout =~ /^(Disk Pool Name.*?)(?=Disk Pool Name|\z)/msig) { + my $pool = $1; + + my ($display, $usage, $status); + $display = centreon::plugins::misc::trim($1) if ($pool =~ /^Disk Pool Name\s*:\s*(.*?)\n/msi); + $status = $1 if ($pool =~ /^Status\s*:\s*(.*?)\n/msi); + $usage = $1 if ($pool =~ /^Use%\s*:\s*(.*?)\n/msi); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $display !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1); + next; + } + + $self->{pool}->{$display} = { display => $display, usage => $usage, status => $status }; + } + + if (scalar(keys %{$self->{pool}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No pool found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check deduplication status. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'nbdevquery'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-listdv -U -stype PureDisk'). + +=item B<--filter-name> + +Filter pool name (can be a regexp). + +=item B<--warning-usage> + +Set warning threshold in percent. + +=item B<--critical-usage> + +Set critical threshold in percent. + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{display}, %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} !~ /up/i'). +Can used special variables like: %{display}, %{status} + +=back + +=cut diff --git a/centreon-plugins/apps/backup/netbackup/local/mode/drivecleaning.pm b/centreon-plugins/apps/backup/netbackup/local/mode/drivecleaning.pm new file mode 100644 index 000000000..22422bbfa --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/mode/drivecleaning.pm @@ -0,0 +1,179 @@ +# +# Copyright 2016 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::backup::netbackup::local::mode::drivecleaning; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'drive', type => 0 } + ]; + + $self->{maps_counters}->{drive} = [ + { label => 'cleaning', set => { + key_values => [ { name => 'num_cleaning' }, { name => 'total' } ], + output_template => '%d drives needs a reset mount time', + perfdatas => [ + { label => 'cleaning', value => 'num_cleaning_absolute', template => '%s', + min => 0, max => 'total_absolute' }, + ], + } + }, + ]; +} + +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 => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'tpconfig' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-l' }, + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->{drive} = { total => 0, num_cleaning => 0 }; + #Drive Name Type Mount Time Frequency Last Cleaned Comment + #********** **** ********** ********* **************** ******* + #IBM.ULT3580-HH5.000 hcart2* 18.3 96 05:29 21/12/2015 + #IBM.ULT3580-HH5.002 hcart2* 36.8 0 11:10 20/12/2015 + my @lines = split /\n/, $stdout; + splice(@lines, 0, 2); + foreach my $line (@lines) { + $line =~ /^(\S+)/; + my $name = $1; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + $self->{output}->output_add(long_msg => "drive '" . $name . "' checked.", debug => 1); + + $self->{drive}->{total}++; + if ($line =~ /NEEDS CLEANING/i) { + $self->{drive}->{num_cleaning}++; + } + } + + if (scalar(keys %{$self->{drive}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No drives found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check drive cleaning. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'tpconfig'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-l'). + +=item B<--filter-name> + +Filter drive name (can be a regexp). + +=item B<--warning-*> + +Threshold warning. +Can be: 'cleaning'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'cleaning'. + +=back + +=cut diff --git a/centreon-plugins/apps/backup/netbackup/local/mode/drivestatus.pm b/centreon-plugins/apps/backup/netbackup/local/mode/drivestatus.pm new file mode 100644 index 000000000..423420ff3 --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/mode/drivestatus.pm @@ -0,0 +1,239 @@ +# +# Copyright 2016 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::backup::netbackup::local::mode::drivestatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg = 'status : ' . $self->{result_values}->{status}; + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'drive', type => 1, cb_prefix_output => 'prefix_drive_output', message_multiple => 'All drive status are ok' } + ]; + + $self->{maps_counters}->{drive} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +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 => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'tpconfig' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-l' }, + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_drive_output { + my ($self, %options) = @_; + + return "Drive '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->{drive} = {}; + #robot 0 - TLD - - - - {3,0,0,1} + # drive - 0 hcart2 2 UP - IBM.ULT3580-HH5.000 {3,0,1,0} + # drive - 2 hcart2 1 UP - IBM.ULT3580-HH5.002 {3,0,0,0} + while ($stdout =~ /^robot\s+(\d+)(.*?)(?=robot\s+\d+|\z)/msig) { + my ($robot_num, $drives) = ($1, $2); + while ($drives =~ /drive\s+\S+\s+(\d+)\s+\S+\s+\S+\s+(\S+)/msig) { + my $name = $robot_num . '.' . $1; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + $self->{drive}->{$name} = { display => $name, status => $2 }; + } + } + + if (scalar(keys %{$self->{drive}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No drives found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check drive status. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'tpconfig'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-l'). + +=item B<--filter-name> + +Filter drive name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{display}, %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} !~ /up/i'). +Can used special variables like: %{display}, %{status} + +=back + +=cut diff --git a/centreon-plugins/apps/backup/netbackup/local/mode/jobstatus.pm b/centreon-plugins/apps/backup/netbackup/local/mode/jobstatus.pm new file mode 100644 index 000000000..0a1bee52f --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/mode/jobstatus.pm @@ -0,0 +1,437 @@ +# +# Copyright 2016 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::backup::netbackup::local::mode::jobstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + # To exclude some OK + if (defined($instance_mode->{option_results}->{ok_status}) && $instance_mode->{option_results}->{ok_status} ne '' && + eval "$instance_mode->{option_results}->{ok_status}") { + $status = 'ok'; + } elsif (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg = 'status : ' . $self->{result_values}->{status}; + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + return 0; +} + +sub custom_long_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_long}) && $instance_mode->{option_results}->{critical_long} ne '' && + eval "$instance_mode->{option_results}->{critical_long}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_long}) && $instance_mode->{option_results}->{warning_long} ne '' && + eval "$instance_mode->{option_results}->{warning_long}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_long_output { + my ($self, %options) = @_; + my $msg = 'started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed}); + + return $msg; +} + +sub custom_long_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{elapsed} = $options{new_datas}->{$self->{instance} . '_elapsed'}; + $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + + return -11 if ($self->{result_values}->{state} !~ /queued|active/); + + return 0; +} + +my $last_status_frozen; + +sub custom_frozen_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_frozen}) && $instance_mode->{option_results}->{critical_frozen} ne '' && + eval "$instance_mode->{option_results}->{critical_frozen}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_frozen}) && $instance_mode->{option_results}->{warning_frozen} ne '' && + eval "$instance_mode->{option_results}->{warning_frozen}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + $last_status_frozen = $status; + return $status; +} + +sub custom_frozen_output { + my ($self, %options) = @_; + my $msg = 'frozen : no'; + + if (!$self->{output}->is_status(value => $last_status_frozen, compare => 'ok', litteral => 1)) { + $msg = 'frozen: yes'; + } + return $msg; +} + +sub custom_frozen_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{elapsed} = $options{new_datas}->{$self->{instance} . '_elapsed'}; + $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{kb} = $options{new_datas}->{$self->{instance} . '_kb'} - $options{old_datas}->{$self->{instance} . '_kb'}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'policy', type => 2, cb_prefix_output => 'prefix_policy_output', cb_long_output => 'policy_long_output', message_multiple => 'All policies are ok', + group => [ { name => 'job', cb_prefix_output => 'prefix_job_output', skipped_code => { -11 => 1 } } ] + } + ]; + + $self->{maps_counters}->{job} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' }, { name => 'type' }, { name => 'state' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'long', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' }, { name => 'elapsed' }, { name => 'type' }, { name => 'state' } ], + closure_custom_calc => $self->can('custom_long_calc'), + closure_custom_output => $self->can('custom_long_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_long_threshold'), + } + }, + { label => 'frozen', threshold => 0, set => { + key_values => [ { name => 'kb', diff => 1 }, { name => 'status' }, { name => 'display' }, { name => 'elapsed' }, { name => 'type' }, { name => 'state' } ], + closure_custom_calc => $self->can('custom_frozen_calc'), + closure_custom_output => $self->can('custom_frozen_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_frozen_threshold'), + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'bpdbjobs' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-report -most_columns' }, + "filter-policy-name:s" => { name => 'filter_policy_name' }, + "filter-end-time:s" => { name => 'filter_end_time', default => 86400 }, + "ok-status:s" => { name => 'ok_status', default => '%{status} == 0' }, + "warning-status:s" => { name => 'warning_status', default => '%{status} == 1' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} > 1' }, + "warning-long:s" => { name => 'warning_long' }, + "critical-long:s" => { name => 'critical_long' }, + "warning-frozen:s" => { name => 'warning_frozen' }, + "critical-frozen:s" => { name => 'critical_frozen', default => '%{state} =~ /active|queue/ && %{kb} == 0' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub policy_long_output { + my ($self, %options) = @_; + + return "checking policy '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_policy_output { + my ($self, %options) = @_; + + return "policy '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_job_output { + my ($self, %options) = @_; + + return "job '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('ok_status', 'warning_status', 'critical_status', 'warning_long', 'critical_long', 'warning_frozen', 'critical_frozen')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %job_type = ( + 0 => 'backup', 1 => 'archive', 2 => 'restore', 3 => 'verify', 4 => 'duplicate', 5 => 'phase 1 or phase 2 import', + 6 => 'catalog backup', 7 => 'vault duplicate', 8 => 'label tape', 9 => 'erase tape', + 10 => 'tape request', 11 => 'clean tape', 12 => 'format tape', 13 => 'physical inventory of robotic library', + 14 => 'qualification test of drive or robotic library', 15 => 'catalog recovery', 16 => 'media contents', + 17 => 'image cleanup', 18 => 'LiveUpdate', 20 => 'Replication (Auto Image Replication)', 21 => 'Import (Auto Image Replication)', + 22 => 'backup From Snapshot', 23 => 'Replication (snap)', 24 => 'Import (snap)', 25 => 'application state capture', + 26 => 'indexing', 27 => 'index cleanup', 28 => 'Snapshot', + 29 => 'SnapIndex', 30 => 'ActivateInstantRecovery', 31 => 'DeactivateInstantRecovery', + 32 => 'ReactivateInstantRecovery', 33 => 'StopInstantRecovery', 34 => 'InstantRecovery', +); + +my %job_state = ( + 0 => 'queued and awaiting resources', + 1 => 'active', + 2 => 'requeued and awaiting resources', + 3 => 'done', 4 => 'suspended', 5 => 'incomplete', +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "netbackup_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{sudo} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->{policy} = {}; + my $current_time = time(); + foreach my $line (split /\n/, $stdout) { + my @values = split /,/, $line; + my ($job_id, $job_type, $job_state, $job_status, $job_pname, $job_start_time, $job_end_time, $job_kb) = + ($values[0], $values[1], $values[2], $values[3], $values[4], $values[8], $values[10], $values[14]); + + $job_pname = defined($job_pname) && $job_pname ne '' ? $job_pname : 'unknown'; + $job_status = defined($job_status) && $job_status =~ /[0-9]/ ? $job_status : undef; + if (defined($self->{option_results}->{filter_policy_name}) && $self->{option_results}->{filter_policy_name} ne '' && + $job_pname !~ /$self->{option_results}->{filter_policy_name}/) { + $self->{output}->output_add(long_msg => "skipping job '" . $job_pname . "/" . $job_id . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_end_time}) && $self->{option_results}->{filter_end_time} =~ /[0-9]+/ && + defined($job_end_time) && $job_end_time =~ /[0-9]+/ && $job_end_time < $current_time - $self->{option_results}->{filter_end_time}) { + $self->{output}->output_add(long_msg => "skipping job '" . $job_pname . "/" . $job_id . "': too old.", debug => 1); + next; + } + + $self->{policy}->{$job_pname} = { job => {}, display => $job_pname } if (!defined($self->{policy}->{$job_pname})); + my $elapsed_time = $current_time - $job_start_time; + $self->{policy}->{$job_pname}->{job}->{$job_id} = { display => $job_id, elapsed => $elapsed_time, + status => $job_status, state => $job_state{$job_state}, type => $job_type{$job_type}, + kb => defined($job_kb) && $job_kb =~ /[0-9]+/ ? $job_kb : undef }; + } + + if (scalar(keys %{$self->{policy}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No job found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check job status. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'bpdbjobs'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-report -most_columns'). + +=item B<--filter-policy-name> + +Filter job policy name (can be a regexp). + +=item B<--filter-end-time> + +Filter job with end time greater than current time less value in seconds (Default: 86400). + +=item B<--ok-status> + +Set ok threshold for status (Default: '%{status} == 0') +Can used special variables like: %{display}, %{status} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} == 1') +Can used special variables like: %{display}, %{status}, %{type} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} > 1'). +Can used special variables like: %{display}, %{status}, %{type} + +=item B<--warning-long> + +Set warning threshold for long jobs (Default: none) +Can used special variables like: %{display}, %{status}, %{elapsed}, %{type} + +=item B<--critical-long> + +Set critical threshold for long jobs (Default: none). +Can used special variables like: %{display}, %{status}, %{elapsed}, %{type} + +=item B<--warning-frozen> + +Set warning threshold for frozen jobs (Default: none) +Can used special variables like: %{display}, %{status}, %{elapsed}, %{type}, %{kb} + +=item B<--critical-frozen> + +Set critical threshold for frozen jobs (Default: '%{state} =~ /active|queue/ && %{kb} == 0'). +Can used special variables like: %{display}, %{status}, %{elapsed}, %{type}, %{kb} + +=back + +=cut diff --git a/centreon-plugins/apps/backup/netbackup/local/mode/listpolicies.pm b/centreon-plugins/apps/backup/netbackup/local/mode/listpolicies.pm new file mode 100644 index 000000000..b27e48404 --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/mode/listpolicies.pm @@ -0,0 +1,189 @@ +# +# Copyright 2016 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::backup::netbackup::local::mode::listpolicies; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +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 => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'bppllist' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '' }, + "command2:s" => { name => 'command2', default => 'bpplinfo %{policy_name} -L' }, + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + + foreach (sort keys %{$self->{policies}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_ !~ /$self->{option_results}->{filter_name}/i) { + $self->{output}->output_add(long_msg => "skipping policy '" . $_ . "': no type or no matching filter type"); + next; + } + + $self->{output}->output_add(long_msg => "'" . $_ . "' [active = " . $self->{policies}->{$_}->{active} . "]"); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List policy:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'active']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (sort keys %{$self->{policies}}) { + next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_ !~ /$self->{option_results}->{filter_name}/i); + + $self->{output}->add_disco_entry(name => $_, + active => $self->{policies}->{$_}->{active} + ); + } +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->{policies} = {}; + my @lines = split /\n/, $stdout; + foreach my $policy_name (@lines) { + my $command2 = $self->{option_results}->{command2}; + $command2 =~ s/%{policy_name}/$policy_name/g; + my ($stdout2) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $command2); + + #Policy Type: NBU-Catalog (35) + #Active: yes + my $active = ''; + $active = $1 if ($stdout2 =~ /^Active\s*:\s+(\S+)/msi); + $self->{policies}->{$policy_name} = { active => $active }; + } +} + +1; + +__END__ + +=head1 MODE + +List policies. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'bppllist'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: none). + +=item B<--command2> + +Command to get active policy information (Default: 'bpplinfo %{policy_name} -L'). +Can be changed if you have output in a file. + +=item B<--filter-name> + +Filter policy name (can be a regexp). + +=back + +=cut diff --git a/centreon-plugins/apps/backup/netbackup/local/mode/tapeusage.pm b/centreon-plugins/apps/backup/netbackup/local/mode/tapeusage.pm new file mode 100644 index 000000000..90c8da675 --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/mode/tapeusage.pm @@ -0,0 +1,256 @@ +# +# Copyright 2016 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::backup::netbackup::local::mode::tapeusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; + +my $instance_mode; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = 'used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'free'; + $value_perf = $self->{result_values}->{free}; + } + + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label, + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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 $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $self->{result_values}->{total}, + $self->{result_values}->{used}, $self->{result_values}->{prct_used}, + $self->{result_values}->{free}, $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} . '_used'}; + + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'usage', set => { + key_values => [ { 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 new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'vmquery' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-a -w' }, + "filter-scratch:s" => { name => 'filter_scratch', default => 'scratch' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->{global} = { total => 0, used => 0 }; + #media optical media barcode robot robot robot robot side/ volume prev # of max # of create assigned first mount last mount expiration off sent off return off off + #ID partner type barcode partner host type # slot face group pool pool # pool mounts mounts cleanings datetime datetime datetime datetime datetime status offsite location datetime datetime slot ses id version description + #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + #000001 - HCART2 000001L5 - - NONE - - - --- VP-05WEEKS-EXT 9 VP-SCRATCH 1250 0 - 30/11/2012 15:30 29/02/2016 20:43 27/01/2013 17:57 02/03/2016 01:36 00/00/0000 00:00 0 - 00/00/0000 00:00 00/00/0000 00:00 - - 50 --- + #000002 - HCART2 000002L5 - XXX-NBU-XXX TLD 0 8 - 000_00000_TLD VP-SCRATCH 4 VP-05WEEKS-EXT + + # Remove header + $stdout =~ s/\x00//msg; + $stdout =~ s/^.*?----.*?\n//ms; + foreach my $line (split /\n/, $stdout) { + $line =~ /^\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)/; + my ($robot_host, $robot_slot, $pool) = ($1, $2, $3); + + next if ($robot_slot !~ /[0-9]/); + + $self->{global}->{total}++; + if (defined($self->{option_results}->{filter_scratch}) && $self->{option_results}->{filter_scratch} ne '' && + $pool !~ /$self->{option_results}->{filter_scratch}/i) { + $self->{global}->{used}++; + } + } + + if ($self->{global}->{total} == 0) { + $self->{output}->add_option_msg(short_msg => "No tape found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check tapes available in library. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'vmquery'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-a -w'). + +=item B<--filter-scratch> + +Filter tape scratch (Default: 'scratch'). + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'absolute'). + +=item B<--free> + +Thresholds are on free tape left. + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage'. + +=back + +=cut diff --git a/centreon-plugins/apps/backup/netbackup/local/plugin.pm b/centreon-plugins/apps/backup/netbackup/local/plugin.pm new file mode 100644 index 000000000..3c575df15 --- /dev/null +++ b/centreon-plugins/apps/backup/netbackup/local/plugin.pm @@ -0,0 +1,53 @@ +# +# Copyright 2016 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::backup::netbackup::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'dedup-status' => 'apps::backup::netbackup::local::mode::dedupstatus', + 'drive-cleaning' => 'apps::backup::netbackup::local::mode::drivecleaning', + 'drive-status' => 'apps::backup::netbackup::local::mode::drivestatus', + 'job-status' => 'apps::backup::netbackup::local::mode::jobstatus', + 'list-policies' => 'apps::backup::netbackup::local::mode::listpolicies', + 'tape-usage' => 'apps::backup::netbackup::local::mode::tapeusage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Netbackup through local commands (the plugin can use SSH). + +=cut diff --git a/centreon-plugins/apps/biztalk/sql/mode/rlocationdisabled.pm b/centreon-plugins/apps/biztalk/sql/mode/rlocationdisabled.pm index 12d10e16a..657cd1710 100644 --- a/centreon-plugins/apps/biztalk/sql/mode/rlocationdisabled.pm +++ b/centreon-plugins/apps/biztalk/sql/mode/rlocationdisabled.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/bluemind/mode/incoming.pm b/centreon-plugins/apps/bluemind/mode/incoming.pm index 3e2c4de35..2ff258003 100644 --- a/centreon-plugins/apps/bluemind/mode/incoming.pm +++ b/centreon-plugins/apps/bluemind/mode/incoming.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/bluemind/plugin.pm b/centreon-plugins/apps/bluemind/plugin.pm index 1f6b2a843..c9c0bee69 100644 --- a/centreon-plugins/apps/bluemind/plugin.pm +++ b/centreon-plugins/apps/bluemind/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/centreon/local/mode/metaservice.pm b/centreon-plugins/apps/centreon/local/mode/metaservice.pm index f2b9ab8d9..d67614351 100644 --- a/centreon-plugins/apps/centreon/local/mode/metaservice.pm +++ b/centreon-plugins/apps/centreon/local/mode/metaservice.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/local/mode/retentionbroker.pm b/centreon-plugins/apps/centreon/local/mode/retentionbroker.pm index b8afd3a22..a5efc7640 100644 --- a/centreon-plugins/apps/centreon/local/mode/retentionbroker.pm +++ b/centreon-plugins/apps/centreon/local/mode/retentionbroker.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/local/plugin.pm b/centreon-plugins/apps/centreon/local/plugin.pm index e1de66801..e9b02e138 100644 --- a/centreon-plugins/apps/centreon/local/plugin.pm +++ b/centreon-plugins/apps/centreon/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/eventqueue.pm b/centreon-plugins/apps/centreon/map/jmx/mode/eventqueue.pm index 9cd6a8e00..cea2649df 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/eventqueue.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/eventqueue.pm @@ -1,4 +1,4 @@ -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/eventstatistics.pm b/centreon-plugins/apps/centreon/map/jmx/mode/eventstatistics.pm index 494fb186d..b1b9b2a40 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/eventstatistics.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/eventstatistics.pm @@ -1,4 +1,4 @@ -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm b/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm index 27d855c15..62bef8224 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm @@ -1,4 +1,4 @@ -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{connector} = $options{custom}; $self->{request} = [ diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/sessions.pm b/centreon-plugins/apps/centreon/map/jmx/mode/sessions.pm index 443bde899..f0ae02058 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/sessions.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/sessions.pm @@ -1,4 +1,4 @@ -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{connector} = $options{custom}; $self->{request} = [ diff --git a/centreon-plugins/apps/centreon/map/jmx/plugin.pm b/centreon-plugins/apps/centreon/map/jmx/plugin.pm index 2fb2c9626..6320d3f82 100644 --- a/centreon-plugins/apps/centreon/map/jmx/plugin.pm +++ b/centreon-plugins/apps/centreon/map/jmx/plugin.pm @@ -1,4 +1,4 @@ -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -27,7 +27,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/centreon/sql/mode/countnotifications.pm b/centreon-plugins/apps/centreon/sql/mode/countnotifications.pm index e3faf7f31..11cdb2757 100644 --- a/centreon-plugins/apps/centreon/sql/mode/countnotifications.pm +++ b/centreon-plugins/apps/centreon/sql/mode/countnotifications.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/sql/mode/countproblems.pm b/centreon-plugins/apps/centreon/sql/mode/countproblems.pm index 8a58ee593..4ecedb339 100644 --- a/centreon-plugins/apps/centreon/sql/mode/countproblems.pm +++ b/centreon-plugins/apps/centreon/sql/mode/countproblems.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/sql/mode/countservices.pm b/centreon-plugins/apps/centreon/sql/mode/countservices.pm new file mode 100644 index 000000000..4e79c53e6 --- /dev/null +++ b/centreon-plugins/apps/centreon/sql/mode/countservices.pm @@ -0,0 +1,139 @@ +# +# Copyright 2016 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::centreon::sql::mode::countservices; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'poller', type => 1, cb_prefix_output => 'prefix_poller_output', message_multiple => 'All poller hosts/services are ok' } + ]; + + $self->{maps_counters}->{poller} = [ + { label => 'host', set => { + key_values => [ { name => 'hosts' }, { name => 'display' } ], + output_template => 'Number of hosts : %s', + perfdatas => [ + { label => 'total_hosts', value => 'hosts_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'service', set => { + key_values => [ { name => 'services' }, { name => 'display' } ], + output_template => 'Number of services : %s', + perfdatas => [ + { label => 'total_services', value => 'services_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + ]; +} + +sub prefix_poller_output { + my ($self, %options) = @_; + + return "Poller '" . $options{instance_value}->{display} . "' "; +} + +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-poller:s" => { name => 'filter_poller' }, + "centreon-storage-database:s" => { name => 'centreon_storage_database', default => 'centreon_storage' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query = "SELECT instances.name, COUNT(DISTINCT hosts.host_id) as num_hosts, count(DISTINCT services.host_id, services.service_id) as num_services + FROM " . $self->{option_results}->{centreon_storage_database} . ".instances, " . $self->{option_results}->{centreon_storage_database} . ".hosts, " . $self->{option_results}->{centreon_storage_database} . ".services WHERE instances.running = '1' AND instances.instance_id = hosts.instance_id AND hosts.enabled = '1' AND hosts.host_id = services.host_id AND services.enabled = '1' GROUP BY hosts.instance_id"; + $options{sql}->connect(); + $options{sql}->query(query => $query); + + # check by poller + $self->{poller} = {}; + while ((my $row = $options{sql}->fetchrow_hashref())) { + if (defined($self->{option_results}->{filter_poller}) && $self->{option_results}->{filter_poller} ne '' && + $row->{name} !~ /$self->{option_results}->{filter_poller}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $row->{name} . "': no matching filter.", debug => 1); + next; + } + + $self->{poller}->{$row->{name}} = { display => $row->{name}, hosts => $row->{num_hosts}, services => $row->{num_services} }; + } + + if (scalar(keys %{$self->{poller}}) == 0) { + $self->{output}->add_option_msg(short_msg => "No poller found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check the number of hosts/services by poller. + +=over 8 + +=item B<--centreon-storage-database> + +Centreon storage database name (default: 'centreon_storage'). + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^services$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'host', 'service'. + +=item B<--critical-*> + +Threshold critical. +Can be: Can be: 'host', 'service'. + +=item B<--filter-poller> + +Filter by poller name (regexp can be used). + +=back + +=cut diff --git a/centreon-plugins/apps/centreon/sql/mode/partitioning.pm b/centreon-plugins/apps/centreon/sql/mode/partitioning.pm index 2eeabf0eb..fdc02a942 100644 --- a/centreon-plugins/apps/centreon/sql/mode/partitioning.pm +++ b/centreon-plugins/apps/centreon/sql/mode/partitioning.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm b/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm index 38652eb44..4429d4a99 100644 --- a/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm +++ b/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/checkmyws/mode/status.pm b/centreon-plugins/apps/checkmyws/mode/status.pm index 81b1aa75d..e6de45cc0 100644 --- a/centreon-plugins/apps/checkmyws/mode/status.pm +++ b/centreon-plugins/apps/checkmyws/mode/status.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/checkmyws/plugin.pm b/centreon-plugins/apps/checkmyws/plugin.pm index 41a5e0fc4..ba1b77a53 100644 --- a/centreon-plugins/apps/checkmyws/plugin.pm +++ b/centreon-plugins/apps/checkmyws/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '1.0'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/citrix/local/mode/folder.pm b/centreon-plugins/apps/citrix/local/mode/folder.pm index fa9efb418..7d9c486cb 100644 --- a/centreon-plugins/apps/citrix/local/mode/folder.pm +++ b/centreon-plugins/apps/citrix/local/mode/folder.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/citrix/local/mode/license.pm b/centreon-plugins/apps/citrix/local/mode/license.pm index ec5653f4a..09586dfb3 100644 --- a/centreon-plugins/apps/citrix/local/mode/license.pm +++ b/centreon-plugins/apps/citrix/local/mode/license.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/citrix/local/mode/session.pm b/centreon-plugins/apps/citrix/local/mode/session.pm index e0348f6ba..18eb512e6 100644 --- a/centreon-plugins/apps/citrix/local/mode/session.pm +++ b/centreon-plugins/apps/citrix/local/mode/session.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/citrix/local/mode/zone.pm b/centreon-plugins/apps/citrix/local/mode/zone.pm index e7f5c10c4..9c5c608d4 100644 --- a/centreon-plugins/apps/citrix/local/mode/zone.pm +++ b/centreon-plugins/apps/citrix/local/mode/zone.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/citrix/local/plugin.pm b/centreon-plugins/apps/citrix/local/plugin.pm index 044724cc2..bcb1ea708 100644 --- a/centreon-plugins/apps/citrix/local/plugin.pm +++ b/centreon-plugins/apps/citrix/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/cluster/mscs/local/mode/listnodes.pm b/centreon-plugins/apps/cluster/mscs/local/mode/listnodes.pm new file mode 100644 index 000000000..28ab65f79 --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/mode/listnodes.pm @@ -0,0 +1,128 @@ +# +# Copyright 2016 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::cluster::mscs::local::mode::listnodes; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Win32::OLE; + +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' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my %map_state = ( + -1 => 'unknown', + 0 => 'up', + 1 => 'down', + 2 => 'paused', + 3 => 'joining', +); + +sub manage_selection { + my ($self, %options) = @_; + + # winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\mscluster + my $wmi = Win32::OLE->GetObject('winmgmts:root\mscluster'); + if (!defined($wmi)) { + $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); + $self->{output}->option_exit(); + } + + $self->{nodes} = {}; + my $query = "Select * from MSCluster_Node"; + my $resultset = $wmi->ExecQuery($query); + foreach my $obj (in $resultset) { + my $name = $obj->{Name}; + my $state = $map_state{$obj->{State}}; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{nodes}->{$name} = { name => $name, state => $state }; + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(); + foreach my $name (sort keys %{$self->{nodes}}) { + $self->{output}->output_add(long_msg => "'" . $name . "' [state = " . $self->{nodes}->{$name}->{state} . "]"); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List Nodes:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'state']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(disco => 1); + foreach my $name (sort keys %{$self->{nodes}}) { + $self->{output}->add_disco_entry(name => $name, state => $self->{nodes}->{$name}->{state}); + } +} + +1; + +__END__ + +=head1 MODE + +List nodes. + +=over 8 + +=item B<--filter-name> + +Filter node name (can be a regexp). + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/apps/cluster/mscs/local/mode/listresources.pm b/centreon-plugins/apps/cluster/mscs/local/mode/listresources.pm new file mode 100644 index 000000000..47ad9e578 --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/mode/listresources.pm @@ -0,0 +1,150 @@ +# +# Copyright 2016 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::cluster::mscs::local::mode::listresources; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Win32::OLE; + +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' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my %map_state = ( + -1 => 'unknown', + 0 => 'inherited', + 1 => 'initializing', + 2 => 'online', + 3 => 'offline', + 4 => 'failed', + 128 => 'pending', + 129 => 'online pending', + 130 => 'offline pending', +); + +my %map_class = ( + 0 => 'unknown', + 1 => 'storage', + 2 => 'network', + 32768 => 'user', +); + +sub manage_selection { + my ($self, %options) = @_; + + # winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\mscluster + my $wmi = Win32::OLE->GetObject('winmgmts:root\mscluster'); + if (!defined($wmi)) { + $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); + $self->{output}->option_exit(); + } + + $self->{resources} = {}; + my $query = "Select * from MSCluster_Resource"; + my $resultset = $wmi->ExecQuery($query); + foreach my $obj (in $resultset) { + my $name = $obj->{Name}; + my $state = $map_state{$obj->{State}}; + my $class = defined($obj->{ResourceClass}) ? $map_class{$obj->{ResourceClass}} : '-'; + my $id = defined($obj->{Id}) ? $obj->{Id} : $name; + my $owner_node = defined($obj->{OwnerNode}) ? $obj->{OwnerNode} : '-'; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{resources}->{$id} = { name => $name, state => $state, owner_node => $owner_node, + class => $class }; + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(); + foreach my $id (sort keys %{$self->{resources}}) { + $self->{output}->output_add(long_msg => "'" . $self->{resources}->{$id}->{name} . + "' [state = " . $self->{resources}->{$id}->{state} . "]" . + "[owner node = " . $self->{resources}->{$id}->{owner_node} . "]" . + "[class = " . $self->{resources}->{$id}->{class} . "]"); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List Resources:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'state', 'id', 'owner_node', 'class']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(disco => 1); + foreach my $id (sort keys %{$self->{resources}}) { + $self->{output}->add_disco_entry(name => $self->{resources}->{$id}->{name}, + state => $self->{resources}->{$id}->{state}, + id => $id, + owner_node => $self->{resources}->{$id}->{owner_node}, + class => $self->{resources}->{$id}->{class}); + } +} + +1; + +__END__ + +=head1 MODE + +List resources. + +=over 8 + +=item B<--filter-name> + +Filter resource name (can be a regexp). + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/apps/cluster/mscs/local/mode/networkstatus.pm b/centreon-plugins/apps/cluster/mscs/local/mode/networkstatus.pm new file mode 100644 index 000000000..b3a6c907a --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/mode/networkstatus.pm @@ -0,0 +1,200 @@ +# +# Copyright 2016 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::cluster::mscs::local::mode::networkstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Win32::OLE; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'network', type => 1, cb_prefix_output => 'prefix_network_output', message_multiple => 'All networks are ok' } + ]; + + $self->{maps_counters}->{network} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'state : ' . $self->{result_values}->{state}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub prefix_network_output { + my ($self, %options) = @_; + + return "Network '" . $options{instance_value}->{display} . "' "; +} + +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' }, + "unknown-status:s" => { name => 'unknown_status', default => '%{state} =~ /unknown/' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} =~ /down|paritioned|unavailable/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + -1 => 'unknown', + 0 => 'unavailable', + 1 => 'down', + 2 => 'paritioned', + 3 => 'up', +); + +sub manage_selection { + my ($self, %options) = @_; + + # winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\mscluster + my $wmi = Win32::OLE->GetObject('winmgmts:root\mscluster'); + if (!defined($wmi)) { + $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); + $self->{output}->option_exit(); + } + + $self->{network} = {}; + my $query = "Select * from MSCluster_Network"; + my $resultset = $wmi->ExecQuery($query); + foreach my $obj (in $resultset) { + my $name = $obj->{Name}; + my $state = $map_state{$obj->{State}}; + my $id = defined($obj->{ID}) ? $obj->{ID} : $name; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{network}->{$id} = { display => $name, state => $state }; + } +} + +1; + +__END__ + +=head1 MODE + +Check network status. + +=over 8 + +=item B<--filter-name> + +Filter interface name (can be a regexp). + +=item B<--unknown-status> + +Set warning threshold for status (Default: '%{state} =~ /unknown/'). +Can used special variables like: %{state}, %{display} + +=item B<--warning-status> + +Set warning threshold for status (Default: none). +Can used special variables like: %{state}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} =~ /down|paritioned|unavailable/'). +Can used special variables like: %{state}, %{display} + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/apps/cluster/mscs/local/mode/nodestatus.pm b/centreon-plugins/apps/cluster/mscs/local/mode/nodestatus.pm new file mode 100644 index 000000000..89d28337b --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/mode/nodestatus.pm @@ -0,0 +1,199 @@ +# +# Copyright 2016 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::cluster::mscs::local::mode::nodestatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Win32::OLE; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'node', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All nodes are ok' } + ]; + + $self->{maps_counters}->{node} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'state : ' . $self->{result_values}->{state}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub prefix_node_output { + my ($self, %options) = @_; + + return "Node '" . $options{instance_value}->{display} . "' "; +} + +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' }, + "unknown-status:s" => { name => 'unknown_status', default => '%{state} =~ /unknown/' }, + "warning-status:s" => { name => 'warning_status', default => '%{state} =~ /pause|joining/' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} =~ /down/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + -1 => 'unknown', + 0 => 'up', + 1 => 'down', + 2 => 'paused', + 3 => 'joining', +); + +sub manage_selection { + my ($self, %options) = @_; + + # winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\mscluster + my $wmi = Win32::OLE->GetObject('winmgmts:root\mscluster'); + if (!defined($wmi)) { + $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); + $self->{output}->option_exit(); + } + + $self->{node} = {}; + my $query = "Select * from MSCluster_Node"; + my $resultset = $wmi->ExecQuery($query); + foreach my $obj (in $resultset) { + my $name = $obj->{Name}; + my $state = $map_state{$obj->{State}}; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{node}->{$name} = { display => $name, state => $state }; + } +} + +1; + +__END__ + +=head1 MODE + +Check node status. + +=over 8 + +=item B<--filter-name> + +Filter node name (can be a regexp). + +=item B<--unknown-status> + +Set warning threshold for status (Default: '%{state} =~ /unknown/'). +Can used special variables like: %{state}, %{display} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{state} =~ /pause|joining/'). +Can used special variables like: %{state}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} =~ /down/'). +Can used special variables like: %{state}, %{display} + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/apps/cluster/mscs/local/mode/resourcegroupstatus.pm b/centreon-plugins/apps/cluster/mscs/local/mode/resourcegroupstatus.pm new file mode 100644 index 000000000..bdf277526 --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/mode/resourcegroupstatus.pm @@ -0,0 +1,244 @@ +# +# Copyright 2016 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::cluster::mscs::local::mode::resourcegroupstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Win32::OLE; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'rg', type => 1, cb_prefix_output => 'prefix_rg_output', message_multiple => 'All resource groups are ok' } + ]; + + $self->{maps_counters}->{rg} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' }, { name => 'owner_node' }, { name => 'preferred_owners' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +my $instance_mode; +my $instance_current; + +sub is_preferred_node { + if (!defined($instance_current->{result_values}->{preferred_owners}) || + scalar(@{$instance_current->{result_values}->{preferred_owners}}) == 0) { + return 1; + } + + foreach my $pref_node (@{$instance_current->{result_values}->{preferred_owners}}) { + if ($pref_node eq $instance_current->{result_values}->{owner_node}) { + return 1; + } + } + + return 0; +} + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + $instance_current = $self; + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $pref_nodes = 'any'; + if (defined($instance_current->{result_values}->{preferred_owners}) && + scalar(@{$instance_current->{result_values}->{preferred_owners}}) > 0) { + $pref_nodes = join(', ', @{$instance_current->{result_values}->{preferred_owners}}); + } + + my $msg = 'state : ' . $self->{result_values}->{state} . ' [node: ' . $self->{result_values}->{owner_node} . '] [preferred nodes: ' . $pref_nodes . ']'; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{owner_node} = $options{new_datas}->{$self->{instance} . '_owner_node'}; + $self->{result_values}->{preferred_owners} = $options{new_datas}->{$self->{instance} . '_preferred_owners'}; + return 0; +} + +sub prefix_rg_output { + my ($self, %options) = @_; + + return "Resource group '" . $options{instance_value}->{display} . "' "; +} + +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' }, + "unknown-status:s" => { name => 'unknown_status', default => '%{state} =~ /unknown/' }, + "warning-status:s" => { name => 'warning_status', default => 'not is_preferred_node()' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} =~ /failed|offline/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + -1 => 'unknown', + 0 => 'online', + 1 => 'offline', + 2 => 'failed', + 3 => 'partial online', + 4 => 'pending', +); + +sub manage_selection { + my ($self, %options) = @_; + + # winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\mscluster + my $wmi = Win32::OLE->GetObject('winmgmts:root\mscluster'); + if (!defined($wmi)) { + $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); + $self->{output}->option_exit(); + } + + my $query = "Select * from MSCluster_ResourceGroupToPreferredNode"; + my $resultset = $wmi->ExecQuery($query); + my $preferred_nodes = {}; + foreach my $obj (in $resultset) { + use Data::Dumper; + + # MSCluster_ResourceGroup.Name="xxx" + if ($obj->GroupComponent =~ /MSCluster_ResourceGroup.Name="(.*?)"/i) { + my $rg = $1; + next if ($obj->PartComponent !~ /MSCluster_Node.Name="(.*?)"/i); + my $node = $1; + $preferred_nodes->{$rg} = [] if (!defined($preferred_nodes->{$rg})); + push @{$preferred_nodes->{$rg}}, $node; + } + } + + $self->{rg} = {}; + $query = "Select * from MSCluster_ResourceGroup"; + $resultset = $wmi->ExecQuery($query); + foreach my $obj (in $resultset) { + my $name = $obj->{Name}; + my $state = $map_state{$obj->{State}}; + my $id = defined($obj->{Id}) ? $obj->{Id} : $name; + my $owner_node = defined($obj->{OwnerNode}) ? $obj->{OwnerNode} : '-'; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{rg}->{$id} = { display => $name, state => $state, owner_node => $owner_node, + preferred_owners => defined($preferred_nodes->{$name}) ? $preferred_nodes->{$name} : [] }; + } +} + +1; + +__END__ + +=head1 MODE + +Check resource group status. + +=over 8 + +=item B<--filter-name> + +Filter resource group name (can be a regexp). + +=item B<--unknown-status> + +Set warning threshold for status (Default: '%{state} =~ /unknown/'). +Can used special variables like: %{state}, %{display}, %{owner_node} + +=item B<--warning-status> + +Set warning threshold for status (Default: 'not is_preferred_node()'). +Can used special variables like: %{state}, %{display}, %{owner_node} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} =~ /failed|offline/'). +Can used special variables like: %{state}, %{display}, %{owner_node} + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/apps/cluster/mscs/local/mode/resourcestatus.pm b/centreon-plugins/apps/cluster/mscs/local/mode/resourcestatus.pm new file mode 100644 index 000000000..28ed41a42 --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/mode/resourcestatus.pm @@ -0,0 +1,206 @@ +# +# Copyright 2016 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::cluster::mscs::local::mode::resourcestatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Win32::OLE; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'resource', type => 1, cb_prefix_output => 'prefix_resource_output', message_multiple => 'All resources are ok' } + ]; + + $self->{maps_counters}->{resource} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' }, { name => 'owner_node' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'state : ' . $self->{result_values}->{state} . ' [node: ' . $self->{result_values}->{owner_node} . ']'; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{owner_node} = $options{new_datas}->{$self->{instance} . '_owner_node'}; + return 0; +} + +sub prefix_resource_output { + my ($self, %options) = @_; + + return "Resource '" . $options{instance_value}->{display} . "' "; +} + +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' }, + "unknown-status:s" => { name => 'unknown_status', default => '%{state} =~ /unknown/' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} =~ /failed|offline/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + -1 => 'unknown', + 0 => 'inherited', + 1 => 'initializing', + 2 => 'online', + 3 => 'offline', + 4 => 'failed', + 128 => 'pending', + 129 => 'online pending', + 130 => 'offline pending', +); + +sub manage_selection { + my ($self, %options) = @_; + + # winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\mscluster + my $wmi = Win32::OLE->GetObject('winmgmts:root\mscluster'); + if (!defined($wmi)) { + $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); + $self->{output}->option_exit(); + } + + $self->{resource} = {}; + my $query = "Select * from MSCluster_Resource"; + my $resultset = $wmi->ExecQuery($query); + foreach my $obj (in $resultset) { + my $name = $obj->{Name}; + my $state = $map_state{$obj->{State}}; + my $id = defined($obj->{Id}) ? $obj->{Id} : $name; + my $owner_node = defined($obj->{OwnerNode}) ? $obj->{OwnerNode} : '-'; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{resource}->{$id} = { display => $name, state => $state, owner_node => $owner_node }; + } +} + +1; + +__END__ + +=head1 MODE + +Check resource status. + +=over 8 + +=item B<--filter-name> + +Filter resource name (can be a regexp). + +=item B<--unknown-status> + +Set warning threshold for status (Default: '%{state} =~ /unknown/'). +Can used special variables like: %{state}, %{display} + +=item B<--warning-status> + +Set warning threshold for status (Default: none). +Can used special variables like: %{state}, %{display}, %{owner_node} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} =~ /failed|offline/'). +Can used special variables like: %{state}, %{display}, %{owner_node} + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/apps/cluster/mscs/local/plugin.pm b/centreon-plugins/apps/cluster/mscs/local/plugin.pm new file mode 100644 index 000000000..482d7d4c7 --- /dev/null +++ b/centreon-plugins/apps/cluster/mscs/local/plugin.pm @@ -0,0 +1,53 @@ +# +# Copyright 2016 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::cluster::mscs::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'list-nodes' => 'apps::cluster::mscs::local::mode::listnodes', + 'list-resources' => 'apps::cluster::mscs::local::mode::listresources', + 'network-status' => 'apps::cluster::mscs::local::mode::networkstatus', + 'node-status' => 'apps::cluster::mscs::local::mode::nodestatus', + 'resource-status' => 'apps::cluster::mscs::local::mode::resourcestatus', + 'resourcegroup-status' => 'apps::cluster::mscs::local::mode::resourcegroupstatus', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Microsoft Cluster Service. + +=cut diff --git a/centreon-plugins/apps/elasticsearch/mode/cluster.pm b/centreon-plugins/apps/elasticsearch/mode/cluster.pm index b11d9b85e..868be4134 100644 --- a/centreon-plugins/apps/elasticsearch/mode/cluster.pm +++ b/centreon-plugins/apps/elasticsearch/mode/cluster.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -65,12 +65,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); diff --git a/centreon-plugins/apps/elasticsearch/mode/indices.pm b/centreon-plugins/apps/elasticsearch/mode/indices.pm index 0d510a2a1..c805d8b6b 100644 --- a/centreon-plugins/apps/elasticsearch/mode/indices.pm +++ b/centreon-plugins/apps/elasticsearch/mode/indices.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -72,12 +72,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); diff --git a/centreon-plugins/apps/elasticsearch/mode/nodescount.pm b/centreon-plugins/apps/elasticsearch/mode/nodescount.pm index 1babb409a..c46eef4cd 100644 --- a/centreon-plugins/apps/elasticsearch/mode/nodescount.pm +++ b/centreon-plugins/apps/elasticsearch/mode/nodescount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/elasticsearch/plugin.pm b/centreon-plugins/apps/elasticsearch/plugin.pm index 24e90cda2..f071b4c2b 100644 --- a/centreon-plugins/apps/elasticsearch/plugin.pm +++ b/centreon-plugins/apps/elasticsearch/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/exchange/2010/local/mode/activesyncmailbox.pm b/centreon-plugins/apps/exchange/2010/local/mode/activesyncmailbox.pm index a74a6e40f..47c89fa6b 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/activesyncmailbox.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/activesyncmailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/databases.pm b/centreon-plugins/apps/exchange/2010/local/mode/databases.pm index 5e1f27bfc..bff0bc11a 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/databases.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/databases.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/imapmailbox.pm b/centreon-plugins/apps/exchange/2010/local/mode/imapmailbox.pm index e1e186cd5..18dd1cbd9 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/imapmailbox.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/imapmailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/listdatabases.pm b/centreon-plugins/apps/exchange/2010/local/mode/listdatabases.pm index 068e21094..90fb1dd7d 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/listdatabases.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/listdatabases.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/mapimailbox.pm b/centreon-plugins/apps/exchange/2010/local/mode/mapimailbox.pm index 1b8c93fc4..c78d1e640 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/mapimailbox.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/mapimailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/outlookwebservices.pm b/centreon-plugins/apps/exchange/2010/local/mode/outlookwebservices.pm index f8e558ef3..00feff54a 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/outlookwebservices.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/outlookwebservices.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/owamailbox.pm b/centreon-plugins/apps/exchange/2010/local/mode/owamailbox.pm index 98c027094..747e74663 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/owamailbox.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/owamailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/queues.pm b/centreon-plugins/apps/exchange/2010/local/mode/queues.pm index 8e9c88437..ca8f0af0d 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/queues.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/queues.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/replicationhealth.pm b/centreon-plugins/apps/exchange/2010/local/mode/replicationhealth.pm index c0533ca1b..546b4818c 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/replicationhealth.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/replicationhealth.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/mode/services.pm b/centreon-plugins/apps/exchange/2010/local/mode/services.pm index 6aa384657..a43d36741 100644 --- a/centreon-plugins/apps/exchange/2010/local/mode/services.pm +++ b/centreon-plugins/apps/exchange/2010/local/mode/services.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/exchange/2010/local/plugin.pm b/centreon-plugins/apps/exchange/2010/local/plugin.pm index 344967426..22a54fce9 100644 --- a/centreon-plugins/apps/exchange/2010/local/plugin.pm +++ b/centreon-plugins/apps/exchange/2010/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/github/mode/commits.pm b/centreon-plugins/apps/github/mode/commits.pm index 015db74ba..4972f0f81 100644 --- a/centreon-plugins/apps/github/mode/commits.pm +++ b/centreon-plugins/apps/github/mode/commits.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/github/mode/issues.pm b/centreon-plugins/apps/github/mode/issues.pm index f2c2f7f2f..0fffc26c5 100644 --- a/centreon-plugins/apps/github/mode/issues.pm +++ b/centreon-plugins/apps/github/mode/issues.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -74,7 +74,7 @@ sub check_options { $self->{output}->option_exit(); } - $self->{option_results}->{url_path} = "/search/issues?q=state:open+repo:" . $self->{option_results}->{owner} . "/" . $self->{option_results}->{repository}; + $self->{option_results}->{url_path} = "/search/issues?q=state:open+is:issue+repo:" . $self->{option_results}->{owner} . "/" . $self->{option_results}->{repository}; if (defined($self->{option_results}->{label}) && $self->{option_results}->{label} ne '') { $self->{option_results}->{url_path} .= "+label:" . $self->{option_results}->{label}; } diff --git a/centreon-plugins/apps/github/mode/pullrequests.pm b/centreon-plugins/apps/github/mode/pullrequests.pm index edfb7c1c1..c37033a55 100644 --- a/centreon-plugins/apps/github/mode/pullrequests.pm +++ b/centreon-plugins/apps/github/mode/pullrequests.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/github/mode/stats.pm b/centreon-plugins/apps/github/mode/stats.pm index 12a8fc354..071e362b6 100644 --- a/centreon-plugins/apps/github/mode/stats.pm +++ b/centreon-plugins/apps/github/mode/stats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -26,6 +26,7 @@ use strict; use warnings; use centreon::plugins::http; use JSON; +use Data::Dumper; sub new { my ($class, %options) = @_; @@ -79,8 +80,7 @@ sub run { }; if ($@) { - use Data::Dumper; - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); $self->{output}->output_add(long_msg => Data::Dumper::Dumper(), debug => 1); $self->{output}->option_exit(); } @@ -93,11 +93,14 @@ sub run { short_msg => sprintf("%d forks - %d watchers - %d stars", $forks, $watchers, $stars)); $self->{output}->perfdata_add(label => 'forks', - value => $forks); + value => $forks, + min => 0); $self->{output}->perfdata_add(label => 'watchers', - value => $watchers); + value => $watchers, + min => 0); $self->{output}->perfdata_add(label => 'stars', - value => $stars); + value => $stars, + min => 0); $self->{output}->display(); $self->{output}->exit(); @@ -143,6 +146,8 @@ Specify password =item B<--timeout> +Threshold for HTTP timeout (Default: 5) + =back =cut diff --git a/centreon-plugins/apps/github/mode/status.pm b/centreon-plugins/apps/github/mode/status.pm index 5058e80db..59cbd290a 100644 --- a/centreon-plugins/apps/github/mode/status.pm +++ b/centreon-plugins/apps/github/mode/status.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -65,12 +65,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ('status', $1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); diff --git a/centreon-plugins/apps/github/plugin.pm b/centreon-plugins/apps/github/plugin.pm index 748e1973d..cddc714f6 100644 --- a/centreon-plugins/apps/github/plugin.pm +++ b/centreon-plugins/apps/github/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/hddtemp/local/mode/temperature.pm b/centreon-plugins/apps/hddtemp/local/mode/temperature.pm index fc4a4d2db..fbfc2fd00 100644 --- a/centreon-plugins/apps/hddtemp/local/mode/temperature.pm +++ b/centreon-plugins/apps/hddtemp/local/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/hddtemp/local/plugin.pm b/centreon-plugins/apps/hddtemp/local/plugin.pm index f0033bc30..58778ed91 100644 --- a/centreon-plugins/apps/hddtemp/local/plugin.pm +++ b/centreon-plugins/apps/hddtemp/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/hddtemp/remote/mode/listdrives.pm b/centreon-plugins/apps/hddtemp/remote/mode/listdrives.pm index d79719787..1a9d1e85c 100644 --- a/centreon-plugins/apps/hddtemp/remote/mode/listdrives.pm +++ b/centreon-plugins/apps/hddtemp/remote/mode/listdrives.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/hddtemp/remote/mode/temperature.pm b/centreon-plugins/apps/hddtemp/remote/mode/temperature.pm index 4bcaa1771..e1cff58c0 100644 --- a/centreon-plugins/apps/hddtemp/remote/mode/temperature.pm +++ b/centreon-plugins/apps/hddtemp/remote/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/hddtemp/remote/plugin.pm b/centreon-plugins/apps/hddtemp/remote/plugin.pm index 2b9d910f7..6b7dd8c9b 100644 --- a/centreon-plugins/apps/hddtemp/remote/plugin.pm +++ b/centreon-plugins/apps/hddtemp/remote/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; -# $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/iis/local/mode/applicationpoolstate.pm b/centreon-plugins/apps/iis/local/mode/applicationpoolstate.pm index 5146997e1..1df35b22e 100644 --- a/centreon-plugins/apps/iis/local/mode/applicationpoolstate.pm +++ b/centreon-plugins/apps/iis/local/mode/applicationpoolstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/iis/local/mode/listapplicationpools.pm b/centreon-plugins/apps/iis/local/mode/listapplicationpools.pm index 337f32f04..5368a51d9 100644 --- a/centreon-plugins/apps/iis/local/mode/listapplicationpools.pm +++ b/centreon-plugins/apps/iis/local/mode/listapplicationpools.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/iis/local/mode/listsites.pm b/centreon-plugins/apps/iis/local/mode/listsites.pm index abca20404..608443a50 100644 --- a/centreon-plugins/apps/iis/local/mode/listsites.pm +++ b/centreon-plugins/apps/iis/local/mode/listsites.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/iis/local/mode/webservicestatistics.pm b/centreon-plugins/apps/iis/local/mode/webservicestatistics.pm index e89233c9a..d6eb6becf 100644 --- a/centreon-plugins/apps/iis/local/mode/webservicestatistics.pm +++ b/centreon-plugins/apps/iis/local/mode/webservicestatistics.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/iis/local/plugin.pm b/centreon-plugins/apps/iis/local/plugin.pm index f5ebf3adc..048aacc4f 100644 --- a/centreon-plugins/apps/iis/local/plugin.pm +++ b/centreon-plugins/apps/iis/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/iis/wsman/mode/applicationpoolstate.pm b/centreon-plugins/apps/iis/wsman/mode/applicationpoolstate.pm index 7f6e4d879..05285b39f 100644 --- a/centreon-plugins/apps/iis/wsman/mode/applicationpoolstate.pm +++ b/centreon-plugins/apps/iis/wsman/mode/applicationpoolstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/iis/wsman/mode/listapplicationpools.pm b/centreon-plugins/apps/iis/wsman/mode/listapplicationpools.pm index bc72aaee3..5ff2b5f3f 100644 --- a/centreon-plugins/apps/iis/wsman/mode/listapplicationpools.pm +++ b/centreon-plugins/apps/iis/wsman/mode/listapplicationpools.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/iis/wsman/plugin.pm b/centreon-plugins/apps/iis/wsman/plugin.pm index 83e1503b3..f0c9117ce 100644 --- a/centreon-plugins/apps/iis/wsman/plugin.pm +++ b/centreon-plugins/apps/iis/wsman/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/java/peoplesoft/jmx/mode/queuelength.pm b/centreon-plugins/apps/java/peoplesoft/jmx/mode/queuelength.pm index 60b78bd56..500fc2be9 100644 --- a/centreon-plugins/apps/java/peoplesoft/jmx/mode/queuelength.pm +++ b/centreon-plugins/apps/java/peoplesoft/jmx/mode/queuelength.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/java/peoplesoft/jmx/mode/sessions.pm b/centreon-plugins/apps/java/peoplesoft/jmx/mode/sessions.pm index 1c89017ea..cd49efdfc 100644 --- a/centreon-plugins/apps/java/peoplesoft/jmx/mode/sessions.pm +++ b/centreon-plugins/apps/java/peoplesoft/jmx/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm b/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm index c50d9807e..17a0a233d 100644 --- a/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm +++ b/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/java/weblogic/jmx/mode/workmanager.pm b/centreon-plugins/apps/java/weblogic/jmx/mode/workmanager.pm index 30bdbab45..5c06eca0c 100644 --- a/centreon-plugins/apps/java/weblogic/jmx/mode/workmanager.pm +++ b/centreon-plugins/apps/java/weblogic/jmx/mode/workmanager.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/java/weblogic/jmx/plugin.pm b/centreon-plugins/apps/java/weblogic/jmx/plugin.pm index 7c227b9f7..00219ca31 100644 --- a/centreon-plugins/apps/java/weblogic/jmx/plugin.pm +++ b/centreon-plugins/apps/java/weblogic/jmx/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/jenkins/mode/jobstate.pm b/centreon-plugins/apps/jenkins/mode/jobstate.pm index 34c80a98a..3db09d98c 100644 --- a/centreon-plugins/apps/jenkins/mode/jobstate.pm +++ b/centreon-plugins/apps/jenkins/mode/jobstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -157,6 +157,10 @@ Specify https if needed (Default: 'http') Set path to get Jenkins information +=item B <--credentials> + +Required to use username/password authentication method + =item B<--username> Specify username for API authentification diff --git a/centreon-plugins/apps/jenkins/plugin.pm b/centreon-plugins/apps/jenkins/plugin.pm index 38551eb2e..dbe2a6fd2 100644 --- a/centreon-plugins/apps/jenkins/plugin.pm +++ b/centreon-plugins/apps/jenkins/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/jive/sql/mode/etljobstatus.pm b/centreon-plugins/apps/jive/sql/mode/etljobstatus.pm index 6e234d595..a6c675b86 100644 --- a/centreon-plugins/apps/jive/sql/mode/etljobstatus.pm +++ b/centreon-plugins/apps/jive/sql/mode/etljobstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/api/mode/listdepartment.pm b/centreon-plugins/apps/kayako/api/mode/listdepartment.pm index 353e5df33..4c0a85664 100644 --- a/centreon-plugins/apps/kayako/api/mode/listdepartment.pm +++ b/centreon-plugins/apps/kayako/api/mode/listdepartment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/api/mode/listpriority.pm b/centreon-plugins/apps/kayako/api/mode/listpriority.pm index 2917a8848..76caff8d9 100644 --- a/centreon-plugins/apps/kayako/api/mode/listpriority.pm +++ b/centreon-plugins/apps/kayako/api/mode/listpriority.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/api/mode/liststaff.pm b/centreon-plugins/apps/kayako/api/mode/liststaff.pm index d28c6503b..1cedebfeb 100644 --- a/centreon-plugins/apps/kayako/api/mode/liststaff.pm +++ b/centreon-plugins/apps/kayako/api/mode/liststaff.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/api/mode/liststatus.pm b/centreon-plugins/apps/kayako/api/mode/liststatus.pm index 822e45aad..52ca12f78 100644 --- a/centreon-plugins/apps/kayako/api/mode/liststatus.pm +++ b/centreon-plugins/apps/kayako/api/mode/liststatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/api/mode/ticketcount.pm b/centreon-plugins/apps/kayako/api/mode/ticketcount.pm index 15ba28222..f8008d84a 100644 --- a/centreon-plugins/apps/kayako/api/mode/ticketcount.pm +++ b/centreon-plugins/apps/kayako/api/mode/ticketcount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/api/plugin.pm b/centreon-plugins/apps/kayako/api/plugin.pm index 9357c410d..65bb80983 100644 --- a/centreon-plugins/apps/kayako/api/plugin.pm +++ b/centreon-plugins/apps/kayako/api/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/kayako/sql/mode/listdepartment.pm b/centreon-plugins/apps/kayako/sql/mode/listdepartment.pm index b50c01cfe..b376bbb57 100644 --- a/centreon-plugins/apps/kayako/sql/mode/listdepartment.pm +++ b/centreon-plugins/apps/kayako/sql/mode/listdepartment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/sql/mode/listpriority.pm b/centreon-plugins/apps/kayako/sql/mode/listpriority.pm index 533d6763b..3ababda75 100644 --- a/centreon-plugins/apps/kayako/sql/mode/listpriority.pm +++ b/centreon-plugins/apps/kayako/sql/mode/listpriority.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/sql/mode/liststaff.pm b/centreon-plugins/apps/kayako/sql/mode/liststaff.pm index 90d7aa34e..91fe605a6 100644 --- a/centreon-plugins/apps/kayako/sql/mode/liststaff.pm +++ b/centreon-plugins/apps/kayako/sql/mode/liststaff.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/sql/mode/liststatus.pm b/centreon-plugins/apps/kayako/sql/mode/liststatus.pm index f30adab93..4a9377472 100644 --- a/centreon-plugins/apps/kayako/sql/mode/liststatus.pm +++ b/centreon-plugins/apps/kayako/sql/mode/liststatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/kayako/sql/mode/ticketcount.pm b/centreon-plugins/apps/kayako/sql/mode/ticketcount.pm index 567e1fdfd..c29f52c6b 100644 --- a/centreon-plugins/apps/kayako/sql/mode/ticketcount.pm +++ b/centreon-plugins/apps/kayako/sql/mode/ticketcount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/lmsensors/mode/fan.pm b/centreon-plugins/apps/lmsensors/mode/fan.pm index 44f7ca72c..cb6e0a3c0 100644 --- a/centreon-plugins/apps/lmsensors/mode/fan.pm +++ b/centreon-plugins/apps/lmsensors/mode/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,7 +66,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/apps/lmsensors/mode/misc.pm b/centreon-plugins/apps/lmsensors/mode/misc.pm index 0cf6f9379..7e7a663aa 100644 --- a/centreon-plugins/apps/lmsensors/mode/misc.pm +++ b/centreon-plugins/apps/lmsensors/mode/misc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,7 +66,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/apps/lmsensors/mode/temperature.pm b/centreon-plugins/apps/lmsensors/mode/temperature.pm index 84b9d57af..9151cc5d9 100644 --- a/centreon-plugins/apps/lmsensors/mode/temperature.pm +++ b/centreon-plugins/apps/lmsensors/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,7 +66,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/apps/lmsensors/mode/voltage.pm b/centreon-plugins/apps/lmsensors/mode/voltage.pm index 0c3479252..712426a81 100644 --- a/centreon-plugins/apps/lmsensors/mode/voltage.pm +++ b/centreon-plugins/apps/lmsensors/mode/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,7 +66,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/apps/lmsensors/plugin.pm b/centreon-plugins/apps/lmsensors/plugin.pm index 8044216aa..8ebc72276 100644 --- a/centreon-plugins/apps/lmsensors/plugin.pm +++ b/centreon-plugins/apps/lmsensors/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/lotus/snmp/mode/mailstate.pm b/centreon-plugins/apps/lotus/snmp/mode/mailstate.pm index f3493aa0c..e25d56445 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/mailstate.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/mailstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -67,7 +67,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_lnDeadMail = '.1.3.6.1.4.1.334.72.1.1.4.1.0'; diff --git a/centreon-plugins/apps/lotus/snmp/mode/mailtime.pm b/centreon-plugins/apps/lotus/snmp/mode/mailtime.pm index 8eaf78f97..b82900a8f 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/mailtime.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/mailtime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_lnAverageMailDeliverTime = '.1.3.6.1.4.1.334.72.1.1.4.9.0'; diff --git a/centreon-plugins/apps/lotus/snmp/mode/serveravailability.pm b/centreon-plugins/apps/lotus/snmp/mode/serveravailability.pm index 08927110a..9bd2f7d1c 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/serveravailability.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/serveravailability.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_lnServerAvailabilityIndex = '.1.3.6.1.4.1.334.72.1.1.6.3.19.0'; diff --git a/centreon-plugins/apps/lotus/snmp/mode/servertransactions.pm b/centreon-plugins/apps/lotus/snmp/mode/servertransactions.pm index 5af785422..3a49a9ffa 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/servertransactions.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/servertransactions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_lnServerTransPerMin = '.1.3.6.1.4.1.334.72.1.1.6.3.2.0'; diff --git a/centreon-plugins/apps/lotus/snmp/mode/usersessions.pm b/centreon-plugins/apps/lotus/snmp/mode/usersessions.pm index 81cbec9b7..c60449e60 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/usersessions.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/usersessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_lnServerUsers = '.1.3.6.1.4.1.334.72.1.1.6.3.6.0'; diff --git a/centreon-plugins/apps/lotus/snmp/plugin.pm b/centreon-plugins/apps/lotus/snmp/plugin.pm index 8d40ab21a..6def9b5d1 100644 --- a/centreon-plugins/apps/lotus/snmp/plugin.pm +++ b/centreon-plugins/apps/lotus/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/lync/2013/mssql/mode/appsharingqoe.pm b/centreon-plugins/apps/lync/2013/mssql/mode/appsharingqoe.pm new file mode 100644 index 000000000..87e15beea --- /dev/null +++ b/centreon-plugins/apps/lync/2013/mssql/mode/appsharingqoe.pm @@ -0,0 +1,134 @@ +# +# Copyright 2016 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::lync::2013::mssql::mode::appsharingqoe; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'spoiled_tile_prct_total_avg', type => 0 }, + { name => 'rdp_tile_processing_latency_avg', type => 0 }, + { name => 'relative_one_way_average', type => 0 }, + ]; + + $self->{maps_counters}->{spoiled_tile_prct_total_avg} = [ + { label => 'spoiled-tile-prct-total-avg', set => { + key_values => [ { name => 'value' } ], + output_template => 'SpoiledTilePercentTotal(Avg) : %.2f ms', + perfdatas => [ + { label => 'spoiled_tile_prct_total_avg', value => 'value_absolute', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + + $self->{maps_counters}->{rdp_tile_processing_latency_avg} = [ + { label => 'rdp-tile-processing-latency-avg', set => { + key_values => [ { name => 'value' } ], + output_template => 'RDPTileProcessingLatencyAverage : %.2f ms', + perfdatas => [ + { label => 'rdp_tile_processing_latency_avg', value => 'value_absolute', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{relative_one_way_average} = [ + { label => 'relative-one-way-average', set => { + key_values => [ { name => 'value' } ], + output_template => 'RelativeOneWayAverage : %.2f ms', + perfdatas => [ + { label => 'relative_one_way_average', value => 'value_absolute', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 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 => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{SELECT avg(SpoiledTilePercentTotal) + ,avg(RDPTileProcessingLatencyAverage) + ,avg(RelativeOneWayAverage) + FROM [QoEMetrics].[dbo].AppSharingStream}); + + my ($spoiled_tile_prct_total_avg, $rdp_tile_processing_latency_avg, $relative_one_way_average) = $self->{sql}->fetchrow_array(); + + $self->{spoiled_tile_prct_total_avg} = { value => $spoiled_tile_prct_total_avg }; + $self->{rdp_tile_processing_latency_avg} = { value => $rdp_tile_processing_latency_avg }; + $self->{relative_one_way_average} = { value => $relative_one_way_average }; + +} + +1; + +__END__ + +=head1 MODE + +Check AppSharing Qoe metrics from SQL Server Lync 2013 Database ([QoEMetrics].[dbo].AppSharingStream) + +MS Recommandations : + +SpoiledTilePercentTotal (Total percentage of the content that did not reach the viewer but was instead discarded and overwritten by fresh content) > 36 +RDPTileProcessingLatencyAverage (Average processing time for remote desktop protocol (RDP) tiles. A higher total equates to a longer delay in the viewing experience) > 400 +RelativeOneWayAverage (Average amount of one-way latency. Relative one-way latency measures the delay between the client and the server) > 1.75 + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'spoiled-tile-prct-total-avg', 'rdp-tile-processing-latency-avg', 'relative-one-way-average' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'spoiled-tile-prct-total-avg', 'rdp-tile-processing-latency-avg', 'relative-one-way-average' + +=back + +=cut diff --git a/centreon-plugins/apps/lync/2013/mssql/mode/audioqoe.pm b/centreon-plugins/apps/lync/2013/mssql/mode/audioqoe.pm new file mode 100644 index 000000000..2e8f9895b --- /dev/null +++ b/centreon-plugins/apps/lync/2013/mssql/mode/audioqoe.pm @@ -0,0 +1,172 @@ +# +# Copyright 2016 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::lync::2013::mssql::mode::audioqoe; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'jittermin', type => 0 }, + { name => 'jittermax', type => 0 }, + { name => 'jitteravg', type => 0 }, + { name => 'pcktlossmin', type => 0 }, + { name => 'pcktlossmax', type => 0 }, + { name => 'pcktlossavg', type => 0 }, + ]; + + $self->{maps_counters}->{jittermin} = [ + { label => 'jitter-min', set => { + key_values => [ { name => 'min' } ], + output_template => 'Jitter(Min) : %d ms', + perfdatas => [ + { label => 'jitter_min', value => 'min_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{jittermax} = [ + { label => 'jitter-max', set => { + key_values => [ { name => 'max' } ], + output_template => 'Jitter(Max) : %d ms', + perfdatas => [ + { label => 'jitter_max', value => 'max_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{jitteravg} = [ + { label => 'jitter-avg', set => { + key_values => [ { name => 'avg' } ], + output_template => 'Jitter(Avg) : %d ms', + perfdatas => [ + { label => 'jitter_avg', value => 'avg_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{pcktlossmin} = [ + { label => 'loss-min', set => { + key_values => [ { name => 'min' } ], + output_template => 'Packet-loss(Min) : %.2f%%', + perfdatas => [ + { label => 'pckt_loss_min', value => 'min_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{pcktlossmax} = [ + { label => 'loss-max', set => { + key_values => [ { name => 'max' } ], + output_template => 'Packet-loss(Max) : %.2f%%', + perfdatas => [ + { label => 'pckt_loss_max', value => 'max_absolute', template => '%.2f', + unit => '%', min => 0, max => 100 }, + ], + } + }, + ]; + $self->{maps_counters}->{pcktlossavg} = [ + { label => 'loss-avg', set => { + key_values => [ { name => 'avg' } ], + output_template => 'Packet-loss(Avg) : %.2f%%', + perfdatas => [ + { label => 'pckt_loss_avg', value => 'avg_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 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 => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{select min(cast(JitterInterArrival as bigint)) as JitterMin, + max(cast(JitterInterArrival as bigint)) as JitterMax, + avg(cast(JitterInterArrival as bigint)) as JitterAvg, + min(PacketLossRate) as PacketLossMin, + max(PacketLossRate) as PacketLossMax, + avg(PacketLossRate) as PacketLossRateAvg + from [QoEMetrics].[dbo].AudioStream + } + ); + + my ($jittermin, $jittermax, $jitteravg, $pcktlossmin, $pcktlossmax, $pcktlossavg) = $self->{sql}->fetchrow_array(); + + $self->{jittermin} = { min => $jittermin }; + $self->{jittermax} = { max => $jittermax }; + $self->{jitteravg} = { avg => $jitteravg }; + $self->{pcktlossmin} = { min => $pcktlossmin }; + $self->{pcktlossmax} = { max => $pcktlossmax }; + $self->{pcktlossavg} = { avg => $pcktlossavg }; + +} + +1; + +__END__ + +=head1 MODE + +Check audio metrics QoE from SQL Server Lync Database [QoEMetrics].[dbo].AudioStream + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'jitter-min', 'jitter-max', 'jitter-avg', 'loss-min', 'loss-max', 'loss-avg' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'jitter-min', 'jitter-max', 'jitter-avg', 'loss-min', 'loss-max', 'loss-avg' + +=back + +=cut diff --git a/centreon-plugins/apps/lync/2013/mssql/mode/lyncusers.pm b/centreon-plugins/apps/lync/2013/mssql/mode/lyncusers.pm new file mode 100644 index 000000000..9e04aaff5 --- /dev/null +++ b/centreon-plugins/apps/lync/2013/mssql/mode/lyncusers.pm @@ -0,0 +1,118 @@ +# +# Copyright 2016 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::lync::2013::mssql::mode::lyncusers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'User counts are OK' }, + ]; + + $self->{maps_counters}->{users} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => '%d Total users', + perfdatas => [ + { label => 'total_users', value => 'total_absolute', template => '%d', + unit => 'users', min => 0, label_extra_instance => 0 }, + ], + } + }, + { label => 'unique', set => { + key_values => [ { name => 'unique' } ], + output_template => '%d Unique users', + perfdatas => [ + { label => 'unique_users', value => 'unique_absolute', template => '%d', + unit => 'users', min => 0, label_extra_instance => 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 => + { + }); + return $self; +} + +sub prefix_user_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{Select count(*) as totalonline, + count(distinct UserAtHost) as totalunique + From rtcdyn.dbo.RegistrarEndpoint RE + Inner Join + rtc.dbo.Resource R on R.ResourceId = RE.OwnerId + Inner Join + rtcdyn.dbo.Registrar Reg on Reg.RegistrarId = RE.PrimaryRegistrarClusterId}); + + my ($total_online, $total_unique) = $self->{sql}->fetchrow_array(); + $self->{users}{total} = { total => $total_online, unique => $total_unique, display => 'Frontend' }; + +} + +1; + +__END__ + +=head1 MODE + +Check Lync Users Total and Unique. Query your RTCLocal Lync Frontend Dabatase (Get instance port in SQL Server configuration if dynamic mode) + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'total', 'unique' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'total', 'unique' + +=back + +=cut diff --git a/centreon-plugins/apps/lync/2013/mssql/mode/poorcalls.pm b/centreon-plugins/apps/lync/2013/mssql/mode/poorcalls.pm new file mode 100644 index 000000000..96d8a21bf --- /dev/null +++ b/centreon-plugins/apps/lync/2013/mssql/mode/poorcalls.pm @@ -0,0 +1,136 @@ +# +# Copyright 2016 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::lync::2013::mssql::mode::poorcalls; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'uri', type => 1, cb_prefix_output => 'prefix_uri_output', message_multiple => 'All users are ok' }, + + ]; + + $self->{maps_counters}->{global} = [ + { label => 'global', set => { + key_values => [ { name => 'count' } ], + output_template => '%d Poor calls', + perfdatas => [ + { label => 'poor_calls', value => 'count_absolute', template => '%d', + unit => 'calls', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{uri} = [ + { label => 'user', set => { + key_values => [ { name => 'count' }, { name => 'display' } ], + output_template => 'count : %d', + perfdatas => [ + { label => 'poor_calls', value => 'count_absolute', template => '%d', + unit => 'calls', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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 => + { + 'lookback:s' => { name => 'lookback', default => '65' }, + 'filter-user:s' => { name => 'filter_user' }, + }); + return $self; +} + +sub prefix_uri_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => "SELECT URI, LastPoorCallTime + FROM [QoEMetrics].[dbo].[User] + WHERE LastPoorCallTime>=dateadd(minute,-".$self->{option_results}->{lookback}.",getdate())"); + my $total; + while (my $row = $self->{sql}->fetchrow_hashref()) { + if (defined($self->{option_results}->{filter_user}) && $self->{option_results}->{filter_user} ne '' && + $row->{URI} !~ /$self->{option_results}->{filter_user}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $row->{URI} . "': no matching filter.", debug => 1); + next; + } + $self->{global}->{count}++; + $self->{uri}->{$row->{URI}} = {count => 0, display => $row->{URI}} if (!defined($self->{uri}->{$row->{URI}})); + $self->{uri}->{$row->{URI}}->{count}++; + } + +} + +1; + +__END__ + +=head1 MODE + +Check Lync Poor Calls during last X minutes (Total and per users) + +=over 8 + +=item B<--filter-user> + +Filter user name (can be a regexp) + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--lookback> + +Minutes to lookback (From you to UTC) default: 65 + +=item B<--warning-*> + +Set warning threshold for number of poor calls. Can be : 'total', 'user' + +=item B<--critical-*> + +Set critical threshold for number of poor calls. Can be : 'total', 'user' + +=back + +=cut diff --git a/centreon-plugins/apps/lync/2013/mssql/mode/sessionstypes.pm b/centreon-plugins/apps/lync/2013/mssql/mode/sessionstypes.pm new file mode 100644 index 000000000..8ad9703d2 --- /dev/null +++ b/centreon-plugins/apps/lync/2013/mssql/mode/sessionstypes.pm @@ -0,0 +1,181 @@ +# +# Copyright 2016 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::lync::2013::mssql::mode::sessionstypes; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'instant_messaging', type => 0 }, + { name => 'file_transfer', type => 0 }, + { name => 'remote_assistance', type => 0 }, + { name => 'app_sharing', type => 0 }, + { name => 'audio', type => 0 }, + { name => 'video', type => 0 }, + { name => 'app_invite', type => 0 }, + ]; + + $self->{maps_counters}->{instant_messaging} = [ + { label => 'instant-messaging', set => { + key_values => [ { name => 'value' } ], + output_template => 'Instant Messaging : %d', + perfdatas => [ + { label => 'instant_messaging', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{file_transfer} = [ + { label => 'file-transfer', set => { + key_values => [ { name => 'value' } ], + output_template => 'File transfer : %d', + perfdatas => [ + { label => 'file_transfer', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{remote_assistance} = [ + { label => 'remote-assistance', set => { + key_values => [ { name => 'value' } ], + output_template => 'Remote assistance : %d', + perfdatas => [ + { label => 'remote_assistance', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{app_sharing} = [ + { label => 'app-sharing', set => { + key_values => [ { name => 'value' } ], + output_template => 'App Sharing : %d', + perfdatas => [ + { label => 'app_sharing', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{audio} = [ + { label => 'audio', set => { + key_values => [ { name => 'value' } ], + output_template => 'Audio : %d', + perfdatas => [ + { label => 'audio', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{video} = [ + { label => 'video', set => { + key_values => [ { name => 'value' } ], + output_template => 'Video : %d', + perfdatas => [ + { label => 'video', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 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 => + { + 'lookback:s' => { name => 'lookback', default => '5' }, + }); + return $self; +} + +my %mapping_types = ( + 1 => 'instant_messaging', + 2 => 'file_transfer', + 4 => 'remote_assistance', + 8 => 'app_sharing', + 16 => 'audio', + 32 => 'video', + 64 => 'app_invite', +); + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + foreach my $bit (keys %mapping_types) { + my $query = "SELECT count(*) + FROM [LcsCDR].[dbo].[SessionDetails] s + left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId + WHERE MediaTypes=".$bit." + AND s.SessionIdTime>=dateadd(minute,-".$self->{option_results}->{lookback}.",getdate())"; + + $self->{sql}->query(query => $query); + my $value = $self->{sql}->fetchrow_array(); + $self->{$mapping_types{$bit}} = { value => $value }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check number of sessions ordered by type during last X minutes + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--lookback> + +Minutes to lookback (From you to UTC) + +=item B<--warning-*> + +Set warning threshold Can be : 'instant-messaging', 'app-sharing', 'audio', 'video', 'app-invite', 'remote-assistance' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'instant-messaging', 'app-sharing', 'audio', 'video', 'app-invite', 'remote-assistance' + +=back + +=cut diff --git a/centreon-plugins/apps/lync/2013/mssql/mode/videoqoe.pm b/centreon-plugins/apps/lync/2013/mssql/mode/videoqoe.pm new file mode 100644 index 000000000..96cc688ac --- /dev/null +++ b/centreon-plugins/apps/lync/2013/mssql/mode/videoqoe.pm @@ -0,0 +1,152 @@ +package apps::lync::2013::mssql::mode::videoqoe; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'video_post_fecplr', type => 0 }, + { name => 'video_local_frame_loss_prct_avg', type => 0 }, + { name => 'recv_frame_rate_avg', type => 0 }, + { name => 'video_packet_loss_rate', type => 0 }, + { name => 'inbound_video_frame_rate_avg', type => 0 }, + { name => 'outbound_video_frame_rate_avg', type => 0 }, + ]; + + $self->{maps_counters}->{video_post_fecplr} = [ + { label => 'post-fecplr', set => { + key_values => [ { name => 'value' } ], + output_template => 'VideoPostFECPLR : %d', + perfdatas => [ + { label => 'video_post_fecplr', value => 'value_absolute', template => '%d', + unit => '', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{video_local_frame_loss_prct_avg} = [ + { label => 'local-frame-loss', set => { + key_values => [ { name => 'value' } ], + output_template => 'VideoLocalFrameLossPercentageAvg : %d', + perfdatas => [ + { label => 'video_frame_loss_prct_avg', value => 'value_absolute', template => '%d', + unit => '', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{recv_frame_rate_avg} = [ + { label => 'recv-frame', set => { + key_values => [ { name => 'value' } ], + output_template => 'RecvFrameRateAverage : %d', + perfdatas => [ + { label => 'rcv_frame_rate_avg', value => 'value_absolute', template => '%d', + unit => '', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{video_packet_loss_rate} = [ + { label => 'packet-loss', set => { + key_values => [ { name => 'value' } ], + output_template => 'video_packet_loss_rate : %.2f%%', + perfdatas => [ + { label => 'video_pckt_loss_rate', value => 'value_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{inbound_video_frame_rate_avg} = [ + { label => 'inbound-frame', set => { + key_values => [ { name => 'value' } ], + output_template => 'inbound_video_frame_rate_avg : %.2f%%', + perfdatas => [ + { label => 'inbound_video_frame_rate_avg', value => 'value_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{outbound_video_frame_rate_avg} = [ + { label => 'outbound-frame', set => { + key_values => [ { name => 'value' } ], + output_template => 'outbound_video_frame_rate_avg : %.2f%%', + perfdatas => [ + { label => 'outbound_video_frame_rate_avg', value => 'value_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 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 => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{select avg(VideoPostFECPLR) + ,avg(VideoLocalFrameLossPercentageAvg) + ,avg(RecvFrameRateAverage) + ,avg(VideoPacketLossRate) + ,avg(InboundVideoFrameRateAvg) + ,avg(OutboundVideoFrameRateAvg) + from [QoEMetrics].[dbo].VideoStream + } + ); + + my ($video_post_fecplr, $video_local_frame_loss_prct_avg, $recv_frame_rate_avg, + $video_packet_loss_rate, $inbound_video_frame_rate_avg, $outbound_video_frame_rate_avg) = $self->{sql}->fetchrow_array(); + + $self->{video_post_fecplr} = { value => $video_post_fecplr }; + $self->{video_local_frame_loss_prct_avg} = { value => $video_local_frame_loss_prct_avg }; + $self->{recv_frame_rate_avg} = { value => $recv_frame_rate_avg }; + $self->{video_packet_loss_rate} = { value => $video_packet_loss_rate }; + $self->{inbound_video_frame_rate_avg} = { value => $inbound_video_frame_rate_avg }; + $self->{outbound_video_frame_rate_avg} = { value => $outbound_video_frame_rate_avg }; + +} + +1; + +__END__ + +=head1 MODE + +Check video metrics QoE from SQL Server Lync Database [QoEMetrics].[dbo].VideoStream + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for QoE metrics. Can be : 'recv-frame', 'local-frame-loss', 'post-fecplr', ''packet-loss', 'inboud-frame', 'outbound-frame' + +=item B<--critical-*> + +Set critical threshold for QoE. Can be : 'recv-frame', 'local-frame-loss', 'post-fecplr', ''packet-loss', 'inboud-frame', 'outbound-frame' + +=back + +=cut diff --git a/centreon-plugins/apps/lync/mode/lyncusers.pm b/centreon-plugins/apps/lync/mode/lyncusers.pm deleted file mode 100644 index 68d8a02dc..000000000 --- a/centreon-plugins/apps/lync/mode/lyncusers.pm +++ /dev/null @@ -1,148 +0,0 @@ -# -# 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::lync::mode::lyncusers; - -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', }, - "warning-unique:s" => { name => 'warning_unique', }, - "critical-unique:s" => { name => 'critical_unique', }, - }); - - 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 (($self->{perfdata}->threshold_validate(label => 'warning-unique', 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-unique', 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}; - - $self->{sql}->connect(); - $self->{sql}->query(query => q{Select - (cast (RE.ClientApp as varchar (100))) as ClientVersion, - R.UserAtHost as UserName, - Reg.Fqdn - From - rtcdyn.dbo.RegistrarEndpoint RE - Inner Join - rtc.dbo.Resource R on R.ResourceId = RE.OwnerId - Inner Join - rtcdyn.dbo.Registrar Reg on Reg.RegistrarId = RE.PrimaryRegistrarClusterId - Order By ClientVersion, UserName } - ); - my $users = $self->{sql}->fetchrow_array(); - - $self->{sql}->query(query => q{Select - count(*) as totalonline, count(distinct UserAtHost) as totalunique - From - rtcdyn.dbo.RegistrarEndpoint RE - Inner Join - rtc.dbo.Resource R on R.ResourceId = RE.OwnerId - Inner Join - rtcdyn.dbo.Registrar Reg on Reg.RegistrarId = RE.PrimaryRegistrarClusterId} - ); - my $unique_users = $self->{sql}->fetchrow_array(); - - my $exit1 = $self->{perfdata}->threshold_check(value => $unique_users, threshold => [ { label => 'critical-unique', 'exit_litteral' => 'critical' }, { label => 'warning-unique', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $users, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - my $exit_code = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("%i lync unique user(s). (%i total users)", $unique_users, $users)); - $self->{output}->perfdata_add(label => 'unique_users', - value => $unique_users, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-unique'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-unique'), - min => 0); - $self->{output}->perfdata_add(label => 'total_users', - value => $users, - 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 Lync users and unique users (one user can be connected with several devices) -- use with dyn-mode mssql plugin) - -=over 8 - -=item B<--warning> - -Threshold warning on total users - -=item B<--critical> - -Threshold critical on total users - -=item B<--warning-unique> - -Threshold warning on unique users - -=item B<--critical-unique> - -Threshold critical on unique users - - -=back - -=cut diff --git a/centreon-plugins/apps/lync/mode/sessionstype.pm b/centreon-plugins/apps/lync/mode/sessionstype.pm deleted file mode 100644 index e2b9404fe..000000000 --- a/centreon-plugins/apps/lync/mode/sessionstype.pm +++ /dev/null @@ -1,142 +0,0 @@ -# -# 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::lync::mode::sessionstype; - -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-audio:s" => { name => 'warning-audio', }, - "critical-audio:s" => { name => 'critical-audio', }, - "warning-video:s" => { name => 'warning_video', }, - "critical-video:s" => { name => 'critical_video', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning-audio', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-audio threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-audio', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-audio threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-video', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-video threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-video', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-video threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - - $self->{sql}->connect(); - - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=16 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - - - my $audio = $self->{sql}->fetchrow_array(); - - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=32 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - - my $video = $self->{sql}->fetchrow_array(); - - my $exit1 = $self->{perfdata}->threshold_check(value => $audio, threshold => [ { label => 'critical-audio', 'exit_litteral' => 'critical' }, { label => 'warning-audio', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $video, threshold => [ { label => 'critical-video', 'exit_litteral' => 'critical' }, { label => 'warning-video', exit_litteral => 'warning' } ]); - my $exit_code = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Lync sessions type : %i audio sessions and %i video sessions", $audio, $video)); - $self->{output}->perfdata_add(label => 'video_sessions', - value => $video, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-video'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-video'), - min => 0); - $self->{output}->perfdata_add(label => 'audio_sessions', - value => $audio, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-audio'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-audio'), - min => 0); - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check Lync type of sessions (audio or video) during the last five minutes -- use with dyn-mode and mssql plugin - -=over 8 - -=item B<--warning-audio> - -Threshold warning on number of audio sessions during last five minutes - -=item B<--critical-audio> - -Threshold critical on number of audio sessions during last five minutes - -=item B<--warning-video> - -Threshold critical on number of video sessions during last five minutes - -=item B<--critical-video> - -Threshold critical on number of video sessions during last five minutes - -=back - -=cut diff --git a/centreon-plugins/apps/msmq/local/mode/listqueues.pm b/centreon-plugins/apps/msmq/local/mode/listqueues.pm index 4b85259b7..83ede43ac 100644 --- a/centreon-plugins/apps/msmq/local/mode/listqueues.pm +++ b/centreon-plugins/apps/msmq/local/mode/listqueues.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/msmq/local/plugin.pm b/centreon-plugins/apps/msmq/local/plugin.pm index 4206bf544..f09174bae 100644 --- a/centreon-plugins/apps/msmq/local/plugin.pm +++ b/centreon-plugins/apps/msmq/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/nginx/serverstatus/mode/connections.pm b/centreon-plugins/apps/nginx/serverstatus/mode/connections.pm index 3d3816837..592cff24f 100644 --- a/centreon-plugins/apps/nginx/serverstatus/mode/connections.pm +++ b/centreon-plugins/apps/nginx/serverstatus/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/nginx/serverstatus/mode/requests.pm b/centreon-plugins/apps/nginx/serverstatus/mode/requests.pm index 790cb1705..c8732c56d 100644 --- a/centreon-plugins/apps/nginx/serverstatus/mode/requests.pm +++ b/centreon-plugins/apps/nginx/serverstatus/mode/requests.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/nginx/serverstatus/mode/responsetime.pm b/centreon-plugins/apps/nginx/serverstatus/mode/responsetime.pm index 9e1693e4e..019875505 100644 --- a/centreon-plugins/apps/nginx/serverstatus/mode/responsetime.pm +++ b/centreon-plugins/apps/nginx/serverstatus/mode/responsetime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/nginx/serverstatus/plugin.pm b/centreon-plugins/apps/nginx/serverstatus/plugin.pm index 7ffe12b03..9f0112d81 100644 --- a/centreon-plugins/apps/nginx/serverstatus/plugin.pm +++ b/centreon-plugins/apps/nginx/serverstatus/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; -# $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/pacemaker/local/mode/constraints.pm b/centreon-plugins/apps/pacemaker/local/mode/constraints.pm new file mode 100644 index 000000000..bdd4c8354 --- /dev/null +++ b/centreon-plugins/apps/pacemaker/local/mode/constraints.pm @@ -0,0 +1,173 @@ +# +# Copyright 2016 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::pacemaker::local::mode::constraints; + +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 => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'crm_resource' }, + "command-path:s" => { name => 'command_path', default => '/usr/sbin' }, + "command-options:s" => { name => 'command_options', default => ' --constraints -r' }, + "resource:s" => { name => 'resource' }, + "warning" => { name => 'warning' }, + }); + $self->{threshold} = 'CRITICAL'; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { + $self->{output}->add_option_msg(short_msg => "Please set the resource name with --resource option"); + $self->{output}->option_exit(); + } + + $self->{threshold} = 'WARNING' if (defined $self->{option_results}->{warning}); +} + +sub parse_output { + my ($self, %options) = @_; + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Resource '%s' constraint location is OK", $self->{option_results}->{resource})); + + if ($options{output} =~ /Connection to cluster failed\:(.*)/i ) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => "Connection to cluster FAILED: $1"); + return ; + } + + my @lines = split /\n/, $options{output}; + foreach my $line (@lines) { + next if $line !~ /^\s+:\sNode/; + if ($line =~ /^\s+:\sNode/) { + $self->{output}->output_add(long_msg => sprintf('Processed %s', $line), debug => 1); + $line =~ /^\s+:\sNode\s([a-zA-Z0-9-_]+)\s+\(score=([a-zA-Z0-9-_]+),\sid=([a-zA-Z0-9-_]+)/; + my ($node, $score, $rule) = ($1, $2, $3); + if ($score eq '-INFINITY' && $rule =~ /^cli-ban/) { + $self->{output}->output_add(severity => $self->{threshold}, + short_msg => sprintf("Resource '%s' is locked on node '%s' ('%s')", $self->{option_results}->{resource}, $node, $rule)); + } + } else { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => "ERROR: $line"); + } + } +} + +sub run { + my ($self, %options) = @_; + + my $stdout = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}." ".$self->{option_results}->{resource}); + + $self->parse_output(output => $stdout); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check that a resource has no location constraint (migrate without unmigrate) +Can be executed from any cluster node. + +=over 8 + +=item B<--resource> + +Set the resource name you want to check + +=item B<--warning> + +Return a warning instead of a critical + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52"). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'crm_resource'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: '/usr/sbin'). + +=item B<--command-options> + +Command options (Default: ' --constraints -r'). + +=back + +=cut diff --git a/centreon-plugins/apps/pacemaker/local/mode/crm.pm b/centreon-plugins/apps/pacemaker/local/mode/crm.pm index a1348a2ce..01f2b910f 100644 --- a/centreon-plugins/apps/pacemaker/local/mode/crm.pm +++ b/centreon-plugins/apps/pacemaker/local/mode/crm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/pacemaker/local/plugin.pm b/centreon-plugins/apps/pacemaker/local/plugin.pm index 9838f7a35..f07c3de64 100644 --- a/centreon-plugins/apps/pacemaker/local/plugin.pm +++ b/centreon-plugins/apps/pacemaker/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,11 +28,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( 'crm' => 'apps::pacemaker::local::mode::crm', + 'constraints' => 'apps::pacemaker::local::mode::constraints', ); return $self; diff --git a/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm b/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm index 287bab9ca..481697e4f 100644 --- a/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm +++ b/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -80,7 +80,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/apps/pfsense/snmp/mode/memorydroppedpackets.pm b/centreon-plugins/apps/pfsense/snmp/mode/memorydroppedpackets.pm index ca53fe386..109655f7b 100644 --- a/centreon-plugins/apps/pfsense/snmp/mode/memorydroppedpackets.pm +++ b/centreon-plugins/apps/pfsense/snmp/mode/memorydroppedpackets.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -60,7 +60,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/apps/pfsense/snmp/mode/runtime.pm b/centreon-plugins/apps/pfsense/snmp/mode/runtime.pm index cb278a66b..d1cc9dc7b 100644 --- a/centreon-plugins/apps/pfsense/snmp/mode/runtime.pm +++ b/centreon-plugins/apps/pfsense/snmp/mode/runtime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -58,7 +58,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_pfsenseStatus = '.1.3.6.1.4.1.12325.1.200.1.1.1.0'; diff --git a/centreon-plugins/apps/pfsense/snmp/plugin.pm b/centreon-plugins/apps/pfsense/snmp/plugin.pm index 6c1b5b9f6..5746f623b 100644 --- a/centreon-plugins/apps/pfsense/snmp/plugin.pm +++ b/centreon-plugins/apps/pfsense/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/php/apc/web/mode/filecache.pm b/centreon-plugins/apps/php/apc/web/mode/filecache.pm index aa83f8253..a99a42019 100644 --- a/centreon-plugins/apps/php/apc/web/mode/filecache.pm +++ b/centreon-plugins/apps/php/apc/web/mode/filecache.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/php/apc/web/mode/memory.pm b/centreon-plugins/apps/php/apc/web/mode/memory.pm index 6a5fee586..b3f901530 100644 --- a/centreon-plugins/apps/php/apc/web/mode/memory.pm +++ b/centreon-plugins/apps/php/apc/web/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/php/apc/web/plugin.pm b/centreon-plugins/apps/php/apc/web/plugin.pm index 6e240bf96..1415378c4 100644 --- a/centreon-plugins/apps/php/apc/web/plugin.pm +++ b/centreon-plugins/apps/php/apc/web/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/php/fpm/web/mode/usage.pm b/centreon-plugins/apps/php/fpm/web/mode/usage.pm index fd149d20a..b3089376f 100644 --- a/centreon-plugins/apps/php/fpm/web/mode/usage.pm +++ b/centreon-plugins/apps/php/fpm/web/mode/usage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/php/fpm/web/plugin.pm b/centreon-plugins/apps/php/fpm/web/plugin.pm index 73e76f92f..fc412c18f 100644 --- a/centreon-plugins/apps/php/fpm/web/plugin.pm +++ b/centreon-plugins/apps/php/fpm/web/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/bgp/4/mode/bgppeerstate.pm b/centreon-plugins/apps/protocols/bgp/4/mode/bgppeerstate.pm index 1cbbe37ec..0d10eab70 100644 --- a/centreon-plugins/apps/protocols/bgp/4/mode/bgppeerstate.pm +++ b/centreon-plugins/apps/protocols/bgp/4/mode/bgppeerstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -73,12 +73,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -89,7 +89,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_bgpPeerTable = '.1.3.6.1.2.1.15.3'; diff --git a/centreon-plugins/apps/protocols/bgp/4/plugin.pm b/centreon-plugins/apps/protocols/bgp/4/plugin.pm index 1f4415bd8..ff32f1405 100644 --- a/centreon-plugins/apps/protocols/bgp/4/plugin.pm +++ b/centreon-plugins/apps/protocols/bgp/4/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( @@ -44,7 +43,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Arkoon firewall in SNMP. -!!! Be careful: ifAlias and ifName are empty. Use --oid-filter and --oid-display on ifDesc !!! +Check BGP protocol in SNMP. =cut diff --git a/centreon-plugins/apps/protocols/dhcp/mode/connection.pm b/centreon-plugins/apps/protocols/dhcp/mode/connection.pm index 8c5233df7..d0b1d2a6b 100644 --- a/centreon-plugins/apps/protocols/dhcp/mode/connection.pm +++ b/centreon-plugins/apps/protocols/dhcp/mode/connection.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/dhcp/plugin.pm b/centreon-plugins/apps/protocols/dhcp/plugin.pm index d1b76a7c6..e25a739f1 100644 --- a/centreon-plugins/apps/protocols/dhcp/plugin.pm +++ b/centreon-plugins/apps/protocols/dhcp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/apps/protocols/dns/lib/dns.pm b/centreon-plugins/apps/protocols/dns/lib/dns.pm index 6ad5e258c..9416a313d 100644 --- a/centreon-plugins/apps/protocols/dns/lib/dns.pm +++ b/centreon-plugins/apps/protocols/dns/lib/dns.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -72,7 +72,7 @@ sub search { } } - return @results; + return sort @results; } sub connect { diff --git a/centreon-plugins/apps/protocols/dns/mode/request.pm b/centreon-plugins/apps/protocols/dns/mode/request.pm index 5bc8f4c35..f6511037c 100644 --- a/centreon-plugins/apps/protocols/dns/mode/request.pm +++ b/centreon-plugins/apps/protocols/dns/mode/request.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -26,6 +26,8 @@ use strict; use warnings; use Time::HiRes qw(gettimeofday tv_interval); use apps::protocols::dns::lib::dns; +use centreon::plugins::statefile; +use Digest::MD5 qw(md5_hex); sub new { my ($class, %options) = @_; @@ -40,11 +42,13 @@ sub new { "dns-options:s@" => { name => 'dns_options' }, "search:s" => { name => 'search' }, "search-type:s" => { name => 'search_type' }, - "search-field:s" => { name => 'search_field' }, "expected-answer:s" => { name => 'expected_answer' }, "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, + "memory" => { name => 'memory' }, }); + + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); return $self; } @@ -65,6 +69,21 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Please set the search option"); $self->{output}->option_exit(); } + + if (defined($self->{option_results}->{memory})) { + $self->{cache_filename} = $self->{option_results}->{search}; + foreach (('search_type', 'search', 'nameservers')) { + $self->{cache_filename} .= '_'; + if (defined($self->{option_results}->{$_})) { + if (ref($self->{option_results}->{$_}) eq 'ARRAY') { + $self->{cache_filename} .= join('-', @{$self->{option_results}->{$_}}); + } else { + $self->{cache_filename} .= $self->{option_results}->{$_}; + } + } + } + $self->{statefile_cache}->check_options(%options); + } } sub run { @@ -79,7 +98,7 @@ sub run { my $result_str = join(', ', @results); my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, - 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("Response time %.3f second(s) (answer: %s)", $timeelapsed, $result_str)); $self->{output}->perfdata_add(label => "time", unit => 's', @@ -101,6 +120,21 @@ sub run { } } + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->read(statefile => 'cache_dns_' . md5_hex($self->{cache_filename})); + my $datas = { result => $result_str }; + my $old_result = $self->{statefile_cache}->get(name => "result"); + if (defined($old_result)) { + if ($old_result ne $result_str) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Result has changed [answer: %s] [old answer: %s]", $result_str, $old_result)); + } + } else { + $self->{output}->output_add(long_msg => 'cache file created.'); + } + $self->{statefile_cache}->write(data => $datas); + } + $self->{output}->display(); $self->{output}->exit(); } @@ -136,14 +170,6 @@ Set the search value (required). Set the search type. Can be: 'MX', 'SOA', 'NS', 'A' or 'PTR'. 'A' or 'PTR' is used by default (depends if an IP or not). -=item B<--search-field> - -Set the search field used for 'expected-answer'. -By default: -'MX' is 'exchange', 'SOA' is 'mname', 'NS' is 'nsdname', -'A' is 'address' and 'PTR' is 'name'. -'A' or 'PTR' is used by default (depends if an IP or not). - =item B<--expected-answer> What the server must answer (can be a regexp). @@ -154,13 +180,17 @@ Add custom dns options. Example: --dns-options='debug=1' --dns-options='retry=2' --dns-options='port=972' --dns-options='recurse=0' ... +=item B<--memory> + +Critical threshold if the answer changed between two checks. + =item B<--warning> -Threshold warning in seconds +Threshold warning in seconds. =item B<--critical> -Threshold critical in seconds +Threshold critical in seconds. =back diff --git a/centreon-plugins/apps/protocols/dns/plugin.pm b/centreon-plugins/apps/protocols/dns/plugin.pm index aea448f5d..f6449f70d 100644 --- a/centreon-plugins/apps/protocols/dns/plugin.pm +++ b/centreon-plugins/apps/protocols/dns/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/ftp/lib/ftp.pm b/centreon-plugins/apps/protocols/ftp/lib/ftp.pm index 8552a8230..6d0bbe676 100644 --- a/centreon-plugins/apps/protocols/ftp/lib/ftp.pm +++ b/centreon-plugins/apps/protocols/ftp/lib/ftp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ftp/mode/commands.pm b/centreon-plugins/apps/protocols/ftp/mode/commands.pm index e0181779c..32abc484d 100644 --- a/centreon-plugins/apps/protocols/ftp/mode/commands.pm +++ b/centreon-plugins/apps/protocols/ftp/mode/commands.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ftp/mode/date.pm b/centreon-plugins/apps/protocols/ftp/mode/date.pm index 4b9bf30d1..e9ebf46a3 100644 --- a/centreon-plugins/apps/protocols/ftp/mode/date.pm +++ b/centreon-plugins/apps/protocols/ftp/mode/date.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ftp/mode/filescount.pm b/centreon-plugins/apps/protocols/ftp/mode/filescount.pm index 78ea6bdfd..bb9dd1a5d 100644 --- a/centreon-plugins/apps/protocols/ftp/mode/filescount.pm +++ b/centreon-plugins/apps/protocols/ftp/mode/filescount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ftp/mode/login.pm b/centreon-plugins/apps/protocols/ftp/mode/login.pm index ba965d2aa..e4118c057 100644 --- a/centreon-plugins/apps/protocols/ftp/mode/login.pm +++ b/centreon-plugins/apps/protocols/ftp/mode/login.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ftp/plugin.pm b/centreon-plugins/apps/protocols/ftp/plugin.pm index e8c43db69..c8bfad271 100644 --- a/centreon-plugins/apps/protocols/ftp/plugin.pm +++ b/centreon-plugins/apps/protocols/ftp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/http/mode/expectedcontent.pm b/centreon-plugins/apps/protocols/http/mode/expectedcontent.pm index 1f547221c..dc745d280 100644 --- a/centreon-plugins/apps/protocols/http/mode/expectedcontent.pm +++ b/centreon-plugins/apps/protocols/http/mode/expectedcontent.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm b/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm index 372082276..c4f4e7b58 100644 --- a/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm +++ b/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -239,7 +239,7 @@ sub run { $self->{json_response} = $self->{http}->request(method => $self->{method}, query_form_post => $self->{json_request}); my $timeelapsed = tv_interval ($timing0, [gettimeofday]); - $self->{output}->output_add(long_msg => $self->{json_response}); + $self->{output}->output_add(long_msg => $self->{json_response}, debug => 1); if (!defined($self->{option_results}->{lookup}) || scalar(@{$self->{option_results}->{lookup}}) == 0) { $self->{output}->output_add(severity => 'OK', short_msg => "JSON webservice request success"); diff --git a/centreon-plugins/apps/protocols/http/mode/response.pm b/centreon-plugins/apps/protocols/http/mode/response.pm index 3616e37f3..c0305dca4 100644 --- a/centreon-plugins/apps/protocols/http/mode/response.pm +++ b/centreon-plugins/apps/protocols/http/mode/response.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/http/mode/soapcontent.pm b/centreon-plugins/apps/protocols/http/mode/soapcontent.pm index 068c2b216..bdccf9de2 100644 --- a/centreon-plugins/apps/protocols/http/mode/soapcontent.pm +++ b/centreon-plugins/apps/protocols/http/mode/soapcontent.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -248,7 +248,7 @@ sub run { $self->{soap_response} = $self->{http}->request(method => 'POST', query_form_post => $self->{soap_request}); my $timeelapsed = tv_interval ($timing0, [gettimeofday]); - $self->{output}->output_add(long_msg => $self->{soap_response}); + $self->{output}->output_add(long_msg => $self->{soap_response}, debug => 1); if (!defined($self->{option_results}->{lookup}) || scalar(@{$self->{option_results}->{lookup}}) == 0) { $self->{output}->output_add(severity => 'OK', short_msg => "SOAP request success"); diff --git a/centreon-plugins/apps/protocols/http/plugin.pm b/centreon-plugins/apps/protocols/http/plugin.pm index a9cd1079d..48ded3c07 100644 --- a/centreon-plugins/apps/protocols/http/plugin.pm +++ b/centreon-plugins/apps/protocols/http/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; -# $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/imap/lib/imap.pm b/centreon-plugins/apps/protocols/imap/lib/imap.pm index 7454d6604..135b87fa1 100644 --- a/centreon-plugins/apps/protocols/imap/lib/imap.pm +++ b/centreon-plugins/apps/protocols/imap/lib/imap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/imap/mode/login.pm b/centreon-plugins/apps/protocols/imap/mode/login.pm index 2c78c8704..dadfd4ff3 100644 --- a/centreon-plugins/apps/protocols/imap/mode/login.pm +++ b/centreon-plugins/apps/protocols/imap/mode/login.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/imap/mode/searchmessage.pm b/centreon-plugins/apps/protocols/imap/mode/searchmessage.pm index 18b3e21c8..f022d3407 100644 --- a/centreon-plugins/apps/protocols/imap/mode/searchmessage.pm +++ b/centreon-plugins/apps/protocols/imap/mode/searchmessage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/imap/plugin.pm b/centreon-plugins/apps/protocols/imap/plugin.pm index 8c7240c6b..d10251fad 100644 --- a/centreon-plugins/apps/protocols/imap/plugin.pm +++ b/centreon-plugins/apps/protocols/imap/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/jmx/mode/listattributes.pm b/centreon-plugins/apps/protocols/jmx/mode/listattributes.pm index ff55dcf5b..846a43ee7 100644 --- a/centreon-plugins/apps/protocols/jmx/mode/listattributes.pm +++ b/centreon-plugins/apps/protocols/jmx/mode/listattributes.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm b/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm index a91d6630d..04f24b667 100644 --- a/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm +++ b/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -227,7 +227,6 @@ sub find_values { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{connector} = $options{custom}; my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); @@ -258,10 +257,6 @@ perl centreon_plugins.pl --plugin=apps::protocols::jmx::plugin --custommode=jolo =over 8 -=item B<--oid> - -OID value to check (numeric format only). - =item B<--lookup-path> What to lookup (from internal Jmx4Perl). Use --lookup-jpath for complex matching. @@ -279,9 +274,9 @@ Threshold warning. Threshold critical. -=item B<--oid-type> +=item B<--type> -Type of the OID (Default: 'gauge'). +Type (Default: 'gauge'). Can be 'counter' also. 'counter' will use a retention file. =item B<--counter-per-seconds> diff --git a/centreon-plugins/apps/protocols/jmx/plugin.pm b/centreon-plugins/apps/protocols/jmx/plugin.pm index 375d79d97..ab813fb9e 100644 --- a/centreon-plugins/apps/protocols/jmx/plugin.pm +++ b/centreon-plugins/apps/protocols/jmx/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/ldap/lib/ldap.pm b/centreon-plugins/apps/protocols/ldap/lib/ldap.pm index 0eca07b12..4a1705623 100644 --- a/centreon-plugins/apps/protocols/ldap/lib/ldap.pm +++ b/centreon-plugins/apps/protocols/ldap/lib/ldap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ldap/mode/login.pm b/centreon-plugins/apps/protocols/ldap/mode/login.pm index 01edec7cf..37a5e548e 100644 --- a/centreon-plugins/apps/protocols/ldap/mode/login.pm +++ b/centreon-plugins/apps/protocols/ldap/mode/login.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ldap/mode/search.pm b/centreon-plugins/apps/protocols/ldap/mode/search.pm index fbbcc94b7..0932d11e8 100644 --- a/centreon-plugins/apps/protocols/ldap/mode/search.pm +++ b/centreon-plugins/apps/protocols/ldap/mode/search.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ldap/plugin.pm b/centreon-plugins/apps/protocols/ldap/plugin.pm index 3c680279a..7876e15a6 100644 --- a/centreon-plugins/apps/protocols/ldap/plugin.pm +++ b/centreon-plugins/apps/protocols/ldap/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/ntp/mode/offset.pm b/centreon-plugins/apps/protocols/ntp/mode/offset.pm index 6314e96b2..600a48ffc 100644 --- a/centreon-plugins/apps/protocols/ntp/mode/offset.pm +++ b/centreon-plugins/apps/protocols/ntp/mode/offset.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -77,7 +77,7 @@ sub run { } my $localtime = time(); - my $offset = ($ntp{'Receive Timestamp'} - $ntp{'Originate Timestamp'}) + ($ntp{'Transmit Timestamp'} - $localtime) / 2); + 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' } ]); diff --git a/centreon-plugins/apps/protocols/ntp/mode/responsetime.pm b/centreon-plugins/apps/protocols/ntp/mode/responsetime.pm index c36572aff..070532408 100644 --- a/centreon-plugins/apps/protocols/ntp/mode/responsetime.pm +++ b/centreon-plugins/apps/protocols/ntp/mode/responsetime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/ntp/plugin.pm b/centreon-plugins/apps/protocols/ntp/plugin.pm index 650aff220..464104da8 100644 --- a/centreon-plugins/apps/protocols/ntp/plugin.pm +++ b/centreon-plugins/apps/protocols/ntp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/ospf/snmp/mode/neighbor.pm b/centreon-plugins/apps/protocols/ospf/snmp/mode/neighbor.pm new file mode 100644 index 000000000..10b3690d2 --- /dev/null +++ b/centreon-plugins/apps/protocols/ospf/snmp/mode/neighbor.pm @@ -0,0 +1,281 @@ +# +# Copyright 2016 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::ospf::snmp::mode::neighbor; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'state : ' . $self->{result_values}->{NbrState}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{NbrState} = $options{new_datas}->{$self->{instance} . '_NbrState'}; + $self->{result_values}->{NbrIpAddr} = $options{new_datas}->{$self->{instance} . '_NbrIpAddr'}; + $self->{result_values}->{NbrRtrId} = $options{new_datas}->{$self->{instance} . '_NbrRtrId'}; + return 0; +} + +sub custom_change_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_total_change}) && $instance_mode->{option_results}->{critical_total_change} ne '' && + eval "$instance_mode->{option_results}->{critical_total_change}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_total_change}) && $instance_mode->{option_results}->{warning_total_change} ne '' && + eval "$instance_mode->{option_results}->{warning_total_change}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_change_output { + my ($self, %options) = @_; + + my $msg = 'Neighbors current : ' . $self->{result_values}->{Total} . ' (last : ' . $self->{result_values}->{TotalLast} . ')'; + return $msg; +} + +sub custom_change_calc { + my ($self, %options) = @_; + + $self->{result_values}->{TotalLast} = $options{old_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{Total} = $options{new_datas}->{$self->{instance} . '_total'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' }, + { name => 'nb', type => 1, cb_prefix_output => 'prefix_nb_output', message_multiple => 'All neighbor relations are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total neighbors : %s', + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-change', threshold => 0, set => { + key_values => [ { name => 'total', diff => 1 } ], + closure_custom_calc => $self->can('custom_change_calc'), + closure_custom_output => $self->can('custom_change_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_change_threshold'), + } + }, + ]; + $self->{maps_counters}->{nb} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'NbrIpAddr' }, { name => 'NbrRtrId' }, { name => 'NbrState' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{NbrState} =~ /down/i' }, + "warning-total-change:s" => { name => 'warning_total_change', default => '' }, + "critical-total-change:s" => { name => 'critical_total_change', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_nb_output { + my ($self, %options) = @_; + + return "Neighbor '" . $options{instance_value}->{NbrIpAddr} . "/" . $options{instance_value}->{NbrRtrId} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'warning_total_change', 'critical_total_change')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + 1 => 'down', + 2 => 'attempt', + 3 => 'init', + 4 => 'twoWay', + 5 => 'exchangeStart', + 6 => 'exchange', + 7 => 'loading', + 8 => 'full', +); +my $mapping = { + NbrIpAddr => { oid => '.1.3.6.1.2.1.14.10.1.1' }, + NbrRtrId => { oid => '.1.3.6.1.2.1.14.10.1.3' }, + NbrState => { oid => '.1.3.6.1.2.1.14.10.1.6', map => \%map_state }, +}; + +my $oid_ospfNbrEntry = '.1.3.6.1.2.1.14.10.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{nb} = {}; + $self->{global} = { total => 0 }; + my $snmp_result = $options{snmp}->get_table(oid => $oid_ospfNbrEntry, + nothing_quit => 1); + + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{NbrState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + $self->{global}->{total}++; + $self->{nb}->{$instance} = { %$result }; + } + + if (scalar(keys %{$self->{nb}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No neighbors found."); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "ospf_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check neighbor relations. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{NbrState}, %{NbrRtrId}, %{NbrIpAddr} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{NbrState} =~ /down/i'). +Can used special variables like: %{NbrState}, %{NbrRtrId}, %{NbrIpAddr} + +=item B<--warning-total-change> + +Set warning threshold. Should be used if there is a difference of total neighbors between two checks. +Example: %{TotalLast} != %{Total} + +=item B<--critical-total-change> + +Set critical threshold. Should be used if there is a difference of total neighbors between two checks. +Example: %{TotalLast} != %{Total} + +=item B<--warning-*> + +Threshold warning. +Can be: 'total'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'total'. + +=back + +=cut diff --git a/centreon-plugins/apps/protocols/ospf/snmp/plugin.pm b/centreon-plugins/apps/protocols/ospf/snmp/plugin.pm new file mode 100644 index 000000000..4c1e3dd59 --- /dev/null +++ b/centreon-plugins/apps/protocols/ospf/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::ospf::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}} = ( + 'neighbor' => 'apps::protocols::ospf::snmp::mode::neighbor', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check OSPF protocol in SNMP. + +=cut diff --git a/centreon-plugins/apps/protocols/radius/mode/login.pm b/centreon-plugins/apps/protocols/radius/mode/login.pm index 6b57b81bd..ee6887096 100644 --- a/centreon-plugins/apps/protocols/radius/mode/login.pm +++ b/centreon-plugins/apps/protocols/radius/mode/login.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/radius/plugin.pm b/centreon-plugins/apps/protocols/radius/plugin.pm index 6b742cee1..bf9a391db 100644 --- a/centreon-plugins/apps/protocols/radius/plugin.pm +++ b/centreon-plugins/apps/protocols/radius/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/smtp/lib/smtp.pm b/centreon-plugins/apps/protocols/smtp/lib/smtp.pm index e427069c5..0e4984332 100644 --- a/centreon-plugins/apps/protocols/smtp/lib/smtp.pm +++ b/centreon-plugins/apps/protocols/smtp/lib/smtp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/smtp/mode/login.pm b/centreon-plugins/apps/protocols/smtp/mode/login.pm index 8f76e8f0c..ef0281369 100644 --- a/centreon-plugins/apps/protocols/smtp/mode/login.pm +++ b/centreon-plugins/apps/protocols/smtp/mode/login.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/smtp/mode/message.pm b/centreon-plugins/apps/protocols/smtp/mode/message.pm index 930c14565..db8857c56 100644 --- a/centreon-plugins/apps/protocols/smtp/mode/message.pm +++ b/centreon-plugins/apps/protocols/smtp/mode/message.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -113,7 +113,7 @@ Check send a message to a SMTP Server. =item B<--hostname> -IP Addr/FQDN of the ftp host +IP Addr/FQDN of the smtp host =item B<--port> diff --git a/centreon-plugins/apps/protocols/smtp/plugin.pm b/centreon-plugins/apps/protocols/smtp/plugin.pm index a034302cb..c0160c212 100644 --- a/centreon-plugins/apps/protocols/smtp/plugin.pm +++ b/centreon-plugins/apps/protocols/smtp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/tcp/mode/responsetime.pm b/centreon-plugins/apps/protocols/tcp/mode/responsetime.pm index e4194dde5..9bee17d11 100644 --- a/centreon-plugins/apps/protocols/tcp/mode/responsetime.pm +++ b/centreon-plugins/apps/protocols/tcp/mode/responsetime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/protocols/tcp/plugin.pm b/centreon-plugins/apps/protocols/tcp/plugin.pm index e03a46273..b430ee5f3 100644 --- a/centreon-plugins/apps/protocols/tcp/plugin.pm +++ b/centreon-plugins/apps/protocols/tcp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/telnet/mode/scenario.pm b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm new file mode 100644 index 000000000..257ae9339 --- /dev/null +++ b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm @@ -0,0 +1,206 @@ +# +# Copyright 2016 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::telnet::mode::scenario; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Time::HiRes qw(gettimeofday tv_interval); +use JSON; +use Net::Telnet; + +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 => + { + "scenario:s" => { name => 'scenario' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => 23 }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + # Example of a scenario file: + # [ + # {"cmd": "open", "options": { "Host": "10.0.0.1", "Port": "23", "Timeout": "30" } }, + # {"cmd": "login", "options": { "Name": "admin", "Password": "pass", "Timeout": "5" } }, + # {"cmd": "waitfor", "options": { "Match": "/string/", "Timeout": "5" } }, + # {"cmd": "put", "options": { "String": "/mystring/", "Timeout": "5" } }, + # {"cmd": "close" } + #] + if (!defined($self->{option_results}->{scenario})) { + $self->{output}->add_option_msg(short_msg => "Please specify a scenario file."); + $self->{output}->option_exit(); + } + 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 read_scenario { + my ($self, %options) = @_; + + my $content_scenario; + if (-f $self->{option_results}->{scenario}) { + $content_scenario = do { + local $/ = undef; + if (!open my $fh, "<", $self->{option_results}->{scenario}) { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{scenario} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + } else { + $content_scenario = $self->{option_results}->{scenario}; + } + + eval { + $self->{json_scenario} = decode_json($content_scenario); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json scenario"); + $self->{output}->option_exit(); + } +} + +sub execute_scenario { + my ($self, %options) = @_; + + my $timing0 = [gettimeofday]; + my $session = new Net::Telnet(); + $session->errmode('return'); + + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + if (!$session->open(Host => $self->{option_results}->{hostname}, Port => $self->{option_results}->{port}, Timeout => 30)) { + $self->{output}->output_add(severity => 'critical', + short_msg => sprintf("cannot open session: %s", $session->errmsg())); + return ; + } + } + + my ($step_ok, $exit1) = (0, 'OK'); + my $step_total = scalar(@{$self->{json_scenario}}); + foreach my $cmd (@{$self->{json_scenario}}) { + next if (!defined($cmd->{cmd})); + if ($cmd->{cmd} !~ /^(open|login|waitfor|put|close)$/i) { + $self->{output}->add_option_msg(short_msg => "command '$cmd->{cmd}' is not managed"); + $self->{output}->option_exit(); + } + + my $cmd_name = lc($cmd->{cmd}); + my $method = $session->can($cmd_name); + if ($method) { + my $ret = $method->($session, defined($cmd->{options}) ? %{$cmd->{options}} : undef); + if (!defined($ret)) { + $self->{output}->output_add(long_msg => sprintf("errmsg: %s", $session->errmsg())); + $exit1 = 'CRITICAL'; + last; + } + } + + $step_ok++; + } + + my $timeelapsed = tv_interval($timing0, [gettimeofday]); + my $exit2 = $self->{perfdata}->threshold_check(value => $timeelapsed, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%d/%d steps (%.3fs)", $step_ok, $step_total, $timeelapsed)); + + $self->{output}->perfdata_add(label => "time", unit => 's', + value => sprintf('%.3f', $timeelapsed), + min => 0, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); + $self->{output}->perfdata_add(label => "steps", + value => $step_ok, + min => 0, + max => $step_total); +} + +sub run { + my ($self, %options) = @_; + + $self->read_scenario(); + $self->execute_scenario(); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check telnet scenario execution + +=over 8 + +=item B<--scenario> + +Scenario used (Required). +Can be a file or json content. + +=item B<--timeout> + +Set global execution timeout (Default: 50) + +=item B<--hostname> + +Set telnet hostname. +Could be used if you want to use the same scenario for X hosts. + +=item B<--port> + +Set telnet port. +Could be used if you want to use the same scenario for X hosts. + +=item B<--warning> + +Threshold warning in seconds (Scenario execution time) + +=item B<--critical> + +Threshold critical in seconds (Scenario execution time) + +=back + +=cut diff --git a/centreon-plugins/apps/protocols/telnet/plugin.pm b/centreon-plugins/apps/protocols/telnet/plugin.pm new file mode 100644 index 000000000..6409fb2d4 --- /dev/null +++ b/centreon-plugins/apps/protocols/telnet/plugin.pm @@ -0,0 +1,47 @@ +# +# Copyright 2016 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::telnet::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'scenario' => 'apps::protocols::telnet::mode::scenario', + ); + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check telnet server. + +=cut diff --git a/centreon-plugins/apps/protocols/udp/mode/connection.pm b/centreon-plugins/apps/protocols/udp/mode/connection.pm index 2228a8243..47ce6af46 100644 --- a/centreon-plugins/apps/protocols/udp/mode/connection.pm +++ b/centreon-plugins/apps/protocols/udp/mode/connection.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -67,7 +67,11 @@ sub check_options { sub run { my ($self, %options) = @_; - my $icmp_sock = new IO::Socket::INET(Proto=>"icmp"); + my $icmp_sock = new IO::Socket::INET(Proto => "icmp"); + if (!defined($icmp_sock)) { + $self->{output}->add_option_msg(short_msg => "Cannot create socket: $!"); + $self->{output}->option_exit(); + } my $read_set = new IO::Select(); $read_set->add($icmp_sock); @@ -78,7 +82,8 @@ sub run { $sock->send("Hello"); close($sock); - (my $new_readable) = IO::Select->select($read_set, undef, undef, $self->{option_results}->{timeout}); + + my ($new_readable) = IO::Select->select($read_set, undef, undef, $self->{option_results}->{timeout}); my $icmp_arrived = 0; foreach $sock (@$new_readable) { if ($sock == $icmp_sock) { @@ -89,8 +94,8 @@ sub run { close($icmp_sock); if ($icmp_arrived == 1) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Connection failed on port %s", $self->{option_results}->{port})); + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Connection failed on port %s", $self->{option_results}->{port})); } else { $self->{output}->output_add(severity => 'OK', short_msg => sprintf("Connection success on port %s", $self->{option_results}->{port})); diff --git a/centreon-plugins/apps/protocols/udp/plugin.pm b/centreon-plugins/apps/protocols/udp/plugin.pm index 946ef6133..e7f6d4c52 100644 --- a/centreon-plugins/apps/protocols/udp/plugin.pm +++ b/centreon-plugins/apps/protocols/udp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/protocols/x509/mode/validity.pm b/centreon-plugins/apps/protocols/x509/mode/validity.pm index e04750d08..1061fa6f3 100644 --- a/centreon-plugins/apps/protocols/x509/mode/validity.pm +++ b/centreon-plugins/apps/protocols/x509/mode/validity.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -33,11 +33,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.3'; + $self->{version} = '1.4'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => 443 }, + "port:s" => { name => 'port' }, + "servername:s" => { name => 'servername' }, "validity-mode:s" => { name => 'validity_mode' }, "warning-date:s" => { name => 'warning' }, "critical-date:s" => { name => 'critical' }, @@ -77,104 +78,85 @@ sub check_options { sub run { my ($self, %options) = @_; - #Global variables - my ($connection, $ctx, $ssl, $cert); + # Global variables - #Create Socket connection - $connection = IO::Socket::INET->new(PeerAddr => $self->{option_results}->{hostname}, - PeerPort => $self->{option_results}->{port}, - Timeout => $self->{option_results}->{timeout}, - ); - if (!defined($connection)) { + my $client = IO::Socket::SSL->new( + PeerHost => $self->{option_results}->{hostname}, + PeerPort => $self->{option_results}->{port}, + $self->{option_results}->{servername} ? ( SSL_hostname => $self->{option_results}->{servername} ):(), + ); + if (!defined($client)) { $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("%s", $!)); - $self->{output}->display(); - $self->{output}->exit(); - } else { - #Create SSL context - eval { $ctx = Net::SSLeay::CTX_new() }; - if ($@) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf ("%s", $!)); + short_msg => "failed to accept or ssl handshake: $!,$SSL_ERROR"); + $self->{output}->display(); + $self->{output}->exit() + } - $self->{output}->display(); - $self->{output}->exit() + #Retrieve Certificat + my $cert; + eval { $cert = $client->peer_certificate() }; + if ($@) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("%s", $@)); + $self->{output}->display(); + $self->{output}->exit() + } + + #Expiration Date + if ($self->{option_results}->{validity_mode} eq 'expiration') { + (my $notafterdate = Net::SSLeay::P_ASN1_UTCTIME_put2string(Net::SSLeay::X509_get_notAfter($cert))) =~ s/ GMT//; + my $daysbefore = int((&UnixDate(&ParseDate($notafterdate),"%s") - time) / 86400); + my $exit = $self->{perfdata}->threshold_check(value => $daysbefore, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Certificate expiration days: %s - Validity Date: %s", $daysbefore, $notafterdate)); + #Subject Name + } elsif ($self->{option_results}->{validity_mode} eq 'subject') { + my @subject_matched = (); + + my $subject = Net::SSLeay::X509_NAME_get_text_by_NID( + Net::SSLeay::X509_get_subject_name($cert), 13); # NID_CommonName + $subject =~s{\0$}{}; # work around Bug in Net::SSLeay <1.33 + if ($subject =~ /$self->{option_results}->{subjectname}/mi) { + push @subject_matched, $subject; + } else { + $self->{output}->output_add(long_msg => sprintf("Subject Name '%s' is also present in Certificate", $subject), debug => 1); } - - #Create SSL connection - Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL); - - eval { $ssl = Net::SSLeay::new($ctx) }; - if ($@) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("%s", $!)); - - $self->{output}->display(); - $self->{output}->exit() - } - - eval { Net::SSLeay::set_fd($ssl, fileno($connection)) }; - if ($@) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("%s", $!)); - - $self->{output}->display(); - $self->{output}->exit() - } - - eval { Net::SSLeay::connect($ssl) }; - if ($@) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("%s", $!)); - - $self->{output}->display(); - $self->{output}->exit() - } - - #Retrieve Certificat - $cert = Net::SSLeay::get_peer_certificate($ssl); - - #Expiration Date - if ($self->{option_results}->{validity_mode} eq 'expiration') { - (my $notafterdate = Net::SSLeay::P_ASN1_UTCTIME_put2string(Net::SSLeay::X509_get_notAfter($cert))) =~ s/ GMT//; - my $daysbefore = int((&UnixDate(&ParseDate($notafterdate),"%s") - time) / 86400); - my $exit = $self->{perfdata}->threshold_check(value => $daysbefore, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Certificate expiration days: %s - Validity Date: %s", $daysbefore, $notafterdate)); - - $self->{output}->display(); - $self->{output}->exit() - - #Subject Name - } elsif ($self->{option_results}->{validity_mode} eq 'subject') { - my $subject_name = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert)); - if ($subject_name =~ /$self->{option_results}->{subjectname}/mi) { - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("Subject Name '%s' is present in Certificate: %s", $self->{option_results}->{subjectname}, $subject_name)); + + my @subject_alt_names = Net::SSLeay::X509_get_subjectAltNames($cert); + for (my $i = 0; $i < $#subject_alt_names; $i++) { + next if ($i % 2 == 0); + if ($subject_alt_names[$i] =~ /$self->{option_results}->{subjectname}/mi) { + push @subject_matched, $subject_alt_names[$i]; } else { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Subject Name '%s' is not present in Certificate: %s", $self->{option_results}->{subjectname}, $subject_name)); + $self->{output}->output_add(long_msg => sprintf("Subject Name '%s' is also present in Certificate", $subject_alt_names[$i]), debug => 1); } + } - $self->{output}->display(); - $self->{output}->exit() + + + if (@subject_matched == 0) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("No Subject Name matched '%s' in Certificate", $self->{option_results}->{subjectname})); + } else { + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Subject Name [%s] is present in Certificate", join(', ', @subject_matched))); + } - #Issuer Name - } elsif ($self->{option_results}->{validity_mode} eq 'issuer') { - my $issuer_name = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($cert)); - if ($issuer_name =~ /$self->{option_results}->{issuername}/mi) { - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("Issuer Name '%s' is present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name)); - } else { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Issuer Name '%s' is not present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name)); - } - - $self->{output}->display(); - $self->{output}->exit() + #Issuer Name + } elsif ($self->{option_results}->{validity_mode} eq 'issuer') { + my $issuer_name = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($cert)); + if ($issuer_name =~ /$self->{option_results}->{issuername}/mi) { + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Issuer Name '%s' is present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name)); + } else { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Issuer Name '%s' is not present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name)); } } + + $self->{output}->display(); + $self->{output}->exit(); } 1; @@ -183,7 +165,7 @@ __END__ =head1 MODE -Check X509's certificate validity +Check X509's certificate validity (for SMTPS, POPS, IMAPS, HTTPS) =over 8 @@ -191,9 +173,13 @@ Check X509's certificate validity IP Addr/FQDN of the host +=item B<--servername> + +Servername of the host for SNI support (only with IO::Socket::SSL >= 1.56) (eg: foo.bar.com) + =item B<--port> -Port used by Server (Default: '443') +Port used by Server =item B<--validity-mode> @@ -210,7 +196,7 @@ Threshold critical in days (Days before expiration, eg: '30:' for 30 days before =item B<--subjectname> -Subject Name pattern +Subject Name pattern (support alternative subject name) =item B<--issuername> diff --git a/centreon-plugins/apps/protocols/x509/plugin.pm b/centreon-plugins/apps/protocols/x509/plugin.pm index 559b351b7..8cea1e568 100644 --- a/centreon-plugins/apps/protocols/x509/plugin.pm +++ b/centreon-plugins/apps/protocols/x509/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/rrdcached/mode/stats.pm b/centreon-plugins/apps/rrdcached/mode/stats.pm index b9224ad84..cae7b34bf 100644 --- a/centreon-plugins/apps/rrdcached/mode/stats.pm +++ b/centreon-plugins/apps/rrdcached/mode/stats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/rrdcached/plugin.pm b/centreon-plugins/apps/rrdcached/plugin.pm index c32da88fb..30e6fa135 100644 --- a/centreon-plugins/apps/rrdcached/plugin.pm +++ b/centreon-plugins/apps/rrdcached/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/selenium/mode/scenario.pm b/centreon-plugins/apps/selenium/mode/scenario.pm index 27ead607b..df5f90a2f 100644 --- a/centreon-plugins/apps/selenium/mode/scenario.pm +++ b/centreon-plugins/apps/selenium/mode/scenario.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/selenium/plugin.pm b/centreon-plugins/apps/selenium/plugin.pm index 499fc4630..c35e4b434 100644 --- a/centreon-plugins/apps/selenium/plugin.pm +++ b/centreon-plugins/apps/selenium/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/apps/tomcat/jmx/plugin.pm b/centreon-plugins/apps/tomcat/jmx/plugin.pm index 07bf9bcc5..945a2668b 100644 --- a/centreon-plugins/apps/tomcat/jmx/plugin.pm +++ b/centreon-plugins/apps/tomcat/jmx/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/tomcat/web/mode/applications.pm b/centreon-plugins/apps/tomcat/web/mode/applications.pm index d6aafb2fb..f360564b8 100644 --- a/centreon-plugins/apps/tomcat/web/mode/applications.pm +++ b/centreon-plugins/apps/tomcat/web/mode/applications.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -65,7 +65,7 @@ sub manage_selection { my $webcontent = $self->{http}->request(); - while ($webcontent =~ m/(.*):(.*):(.*):(.*)/g) { + while ($webcontent =~ /^(.*?):(.*?):(.*?):(.*)/mg) { my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4); next if (defined($self->{option_results}->{filter_path}) && $self->{option_results}->{filter_path} ne '' && diff --git a/centreon-plugins/apps/tomcat/web/mode/listapplication.pm b/centreon-plugins/apps/tomcat/web/mode/listapplication.pm index da7a45b36..64ddd53e8 100644 --- a/centreon-plugins/apps/tomcat/web/mode/listapplication.pm +++ b/centreon-plugins/apps/tomcat/web/mode/listapplication.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/tomcat/web/mode/memory.pm b/centreon-plugins/apps/tomcat/web/mode/memory.pm index 1a53a8189..59629286d 100644 --- a/centreon-plugins/apps/tomcat/web/mode/memory.pm +++ b/centreon-plugins/apps/tomcat/web/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/tomcat/web/mode/requestinfo.pm b/centreon-plugins/apps/tomcat/web/mode/requestinfo.pm index ca2a7f689..10fa3ecbe 100644 --- a/centreon-plugins/apps/tomcat/web/mode/requestinfo.pm +++ b/centreon-plugins/apps/tomcat/web/mode/requestinfo.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/tomcat/web/mode/sessions.pm b/centreon-plugins/apps/tomcat/web/mode/sessions.pm index e990e0063..d4edc59ad 100644 --- a/centreon-plugins/apps/tomcat/web/mode/sessions.pm +++ b/centreon-plugins/apps/tomcat/web/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/tomcat/web/mode/threads.pm b/centreon-plugins/apps/tomcat/web/mode/threads.pm index e9d6e1462..2b147db55 100644 --- a/centreon-plugins/apps/tomcat/web/mode/threads.pm +++ b/centreon-plugins/apps/tomcat/web/mode/threads.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/tomcat/web/mode/traffic.pm b/centreon-plugins/apps/tomcat/web/mode/traffic.pm index 219286a7a..dff575cfa 100644 --- a/centreon-plugins/apps/tomcat/web/mode/traffic.pm +++ b/centreon-plugins/apps/tomcat/web/mode/traffic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/tomcat/web/plugin.pm b/centreon-plugins/apps/tomcat/web/plugin.pm index c720937db..dff816934 100644 --- a/centreon-plugins/apps/tomcat/web/plugin.pm +++ b/centreon-plugins/apps/tomcat/web/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/varnish/local/mode/backend.pm b/centreon-plugins/apps/varnish/local/mode/backend.pm index 3dd639466..9cfbd889c 100644 --- a/centreon-plugins/apps/varnish/local/mode/backend.pm +++ b/centreon-plugins/apps/varnish/local/mode/backend.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/bans.pm b/centreon-plugins/apps/varnish/local/mode/bans.pm index 0f7762359..04772ebb7 100644 --- a/centreon-plugins/apps/varnish/local/mode/bans.pm +++ b/centreon-plugins/apps/varnish/local/mode/bans.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/cache.pm b/centreon-plugins/apps/varnish/local/mode/cache.pm index 487c6d5b6..c2d6f1859 100644 --- a/centreon-plugins/apps/varnish/local/mode/cache.pm +++ b/centreon-plugins/apps/varnish/local/mode/cache.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/connections.pm b/centreon-plugins/apps/varnish/local/mode/connections.pm index 338b58034..0aae615cd 100644 --- a/centreon-plugins/apps/varnish/local/mode/connections.pm +++ b/centreon-plugins/apps/varnish/local/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/dns.pm b/centreon-plugins/apps/varnish/local/mode/dns.pm index f6067f7bc..79449164b 100644 --- a/centreon-plugins/apps/varnish/local/mode/dns.pm +++ b/centreon-plugins/apps/varnish/local/mode/dns.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/esi.pm b/centreon-plugins/apps/varnish/local/mode/esi.pm index ca5a1d9f1..8c16a2812 100644 --- a/centreon-plugins/apps/varnish/local/mode/esi.pm +++ b/centreon-plugins/apps/varnish/local/mode/esi.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/fetch.pm b/centreon-plugins/apps/varnish/local/mode/fetch.pm index fe25ddc81..6d7b1e94b 100644 --- a/centreon-plugins/apps/varnish/local/mode/fetch.pm +++ b/centreon-plugins/apps/varnish/local/mode/fetch.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/hcb.pm b/centreon-plugins/apps/varnish/local/mode/hcb.pm index ed812f0e8..2c9f85231 100644 --- a/centreon-plugins/apps/varnish/local/mode/hcb.pm +++ b/centreon-plugins/apps/varnish/local/mode/hcb.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/n.pm b/centreon-plugins/apps/varnish/local/mode/n.pm index 0d94a6deb..065420b3a 100644 --- a/centreon-plugins/apps/varnish/local/mode/n.pm +++ b/centreon-plugins/apps/varnish/local/mode/n.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/objects.pm b/centreon-plugins/apps/varnish/local/mode/objects.pm index 76e4dd5c0..7d518cad6 100644 --- a/centreon-plugins/apps/varnish/local/mode/objects.pm +++ b/centreon-plugins/apps/varnish/local/mode/objects.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/sessions.pm b/centreon-plugins/apps/varnish/local/mode/sessions.pm index 0960a811f..9cb7fb78e 100644 --- a/centreon-plugins/apps/varnish/local/mode/sessions.pm +++ b/centreon-plugins/apps/varnish/local/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/shm.pm b/centreon-plugins/apps/varnish/local/mode/shm.pm index b0ccedcd4..a16511855 100644 --- a/centreon-plugins/apps/varnish/local/mode/shm.pm +++ b/centreon-plugins/apps/varnish/local/mode/shm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/sms.pm b/centreon-plugins/apps/varnish/local/mode/sms.pm index fcbbb9544..62c13c8f3 100644 --- a/centreon-plugins/apps/varnish/local/mode/sms.pm +++ b/centreon-plugins/apps/varnish/local/mode/sms.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/totals.pm b/centreon-plugins/apps/varnish/local/mode/totals.pm index b91c623d1..979835d7a 100644 --- a/centreon-plugins/apps/varnish/local/mode/totals.pm +++ b/centreon-plugins/apps/varnish/local/mode/totals.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/uptime.pm b/centreon-plugins/apps/varnish/local/mode/uptime.pm index 47e810662..288d17423 100644 --- a/centreon-plugins/apps/varnish/local/mode/uptime.pm +++ b/centreon-plugins/apps/varnish/local/mode/uptime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/vcl.pm b/centreon-plugins/apps/varnish/local/mode/vcl.pm index 1eff737d1..f248f7db2 100644 --- a/centreon-plugins/apps/varnish/local/mode/vcl.pm +++ b/centreon-plugins/apps/varnish/local/mode/vcl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/mode/workers.pm b/centreon-plugins/apps/varnish/local/mode/workers.pm index a41a848d4..1508f6cf7 100644 --- a/centreon-plugins/apps/varnish/local/mode/workers.pm +++ b/centreon-plugins/apps/varnish/local/mode/workers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/varnish/local/plugin.pm b/centreon-plugins/apps/varnish/local/plugin.pm index 1d2206017..a5fb9b8b1 100644 --- a/centreon-plugins/apps/varnish/local/plugin.pm +++ b/centreon-plugins/apps/varnish/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; -# $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/vmware/connector/custom/connector.pm b/centreon-plugins/apps/vmware/connector/custom/connector.pm index fb9dde9d2..aaae66180 100644 --- a/centreon-plugins/apps/vmware/connector/custom/connector.pm +++ b/centreon-plugins/apps/vmware/connector/custom/connector.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/alarmdatacenter.pm b/centreon-plugins/apps/vmware/connector/mode/alarmdatacenter.pm index d20de2db0..1df2dc068 100644 --- a/centreon-plugins/apps/vmware/connector/mode/alarmdatacenter.pm +++ b/centreon-plugins/apps/vmware/connector/mode/alarmdatacenter.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/alarmhost.pm b/centreon-plugins/apps/vmware/connector/mode/alarmhost.pm index 727e3acee..f965f44fd 100644 --- a/centreon-plugins/apps/vmware/connector/mode/alarmhost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/alarmhost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/countvmhost.pm b/centreon-plugins/apps/vmware/connector/mode/countvmhost.pm index 5083524c2..046d2b022 100644 --- a/centreon-plugins/apps/vmware/connector/mode/countvmhost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/countvmhost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/cpuhost.pm b/centreon-plugins/apps/vmware/connector/mode/cpuhost.pm index ee92743ab..26961e56b 100644 --- a/centreon-plugins/apps/vmware/connector/mode/cpuhost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/cpuhost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/cpuvm.pm b/centreon-plugins/apps/vmware/connector/mode/cpuvm.pm index 5ce6b2a83..ce6ec637a 100644 --- a/centreon-plugins/apps/vmware/connector/mode/cpuvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/cpuvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastorecountvm.pm b/centreon-plugins/apps/vmware/connector/mode/datastorecountvm.pm index 37ed14893..bacd304b3 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastorecountvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastorecountvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastorehost.pm b/centreon-plugins/apps/vmware/connector/mode/datastorehost.pm index 337a90f84..3c6673164 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastorehost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastorehost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastoreio.pm b/centreon-plugins/apps/vmware/connector/mode/datastoreio.pm index 0ebbffd57..d83a243e5 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastoreio.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastoreio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastoreiops.pm b/centreon-plugins/apps/vmware/connector/mode/datastoreiops.pm index 2940f5992..928f8414a 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastoreiops.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastoreiops.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastoresnapshot.pm b/centreon-plugins/apps/vmware/connector/mode/datastoresnapshot.pm index bde781c44..d8d2af24e 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastoresnapshot.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastoresnapshot.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastoreusage.pm b/centreon-plugins/apps/vmware/connector/mode/datastoreusage.pm index e25d45f6a..2109b7279 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastoreusage.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastoreusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/datastorevm.pm b/centreon-plugins/apps/vmware/connector/mode/datastorevm.pm index ca20b23cd..99ecde259 100644 --- a/centreon-plugins/apps/vmware/connector/mode/datastorevm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/datastorevm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -44,8 +44,10 @@ sub new { "display-description" => { name => 'display_description' }, "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, - "datastore-name:s" => { name => 'datastore_name' }, - "filter-datastore:s" => { name => 'filter_datastore' }, + "warning-max-total-latency:s" => { name => 'warning_max_total_latency' }, + "critical-max-total-latency:s" => { name => 'critical_max_total_latency' }, + "datastore-name:s" => { name => 'datastore_name' }, + "filter-datastore:s" => { name => 'filter_datastore' }, }); return $self; } @@ -54,7 +56,7 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - foreach my $label (('warning', 'critical')) { + foreach my $label (('warning', 'critical', 'warning_max_total_latency', 'critical_max_total_latency')) { if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) { my ($label_opt) = $label; $label_opt =~ tr/_/-/; @@ -146,6 +148,14 @@ Threshold warning in IOPs. Threshold critical in IOPs. +=item B<--warning-max-total-latency> + +Threshold warning in ms. + +=item B<--critical-max-total-latency> + +Threshold critical in ms. + =back =cut diff --git a/centreon-plugins/apps/vmware/connector/mode/devicevm.pm b/centreon-plugins/apps/vmware/connector/mode/devicevm.pm new file mode 100644 index 000000000..4a9d2270c --- /dev/null +++ b/centreon-plugins/apps/vmware/connector/mode/devicevm.pm @@ -0,0 +1,149 @@ +# +# Copyright 2016 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::vmware::connector::mode::devicevm; + +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 => + { + "vm-hostname:s" => { name => 'vm_hostname' }, + "filter" => { name => 'filter' }, + "scope-datacenter:s" => { name => 'scope_datacenter' }, + "scope-cluster:s" => { name => 'scope_cluster' }, + "scope-host:s" => { name => 'scope_host' }, + "filter-description:s" => { name => 'filter_description' }, + "disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' }, + "nopoweredon-status:s" => { name => 'nopoweredon_status', default => 'unknown' }, + "display-description" => { name => 'display_description' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "device:s" => { name => 'device' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach my $label (('warning', 'critical')) { + if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) { + my ($label_opt) = $label; + $label_opt =~ tr/_/-/; + $self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'."); + $self->{output}->option_exit(); + } + } + + if (!defined($self->{option_results}->{device}) || $self->{option_results}->{device} eq '') { + $self->{output}->add_option_msg(short_msg => "Please set device option."); + $self->{output}->option_exit(); + } + if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'."); + $self->{output}->option_exit(); + } + if ($self->{output}->is_litteral_status(status => $self->{option_results}->{nopoweredon_status}) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong nopoweredon-status option '" . $self->{option_results}->{nopoweredon_status} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + $self->{connector} = $options{custom}; + + $self->{connector}->add_params(params => $self->{option_results}, + command => 'devicevm'); + $self->{connector}->run(); +} + +1; + +__END__ + +=head1 MODE + +Check virtual machine device connected. + +=over 8 + +=item B<--vm-hostname> + +VM hostname to check. +If not set, we check all VMs. + +=item B<--filter> + +VM hostname is a regexp. + +=item B<--filter-description> + +Filter also virtual machines description (can be a regexp). + +=item B<--scope-datacenter> + +Search in following datacenter(s) (can be a regexp). + +=item B<--scope-cluster> + +Search in following cluster(s) (can be a regexp). + +=item B<--scope-host> + +Search in following host(s) (can be a regexp). + +=item B<--disconnect-status> + +Status if VM disconnected (default: 'unknown'). + +=item B<--nopoweredon-status> + +Status if VM is not poweredOn (default: 'unknown'). + +=item B<--display-description> + +Display virtual machine description. + +=item B<--warning> + +Threshold warning in bytes per seconds. + +=item B<--critical> + +Threshold critical in bytes per seconds. + +=item B<--device> + +Device to check (Required) (Example: --device='VirtualCdrom'). + +=back + +=cut diff --git a/centreon-plugins/apps/vmware/connector/mode/getmap.pm b/centreon-plugins/apps/vmware/connector/mode/getmap.pm index 2eb25db92..aaa242c35 100644 --- a/centreon-plugins/apps/vmware/connector/mode/getmap.pm +++ b/centreon-plugins/apps/vmware/connector/mode/getmap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/healthhost.pm b/centreon-plugins/apps/vmware/connector/mode/healthhost.pm index 9800f0718..c6b42a8fd 100644 --- a/centreon-plugins/apps/vmware/connector/mode/healthhost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/healthhost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/limitvm.pm b/centreon-plugins/apps/vmware/connector/mode/limitvm.pm index 0c5abe882..11b0343e8 100644 --- a/centreon-plugins/apps/vmware/connector/mode/limitvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/limitvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/listdatacenters.pm b/centreon-plugins/apps/vmware/connector/mode/listdatacenters.pm index 20f1661ea..c4a0669b8 100644 --- a/centreon-plugins/apps/vmware/connector/mode/listdatacenters.pm +++ b/centreon-plugins/apps/vmware/connector/mode/listdatacenters.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/listdatastores.pm b/centreon-plugins/apps/vmware/connector/mode/listdatastores.pm index 93c00ca5e..21b0d71c0 100644 --- a/centreon-plugins/apps/vmware/connector/mode/listdatastores.pm +++ b/centreon-plugins/apps/vmware/connector/mode/listdatastores.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/listnichost.pm b/centreon-plugins/apps/vmware/connector/mode/listnichost.pm index cf6c8aff4..0229f6c43 100644 --- a/centreon-plugins/apps/vmware/connector/mode/listnichost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/listnichost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/maintenancehost.pm b/centreon-plugins/apps/vmware/connector/mode/maintenancehost.pm index cdb6b6cf8..aa56d085f 100644 --- a/centreon-plugins/apps/vmware/connector/mode/maintenancehost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/maintenancehost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm b/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm index d2dc17cc5..09964fecd 100644 --- a/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -38,8 +38,10 @@ sub new { "scope-datacenter:s" => { name => 'scope_datacenter' }, "scope-cluster:s" => { name => 'scope_cluster' }, "disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' }, - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "warning-state:s" => { name => 'warning_state' }, + "critical-state:s" => { name => 'critical_state' }, }); return $self; } @@ -48,13 +50,13 @@ 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(); + foreach my $label (('warning', 'critical', 'warning_state', 'critical_state')) { + if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) { + my ($label_opt) = $label; + $label_opt =~ tr/_/-/; + $self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'."); + $self->{output}->option_exit(); + } } if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'."); @@ -110,6 +112,14 @@ Threshold warning in percent. Threshold critical in percent. +=item B<--warning-state> + +Threshold warning. For state != 'high': --warning-state=0 + +=item B<--critical-state> + +Threshold critical. For state != 'high': --warning-state=0 + =back =cut diff --git a/centreon-plugins/apps/vmware/connector/mode/memoryvm.pm b/centreon-plugins/apps/vmware/connector/mode/memoryvm.pm index 50567b87d..86805ccf0 100644 --- a/centreon-plugins/apps/vmware/connector/mode/memoryvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/memoryvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/nethost.pm b/centreon-plugins/apps/vmware/connector/mode/nethost.pm index ee8bfbf85..84498c001 100644 --- a/centreon-plugins/apps/vmware/connector/mode/nethost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/nethost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/servicehost.pm b/centreon-plugins/apps/vmware/connector/mode/servicehost.pm index 6e9ee4a86..05cff7c79 100644 --- a/centreon-plugins/apps/vmware/connector/mode/servicehost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/servicehost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/snapshotvm.pm b/centreon-plugins/apps/vmware/connector/mode/snapshotvm.pm index 1f89efbfe..cb9147bd3 100644 --- a/centreon-plugins/apps/vmware/connector/mode/snapshotvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/snapshotvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/statconnectors.pm b/centreon-plugins/apps/vmware/connector/mode/statconnectors.pm index e3cd0b1a2..186be8fce 100644 --- a/centreon-plugins/apps/vmware/connector/mode/statconnectors.pm +++ b/centreon-plugins/apps/vmware/connector/mode/statconnectors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/statushost.pm b/centreon-plugins/apps/vmware/connector/mode/statushost.pm index 0596c5005..88d1fd01b 100644 --- a/centreon-plugins/apps/vmware/connector/mode/statushost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/statushost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/statusvm.pm b/centreon-plugins/apps/vmware/connector/mode/statusvm.pm index 30b7d58f2..1dfe69102 100644 --- a/centreon-plugins/apps/vmware/connector/mode/statusvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/statusvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/swaphost.pm b/centreon-plugins/apps/vmware/connector/mode/swaphost.pm index e62846f18..d7fec9e09 100644 --- a/centreon-plugins/apps/vmware/connector/mode/swaphost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/swaphost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/swapvm.pm b/centreon-plugins/apps/vmware/connector/mode/swapvm.pm index 8411fdcd9..f24b04696 100644 --- a/centreon-plugins/apps/vmware/connector/mode/swapvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/swapvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/thinprovisioningvm.pm b/centreon-plugins/apps/vmware/connector/mode/thinprovisioningvm.pm index 5f17ff609..e3cfb383e 100644 --- a/centreon-plugins/apps/vmware/connector/mode/thinprovisioningvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/thinprovisioningvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/timehost.pm b/centreon-plugins/apps/vmware/connector/mode/timehost.pm index ab46109f5..f1dce6305 100644 --- a/centreon-plugins/apps/vmware/connector/mode/timehost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/timehost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -35,8 +35,11 @@ sub new { { "esx-hostname:s" => { name => 'esx_hostname' }, "filter" => { name => 'filter' }, + "disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' }, "scope-datacenter:s" => { name => 'scope_datacenter' }, "scope-cluster:s" => { name => 'scope_cluster' }, + "warning-time:s" => { name => 'warning_time' }, + "critical-time:s" => { name => 'critical_time' }, }); return $self; } @@ -44,13 +47,25 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + + foreach my $label (('warning_time', 'critical_time')) { + if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) { + my ($label_opt) = $label; + $label_opt =~ tr/_/-/; + $self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'."); + $self->{output}->option_exit(); + } + } + if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'."); + $self->{output}->option_exit(); + } } sub run { my ($self, %options) = @_; $self->{connector} = $options{custom}; - $self->{connector}->set_discovery(); $self->{connector}->add_params(params => $self->{option_results}, command => 'timehost'); $self->{connector}->run(); @@ -83,6 +98,17 @@ Search in following datacenter(s) (can be a regexp). Search in following cluster(s) (can be a regexp). +=item B<--disconnect-status> + +Status if VM disconnected (default: 'unknown'). + +=item B<--warning-time> + +Threshold warning in seconds. + +=item B<--critical-time> + +Threshold critical in seconds. =back diff --git a/centreon-plugins/apps/vmware/connector/mode/toolsvm.pm b/centreon-plugins/apps/vmware/connector/mode/toolsvm.pm index 563fba0e0..1ca302f32 100644 --- a/centreon-plugins/apps/vmware/connector/mode/toolsvm.pm +++ b/centreon-plugins/apps/vmware/connector/mode/toolsvm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/uptimehost.pm b/centreon-plugins/apps/vmware/connector/mode/uptimehost.pm index 7c54bede4..cebe13380 100644 --- a/centreon-plugins/apps/vmware/connector/mode/uptimehost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/uptimehost.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/mode/vmoperationcluster.pm b/centreon-plugins/apps/vmware/connector/mode/vmoperationcluster.pm index e92509736..a86967c9b 100644 --- a/centreon-plugins/apps/vmware/connector/mode/vmoperationcluster.pm +++ b/centreon-plugins/apps/vmware/connector/mode/vmoperationcluster.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/connector/plugin.pm b/centreon-plugins/apps/vmware/connector/plugin.pm index f7196b9fc..9eeb4c665 100644 --- a/centreon-plugins/apps/vmware/connector/plugin.pm +++ b/centreon-plugins/apps/vmware/connector/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( @@ -43,7 +42,8 @@ sub new { 'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops', 'datastore-snapshot' => 'apps::vmware::connector::mode::datastoresnapshot', 'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage', - 'datastore-vm' => 'apps::vmware::connector::mode::datastorevm', + 'datastore-vm' => 'apps::vmware::connector::mode::datastorevm', + 'device-vm' => 'apps::vmware::connector::mode::devicevm', 'getmap' => 'apps::vmware::connector::mode::getmap', 'health-host' => 'apps::vmware::connector::mode::healthhost', 'limit-vm' => 'apps::vmware::connector::mode::limitvm', diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/cim_card.pm b/centreon-plugins/apps/vmware/wsman/mode/components/cim_card.pm index de4df27ca..d1cfefef1 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/cim_card.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/cim_card.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/cim_computersystem.pm b/centreon-plugins/apps/vmware/wsman/mode/components/cim_computersystem.pm index 8b02cfbc5..4586b8340 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/cim_computersystem.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/cim_computersystem.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/cim_memory.pm b/centreon-plugins/apps/vmware/wsman/mode/components/cim_memory.pm index 9994b2a21..fcbb0f477 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/cim_memory.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/cim_memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/cim_numericsensor.pm b/centreon-plugins/apps/vmware/wsman/mode/components/cim_numericsensor.pm index c0f8d0325..dab17caf7 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/cim_numericsensor.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/cim_numericsensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/cim_processor.pm b/centreon-plugins/apps/vmware/wsman/mode/components/cim_processor.pm index e2b6f7785..a80d6e4b6 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/cim_processor.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/cim_processor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/cim_recordlog.pm b/centreon-plugins/apps/vmware/wsman/mode/components/cim_recordlog.pm index 24f279fff..dbc5fb1b1 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/cim_recordlog.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/cim_recordlog.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/omc_discretesensor.pm b/centreon-plugins/apps/vmware/wsman/mode/components/omc_discretesensor.pm index 524735c6a..97f0cafc8 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/omc_discretesensor.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/omc_discretesensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/omc_fan.pm b/centreon-plugins/apps/vmware/wsman/mode/components/omc_fan.pm index 55a034b4d..ee3922da0 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/omc_fan.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/omc_fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/omc_psu.pm b/centreon-plugins/apps/vmware/wsman/mode/components/omc_psu.pm index b720a66d5..ea48ddd22 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/omc_psu.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/omc_psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/resources.pm b/centreon-plugins/apps/vmware/wsman/mode/components/resources.pm index 706877fb9..02e98f853 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/resources.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/resources.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_battery.pm b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_battery.pm index bd69cc7ce..254a5c231 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_battery.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_battery.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_controller.pm b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_controller.pm index f254f5790..bd3ac5478 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_controller.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_controller.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_sassataport.pm b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_sassataport.pm index a95dc3069..2fe5c0bfe 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_sassataport.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_sassataport.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storageextent.pm b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storageextent.pm index 5d4acee7c..c78359b77 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storageextent.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storageextent.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storagevolume.pm b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storagevolume.pm index 1a2e741ce..bcfeed42e 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storagevolume.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/components/vmware_storagevolume.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/mode/hardware.pm b/centreon-plugins/apps/vmware/wsman/mode/hardware.pm index bcac00b63..f4b4f247e 100644 --- a/centreon-plugins/apps/vmware/wsman/mode/hardware.pm +++ b/centreon-plugins/apps/vmware/wsman/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/vmware/wsman/plugin.pm b/centreon-plugins/apps/vmware/wsman/plugin.pm index f29127443..6e99d865d 100644 --- a/centreon-plugins/apps/vmware/wsman/plugin.pm +++ b/centreon-plugins/apps/vmware/wsman/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/voip/asterisk/remote/lib/ami.pm b/centreon-plugins/apps/voip/asterisk/remote/lib/ami.pm index bf3990991..87efb753c 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/lib/ami.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/lib/ami.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/voip/asterisk/remote/mode/activecalls.pm b/centreon-plugins/apps/voip/asterisk/remote/mode/activecalls.pm index 18a6273eb..4cf3828ec 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/mode/activecalls.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/mode/activecalls.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/voip/asterisk/remote/mode/dahdistatus.pm b/centreon-plugins/apps/voip/asterisk/remote/mode/dahdistatus.pm index 0abf5cb83..e165c4d15 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/mode/dahdistatus.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/mode/dahdistatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/voip/asterisk/remote/mode/externalcalls.pm b/centreon-plugins/apps/voip/asterisk/remote/mode/externalcalls.pm index c1be48bba..2d699bd24 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/mode/externalcalls.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/mode/externalcalls.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/voip/asterisk/remote/mode/showpeers.pm b/centreon-plugins/apps/voip/asterisk/remote/mode/showpeers.pm index e661cfbe1..92c5d7959 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/mode/showpeers.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/mode/showpeers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/apps/voip/asterisk/remote/plugin.pm b/centreon-plugins/apps/voip/asterisk/remote/plugin.pm index 423a65761..eb0cc05fc 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/plugin.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '1.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/voip/asterisk/snmp/mode/activecalls.pm b/centreon-plugins/apps/voip/asterisk/snmp/mode/activecalls.pm index f0e473de3..bb0f76135 100644 --- a/centreon-plugins/apps/voip/asterisk/snmp/mode/activecalls.pm +++ b/centreon-plugins/apps/voip/asterisk/snmp/mode/activecalls.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,7 +64,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my ($result, $value); diff --git a/centreon-plugins/apps/voip/asterisk/snmp/mode/externalcalls.pm b/centreon-plugins/apps/voip/asterisk/snmp/mode/externalcalls.pm index 3e06cd4a6..c26fabdc7 100644 --- a/centreon-plugins/apps/voip/asterisk/snmp/mode/externalcalls.pm +++ b/centreon-plugins/apps/voip/asterisk/snmp/mode/externalcalls.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -82,7 +82,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my ($result, $value); diff --git a/centreon-plugins/apps/voip/asterisk/snmp/plugin.pm b/centreon-plugins/apps/voip/asterisk/snmp/plugin.pm index 25df7f59c..93e7e5e5f 100644 --- a/centreon-plugins/apps/voip/asterisk/snmp/plugin.pm +++ b/centreon-plugins/apps/voip/asterisk/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/apps/voip/cisco/meetingplace/mode/audiolicenses.pm b/centreon-plugins/apps/voip/cisco/meetingplace/mode/audiolicenses.pm index 85f1ffbf9..d9ca5ddd7 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/audiolicenses.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/audiolicenses.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # Nombre de ports audio utilise diff --git a/centreon-plugins/apps/voip/cisco/meetingplace/mode/audioports.pm b/centreon-plugins/apps/voip/cisco/meetingplace/mode/audioports.pm index 7285994c0..10bdeff45 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/audioports.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/audioports.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # Nombre de ports audio utilise diff --git a/centreon-plugins/apps/voip/cisco/meetingplace/mode/videolicenses.pm b/centreon-plugins/apps/voip/cisco/meetingplace/mode/videolicenses.pm index 7b4b60c32..892ee52cf 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/videolicenses.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/videolicenses.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # Nombre de ports audio utilise diff --git a/centreon-plugins/apps/voip/cisco/meetingplace/mode/videoports.pm b/centreon-plugins/apps/voip/cisco/meetingplace/mode/videoports.pm index bd72f09cf..222248e93 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/videoports.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/videoports.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # Nombre de ports video utilise diff --git a/centreon-plugins/apps/voip/cisco/meetingplace/plugin.pm b/centreon-plugins/apps/voip/cisco/meetingplace/plugin.pm index e00141893..e27739863 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/plugin.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/component.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/component.pm new file mode 100644 index 000000000..50a3bc195 --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/component.pm @@ -0,0 +1,78 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::component; + +use strict; +use warnings; +use centreon::plugins::misc; + +my %map_status = ( + 1 => 'unknown', + 2 => 'unused', + 3 => 'ok', + 4 => 'warning', + 5 => 'failed', +); + +# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB' +my $mapping = { + componentDisplayName => { oid => '.1.3.6.1.4.1.3764.1.1.30.10.1.3' }, + componentStatus => { oid => '.1.3.6.1.4.1.3764.1.1.30.10.1.8', map => \%map_status }, +}; +my $oid_componentEntry = '.1.3.6.1.4.1.3764.1.1.30.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_componentEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking components"); + $self->{components}->{component} = {name => 'components', total => 0, skip => 0}; + return if ($self->check_filter(section => 'component')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_componentEntry}})) { + next if ($oid !~ /^$mapping->{componentStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_componentEntry}, instance => $instance); + + next if ($self->check_filter(section => 'component', instance => $result->{componentDisplayName})); + $self->{components}->{component}->{total}++; + + $result->{componentDisplayName} =~ s/\s+/ /g; + $result->{componentDisplayName} = centreon::plugins::misc::trim($result->{componentDisplayName}); + $self->{output}->output_add(long_msg => sprintf("component '%s' status is %s [instance: %s].", + $result->{componentDisplayName}, $result->{componentStatus}, + $result->{componentDisplayName} + )); + my $exit = $self->get_severity(section => 'component', value => $result->{componentStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Component '%s' status is %s", + $result->{componentDisplayName}, $result->{componentStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/fan.pm new file mode 100644 index 000000000..2b0d91828 --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/fan.pm @@ -0,0 +1,117 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'nominal', + 2 => 'warningLow', 3 => 'warningHigh', + 4 => 'alarmLow', 5 => 'alarmHigh', + 6 => 'notInstalled', 7 => 'noData', +); + +my $mapping = { + coolingFanName => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.2' }, + coolingFanStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.3', map => \%map_status }, + coolingFanRPM => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.4' }, + coolingFanWarningHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.8' }, + coolingFanNominalHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.6' }, + coolingFanNominalLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.5' }, + coolingFanWarningLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.7' }, + coolingFanLocation => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.9' }, +}; +my $oid_coolingFanEntry = '.1.3.6.1.4.1.3764.1.1.200.200.40.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_coolingFanEntry }; +} + +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_coolingFanEntry}})) { + next if ($oid !~ /^$mapping->{coolingFanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingFanEntry}, instance => $instance); + + $result->{coolingFanName} =~ s/\s+/ /g; + $result->{coolingFanName} = centreon::plugins::misc::trim($result->{coolingFanName}); + $result->{coolingFanLocation} =~ s/,/_/g; + my $id = $result->{coolingFanName} . '_' . $result->{coolingFanLocation}; + + next if ($self->check_filter(section => 'fan', instance => $id)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s] [value = %s]", + $id, $result->{coolingFanStatus}, $id, + $result->{coolingFanRPM})); + + my $exit = $self->get_severity(label => 'sensor', section => 'fan', value => $result->{coolingFanStatus}); + 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'", $id, $result->{coolingFanStatus})); + next; + } + + if (defined($result->{coolingFanRPM}) && $result->{coolingFanRPM} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{coolingFanRPM}); + if ($checked == 0) { + $result->{coolingFanNominalLo} = (defined($result->{coolingFanNominalLo}) && $result->{coolingFanNominalLo} =~ /[0-9]/) ? + $result->{coolingFanNominalLo} : ''; + $result->{coolingFanWarningLo} = (defined($result->{coolingFanWarningLo}) && $result->{coolingFanWarningLo} =~ /[0-9]/) ? + $result->{coolingFanWarningLo} : ''; + $result->{coolingFanNominalHi} = (defined($result->{coolingFanNominalHi}) && $result->{coolingFanNominalHi} =~ /[0-9]/) ? + $result->{coolingFanNominalHi} : ''; + $result->{coolingFanWarningHi} = (defined($result->{coolingFanWarningHi}) && $result->{coolingFanWarningHi} =~ /[0-9]/) ? + $result->{coolingFanWarningHi} : ''; + my $warn_th = $result->{coolingFanNominalLo} . ':' . $result->{coolingFanNominalHi}; + my $crit_th = $result->{coolingFanWarningLo} . ':' . $result->{coolingFanWarningHi}; + $self->{perfdata}->threshold_validate(label => 'warning-fan-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-fan-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{coolingFanRPM}, threshold => [ { label => 'critical-fan-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-fan-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-fan-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-fan-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' is %s rpm", $id, $result->{coolingFanRPM})); + } + $self->{output}->perfdata_add(label => 'fan_' . $id, unit => 'rpm', + value => $result->{coolingFanRPM}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/global.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/global.pm new file mode 100644 index 000000000..29914680d --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/global.pm @@ -0,0 +1,91 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::global; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'good', + 2 => 'failed', + 3 => 'degraded', + 4 => 'warning', + 5 => 'informational', + 6 => 'unknown', + 7 => 'invalid', +); +my %map_agent_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'non-critical', + 5 => 'critical', + 6 => 'non-recoverable', +); + +# In MIB 'ADIC-TAPE-LIBRARY-MIB' +my $mapping = { + GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status }, # libraryGlobalStatus +}; +# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB' +my $mapping2 = { + GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.1.20.1', map => \%map_agent_status }, # agentGlobalStatus +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{GlobalStatus}->{oid} }, + { oid => $mapping2->{GlobalStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking global"); + $self->{components}->{global} = {name => 'global', total => 0, skip => 0}; + return if ($self->check_filter(section => 'global')); + + my $instance = '0'; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{GlobalStatus}->{oid}}, instance => $instance); + if (!defined($result->{GlobalStatus})) { + $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{GlobalStatus}->{oid}}, instance => $instance); + } + if (!defined($result->{GlobalStatus})) { + $self->{output}->output_add(long_msg => "skipping global status: no value."); + return ; + } + + return if ($self->check_filter(section => 'global', instance => $instance)); + $self->{components}->{global}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("library global status is %s [instance: %s].", + $result->{GlobalStatus}, $instance + )); + my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{GlobalStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Library global status is %s", + $result->{GlobalStatus})); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm new file mode 100644 index 000000000..650f04205 --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm @@ -0,0 +1,96 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::physicaldrive; + +use strict; +use warnings; +use centreon::plugins::misc; + +my %map_status = ( + 1 => 'good', + 2 => 'failed', + 3 => 'degraded', + 4 => 'warning', + 5 => 'informational', + 6 => 'unknown', + 7 => 'invalid', +); + +my $mapping = { + # 'ADIC-TAPE-LIBRARY-MIB' + adic_tape => { + phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' }, + phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' }, + phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status }, + }, + # 'ADIC-MANAGEMENT-MIB' + adic_management => { + phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.8' }, + phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.7' }, # phDriveProduct + phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.31', map => \%map_status }, + } +}; + +my %oid_table = ( + adic_tape => '.1.3.6.1.4.1.3764.1.10.10.11.3.1', # physicalDriveEntry + adic_management => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1', # phDriveEntry +); + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_table{adic_tape} }, { oid => $oid_table{adic_management} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking physical drives"); + $self->{components}->{physicaldrive} = {name => 'physical drives', total => 0, skip => 0}; + return if ($self->check_filter(section => 'physicaldrive')); + + foreach my $label (keys %{$mapping}) { + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_table{$label}}})) { + next if ($oid !~ /^$mapping->{$label}->{phDriveRasStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping->{$label}, results => $self->{results}->{$oid_table{$label}}, instance => $instance); + + $result->{phDriveSerialNumber} = centreon::plugins::misc::trim($result->{phDriveSerialNumber}); + + next if ($self->check_filter(section => 'physicaldrive', instance => $result->{phDriveSerialNumber})); + $self->{components}->{physicaldrive}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].", + $result->{phDriveSerialNumber}, $result->{phDriveRasStatus}, + $result->{phDriveSerialNumber}, centreon::plugins::misc::trim($result->{phDriveModel}), + centreon::plugins::misc::trim($result->{phDriveSerialNumber}) + )); + my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', value => $result->{phDriveRasStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Physical drive '%s' status is %s", + $result->{phDriveSerialNumber}, $result->{phDriveRasStatus})); + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/subsystem.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/subsystem.pm new file mode 100644 index 000000000..d46098ce8 --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/subsystem.pm @@ -0,0 +1,84 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::subsystem; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'good', + 2 => 'failed', + 3 => 'degraded', + 4 => 'warning', + 5 => 'informational', + 6 => 'unknown', + 7 => 'invalid', +); + +# In MIB 'ADIC-TAPE-LIBRARY-MIB' +my $mapping = { + powerStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.1', map => \%map_status, label => 'power', instance => 1 }, + coolingStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.2', map => \%map_status, label => 'cooling', instance => 2 }, + controlStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.3', map => \%map_status, label => 'control', instance => 3 }, + connectivityStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.4', map => \%map_status, label => 'connectivity', instance => 4 }, + roboticsStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.5', map => \%map_status, label => 'robotics', instance => 5 }, + mediaStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.6', map => \%map_status, label => 'media', instance => 6 }, + driveStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.6', map => \%map_status, label => 'drive', instance => 7 }, +}; +my $oid_rasSubSystem = '.1.3.6.1.4.1.3764.1.10.10.12'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_rasSubSystem }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking subsystems"); + $self->{components}->{subsystem} = {name => 'subsystems', total => 0, skip => 0}; + return if ($self->check_filter(section => 'subsystem')); + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rasSubSystem}, instance => '0'); + foreach my $name (keys %$mapping) { + if (!defined($result->{$name})) { + $self->{output}->output_add(long_msg => sprintf("skipping %s status: no value.", $mapping->{$name}->{label})); + next; + } + + next if ($self->check_filter(section => 'subsystem', instance => $mapping->{$name}->{instance})); + $self->{components}->{subsystem}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("%s status is %s [instance: %s].", + $mapping->{$name}->{label}, $result->{$name}, + $mapping->{$name}->{instance} + )); + my $exit = $self->get_severity(section => 'subsystem', label => 'default', value => $result->{$name}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%s status is %s", + ucfirst($mapping->{$name}->{label}), $result->{$name})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..49821f26a --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/temperature.pm @@ -0,0 +1,117 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::components::temperature; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'nominal', + 2 => 'warningLow', 3 => 'warningHigh', + 4 => 'alarmLow', 5 => 'alarmHigh', + 6 => 'notInstalled', 7 => 'noData', +); + +my $mapping = { + temperatureSensorName => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.2' }, + temperatureSensorStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.3', map => \%map_status }, + temperatureSensorDegreesCelsius => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.4' }, + temperatureSensorWarningHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.8' }, + temperatureSensorNominalHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.6' }, + temperatureSensorNominalLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.5' }, + temperatureSensorWarningLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.7' }, + temperatureSensorLocation => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.9' }, +}; +my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.3764.1.1.200.200.30.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_temperatureSensorEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureSensorEntry}})) { + next if ($oid !~ /^$mapping->{temperatureSensorStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureSensorEntry}, instance => $instance); + + $result->{temperatureSensorName} =~ s/\s+/ /g; + $result->{temperatureSensorName} = centreon::plugins::misc::trim($result->{temperatureSensorName}); + $result->{temperatureSensorLocation} =~ s/,/_/g; + my $id = $result->{temperatureSensorName} . '_' . $result->{temperatureSensorLocation}; + + next if ($self->check_filter(section => 'temperature', instance => $id)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]", + $id, $result->{temperatureSensorStatus}, $id, + $result->{temperatureSensorDegreesCelsius})); + + my $exit = $self->get_severity(label => 'sensor', section => 'temperature', value => $result->{temperatureSensorStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $id, $result->{temperatureSensorStatus})); + next; + } + + if (defined($result->{temperatureSensorDegreesCelsius}) && $result->{temperatureSensorDegreesCelsius} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureSensorDegreesCelsius}); + if ($checked == 0) { + $result->{temperatureSensorNominalLo} = (defined($result->{temperatureSensorNominalLo}) && $result->{temperatureSensorNominalLo} =~ /[0-9]/) ? + $result->{temperatureSensorNominalLo} : ''; + $result->{temperatureSensorWarningLo} = (defined($result->{temperatureSensorWarningLo}) && $result->{temperatureSensorWarningLo} =~ /[0-9]/) ? + $result->{temperatureSensorWarningLo} : ''; + $result->{temperatureSensorNominalHi} = (defined($result->{temperatureSensorNominalHi}) && $result->{temperatureSensorNominalHi} =~ /[0-9]/) ? + $result->{temperatureSensorNominalHi} : ''; + $result->{temperatureSensorWarningHi} = (defined($result->{temperatureSensorWarningHi}) && $result->{temperatureSensorWarningHi} =~ /[0-9]/) ? + $result->{temperatureSensorWarningHi} : ''; + my $warn_th = $result->{temperatureSensorNominalLo} . ':' . $result->{temperatureSensorNominalHi}; + my $crit_th = $result->{temperatureSensorWarningLo} . ':' . $result->{temperatureSensorWarningHi}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{temperatureSensorDegreesCelsius}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $id, $result->{temperatureSensorDegreesCelsius})); + } + $self->{output}->perfdata_add(label => 'temp_' . $id, unit => 'C', + value => $result->{temperatureSensorDegreesCelsius}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/adic/tape/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/adic/tape/snmp/mode/hardware.pm new file mode 100644 index 000000000..76683d9fd --- /dev/null +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/hardware.pm @@ -0,0 +1,137 @@ +# +# Copyright 2016 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 centreon::common::adic::tape::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(global|physicaldrive|subsystem|component|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['good', 'OK'], + ['failed', 'CRITICAL'], + ['degraded', 'WARNING'], + ['warning', 'WARNING'], + ['informational', 'OK'], + ['unknown', 'UNKNOWN'], + ['invalid', 'CRITICAL'], + + ['other', 'OK'], + ['ok', 'OK'], + ['non-critical', 'WARNING'], + ['critical', 'CRITICAL'], + ['non-recoverable', 'CRITICAL'], + ], + component => [ + ['unknown', 'UNKNOWN'], + ['unused', 'OK'], + ['ok', 'OK'], + ['warning', 'WARNING'], + ['failed', 'CRITICAL'], + ], + sensor => [ + ['nominal', 'OK'], + ['warningLow', 'WARNING'], + ['warningHigh', 'CRITICAL'], + ['alarmLow', 'CRITICAL'], + ['alarmHigh', 'CRITICAL'], + ['notInstalled', 'OK'], + ['noData', 'OK'], + ], + }; + + $self->{components_path} = 'centreon::common::adic::tape::snmp::mode::components'; + $self->{components_module} = ['global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=subsystem) +Can also exclude specific instance: --filter=physicaldrive,1 + +=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='physicaldrive,OK,invalid' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelinterference.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelinterference.pm index ee3b1d882..0a38851eb 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelinterference.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelinterference.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelnoise.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelnoise.pm index 2dbce5b9d..1aba195ad 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelnoise.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/apchannelnoise.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/apstatus.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/apstatus.pm index fabc1ca98..9fca60b16 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/apstatus.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/apstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -140,7 +140,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); @@ -149,7 +149,7 @@ sub check_options { sub skip_global { my ($self, %options) = @_; - scalar(keys %{$self->{ap}}) > 1 ? return(0) : return(1); + scalar(keys %{$self->{ap}}) == 1 ? return(1) : return(0); } sub prefix_ap_output { @@ -208,7 +208,7 @@ sub manage_selection { my $result3 = $options{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.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $result->{bsnAPName} . "': no matching filter.", debug => 1); next; } @@ -216,12 +216,11 @@ sub manage_selection { $self->{global}->{$result2->{bsnAPOperationStatus}}++; $self->{ap}->{$instance} = { display => $result->{bsnAPName}, - opstatus => $result2->{bsnAPOperationStatus}, admstatus => $result3->{bsnAPAdminStatus}}; + opstatus => $result2->{bsnAPOperationStatus}, admstatus => $result3->{bsnAPAdminStatus}}; } if (scalar(keys %{$self->{ap}}) <= 0) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'No AP associated (can be: slave wireless controller or your filter)'); + $self->{output}->output_add(long_msg => 'no AP associated (can be: slave wireless controller or your filter)'); } } diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/apusers.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/apusers.pm index 301becd8b..89d756d16 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/apusers.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/apusers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,6 +30,8 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, + { name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' }, + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by AP are ok' }, ]; $self->{maps_counters}->{global} = [ { label => 'total', set => { @@ -123,6 +125,42 @@ sub set_counters { } }, ]; + + $self->{maps_counters}->{ssid} = [ + { label => 'ssid', set => { + key_values => [ { name => 'total' }, { name => 'display' } ], + output_template => 'users : %s', + perfdatas => [ + { label => 'ssid', value => 'total_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; + + $self->{maps_counters}->{ap} = [ + { label => 'ap', set => { + key_values => [ { name => 'total' }, { name => 'display' } ], + output_template => 'users : %s', + perfdatas => [ + { label => 'ap', value => 'total_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_ssid_output { + my ($self, %options) = @_; + + return "SSID '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "AP '" . $options{instance_value}->{display} . "' "; } sub new { @@ -133,7 +171,8 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "filter-ssid:s" => { name => 'filter_ssid' }, + "filter-ssid:s" => { name => 'filter_ssid' }, + "filter-ap:s" => { name => 'filter_ap' }, }); return $self; @@ -156,8 +195,14 @@ my $mapping = { my $mapping2 = { bsnMobileStationSsid => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.7' }, }; +my $mapping3 = { + bsnDot11EssNumberOfMobileStations => { oid => '.1.3.6.1.4.1.14179.2.1.1.1.38' }, +}; my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3'; +my $oid_bsnDot11EssSsid = '.1.3.6.1.4.1.14179.2.1.1.1.2'; +my $oid_bsnAPName = '.1.3.6.1.4.1.14179.2.2.1.1.3'; +my $oid_bsnAPIfLoadNumOfClients = '.1.3.6.1.4.1.14179.2.2.13.1.4'; sub manage_selection { my ($self, %options) = @_; @@ -168,6 +213,10 @@ sub manage_selection { $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel }, { oid => $mapping->{bsnMobileStationStatus}->{oid} }, { oid => $mapping2->{bsnMobileStationSsid}->{oid} }, + { oid => $oid_bsnDot11EssSsid }, + { oid => $mapping3->{bsnDot11EssNumberOfMobileStations}->{oid} }, + { oid => $oid_bsnAPName }, + { oid => $oid_bsnAPIfLoadNumOfClients }, ], nothing_quit => 1); $self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}); @@ -178,12 +227,48 @@ sub manage_selection { my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{ $mapping2->{bsnMobileStationSsid}->{oid} }, instance => $instance); if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' && $result2->{bsnMobileStationSsid} !~ /$self->{option_results}->{filter_ssid}/) { - $self->{output}->output_add(long_msg => "Skipping '" . $result2->{bsnMobileStationSsid} . "': no matching filter."); + $self->{output}->output_add(long_msg => "Skipping '" . $result2->{bsnMobileStationSsid} . "': no matching filter.", debug => 1); next; } $self->{global}->{total}++; $self->{global}->{'total_' . $result->{bsnMobileStationStatus}}++; } + + # check by ssid + $self->{ssid} = {}; + foreach my $oid (keys %{$self->{results}->{ $oid_bsnDot11EssSsid }}) { + $oid =~ /^$oid_bsnDot11EssSsid\.(.*)$/; + my $instance = $1; + my $ssid_name = $self->{results}->{ $oid_bsnDot11EssSsid }->{$oid}; + my $result = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnDot11EssNumberOfMobileStations}->{oid} }, instance => $instance); + if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' && + $ssid_name !~ /$self->{option_results}->{filter_ssid}/) { + $self->{output}->output_add(long_msg => "skipping ssid '" . $ssid_name . "': no matching filter.", debug => 1); + next; + } + + $self->{ssid}->{$ssid_name} = { display => $ssid_name, total => 0 } if (!defined($self->{ssid}->{$ssid_name})); + $self->{ssid}->{$ssid_name}->{total} += $result->{bsnDot11EssNumberOfMobileStations}; + } + + # check by ap + $self->{ap} = {}; + foreach my $oid (keys %{$self->{results}->{ $oid_bsnAPName }}) { + $oid =~ /^$oid_bsnAPName\.(.*)/; + my $instance = $1; + my $ap_name = $self->{results}->{$oid_bsnAPName}->{$oid}; + if (defined($self->{option_results}->{filter_ap}) && $self->{option_results}->{filter_ap} ne '' && + $ap_name !~ /$self->{option_results}->{filter_ap}/) { + $self->{output}->output_add(long_msg => "skipping ap '" . $ap_name . "': no matching filter.", debug => 1); + next; + } + + foreach my $oid2 (keys %{$self->{results}->{ $oid_bsnAPIfLoadNumOfClients }}) { + next if ($oid2 !~ /^$oid_bsnAPIfLoadNumOfClients\.$instance\./); + $self->{ap}->{$instance} = { display => $ap_name, total => 0 } if (!defined($self->{ap}->{$instance})); + $self->{ap}->{$instance}->{total} += $self->{results}->{$oid_bsnAPIfLoadNumOfClients}->{$oid2}; + } + } } 1; @@ -192,7 +277,7 @@ __END__ =head1 MODE -Check total users connected and status on AP. +Check users connected (total, by SSID, by AP). =over 8 @@ -206,19 +291,23 @@ Example: --filter-counters='^total|total-idle$' Threshold warning. Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated', 'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted', -'total-probing', 'total-blacklisted'. +'total-probing', 'total-blacklisted', 'ssid', 'ap'. =item B<--critical-*> Threshold critical. Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated', 'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted', -'total-probing', 'total-blacklisted'. +'total-probing', 'total-blacklisted', 'ssid', 'ap'. =item B<--filter-ssid> Filter by SSID (can be a regexp). +=item B<--filter-ap> + +Filter by AP (can be a regexp). + =back =cut diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/components/psu.pm index 2700763f0..e8d5b0eeb 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm index b387f7fde..9d8771648 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_agentCurrentCPUUtilization = '.1.3.6.1.4.1.14179.1.1.3.1.0'; diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/hardware.pm index 339a9db7a..3bbecadb1 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/hardware.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -32,7 +32,6 @@ sub set_system { $self->{cb_hook2} = 'snmp_execute'; - #Example for threshold: $self->{thresholds} = { psu => [ ['not operational', 'CRITICAL'], diff --git a/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm index d3820d238..1c954eff0 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_agentTotalMemory = '.1.3.6.1.4.1.14179.1.1.5.2.0'; # in Kbytes diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/apconnections.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/apconnections.pm index ebb58bb18..d6be2cbc4 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/apconnections.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/apconnections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -164,7 +164,6 @@ sub check_total { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm index d3ad95c87..bb85880f9 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,15 +20,21 @@ package centreon::common::aruba::snmp::mode::apusers; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::values; -my $maps_counters = { - global => { - '000_total' => { set => { +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'essid', type => 1, cb_prefix_output => 'prefix_essid_output', message_multiple => 'All users by ESSID are ok' }, + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by AP are ok' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'total', set => { key_values => [ { name => 'total' } ], output_template => 'Total Users : %s', perfdatas => [ @@ -37,7 +43,7 @@ my $maps_counters = { ], } }, - '001_total-none' => { set => { + { label => 'total-none', set => { key_values => [ { name => 'total_none' } ], output_template => 'Total Auth None : %s', perfdatas => [ @@ -46,7 +52,7 @@ my $maps_counters = { ], } }, - '002_total-other' => { set => { + { label => 'total-other', set => { key_values => [ { name => 'total_other' } ], output_template => 'Total Auth Other : %s', perfdatas => [ @@ -55,7 +61,7 @@ my $maps_counters = { ], } }, - '003_total-web' => { set => { + { label => 'total-web', set => { key_values => [ { name => 'total_web' } ], output_template => 'Total Auth Web : %s', perfdatas => [ @@ -64,7 +70,7 @@ my $maps_counters = { ], } }, - '004_total-dot1x' => { set => { + { label => 'total-dot1x', set => { key_values => [ { name => 'total_dot1x' } ], output_template => 'Total Auth Dot1x : %s', perfdatas => [ @@ -73,7 +79,7 @@ my $maps_counters = { ], } }, - '005_total-vpn' => { set => { + { label => 'total-vpn', set => { key_values => [ { name => 'total_vpn' } ], output_template => 'Total Auth Vpn : %s', perfdatas => [ @@ -82,7 +88,7 @@ my $maps_counters = { ], } }, - '006_total-mac' => { set => { + { label => 'total-mac', set => { key_values => [ { name => 'total_mac' } ], output_template => 'Total Auth Mac : %s', perfdatas => [ @@ -91,7 +97,7 @@ my $maps_counters = { ], } }, - '007_avg-connection-time' => { set => { + { label => 'avg-connection-time', set => { key_values => [ { name => 'avg_connection_time' } ], output_template => 'Users average connection time : %.3f seconds', perfdatas => [ @@ -100,30 +106,44 @@ my $maps_counters = { ], } }, - }, - total_ap => { - '000_total-ap' => { set => { - key_values => [ { name => 'users' }, { name => 'bssid' } ], - output_template => 'Users : %s', - perfdatas => [ - { label => 'total', value => 'users_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'bssid_absolute' }, - ], - } - }, - }, - total_essid => { - '000_total-essid' => { set => { + ]; + + $self->{maps_counters}->{essid} = [ + { label => 'total-essid', set => { key_values => [ { name => 'users' }, { name => 'essid' } ], - output_template => 'Users : %s', + output_template => 'users : %s', perfdatas => [ - { label => 'total', value => 'users_absolute', template => '%s', + { label => 'essid', value => 'users_absolute', template => '%s', unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'essid_absolute' }, ], } }, - } -}; + ]; + + $self->{maps_counters}->{ap} = [ + { label => 'total-ap', set => { + key_values => [ { name => 'users' }, { name => 'bssid' } ], + output_template => 'users : %s', + perfdatas => [ + { label => 'ap', value => 'users_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'bssid_absolute' }, + ], + } + }, + ]; +} + +sub prefix_essid_output { + my ($self, %options) = @_; + + return "ESSID '" . $options{instance_value}->{essid} . "' "; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "AP '" . $options{instance_value}->{bssid} . "' "; +} sub new { my ($class, %options) = @_; @@ -134,206 +154,13 @@ sub new { $options{options}->add_options(arguments => { "filter-ip-address:s" => { name => 'filter_ip_address' }, - "filter-essid:s" => { name => 'filter_essid' }, + "filter-bssid:s" => { name => 'filter_bssid' }, + "filter-essid:s" => { name => 'filter_essid' }, }); - - foreach my $key (('global', 'total_ap', 'total_essid')) { - 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', 'total_ap', 'total_essid')) { - foreach (keys %{$maps_counters->{$key}}) { - $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); - } - } -} - -sub run_total { - 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(); - } - - 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_ap { - my ($self, %options) = @_; - - my $multiple = 1; - if (scalar(keys %{$self->{ap_selected}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All users by AP are ok'); - } - - foreach my $id (sort keys %{$self->{ap_selected}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits = (); - foreach (sort keys %{$maps_counters->{total_ap}}) { - my $obj = $maps_counters->{total_ap}->{$_}->{obj}; - $obj->set(instance => $id); - - my ($value_check) = $obj->execute(values => $self->{ap_selected}->{$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 => "AP '$id' $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 => "AP '$id' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "AP '$id' $long_msg"); - } - } -} - -sub run_essid { - my ($self, %options) = @_; - - my $multiple = 1; - if (scalar(keys %{$self->{essid_selected}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All users by ESSID are ok'); - } - - foreach my $id (sort keys %{$self->{essid_selected}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits = (); - foreach (sort keys %{$maps_counters->{total_essid}}) { - my $obj = $maps_counters->{total_essid}->{$_}->{obj}; - $obj->set(instance => $id); - - my ($value_check) = $obj->execute(values => $self->{essid_selected}->{$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 => "ESSID '$id' $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 => "ESSID '$id' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "ESSID '$id' $long_msg"); - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - $self->manage_selection(); - $self->run_total(); - $self->run_ap(); - $self->run_essid(); - - $self->{output}->display(); - $self->{output}->exit(); -} - my %map_auth_method = ( 0 => 'none', 1 => 'web', 2 => 'mac', 3 => 'vpn', @@ -368,10 +195,10 @@ sub manage_selection { $self->{global} = { total => 0, total_none => 0, total_web => 0, total_mac => 0, total_vpn => 0, total_dot1x => 0, total_kerberos => 0, total_secureId => 0, total_pubcookie => 0, total_xSec => 0, xSecMachine => 0, 'total_via-vpn' => 0, total_other => 0 }; - $self->{ap_selected} = {}; - $self->{essid_selected} = {}; + $self->{ap} = {}; + $self->{essid} = {}; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_wlsxSwitchRole }, { oid => $oid_wlsxUserEntry, start => $mapping->{nUserUpTime}->{oid}, end => $mapping->{nUserAuthenticationMethod}->{oid} }, { oid => $mapping2->{nUserApBSSID}->{oid} }, @@ -398,22 +225,24 @@ sub manage_selection { foreach my $oid (keys %{$self->{results}->{$oid_wlsxUserEntry}}) { 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); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxUserEntry}, instance => $instance); + my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{nUserApBSSID}->{oid}}, instance => $instance); # security next if (!defined($result2->{nUserApBSSID})); my $bssid = join('.', unpack('C*', $result2->{nUserApBSSID})); next if (defined($self->{option_results}->{filter_ip_address}) && $self->{option_results}->{filter_ip_address} ne '' && $map_ap{$bssid}->{ip} !~ /$self->{option_results}->{filter_ip_address}/); - next if (defined($self->{option_results}->{filter_ip_address}) && $self->{option_results}->{filter_ip_address} ne '' && + next if (defined($self->{option_results}->{filter_essid}) && $self->{option_results}->{filter_essid} ne '' && $map_ap{$bssid}->{essid} !~ /$self->{option_results}->{filter_essid}/); + next if (defined($self->{option_results}->{filter_bssid}) && $self->{option_results}->{filter_bssid} ne '' && + $bssid !~ /$self->{option_results}->{filter_bssid}/); - $self->{ap_selected}->{$bssid} = { users => 0, bssid => $bssid } if (!defined($self->{ap_selected}->{$bssid})); - $self->{ap_selected}->{$bssid}->{users}++; + $self->{ap}->{$bssid} = { users => 0, bssid => $bssid } if (!defined($self->{ap}->{$bssid})); + $self->{ap}->{$bssid}->{users}++; - $self->{essid_selected}->{$map_ap{$bssid}->{essid}} = { users => 0, essid => $map_ap{$bssid}->{essid} } if (!defined($self->{essid_selected}->{$map_ap{$bssid}->{essid}})); - $self->{essid_selected}->{$map_ap{$bssid}->{essid}}->{users}++; + $self->{essid}->{$map_ap{$bssid}->{essid}} = { users => 0, essid => $map_ap{$bssid}->{essid} } if (!defined($self->{essid}->{$map_ap{$bssid}->{essid}})); + $self->{essid}->{$map_ap{$bssid}->{essid}}->{users}++; $self->{global}->{total}++; $self->{global}->{'total_' . $result->{nUserAuthenticationMethod}}++; @@ -439,13 +268,15 @@ Check total users connected. Threshold warning. Can be: 'total', 'total-none', 'total-other', 'total-web', -'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds). +'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds), +'total-ap', 'total-essid'. =item B<--critical-*> Threshold critical. Can be: 'total', 'total-none', 'total-other', 'total-web', -'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds). +'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds), +'total-ap', 'total-essid'. =item B<--filter-ip-address> @@ -455,6 +286,10 @@ Filter by ip address (regexp can be used). Filter by ESSID (regexp can be used). +=item B<--filter-bssid> + +Filter by BSSID (regexp can be used). + =back =cut diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/components/fan.pm index 14942b192..b3b61b493 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -35,9 +35,9 @@ my $mapping = { my $oid_wlsxSysExtFanEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.17.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_wlsxSysExtFanEntry }; + push @{$self->{request}}, { oid => $oid_wlsxSysExtFanEntry }; } sub check { @@ -45,14 +45,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtFanEntry}})) { next if ($oid !~ /^$mapping->{sysExtFanStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtFanEntry}, instance => $instance); - next if ($self->check_exclude(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].", diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/components/module.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/components/module.pm index eebf2fd5d..35b0f7aba 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/components/module.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/components/module.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,9 +55,9 @@ my $mapping = { my $oid_wlsxSysExtCardEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_wlsxSysExtCardEntry }; + push @{$self->{request}}, { oid => $oid_wlsxSysExtCardEntry }; } sub check { @@ -65,14 +65,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking modules"); $self->{components}->{module} = {name => 'modules', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'module')); + return if ($self->check_filter(section => 'module')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtCardEntry}})) { next if ($oid !~ /^$mapping->{sysExtCardStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtCardEntry}, instance => $instance); - next if ($self->check_exclude(section => 'module', instance => $instance)); + next if ($self->check_filter(section => 'module', instance => $instance)); $self->{components}->{module}->{total}++; $self->{output}->output_add(long_msg => sprintf("Module '%s/%s' status is %s [instance: %s].", diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/components/psu.pm index 754df13ed..b826fa4e4 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -35,9 +35,9 @@ my $mapping = { my $oid_wlsxSysExtPowerSupplyEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.18.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_wlsxSysExtPowerSupplyEntry }; + push @{$self->{request}}, { oid => $oid_wlsxSysExtPowerSupplyEntry }; } sub check { @@ -45,14 +45,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtPowerSupplyEntry}})) { next if ($oid !~ /^$mapping->{sysExtPowerSupplyStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxSysExtPowerSupplyEntry}, instance => $instance); - next if ($self->check_exclude(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].", diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm index ec144d9be..5cacc48ea 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_wlsxSysExtProcessorEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.13.1'; diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/hardware.pm index 3dfc4cb48..3b91dffde 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/hardware.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,168 +20,57 @@ package centreon::common::aruba::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['active', 'OK'], - ['inactive', 'CRITICAL'], - ], - psu => [ - ['active', 'OK'], - ['inactive', 'CRITICAL'], - ], - module => [ - ['active', 'OK'], - ['inactive', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|module)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['active', 'OK'], + ['inactive', 'CRITICAL'], + ], + psu => [ + ['active', 'OK'], + ['inactive', 'CRITICAL'], + ], + module => [ + ['active', 'OK'], + ['inactive', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::aruba::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'module']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'module'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::aruba::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 = "centreon::common::aruba::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - 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) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -197,10 +86,10 @@ Check hardware (modules, fans, power supplies). Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'module'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan,module) -Can also exclude specific instance: --exclude=fan#1#2#,module#1#,psu +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1 =item B<--no-component> @@ -209,7 +98,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,OK,inactive' diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm index 7bb1991d0..4db707a45 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_wlsxSysExtMemoryEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.15.1'; diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/storage.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/storage.pm index 9ad7b306c..c18f7ed26 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/storage.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -63,7 +63,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_wlsxSysExtStorageEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1'; diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm new file mode 100644 index 000000000..edb7156fa --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm @@ -0,0 +1,201 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::clusterstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'node', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All nodes are ok' } + ]; + + $self->{maps_counters}->{node} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'state : ' . $self->{result_values}->{state}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub prefix_node_output { + my ($self, %options) = @_; + + return "Node '" . $options{instance_value}->{display} . "' "; +} + +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' }, + "unknown-status:s" => { name => 'unknown_status', default => '%{state} =~ /unknown/' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} =~ /offline/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_vnode_status = ( + 1 => 'unknown', + 2 => 'onLine', + 3 => 'offLine', +); + +my $mapping = { + clusterVNodeName => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.5.11.1.2' }, + clusterVNodeStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.5.11.1.4', map => \%map_vnode_status }, +}; +my $oid_clusterVNodeEntry = '.1.3.6.1.4.1.11096.6.1.1.1.2.5.11.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{node} = {}; + $self->{results} = $options{snmp}->get_table(oid => $oid_clusterVNodeEntry, + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}}) { + next if ($oid !~ /^$mapping->{clusterVNodeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{clusterVNodeName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{clusterVNodeName} . "': no matching filter.", debug => 1); + next; + } + + $self->{node}->{$instance} = { display => $result->{clusterVNodeName}, + state => $result->{clusterVNodeStatus}}; + } + + if (scalar(keys %{$self->{node}}) <= 0) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'No node(s) finded'); + } +} + +1; + +__END__ + +=head1 MODE + +Check node status. + +=over 8 + +=item B<--filter-name> + +Filter node name (can be a regexp). + +=item B<--unknown-status> + +Set warning threshold for status (Default: '%{state} =~ /unknown/'). +Can used special variables like: %{state}, %{display} + +=item B<--warning-status> + +Set warning threshold for status (Default: -). +Can used special variables like: %{state}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} =~ /offline/i'). +Can used special variables like: %{state}, %{display} + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/fan.pm new file mode 100644 index 000000000..e8456ca8d --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/fan.pm @@ -0,0 +1,87 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_speed_status = ( + 1 => 'ok', + 2 => 'warning', + 3 => 'severe', + 4 => 'unknown', +); + +my $mapping = { + fanSpeedStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.1.11.1.4', map => \%map_speed_status }, + fanSpeed => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.1.11.1.5' }, +}; +my $oid_fanEntry = '.1.3.6.1.4.1.11096.6.1.1.1.2.1.11.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fanEntry }; +} + +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_fanEntry}})) { + next if ($oid !~ /^$mapping->{fanSpeedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanEntry}, 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] [value = %s]", + $instance, $result->{fanSpeedStatus}, $instance, + $result->{fanSpeedStatus})); + + my $exit = $self->get_severity(section => 'fan.speed', value => $result->{fanSpeedStatus}); + 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->{fanSpeedStatus})); + next; + } + + if (defined($result->{fanSpeedStatus}) && $result->{fanSpeedStatus} =~ /[0-9]/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{temperatureSensorCReading}); + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Fan '%s' is %s rpm", $instance, $result->{fanSpeedStatus})); + } + $self->{output}->perfdata_add(label => 'fan_' . $instance, unit => 'rpm', + value => $result->{fanSpeedStatus}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/psu.pm new file mode 100644 index 000000000..303f9eb60 --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/psu.pm @@ -0,0 +1,72 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'failed', + 3 => 'notFitted', + 4 => 'unknown', +); + +my $mapping = { + psuStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.1.13.1.3', map => \%map_status }, +}; +my $oid_psuEntry = '.1.3.6.1.4.1.11096.6.1.1.1.2.1.13.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_psuEntry }; +} + +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_psuEntry}})) { + next if ($oid !~ /^$mapping->{psuStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_psuEntry}, 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->{psuStatus}, + $instance + )); + my $exit = $self->get_severity(section => 'psu', value => $result->{psuStatus}); + 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->{psuStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/components/sysdrive.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/sysdrive.pm new file mode 100644 index 000000000..03097928b --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/sysdrive.pm @@ -0,0 +1,73 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::components::sysdrive; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'online', 2 => 'corrupt', 3 => 'failed', + 4 => 'notPresent', 5 => 'disconnected', + 6 => 'offline', 7 => 'initializing', + 8 => 'formatting', 9 => 'unknown', +); + +my $mapping = { + sysDriveWWN => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.3.4.2.1.2' }, + sysDriveStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.3.4.2.1.4', map => \%map_status }, +}; +my $oid_sysDriveEntry = '.1.3.6.1.4.1.11096.6.1.1.1.3.4.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_sysDriveEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking system drives"); + $self->{components}->{sysdrive} = {name => 'sysdrives', total => 0, skip => 0}; + return if ($self->check_filter(section => 'sysdrive')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_sysDriveEntry}})) { + next if ($oid !~ /^$mapping->{sysDriveStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sysDriveEntry}, instance => $instance); + + next if ($self->check_filter(section => 'sysdrive', instance => $result->{sysDriveWWN})); + $self->{components}->{sysdrive}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("system drive '%s' status is '%s' [instance: %s].", + $result->{sysDriveWWN}, $result->{sysDriveStatus}, + $result->{sysDriveWWN} + )); + my $exit = $self->get_severity(section => 'sysdrive', value => $result->{sysDriveStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System drive '%s' status is '%s'", + $result->{sysDriveWWN}, $result->{sysDriveStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..024410fb4 --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/components/temperature.pm @@ -0,0 +1,86 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::components::temperature; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', 2 => 'tempWarning', 3 => 'tempSevere', + 4 => 'tempSensorFailed', 5 => 'tempSensorWarning', + 6 => 'unknown', +); + +my $mapping = { + temperatureSensorStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.1.9.1.3', map => \%map_status }, + temperatureSensorCReading => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.1.9.1.4' }, +}; +my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.11096.6.1.1.1.2.1.9.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_temperatureSensorEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureSensorEntry}})) { + next if ($oid !~ /^$mapping->{temperatureSensorStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureSensorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]", + $instance, $result->{temperatureSensorStatus}, $instance, + $result->{temperatureSensorCReading})); + + my $exit = $self->get_severity(section => 'temperature', value => $result->{temperatureSensorStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{temperatureSensorStatus})); + next; + } + + if (defined($result->{temperatureSensorCReading}) && $result->{temperatureSensorCReading} =~ /[0-9]/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureSensorCReading}); + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $instance, $result->{temperatureSensorCReading})); + } + $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + value => $result->{temperatureSensorCReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/hardware.pm new file mode 100644 index 000000000..28930bc26 --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/hardware.pm @@ -0,0 +1,137 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|psu|sysdrive)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ['notFitted', 'WARNING'], + ['unknown', 'UNKNOWN'], + ], + 'fan.speed' => [ + ['ok', 'OK'], + ['warning', 'WARNING'], + ['severe', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ], + temperature => [ + ['ok', 'OK'], + ['tempWarning', 'WARNING'], + ['tempSevere', 'CRITICAL'], + ['tempSensorFailed', 'CRITICAL'], + ['tempSensorWarning', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ], + sysdrive => [ + ['online', 'OK'], + ['corrupt', 'WARNING'], + ['failed', 'CRITICAL'], + ['notPresent', 'OK'], + ['disconnected', 'WARNING'], + ['offline', 'OK'], + ['initializing', 'OK'], + ['formatting', 'OK'], + ['unknown', 'UNKNOWN'], + ], + }; + + $self->{components_path} = 'centreon::common::bluearc::snmp::mode::components'; + $self->{components_module} = ['temperature', 'fan', 'psu', 'sysdrive']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'temperature', 'fan', 'psu', 'sysdrive'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=sysdrive) +Can also exclude specific instance: --filter=sysdrive,1 + +=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='sysdrive,OK,formatting' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/volumeusage.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/volumeusage.pm new file mode 100644 index 000000000..171e4302f --- /dev/null +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/volumeusage.pm @@ -0,0 +1,300 @@ +# +# Copyright 2016 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 centreon::common::bluearc::snmp::mode::volumeusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{status}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = 'used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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("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}->{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_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All volumes are ok' } + ]; + + $self->{maps_counters}->{volume} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /needsChecking/i' }, + "critical-status:s" => { name => 'critical_status', default => '' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_volume_output { + my ($self, %options) = @_; + + return "Volume '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_volume_status = ( + 1 => 'unformatted', + 2 => 'mounted', + 3 => 'formatted', + 4 => 'needsChecking', +); + +my $mapping = { + volumeLabel => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.3.5.2.1.3' }, + volumeStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.3.5.2.1.4', map => \%map_volume_status }, + volumeCapacity => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.3.5.2.1.5' }, + volumeFreeCapacity => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.3.5.2.1.6' }, +}; +my $oid_volumeEntry = '.1.3.6.1.4.1.11096.6.1.1.1.3.5.2.1'; + +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->{volume} = {}; + $self->{results} = $options{snmp}->get_table(oid => $oid_volumeEntry, + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}}) { + next if ($oid !~ /^$mapping->{volumeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{volumeLabel} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{volumeLabel} . "': no matching filter.", debug => 1); + next; + } + + $self->{volume}->{$instance} = { display => $result->{volumeLabel}, + status => $result->{volumeStatus}, + total => $result->{volumeCapacity}, + used => $result->{volumeCapacity} - $result->{volumeFreeCapacity} }; + } + + + if (scalar(keys %{$self->{volume}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No volume found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check volume usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter volume name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /needsChecking/i'). +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: -). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage'. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=back + +=cut diff --git a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm index 97ab832e8..7f8ad5fd1 100644 --- a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -39,9 +39,9 @@ my $mapping = { my $oid_rlEnvMonFanStatusEntry = '.1.3.6.1.4.1.9.6.1.101.83.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; + push @{$self->{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; } sub check { @@ -49,14 +49,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fan', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonFanStatusEntry}})) { next if ($oid !~ /^$mapping->{rlEnvMonFanState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonFanStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); if ($result->{rlEnvMonFanState} =~ /notPresent/i) { $self->absent_problem(section => 'fan', instance => $instance); next; diff --git a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm index 0e8a59860..4e97ac9db 100644 --- a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -39,9 +39,9 @@ my $mapping = { my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.9.6.1.101.83.1.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; + push @{$self->{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; } sub check { @@ -49,14 +49,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psu', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) { next if ($oid !~ /^$mapping->{rlEnvMonSupplyState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); if ($result->{rlEnvMonSupplyState} =~ /notPresent/i) { $self->absent_problem(section => 'psu', instance => $instance); next; diff --git a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm index 6864bb882..1c38d8562 100644 --- a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rlCpuUtilDuringLastSecond = '.1.3.6.1.4.1.9.6.1.101.1.7.0'; diff --git a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm index b42b27843..0332fffa0 100644 --- a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm +++ b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,189 +20,61 @@ package centreon::common::cisco::smallbusiness::snmp::mode::environment; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['normal', 'OK'], - ['notPresent', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['notFunctioning', 'CRITICAL'], - ], - psu => [ - ['normal', 'OK'], - ['notPresent', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['notFunctioning', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['normal', 'OK'], + ['notPresent', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notFunctioning', 'CRITICAL'], + ], + psu => [ + ['normal', 'OK'], + ['notPresent', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notFunctioning', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::cisco::smallbusiness::snmp::mode::components'; + $self->{components_module} = ['psu', 'fan']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "absent-problem:s" => { name => 'absent' }, - "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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('psu', 'fan'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::cisco::smallbusiness::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 = "centreon::common::cisco::smallbusiness::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -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__ @@ -218,10 +90,10 @@ Check environment (Fans, Power supplies). Which component to check (Default: '.*'). Can be: 'fan', 'psu'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#0#' +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=psu,0 =item B<--absent-problem> @@ -235,7 +107,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/fan.pm index 89e2ef1d7..a869a541b 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -103,7 +103,7 @@ sub check_fan_entity { my $exit = $self->get_severity(section => 'fan', value => $result->{cefcFanTrayOperStatus}); 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.", $fan_descr, $result->{cefcFanTrayOperStatus})); + short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus})); } } } diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/module.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/module.pm index 51bf40fec..36987ed71 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/module.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/module.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -87,7 +87,8 @@ sub check { my $exit = $self->get_severity(section => 'module', value => $result->{cefcModuleOperStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Module '%s' status is %s", $module_descr, $result->{cefcModuleOperStatus})); + short_msg => sprintf("Module '%s/%s' status is %s", $module_descr, + $instance, $result->{cefcModuleOperStatus})); } } } diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/physical.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/physical.pm index 2f48c0f48..debfd9d0f 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/physical.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/physical.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -69,7 +69,8 @@ sub check { my $exit = $self->get_severity(section => 'physical', value => $result->{cefcPhysicalStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Physical '%s' status is %s", $physical_descr, $result->{cefcPhysicalStatus})); + short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr, + $instance, $result->{cefcPhysicalStatus})); } } } diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/psu.pm index 04f9845a4..f92712a58 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -119,7 +119,7 @@ sub check_psu_entity { my $exit = $self->get_severity(section => 'psu', value => $result->{cefcFRUPowerOperStatus}); 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.", $psu_descr, $result->{cefcFRUPowerOperStatus})); + short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus})); } } } diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/sensor.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/sensor.pm index 3db0d6353..8b0c93814 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/sensor.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/sensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -202,8 +202,8 @@ sub check { my $exit = $self->get_severity(section => $result->{entSensorType}, label => 'sensor', value => $result->{entSensorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Sensor '%s' status is '%s'", - $sensor_descr, $result->{entSensorStatus})); + short_msg => sprintf("Sensor '%s/%s' status is '%s'", + $sensor_descr, $instance, $result->{entSensorStatus})); } next if (!defined($result->{entSensorValue}) || $result->{entSensorValue} !~ /[0-9]/); @@ -222,7 +222,7 @@ sub check { } if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("Sensor '%s' is %s %s", $sensor_descr, $result->{entSensorValue}, $perfdata_unit{$result->{entSensorType}})); + short_msg => sprintf("Sensor '%s/%s' is %s %s", $sensor_descr, $instance, $result->{entSensorValue}, $perfdata_unit{$result->{entSensorType}})); } $self->{output}->perfdata_add(label => $component . '_' . $sensor_descr, unit => $perfdata_unit{$result->{entSensorType}}, value => $result->{entSensorValue}, diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/temperature.pm index 11c143960..b9d045787 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/temperature.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/voltage.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/voltage.pm index 99647b622..9124f5e61 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/voltage.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm index a4870c11c..ff6a9fd39 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -160,7 +160,6 @@ sub check_table_cpu { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # Cisco IOS Software releases later to 12.0(3)T and prior to 12.2(3.5) diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm index adb98425e..0d57fc375 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -191,7 +191,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; @@ -369,14 +368,14 @@ Example: --threshold-overload='fan,CRITICAL,^(?!(up|normal)$)' =item B<--warning> -Set warning threshold for temperatures, voltages, sensors (syntax: type,regexp,treshold) +Set warning threshold for temperatures, voltages, sensors (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures, voltages, sensors (syntax: type,regexp,treshold) +Set critical threshold for temperatures, voltages, sensors (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/hsrp.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/hsrp.pm index eb9d585dd..aeeaf0357 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/hsrp.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/hsrp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -67,7 +67,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $vridout = ''; diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/ipsla.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/ipsla.pm index 64dc72264..ea714dc03 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/ipsla.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/ipsla.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,286 +20,292 @@ package centreon::common::cisco::standard::snmp::mode::ipsla; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::statefile; -use centreon::plugins::values; use Digest::MD5 qw(md5_hex); use Math::Complex; -my $maps_counters = { - '000_status' => { class => 'centreon::plugins::values', obj => undef, threshold => 0, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, - { name => 'rttMonCtrlAdminTag' }, - { name => 'rttMonCtrlAdminRttType' }, - { name => 'rttMonCtrlAdminThreshold' }, - { name => 'rttMonEchoAdminPrecision' }, - { name => 'rttMonLatestRttOperCompletionTime' }, - { name => 'rttMonLatestRttOperSense' }, - { name => 'rttMonLatestRttOperApplSpecificSense' }, - ], - closure_custom_calc => \&custom_status_calc, - closure_custom_output => \&custom_status_output, - closure_custom_perfdata => \&custom_status_perfdata, - closure_custom_threshold_check => \&custom_status_threshold, - } - }, - '001_NumberOverThresholds' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OverThresholds_1' }, { name => 'OverThresholds_2' }, { name => 'OverThresholds_times' }, - ], - closure_custom_calc => \&custom_NumberOverThresholds_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Number Over Thresholds : %s', - threshold_use => 'value', - perfdatas => [ - { label => 'number_over_thresholds', value => 'value', template => '%s', - label_extra_instance => 1 }, - ], - } - }, - '002_AverageDelaySD' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - ], - closure_custom_calc => \&custom_AverageDelaySD_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Delay SD : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'average_delay_sd', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '003_AverageDelayDS' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - ], - closure_custom_calc => \&custom_AverageDelayDS_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Delay DS : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'average_delay_ds', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '004_PacketLossRatio' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'PacketLossDS_1' }, { name => 'PacketLossDS_2' }, { name => 'PacketLossDS_times' }, - { name => 'PacketLossSD_1' }, { name => 'PacketLossSD_2' }, { name => 'PacketLossSD_times' }, - { name => 'PacketMIA_1' }, { name => 'PacketMIA_2' }, { name => 'PacketMIA_times' }, - { name => 'PacketLateArrival_1' }, { name => 'PacketLateArrival_2' }, { name => 'PacketLateArrival_times' }, - { name => 'PacketOutOfSequence_1' }, { name => 'PacketOutOfSequence_2' }, { name => 'PacketOutOfSequence_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_PacketLossRatio_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Packet Loss Ratio : %.2f %%', - threshold_use => 'value', - perfdatas => [ - { label => 'packet_loss_ratio', value => 'value', template => '%.2f', unit => '%', - label_extra_instance => 1, min => 0, max => 100 }, - ], - } - }, - '005_PercentagePacketsPositiveJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_PercentagePacketsPositiveJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Percentage of Packets that had Positive Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'prct_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1, }, - ], - } - }, - '006_AverageJitterPerPacketPositiveJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_AverageJitterPerPacketPositiveJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Jitter per Packet that had Positive Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'average_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1 }, - ], - } - }, - '007_PercentagePacketsNegativeJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_PercentagePacketsNegativeJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Percentage of Packets that had Negative Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'prct_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1, }, - ], - } - }, - '008_AverageJitterPerPacketNegativeJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_AverageJitterPerPacketNegativeJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Jitter per Packet that had Negative Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'average_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1 }, - ], - } - }, - '009_AverageJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, - { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, - { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, - { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, - { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, - { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, - { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, - { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, - ], - closure_custom_calc => \&custom_AverageJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Jitter : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'average_jitter', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '010_RTTStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'RTTSum2High_1' }, { name => 'RTTSum2High_2' }, { name => 'RTTSum2High_times' }, - { name => 'RTTSum2Low_1' }, { name => 'RTTSum2Low_2' }, { name => 'RTTSum2Low_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - { name => 'RTTSum_1' }, { name => 'RTTSum_2' }, { name => 'RTTSum_times' }, - ], - closure_custom_calc => \&custom_RTTStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Round-Trip Time Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'rtt_standard_deviation', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '011_DelaySource2DestinationStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSum2SDHigh_1' }, { name => 'OWSum2SDHigh_2' }, { name => 'OWSum2SDHigh_times' }, - { name => 'OWSum2SDLow_1' }, { name => 'OWSum2SDLow_2' }, { name => 'OWSum2SDLow_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, - ], - closure_custom_calc => \&custom_DelaySource2DestinationStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Delay Source to Destination Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'delay_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - - '012_DelayDestination2SourceStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSum2DSHigh_1' }, { name => 'OWSum2DSHigh_2' }, { name => 'OWSum2DSHigh_times' }, - { name => 'OWSum2DSLow_1' }, { name => 'OWSum2DSLow_2' }, { name => 'OWSum2DSLow_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, - ], - closure_custom_calc => \&custom_DelayDestination2SourceStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Delay Destination to Source Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'delay_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '013_JitterSource2DestinationStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'Sum2PositivesSDHigh_1' }, { name => 'Sum2PositivesSDHigh_2' }, { name => 'Sum2PositivesSDHigh_times' }, - { name => 'Sum2PositivesSDLow_1' }, { name => 'Sum2PositivesSDLow_2' }, { name => 'Sum2PositivesSDLow_times' }, - { name => 'Sum2NegativesSDHigh_1' }, { name => 'Sum2NegativesSDHigh_2' }, { name => 'Sum2NegativesSDHigh_times' }, - { name => 'Sum2NegativesSDLow_1' }, { name => 'Sum2NegativesSDLow_2' }, { name => 'Sum2NegativesSDLow_times' }, - { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, - { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, - { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, - { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, - ], - closure_custom_calc => \&custom_JitterSource2DestinationStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Jitter Source to Destination Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'jitter_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '014_JitterDestination2SourceStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'Sum2PositivesDSHigh_1' }, { name => 'Sum2PositivesDSHigh_2' }, { name => 'Sum2PositivesDSHigh_times' }, - { name => 'Sum2PositivesDSLow_1' }, { name => 'Sum2PositivesDSLow_2' }, { name => 'Sum2PositivesDSLow_times' }, - { name => 'Sum2NegativesDSHigh_1' }, { name => 'Sum2NegativesDSHigh_2' }, { name => 'Sum2NegativesDSHigh_times' }, - { name => 'Sum2NegativesDSLow_1' }, { name => 'Sum2NegativesDSLow_2' }, { name => 'Sum2NegativesDSLow_times' }, - { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, - { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, - { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, - { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, - ], - closure_custom_calc => \&custom_JitterDestination2SourceStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Jitter Destination to Source Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'jitter_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, -}; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'tag', type => 1, cb_prefix_output => 'prefix_tag_output', message_multiple => 'All RTT controls are ok', + skipped_code => { -2 => 1 } } + ]; + $self->{maps_counters}->{tag} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, + { name => 'rttMonCtrlAdminTag' }, + { name => 'rttMonCtrlAdminRttType' }, + { name => 'rttMonCtrlAdminThreshold' }, + { name => 'rttMonEchoAdminPrecision' }, + { name => 'rttMonLatestRttOperCompletionTime' }, + { name => 'rttMonLatestRttOperSense' }, + { name => 'rttMonLatestRttOperApplSpecificSense' }, + ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'CompletionTime', set => { + key_values => [ { name => 'rttMonLatestRttOperCompletionTime' }, { name => 'rttMonEchoAdminPrecision' }, { name => 'rttMonCtrlAdminTag' } + ], + output_template => 'Completion Time : %s', + perfdatas => [ + { label => 'completion_time', value => 'rttMonLatestRttOperCompletionTime_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'NumberOverThresholds', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OverThresholds_1' }, { name => 'OverThresholds_2' }, { name => 'OverThresholds_times' }, + ], + closure_custom_calc => $self->can('custom_NumberOverThresholds_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Number Over Thresholds : %s', + threshold_use => 'value', + perfdatas => [ + { label => 'number_over_thresholds', value => 'value', template => '%s', + label_extra_instance => 1 }, + ], + } + }, + { label => 'AverageDelaySD', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + ], + closure_custom_calc => $self->can('custom_AverageDelaySD_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Delay SD : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'average_delay_sd', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'AverageDelayDS', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + ], + closure_custom_calc => $self->can('custom_AverageDelayDS_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Delay DS : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'average_delay_ds', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'PacketLossRatio', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'PacketLossDS_1' }, { name => 'PacketLossDS_2' }, { name => 'PacketLossDS_times' }, + { name => 'PacketLossSD_1' }, { name => 'PacketLossSD_2' }, { name => 'PacketLossSD_times' }, + { name => 'PacketMIA_1' }, { name => 'PacketMIA_2' }, { name => 'PacketMIA_times' }, + { name => 'PacketLateArrival_1' }, { name => 'PacketLateArrival_2' }, { name => 'PacketLateArrival_times' }, + { name => 'PacketOutOfSequence_1' }, { name => 'PacketOutOfSequence_2' }, { name => 'PacketOutOfSequence_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_PacketLossRatio_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Packet Loss Ratio : %.2f %%', + threshold_use => 'value', + perfdatas => [ + { label => 'packet_loss_ratio', value => 'value', template => '%.2f', unit => '%', + label_extra_instance => 1, min => 0, max => 100 }, + ], + } + }, + { label => 'PercentagePacketsPositiveJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_PercentagePacketsPositiveJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Percentage of Packets that had Positive Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'prct_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1, }, + ], + } + }, + { label => 'AverageJitterPerPacketPositiveJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_AverageJitterPerPacketPositiveJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Jitter per Packet that had Positive Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'average_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1 }, + ], + } + }, + { label => 'PercentagePacketsNegativeJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_PercentagePacketsNegativeJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Percentage of Packets that had Negative Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'prct_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1, }, + ], + } + }, + { label => 'AverageJitterPerPacketNegativeJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_AverageJitterPerPacketNegativeJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Jitter per Packet that had Negative Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'average_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1 }, + ], + } + }, + { label => 'AverageJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, + { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, + { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, + { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, + { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, + { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, + { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, + { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, + ], + closure_custom_calc => $self->can('custom_AverageJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Jitter : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'average_jitter', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'RTTStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'RTTSum2High_1' }, { name => 'RTTSum2High_2' }, { name => 'RTTSum2High_times' }, + { name => 'RTTSum2Low_1' }, { name => 'RTTSum2Low_2' }, { name => 'RTTSum2Low_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + { name => 'RTTSum_1' }, { name => 'RTTSum_2' }, { name => 'RTTSum_times' }, + ], + closure_custom_calc => $self->can('custom_RTTStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Round-Trip Time Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'rtt_standard_deviation', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'DelaySource2DestinationStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSum2SDHigh_1' }, { name => 'OWSum2SDHigh_2' }, { name => 'OWSum2SDHigh_times' }, + { name => 'OWSum2SDLow_1' }, { name => 'OWSum2SDLow_2' }, { name => 'OWSum2SDLow_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, + ], + closure_custom_calc => $self->can('custom_DelaySource2DestinationStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Delay Source to Destination Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'delay_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'DelayDestination2SourceStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSum2DSHigh_1' }, { name => 'OWSum2DSHigh_2' }, { name => 'OWSum2DSHigh_times' }, + { name => 'OWSum2DSLow_1' }, { name => 'OWSum2DSLow_2' }, { name => 'OWSum2DSLow_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, + ], + closure_custom_calc => $self->can('custom_DelayDestination2SourceStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Delay Destination to Source Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'delay_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'JitterSource2DestinationStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'Sum2PositivesSDHigh_1' }, { name => 'Sum2PositivesSDHigh_2' }, { name => 'Sum2PositivesSDHigh_times' }, + { name => 'Sum2PositivesSDLow_1' }, { name => 'Sum2PositivesSDLow_2' }, { name => 'Sum2PositivesSDLow_times' }, + { name => 'Sum2NegativesSDHigh_1' }, { name => 'Sum2NegativesSDHigh_2' }, { name => 'Sum2NegativesSDHigh_times' }, + { name => 'Sum2NegativesSDLow_1' }, { name => 'Sum2NegativesSDLow_2' }, { name => 'Sum2NegativesSDLow_times' }, + { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, + { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, + { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, + { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, + ], + closure_custom_calc => $self->can('custom_JitterSource2DestinationStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Jitter Source to Destination Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'jitter_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'JitterDestination2SourceStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'Sum2PositivesDSHigh_1' }, { name => 'Sum2PositivesDSHigh_2' }, { name => 'Sum2PositivesDSHigh_times' }, + { name => 'Sum2PositivesDSLow_1' }, { name => 'Sum2PositivesDSLow_2' }, { name => 'Sum2PositivesDSLow_times' }, + { name => 'Sum2NegativesDSHigh_1' }, { name => 'Sum2NegativesDSHigh_2' }, { name => 'Sum2NegativesDSHigh_times' }, + { name => 'Sum2NegativesDSLow_1' }, { name => 'Sum2NegativesDSLow_2' }, { name => 'Sum2NegativesDSLow_times' }, + { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, + { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, + { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, + { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, + ], + closure_custom_calc => $self->can('custom_JitterDestination2SourceStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Jitter Destination to Source Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'jitter_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + ]; +} + +sub prefix_tag_output { + my ($self, %options) = @_; + + return "RTT '" . $options{instance_value}->{rttMonCtrlAdminTag} . "' "; +} my $ipsla; my $thresholds = { @@ -348,18 +354,6 @@ sub check_buffer_creation { ###### STATUS ###### -sub custom_status_perfdata { - my ($self, %options) = @_; - - my $extra_label = ''; - if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { - $extra_label .= '_' . $self->{result_values}->{rttMonCtrlAdminTag}; - } - $self->{output}->perfdata_add(label => 'completion_time' . $extra_label, unit => $self->{result_values}->{rttMonEchoAdminPrecision}, - value => $self->{result_values}->{rttMonLatestRttOperCompletionTime}, - min => 0); -} - sub custom_status_threshold { my ($self, %options) = @_; my $status = 'ok'; @@ -803,42 +797,23 @@ my $mapping3 = { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "filter-tag:s" => { name => 'filter_tag', default => '.*' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + "filter-tag:s" => { name => 'filter_tag', default => '.*' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, }); - $self->{statefile_value} = centreon::plugins::statefile->new(%options); - foreach (keys %{$maps_counters}) { - my ($id, $name) = split /_/; - if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { - $options{options}->add_options(arguments => { - 'warning-' . $name . ':s' => { name => 'warning-' . $name }, - 'critical-' . $name . ':s' => { name => 'critical-' . $name }, - }); - } - my $class = $maps_counters->{$_}->{class}; - $maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value}, - output => $self->{output}, perfdata => $self->{perfdata}, - label => $name); - $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); - } return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); - foreach (keys %{$maps_counters}) { - next if (defined($maps_counters->{$_}->{threshold}) && $maps_counters->{$_}->{threshold} == 0); - $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); - } $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { @@ -854,103 +829,35 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } - $self->{statefile_value}->check_options(%options); # to be used on custom function $ipsla = $self; } -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(); - - $self->manage_selection(); - - $self->{new_datas} = {}; - $self->{statefile_value}->read(statefile => "cache_cisco_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . - (defined($self->{option_results}->{filter_tag}) ? md5_hex($self->{option_results}->{filter_tag}) : md5_hex('all'))); - $self->{new_datas}->{last_timestamp} = time(); - - my $multiple = 1; - if (scalar(keys %{$self->{datas}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All RTT controls are ok'); - } - - foreach my $id (sort keys %{$self->{datas}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters}) { - $maps_counters->{$_}->{obj}->set(instance => $id); - - my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{datas}->{$id}, - new_datas => $self->{new_datas}); - next if ($value_check == -2); - if ($value_check != 0) { - $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); - $long_msg_append = ', '; - next; - } - my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); - push @exits, $exit2; - - my $output = $maps_counters->{$_}->{obj}->output(); - $long_msg .= $long_msg_append . $output; - $long_msg_append = ', '; - - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= $short_msg_append . $output; - $short_msg_append = ', '; - } - - $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); - } - - $self->{output}->output_add(long_msg => "RTT '" . $self->{datas}->{$id}->{rttMonCtrlAdminTag} . "' $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 => "RTT '" . $self->{datas}->{$id}->{rttMonCtrlAdminTag} . "' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "RTT '" . $self->{datas}->{$id}->{rttMonCtrlAdminTag} . "' $long_msg"); - } - } - - $self->{statefile_value}->write(data => $self->{new_datas}); - $self->{output}->display(); - $self->{output}->exit(); -} - sub manage_selection { my ($self, %options) = @_; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_rttMonCtrlAdminEntry }, + $self->{cache_name} = "cache_cisco_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_tag}) ? md5_hex($self->{option_results}->{filter_tag}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_rttMonCtrlAdminEntry }, { oid => $oid_rttMonEchoAdminPrecision }, { oid => $oid_rttMonLatestRttOperEntry }, { oid => $oid_rttMonJitterStatsEntry }, ], - nothing_quit => 1); + nothing_quit => 1); - $self->{datas} = {}; - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) { + $self->{tag} = {}; + foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) { next if ($oid !~ /^$mapping->{rttMonCtrlAdminTag}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance); my $tag_name = $result->{rttMonCtrlAdminTag}; if (!defined($tag_name) || $tag_name eq '') { $self->{output}->output_add(long_msg => "skipping: please set a tag name"); next; } - if (defined($self->{datas}->{$tag_name})) { + if (defined($self->{tag}->{$tag_name})) { $self->{output}->output_add(long_msg => "skipping '" . $tag_name . "': duplicate (please change the tag name)."); next; } @@ -959,29 +866,29 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $tag_name . "': no matching filter."); next; } - $self->{datas}->{$tag_name} = { %{$result} }; - $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_rttMonEchoAdminPrecision}, instance => $instance); - $self->{datas}->{$tag_name} = { %{$result}, %{$self->{datas}->{$tag_name}} }; - $result = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_rttMonLatestRttOperEntry}, instance => $instance); - $self->{datas}->{$tag_name} = { %{$result}, %{$self->{datas}->{$tag_name}} }; + $self->{tag}->{$tag_name} = { %{$result} }; + $result = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_rttMonEchoAdminPrecision}, instance => $instance); + $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} }; + $result = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_rttMonLatestRttOperEntry}, instance => $instance); + $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} }; # there are two entries with rotation: 1 -> last hour, 2 -> current hour. foreach my $key (keys %{$oids_jitter_stats}) { - $self->{datas}->{$tag_name}->{$key . '_1'} = 0; - $self->{datas}->{$tag_name}->{$key . '_2'} = 0; + $self->{tag}->{$tag_name}->{$key . '_1'} = 0; + $self->{tag}->{$tag_name}->{$key . '_2'} = 0; my $i = 1; my $instances = []; - foreach my $oid2 ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonJitterStatsEntry}})) { + foreach my $oid2 ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonJitterStatsEntry}})) { next if ($oid2 !~ /^$oids_jitter_stats->{$key}\.$instance.(\d+)/); push @{$instances}, $1; - $self->{datas}->{$tag_name}->{$key . '_' . $i} = $self->{results}->{$oid_rttMonJitterStatsEntry}->{$oid2}; + $self->{tag}->{$tag_name}->{$key . '_' . $i} = $self->{results}->{$oid_rttMonJitterStatsEntry}->{$oid2}; $i++; } - $self->{datas}->{$tag_name}->{$key . '_times'} = join('_', @{$instances}); + $self->{tag}->{$tag_name}->{$key . '_times'} = join('_', @{$instances}); } } - if (scalar(keys %{$self->{datas}}) <= 0) { + if (scalar(keys %{$self->{tag}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->option_exit(); } @@ -1032,7 +939,7 @@ Example: --threshold-overload='opersense,CRITICAL,^(?!(ok)$)' =item B<--warning-*> Threshold warning. -Can be: 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', +Can be: 'CompletionTime', 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', 'PercentagePacketsPositiveJitter', 'AverageJitterPerPacketPositiveJitter', 'PercentagePacketsNegativeJitter', 'AverageJitterPerPacketNegativeJitter', 'AverageJitter', 'RTTStandardDeviation', 'DelaySource2DestinationStandardDeviation', 'DelayDestination2SourceStandardDeviation', 'JitterSource2DestinationStandardDeviation', 'JitterDestination2SourceStandardDeviation'. @@ -1040,7 +947,7 @@ Can be: 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossR =item B<--critical-*> Threshold critical. -Can be: 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', +Can be: 'CompletionTime', 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', 'PercentagePacketsPositiveJitter', 'AverageJitterPerPacketPositiveJitter', 'PercentagePacketsNegativeJitter', 'AverageJitterPerPacketNegativeJitter', 'AverageJitter', 'RTTStandardDeviation', 'DelaySource2DestinationStandardDeviation', 'DelayDestination2SourceStandardDeviation', 'JitterSource2DestinationStandardDeviation', 'JitterDestination2SourceStandardDeviation'. diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm index 0ccc32a73..91c149e14 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -141,7 +141,6 @@ sub check_percent_memory { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_ciscoMemoryPoolEntry = '.1.3.6.1.4.1.9.9.48.1.1.1'; diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memoryflash.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memoryflash.pm index cdd693dc6..e3ea795a8 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memoryflash.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memoryflash.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -122,7 +122,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/sessions.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/sessions.pm new file mode 100644 index 000000000..366285234 --- /dev/null +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/sessions.pm @@ -0,0 +1,289 @@ +# +# Copyright 2016 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 centreon::common::cisco::standard::snmp::mode::sessions; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'connections', type => 0, cb_prefix_output => 'prefix_connections_output', skipped_code => { -10 => 1 } }, + { name => 'sessions', type => 0, cb_prefix_output => 'prefix_sessions_output', skipped_code => { -10 => 1 } }, + ]; + $self->{maps_counters}->{connections} = [ + { label => 'connections-current', set => { + key_values => [ { name => 'cufwConnGlobalNumActive' } ], + output_template => 'current : %s', output_error_template => "current : %s", + perfdatas => [ + { label => 'connections_current', value => 'cufwConnGlobalNumActive_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'connections-1m', set => { + key_values => [ { name => 'cufwConnGlobalConnSetupRate1' } ], + output_template => 'average last 1min : %s', output_error_template => "average last 1min : %s", + perfdatas => [ + { label => 'connections_1m', value => 'cufwConnGlobalConnSetupRate1_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'connections-5m', set => { + key_values => [ { name => 'cufwConnGlobalConnSetupRate5' } ], + output_template => 'average last 5min : %s', output_error_template => "average last 5min : %s", + perfdatas => [ + { label => 'connections_5m', value => 'cufwConnGlobalConnSetupRate5_absolute', template => '%d', + min => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{sessions} = [ + { label => 'sessions-total', set => { + key_values => [ { name => 'crasNumSessions' } ], + output_template => 'total : %s', output_error_template => "total : %s", + perfdatas => [ + { label => 'sessions_total', value => 'crasNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-email-current', set => { + key_values => [ { name => 'crasEmailNumSessions' } ], + output_template => 'current email proxy : %s', output_error_template => "current email proxy : %s", + perfdatas => [ + { label => 'sessions_email_current', value => 'crasEmailNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-email-psec', set => { + key_values => [ { name => 'crasEmailCumulateSessions', diff => 1 } ], + output_template => 'email proxy : %.2f/s', output_error_template => "email proxy : %s", + per_second => 1, + perfdatas => [ + { label => 'sessions_email_psec', value => 'crasEmailCumulateSessions_per_second', template => '%.2f', + min => 0 }, + ], + } + }, + { label => 'sessions-ipsec-current', set => { + key_values => [ { name => 'crasIPSecNumSessions' } ], + output_template => 'current ipsec : %s', output_error_template => "current ipsec : %s", + perfdatas => [ + { label => 'sessions_ipsec_current', value => 'crasIPSecNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-ipsec-psec', set => { + key_values => [ { name => 'crasIPSecCumulateSessions', diff => 1 } ], + output_template => 'ipsec : %.2f/s', output_error_template => "ipsec : %s", + per_second => 1, + perfdatas => [ + { label => 'sessions_ipsec_psec', value => 'crasIPSecCumulateSessions_per_second', template => '%.2f', + min => 0 }, + ], + } + }, + { label => 'sessions-l2l-current', set => { + key_values => [ { name => 'crasL2LNumSessions' } ], + output_template => 'current LAN to LAN : %s', output_error_template => "current LAN to LAN : %s", + perfdatas => [ + { label => 'sessions_l2l_current', value => 'crasL2LNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-l2l-psec', set => { + key_values => [ { name => 'crasL2LCumulateSessions', diff => 1 } ], + output_template => 'LAN to LAN : %.2f/s', output_error_template => "LAN to LAN : %s", + per_second => 1, + perfdatas => [ + { label => 'sessions_l2l_psec', value => 'crasL2LCumulateSessions_per_second', template => '%.2f', + min => 0 }, + ], + } + }, + { label => 'sessions-lb-current', set => { + key_values => [ { name => 'crasLBNumSessions' } ], + output_template => 'current load balancing : %s', output_error_template => "current load balancing : %s", + perfdatas => [ + { label => 'sessions_lb_current', value => 'crasLBNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-lb-psec', set => { + key_values => [ { name => 'crasLBCumulateSessions', diff => 1 } ], + output_template => 'load balancing : %.2f/s', output_error_template => "load balancing : %s", + per_second => 1, + perfdatas => [ + { label => 'sessions_lb_psec', value => 'crasLBCumulateSessions_per_second', template => '%.2f', + min => 0 }, + ], + } + }, + { label => 'sessions-svc-current', set => { + key_values => [ { name => 'crasSVCNumSessions' } ], + output_template => 'current SVC : %s', output_error_template => "current SVC : %s", + perfdatas => [ + { label => 'sessions_svc_current', value => 'crasSVCNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-svc-psec', set => { + key_values => [ { name => 'crasSVCCumulateSessions', diff => 1 } ], + output_template => 'SVC : %.2f/s', output_error_template => "SVC : %s", + per_second => 1, + perfdatas => [ + { label => 'sessions_svc_psec', value => 'crasSVCCumulateSessions_per_second', template => '%.2f', + min => 0 }, + ], + } + }, + { label => 'sessions-webvpn-current', set => { + key_values => [ { name => 'crasWebvpnNumSessions' } ], + output_template => 'current webvpn : %s', output_error_template => "current webvpn : %s", + perfdatas => [ + { label => 'sessions_webvpn_current', value => 'crasWebvpnNumSessions_absolute', template => '%d', + min => 0 }, + ], + } + }, + { label => 'sessions-webvpn-psec', set => { + key_values => [ { name => 'crasWebvpnCumulateSessions', diff => 1 } ], + output_template => 'webvpn : %.2f/s', output_error_template => "webvpn : %s", + per_second => 1, + perfdatas => [ + { label => 'sessions_webvpn_psec', value => 'crasWebvpnCumulateSessions_per_second', template => '%.2f', + min => 0 }, + ], + } + }, + ]; +} + +sub prefix_connections_output { + my ($self, %options) = @_; + + return "Connections "; +} + +sub prefix_sessions_output { + my ($self, %options) = @_; + + return "Sessions "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +my %oids_connections = ( + cufwConnGlobalNumActive => '.1.3.6.1.4.1.9.9.491.1.1.1.6.0', + cufwConnGlobalConnSetupRate1 => '.1.3.6.1.4.1.9.9.491.1.1.1.10.0', + cufwConnGlobalConnSetupRate5 => '.1.3.6.1.4.1.9.9.491.1.1.1.11.0', +); +my %oids_sessions = ( + crasNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.1.0', + crasEmailNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.23.0', + crasEmailCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.24.0', + crasIPSecNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.26.0', + crasIPSecCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.27.0', + crasL2LNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.29.0', + crasL2LCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.30.0', + crasLBNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.32.0', + crasLBCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.33.0', + crasSVCNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.35.0', + crasSVCCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.36.0', + crasWebvpnNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.38.0', + crasWebvpnCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.39.0', +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "cisco_standard_" . $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->{connections} = {}; + $self->{sessions} = {}; + + $self->{results} = $options{snmp}->get_leef(oids => [values %oids_connections, values %oids_sessions], + nothing_quit => 1); + foreach my $name (keys %oids_connections) { + next if (!defined($self->{results}->{$oids_connections{$name}}) || $self->{results}->{$oids_connections{$name}} == 0); + $self->{connections}->{$name} = $self->{results}->{$oids_connections{$name}}; + } + foreach my $name (keys %oids_sessions) { + next if (!defined($self->{results}->{$oids_sessions{$name}}) || $self->{results}->{$oids_sessions{$name}} == 0); + $self->{sessions}->{$name} = $self->{results}->{$oids_sessions{$name}}; + } +} + +1; + +__END__ + +=head1 MODE + +Check sessions. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'connections-current', 'connections-1m', 'connections-5m', +'sessions-total', 'sessions-email-current', 'sessions-email-psec', +'sessions-ipsec-current', 'sessions-ipsec-psec', 'sessions-l2l-current', 'sessions-lb-psec' +'sessions-lb-current', 'sessions-lb-psec', 'sessions-svc-current', 'sessions-svc-psec', +'sessions-webvpn-current', 'sessions-webvpn-psec'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'connections-current', 'connections-1m', 'connections-5m', +'sessions-total', 'sessions-email-current', 'sessions-email-psec', +'sessions-ipsec-current', 'sessions-ipsec-psec', 'sessions-l2l-current', 'sessions-lb-psec' +'sessions-lb-current', 'sessions-lb-psec', 'sessions-svc-current', 'sessions-svc-psec', +'sessions-webvpn-current', 'sessions-webvpn-psec'. + +=back + +=cut diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm index 52ef846bb..e971e36e0 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -65,7 +65,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cswRingRedundant = '.1.3.6.1.4.1.9.9.500.1.1.3'; diff --git a/centreon-plugins/centreon/common/dell/powerconnect3000/mode/globalstatus.pm b/centreon-plugins/centreon/common/dell/powerconnect3000/mode/globalstatus.pm index 7791172b5..c2199f00a 100644 --- a/centreon-plugins/centreon/common/dell/powerconnect3000/mode/globalstatus.pm +++ b/centreon-plugins/centreon/common/dell/powerconnect3000/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -51,7 +51,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_productStatusGlobalStatus = '.1.3.6.1.4.1.674.10895.3000.1.2.110.1'; diff --git a/centreon-plugins/centreon/common/emc/navisphere/custom/custom.pm b/centreon-plugins/centreon/common/emc/navisphere/custom/custom.pm index 2fe2e1997..17e40e06c 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/custom/custom.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/custom/custom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm index eb7d06386..e1c39a72b 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -47,7 +47,6 @@ my %states = ( ], ); - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -81,13 +80,13 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /(.*?):(.*?)=(.*)/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($label, $filter, $threshold) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $threshold) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $self->{overload_th}->{$label} = {} if (!defined($self->{overload_th}->{$label})); diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/controller.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/controller.pm index 639e291c7..b0aa0a81a 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/controller.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/controller.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm index 267694f6d..3971afccc 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,133 +20,14 @@ package centreon::common::emc::navisphere::mode::disk; -sub get_absolute { - my ($self, %options) = @_; - my $name = $options{instance} . '_' . $options{label}; - my $value; - - $self->{new_datas}->{$name} = $1; - - $self->{old_datas}->{$name} = $self->{statefile_value}->get(name => $name); - return undef if (!defined($self->{old_datas}->{$name})); - - # Reward... put to 0 - if ($self->{old_datas}->{$name} > $self->{new_datas}->{$name}) { - $self->{old_datas}->{$name} = 0; - } - - $value = ($self->{new_datas}->{$name} - $self->{old_datas}->{$name}); - - return ($value, $value); -} - -sub get_bytes_per_seconds { - my ($self, %options) = @_; - my $name = $options{instance} . '_' . $options{label}; - my $value; - - $self->{new_datas}->{$name} = $1; - if (!defined($self->{old_datas}->{last_timestamp})) { - $self->{old_datas}->{last_timestamp} = $self->{statefile_value}->get(name => 'last_timestamp'); - } - $self->{old_datas}->{$name} = $self->{statefile_value}->get(name => $name); - return undef if (!defined($self->{old_datas}->{last_timestamp}) || !defined($self->{old_datas}->{$name})); - - # Reward... put to 0 - if ($self->{old_datas}->{$name} > $self->{new_datas}->{$name}) { - $self->{old_datas}->{$name} = 0; - } - # At least one second - my $delta_time = $self->{new_datas}->{last_timestamp} - $self->{old_datas}->{last_timestamp}; - if ($delta_time <= 0) { - $delta_time = 1; - } - - $value = ($self->{new_datas}->{$name} - $self->{old_datas}->{$name}) / $delta_time; - my ($scale_value, $scale_unit) = $self->{perfdata}->change_bytes(value => $value); - - return ($value, $scale_value . ' ' . $scale_unit); -} - -sub get_utils { - my ($self, %options) = @_; - my $name = $options{instance} . '_' . $options{label}; - my $value; - - $self->{new_datas}->{$name . '_busy'} = $1; - $self->{new_datas}->{$name . '_idle'} = $2; - - $self->{old_datas}->{$name . '_busy'} = $self->{statefile_value}->get(name => $name . '_busy'); - $self->{old_datas}->{$name . '_idle'} = $self->{statefile_value}->get(name => $name . '_idle'); - return undef if (!defined($self->{old_datas}->{$name . '_busy'}) || !defined($self->{old_datas}->{$name . '_idle'})); - - # Reward... put to 0 - if ($self->{old_datas}->{$name . '_busy'} > $self->{new_datas}->{$name . '_busy'}) { - $self->{old_datas}->{$name . '_busy'} = 0; - } - if ($self->{old_datas}->{$name . '_idle'} > $self->{new_datas}->{$name . '_idle'}) { - $self->{old_datas}->{$name . '_idle'} = 0; - } - - my $total_ticks = ($self->{new_datas}->{$name . '_idle'} - $self->{old_datas}->{$name . '_idle'}) + - ($self->{new_datas}->{$name . '_busy'} - $self->{old_datas}->{$name . '_busy'}); - if ($total_ticks <= 0) { - return (0, 0); - } - $value = ($self->{new_datas}->{$name . '_busy'} - $self->{old_datas}->{$name . '_busy'}) * 100 / $total_ticks; - - return ($value, $value); -} - -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::statefile; use centreon::plugins::misc; +use Digest::MD5 qw(md5_hex); -my $maps_counters = { - hard_read_errors => { thresholds => { - warning_hard_read_errors => { label => 'warning-hard-read-errors', exit_value => 'warning' }, - critical_hard_read_errors => { label => 'critical-hard-read-errors', exit_value => 'critical' }, - }, - matching => 'Hard Read Errors:\s+(\d+)', closure => \&get_absolute, - output_msg => 'Hard Read Errors : %d', perfdata => '%s', - unit => '', - }, - hard_write_errors => { thresholds => { - warning_hard_write_errors => { label => 'warning-hard-write-errors', exit_value => 'warning' }, - critical_hard_write_errors => { label => 'critical-hard-write-errors', exit_value => 'critical' }, - }, - matching => 'Hard Write Errors:\s+(\d+)', closure => \&get_absolute, - output_msg => 'Hard Write Errors : %d', perfdata => '%s', - unit => '', - }, - write_io => { thresholds => { - warning_write_io => { label => 'warning-write-io', exit_value => 'warning' }, - critical_write_io => { label => 'critical-write-io', exit_value => 'critical' }, - }, - matching => 'Kbytes Written:\s+(\d+)', closure => \&get_bytes_per_seconds, - output_msg => 'Write I/O : %s', perfdata => '%d', - unit => 'B', - }, - read_io => { thresholds => { - warning_read_io => { label => 'warning-read-io', exit_value => 'warning' }, - critical_read_io => { label => 'critical-read-io', exit_value => 'critical' }, - }, - matching => 'Kbytes Read:\s+(\d+)', closure => \&get_bytes_per_seconds, - output_msg => 'Read I/O : %s', perfdata => '%d', - unit => 'B', - }, - utils => { thresholds => { - warning_utils => { label => 'warning-utils', exit_value => 'warning' }, - critical_utils => { label => 'critical-utils', exit_value => 'critical' }, - }, - matching => 'Busy Ticks:\s+(\d+).*Idle Ticks:\s+(\d+)', closure => \&get_utils, - output_msg => 'Utils : %.2f %%', perfdata => '%.2f', - unit => '%', - }, -}; +my $instance_mode; my @states = ( ['^enabled$' , 'OK'], @@ -168,92 +49,151 @@ my @states = ( ['^.*$' , 'CRITICAL'], ); +sub custom_threshold_check { + my ($self, %options) = @_; + + foreach (@states) { + if ($self->{result_values}->{state} =~ /$_->[0]/i) { + return $_->[1]; + } + } + + return 'ok'; +} + +sub custom_state_output { + my ($self, %options) = @_; + + my $msg = sprintf("state is '%s'", $self->{result_values}->{state}); + return $msg; +} + +sub custom_state_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub custom_utils_calc { + my ($self, %options) = @_; + + my $diff_busy = $options{new_datas}->{$self->{instance} . '_busy_ticks'} - $options{old_datas}->{$self->{instance} . '_busy_ticks'}; + my $diff_idle = $options{new_datas}->{$self->{instance} . '_idle_ticks'} - $options{old_datas}->{$self->{instance} . '_idle_ticks'}; + + if (($diff_busy + $diff_idle) == 0) { + $self->{error_msg} = "wait new values"; + return -3; + } + $self->{result_values}->{utils} = $diff_busy * 100 / ($diff_busy + $diff_idle); + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'disk', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All disks are OK', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{disk} = [ + { label => 'state', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_state_calc'), + closure_custom_output => $self->can('custom_state_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_check'), + } + }, + { label => 'hard-read-errors', set => { + key_values => [ { name => 'hard_read_errors', diff => 1 }, { name => 'display' } ], + output_template => 'Hard Read Errors : %d', + perfdatas => [ + { label => 'hard_read_errors', value => 'hard_read_errors_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'hard-write-errors', set => { + key_values => [ { name => 'hard_write_errors', diff => 1 }, { name => 'display' } ], + output_template => 'Hard Write Errors : %d', + perfdatas => [ + { label => 'hard_write_errors', value => 'hard_write_errors_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'read-io', set => { + key_values => [ { name => 'read_io', diff => 1 }, { name => 'display' } ], + output_template => 'Read I/O : %s %s/s', + per_second => 1, output_change_bytes => 1, + perfdatas => [ + { label => 'read_io', value => 'read_io_absolute', template => '%s', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'write-io', set => { + key_values => [ { name => 'write_io', diff => 1 }, { name => 'display' } ], + output_template => 'Write I/O : %s %s/s', + per_second => 1, output_change_bytes => 1, + perfdatas => [ + { label => 'write_io', value => 'write_io_absolute', template => '%s', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'utils', set => { + key_values => [ { name => 'busy_ticks', diff => 1 }, { name => 'idle_ticks', diff => 1 }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_utils_calc'), + output_template => 'Utils : %.2f %%', output_use => 'utils', + perfdatas => [ + { label => 'utils', value => 'utils', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, + ], + } + }, + ]; +} + +sub prefix_disk_output { + my ($self, %options) = @_; + + return "Disk '" . $options{instance_value}->{display} . "' "; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "threshold-overload:s@" => { name => 'threshold_overload' }, "filter-raidgroupid:s" => { name => 'filter_raidgroupid', }, "filter-disk:s" => { name => 'filter_disk', }, }); - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - $options{options}->add_options(arguments => { - $maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name }, - }); - } - } - - $self->{statefile_value} = centreon::plugins::statefile->new(%options); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); - - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'."); - $self->{output}->option_exit(); - } - } - } + $self->SUPER::check_options(%options); - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /(.*?)=(.*)/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - - my ($filter, $threshold) = ($1, $2); - if ($self->{output}->is_litteral_status(status => $threshold) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$filter} = $threshold; - } - - $self->{statefile_value}->check_options(%options); + $instance_mode = $self; } -sub get_severity { +sub manage_selection { my ($self, %options) = @_; - my $status = 'unknown'; - foreach my $entry (@states) { - if ($options{value} =~ /${$entry}[0]/i) { - $status = ${$entry}[1]; - foreach my $filter (keys %{$self->{overload_th}}) { - if (${$entry}[0] =~ /$filter/i) { - $status = $self->{overload_th}->{$filter}; - last; - } - } - last; - } - } - - return $status; -} - -sub run { - my ($self, %options) = @_; - my $clariion = $options{custom}; - - my $response = $clariion->execute_command(cmd => 'getdisk -state -bytrd -bytwrt -hw -hr -busyticks -idleticks -rg'); - - my ($total_num_disks, $skip_num_disks) = (0, 0); - $self->{new_datas} = {}; - $self->{statefile_value}->read(statefile => "cache_clariion_" . $clariion->{hostname} . '_' . $self->{mode}); - $self->{new_datas}->{last_timestamp} = time(); + $self->{disk} = {}; + $self->{cache_name} = "cache_clariion_" . $options{custom}->{hostname} . '_' . $options{custom}->{mode} . '_' . + (defined($self->{option_results}->{filter_disk}) ? md5_hex($self->{option_results}->{filter_disk}) : md5_hex('all')); + + my $response = $options{custom}->execute_command(cmd => 'getdisk -state -bytrd -bytwrt -hw -hr -busyticks -idleticks -rg'); #Bus 1 Enclosure 7 Disk 13 #State: Enabled @@ -264,6 +204,9 @@ sub run { #Busy Ticks: 462350 #Idle Ticks: 388743630 #Raid Group ID: 0 + + # Add a "\n" for the end. + $response .= "\n"; while ($response =~ /^Bus\s+(\S+)\s+Enclosure\s+(\S+)\s+Disk\s+(\S+)(.*?)\n\n/msgi) { my $disk_instance = "$1_$2_$3"; my $values = $4; @@ -271,77 +214,31 @@ sub run { # First Filters if (defined($self->{option_results}->{filter_disk}) && $self->{option_results}->{filter_disk} ne '' && $disk_instance !~ /$self->{option_results}->{filter_disk}/) { - $skip_num_disks++; - $self->{output}->output_add(long_msg => "Skipping disk '" . $disk_instance . "': no matching filter disk"); + $self->{output}->output_add(long_msg => "skipping disk '" . $disk_instance . "': no matching filter disk", debug => 1); next; } if (defined($self->{option_results}->{filter_raidgroupid}) && $self->{option_results}->{filter_raidgroupid} ne '' && $values =~ /^Raid Group ID:\s+(\S+)/mi && $1 !~ /$self->{option_results}->{filter_raidgroupid}/) { - $skip_num_disks++; - $self->{output}->output_add(long_msg => "Skipping disk '" . $disk_instance . "': no matching filter raid group id"); + $self->{output}->output_add(long_msg => "skipping disk '" . $disk_instance . "': no matching filter raid group id", debug => 1); next; } - $total_num_disks++; - $values =~ /^State:\s+(.*?)(\n|$)/msi; - - my $state = centreon::plugins::misc::trim($1); - my $exit = $self->get_severity(value => $state); - if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Disk '%s' state is %s", - $disk_instance, $state)); - # Don't check values if in critical/warning - next; + my $datas = {}; + while ($values =~ /^([^\n]*?):(.*?)\n/msgi) { + $datas->{centreon::plugins::misc::trim(lc($1))} = centreon::plugins::misc::trim($2); } - # Work on values. No check if in 'Hot Spare Ready' or 'Unbound' - next if ($state =~ /^(Hot Spare Ready|Unbound)$/i); - - my ($short_msg, $long_msg) = ('', ''); - my @exits; - foreach (keys %{$maps_counters}) { - next if ($values !~ /$maps_counters->{$_}->{matching}/msi); - my ($value_check, $value_output) = &{$maps_counters->{$_}->{closure}}($self, - instance => $disk_instance, label => $_); - next if (!defined($value_check)); - my ($warning, $critical); - - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - my $exit2 = $self->{perfdata}->threshold_check(value => $value_check, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); - $long_msg .= ' ' . sprintf($maps_counters->{$_}->{output_msg}, $value_output); - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= ' ' . sprintf($maps_counters->{$_}->{output_msg}, $value_output); - } - push @exits, $exit2; - - $warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning'); - $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); - } - - $self->{output}->output_add(long_msg => "Disk '$disk_instance':$long_msg"); - $self->{output}->perfdata_add(label => $_ . '_' . $disk_instance, unit => $maps_counters->{$_}->{unit}, - value => sprintf($maps_counters->{$_}->{perfdata}, $value_check), - warning => $warning, - critical => $critical, - min => 0); - } - - $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 => "Disk '$disk_instance':$short_msg" - ); - } + $self->{disk}->{$disk_instance} = { + display => $disk_instance, + state => $datas->{state}, + hard_read_errors => $datas->{'hard read errors'}, + hard_write_errors => $datas->{'hard write errors'}, + read_io => defined($datas->{'kbytes read'}) ? $datas->{'kbytes read'} * 1024 : undef, + write_io => defined($datas->{'kbytes write'}) ? $datas->{'kbytes write'} * 1024 : undef, + busy_ticks => $datas->{'busy ticks'}, + idle_ticks => $datas->{'idle ticks'}, + }; } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s disks are ok.", - $total_num_disks . '/' . $skip_num_disks) - ); - $self->{statefile_value}->write(data => $self->{new_datas}); - $self->{output}->display(); - $self->{output}->exit(); } 1; @@ -364,11 +261,6 @@ Can be: 'read-errors', 'write-errors', 'read-io', 'write-io', 'utils'. Threshold critical. Can be: 'read-errors', 'write-errors', 'read-io', 'write-io', 'utils'. -=item B<--threshold-overload> - -Set to overload default threshold value. -Example: --threshold-overload='(enabled)=critical' - =item B<--filter-disk> Filter Disk (regexp can be used). diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/faults.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/faults.pm index 82c26452f..0f569c903 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/faults.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/faults.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm index fa3fce133..4cb719d17 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -98,7 +98,7 @@ sub check_hba { my $not_logged = 0; my $logged = 0; - while ($hba_infos =~ /(SP Name:.*?)\n\n/msig) { + while ($hba_infos =~ /(SP Name:.*?)(\n\n|\Z)/msig) { my $port_infos = $1; # Not in good section diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/listluns.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/listluns.pm index cb9981502..088d12428 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/listluns.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/listluns.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm index 8842c6aaa..6a01c8327 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -52,7 +52,7 @@ sub check_port { if ($self->{response} =~ /Information about each SPPORT:(.*)/msi) { my $port_infos = $1; - while ($port_infos =~ /(SP Name:.*?)\n\n/msig) { + while ($port_infos =~ /(SP Name:.*?)(\n\n|\Z)/msig) { my $port_infos = $1; # Not in good section diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm index 0699b360b..b8e9b7f00 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,141 +20,84 @@ package centreon::common::emc::navisphere::mode::sp; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::common::emc::navisphere::mode::spcomponents::fan; -use centreon::common::emc::navisphere::mode::spcomponents::lcc; -use centreon::common::emc::navisphere::mode::spcomponents::psu; -use centreon::common::emc::navisphere::mode::spcomponents::battery; -use centreon::common::emc::navisphere::mode::spcomponents::memory; -use centreon::common::emc::navisphere::mode::spcomponents::cpu; -use centreon::common::emc::navisphere::mode::spcomponents::iomodule; -use centreon::common::emc::navisphere::mode::spcomponents::cable; -use centreon::common::emc::navisphere::mode::spcomponents::sp; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|lcc|psu|battery|memory|cpu|iomodule|cable)$'; + + $self->{cb_hook2} = 'navisphere_execute'; + + $self->{thresholds} = { + battery => [ + ['^(Not Ready|Testing|Unknown)$', 'WARNING'], + ['^(?!(Present|Valid)$)', 'CRITICAL'], + ['.*', 'OK'], + ], + psu => [ + ['^(?!(Present|Valid)$)', 'CRITICAL'], + ['.*', 'OK'], + ], + sp => [ + ['^(?!(Present|Valid)$)', 'CRITICAL'], + ['.*', 'OK'], + ], + cable => [ + ['^(.*Unknown.*)$' => 'WARNING'], + ['^(?!(Present|Valid)$)' => 'CRITICAL'], + ['.*', 'OK'], + ], + cpu => [ + ['^(?!(Present|Valid)$)' => 'CRITICAL'], + ['.*', 'OK'], + ], + fan => [ + ['^(?!(Present|Valid)$)' => 'CRITICAL'], + ['.*', 'OK'], + ], + io => [ + ['^(?!(Present|Valid|Empty)$)' => 'CRITICAL'], + ['.*', 'OK'], + ], + lcc => [ + ['^(?!(Present|Valid)$)' => 'CRITICAL'], + ['.*', 'OK'], + ], + dimm => [ + ['^(?!(Present|Valid)$)' => 'CRITICAL'], + ['.*', 'OK'], + ], + }; + + $self->{components_path} = 'centreon::common::emc::navisphere::mode::spcomponents'; + $self->{components_module} = ['fan', 'lcc', 'psu', 'battery', 'memory', 'cpu', 'iomodule', 'cable']; +} + +sub navisphere_execute { + my ($self, %options) = @_; + + $self->{response} = $options{custom}->execute_command(cmd => 'getcrus ' . $self->{option_results}->{getcrus_options}); + chomp $self->{response}; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "getcrus-options:s" => { name => 'getcrus_options', default => '-all' }, - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => 'all' }, - "no-component:s" => { name => 'no_component' }, }); - - $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'; - } - } -} - -sub component { - my ($self, %options) = @_; - - if ($self->{option_results}->{component} eq 'all') { - centreon::common::emc::navisphere::mode::spcomponents::fan::check($self); - centreon::common::emc::navisphere::mode::spcomponents::lcc::check($self); - centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); - centreon::common::emc::navisphere::mode::spcomponents::battery::check($self); - centreon::common::emc::navisphere::mode::spcomponents::cable::check($self); - centreon::common::emc::navisphere::mode::spcomponents::iomodule::check($self); - centreon::common::emc::navisphere::mode::spcomponents::memory::check($self); - centreon::common::emc::navisphere::mode::spcomponents::cpu::check($self); - centreon::common::emc::navisphere::mode::spcomponents::sp::check($self); - } elsif ($self->{option_results}->{component} eq 'sp') { - centreon::common::emc::navisphere::mode::spcomponents::sp::check($self); - } elsif ($self->{option_results}->{component} eq 'fan') { - centreon::common::emc::navisphere::mode::spcomponents::fan::check($self); - } elsif ($self->{option_results}->{component} eq 'lcc') { - centreon::common::emc::navisphere::mode::spcomponents::lcc::check($self); - } elsif ($self->{option_results}->{component} eq 'psu') { - centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'battery') { - centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'memory') { - centreon::common::emc::navisphere::mode::spcomponents::memory::check($self); - } elsif ($self->{option_results}->{component} eq 'cpu') { - centreon::common::emc::navisphere::mode::spcomponents::cpu::check($self); - } elsif ($self->{option_results}->{component} eq 'io') { - centreon::common::emc::navisphere::mode::spcomponents::iomodule::check($self); - } elsif ($self->{option_results}->{component} eq 'cable') { - centreon::common::emc::navisphere::mode::spcomponents::cable::check($self); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - 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}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components [%s] are ok.", - $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.'); - } -} - -sub run { - my ($self, %options) = @_; - my $clariion = $options{custom}; - - $self->{response} = $clariion->execute_command(cmd => 'getcrus ' . $self->{option_results}->{getcrus_options}); - chomp $self->{response}; - - $self->component(); - - $self->{output}->display(); - $self->{output}->exit(); -} - -sub check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - 1; __END__ @@ -172,13 +115,13 @@ Set option for 'getcrus' command (Default: '-all'). =item B<--component> -Which component to check (Default: 'all'). -Can be: 'cpu', 'psu', 'pc', 'fan', 'network', 'temperature', 'storage', 'battery'. +Which component to check (Default: '.*'). +Can be: 'fan', 'lcc', 'psu', 'battery', 'memory', 'cpu', 'iomodule', 'cable'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan,lcc) -Can also exclude specific instance: --exclude=fan#1.2#,lcc +Exclude some parts (comma seperated list) (Example: --filter=lcc --filter=fan) +Can also exclude specific instance: --filter=fan,1.2 =item B<--no-component> diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/battery.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/battery.pm index 87d98fc7b..5bb257dd4 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/battery.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/battery.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,17 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::battery; use strict; use warnings; -my @conditions = ( - ['^(Not Ready|Testing|Unknown)$' => 'WARNING'], - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking batteries"); $self->{components}->{battery} = {name => 'battery', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'battery')); + return if ($self->check_filter(section => 'battery')); # SPS means = Standby Power Supply @@ -44,19 +41,17 @@ sub check { $instance = "$1.$2.$3.$4"; } - next if ($self->check_exclude(section => 'battery', instance => $instance)); + next if ($self->check_filter(section => 'battery', instance => $instance)); $self->{components}->{battery}->{total}++; $self->{output}->output_add(long_msg => sprintf("Battery '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("Battery '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'battery', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Battery '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cable.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cable.pm index 7d8905973..73a475465 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cable.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cable.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,17 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::cable; use strict; use warnings; -my @conditions = ( - ['^(.*Unknown.*)$' => 'WARNING'], - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking cables"); $self->{components}->{cable} = {name => 'cables', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'cable')); + return if ($self->check_filter(section => 'cable')); # Enclosure SPE SPS A Cabling State: Valid while ($self->{response} =~ /^(?:Bus\s+(\d+)\s+){0,1}Enclosure\s+(\S+)\s+(Power|SPS)\s+(\S+)\s+Cabling\s+State:\s+(.*)$/mgi) { @@ -42,19 +39,17 @@ sub check { $instance = "$1.$2.$3.$4"; } - next if ($self->check_exclude(section => 'cable', instance => $instance)); + next if ($self->check_filter(section => 'cable', instance => $instance)); $self->{components}->{cable}->{total}++; $self->{output}->output_add(long_msg => sprintf("cable '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("cable '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'cable', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("cable '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm index bbde4a76a..4874e3b7f 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::cpu; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking cpu"); $self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'cpu')); + return if ($self->check_filter(section => 'cpu')); # Enclosure SPE CPU Module A State: Present while ($self->{response} =~ /^Enclosure\s+(\S+)\s+CPU\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2"; my $state = $3; - next if ($self->check_exclude(section => 'cpu', instance => $instance)); + next if ($self->check_filter(section => 'cpu', instance => $instance)); $self->{components}->{cpu}->{total}++; $self->{output}->output_add(long_msg => sprintf("cpu '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("cpu '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'cpu', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("cpu '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/fan.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/fan.pm index 3b9ada42a..ea2598480 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/fan.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::fan; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; 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_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); # Bus 0 Enclosure 0 Fan A State: Present while ($self->{response} =~ /^Bus\s+(\d+)\s+Enclosure\s+(\d+)\s+Fan\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2.$3"; my $state = $4; - next if ($self->check_exclude(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' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("fan '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'fan', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("fan '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm index b06f69e10..4a68e5e96 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::iomodule; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid|Empty)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking I/O modules"); $self->{components}->{io} = {name => 'IO module', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'io')); + return if ($self->check_filter(section => 'io')); # Enclosure SPE SP A I/O Module 0 State: Present while ($self->{response} =~ /^Enclosure\s+(\S+)\s+SP\s+(\S+)\s+I\/O\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2.$3"; my $state = $4; - next if ($self->check_exclude(section => 'io', instance => $instance)); + next if ($self->check_filter(section => 'io', instance => $instance)); $self->{components}->{io}->{total}++; $self->{output}->output_add(long_msg => sprintf("I/O module '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("I/O module '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'io', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("I/O module '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm index c0beaeda5..71cc1b105 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::lcc; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking link control card"); $self->{components}->{lcc} = {name => 'lccs', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'lcc')); + return if ($self->check_filter(section => 'lcc')); # Bus 1 Enclosure 6 LCC A State: Present while ($self->{response} =~ /^Bus\s+(\d+)\s+Enclosure\s+(\d+)\s+LCC\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2.$3"; my $state = $4; - next if ($self->check_exclude(section => 'lcc', instance => $instance)); + next if ($self->check_filter(section => 'lcc', instance => $instance)); $self->{components}->{lcc}->{total}++; $self->{output}->output_add(long_msg => sprintf("lcc '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("lcc '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'lcc', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("lcc '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/memory.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/memory.pm index 9cb489a5f..002bb0956 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/memory.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::memory; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking dimm"); $self->{components}->{dimm} = {name => 'dimm', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'dimm')); + return if ($self->check_filter(section => 'dimm')); # Enclosure SPE DIMM Module A State: Present while ($self->{response} =~ /^Enclosure\s+(\S+)\s+DIMM\s+Module\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = "$1.$2"; my $state = $3; - next if ($self->check_exclude(section => 'dimm', instance => $instance)); + next if ($self->check_filter(section => 'dimm', instance => $instance)); $self->{components}->{dimm}->{total}++; $self->{output}->output_add(long_msg => sprintf("Dimm '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("Dimm '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'dimm', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("dimm '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/psu.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/psu.pm index 26ee9d0e1..b25687d83 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/psu.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,16 +23,14 @@ package centreon::common::emc::navisphere::mode::spcomponents::psu; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; 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_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); # Enclosure SPE Power A0 State: Present # Bus 0 Enclosure 0 Power A State: Present @@ -42,19 +40,17 @@ sub check { $instance = "$1.$2.$3.$4"; } - next if ($self->check_exclude(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' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("Power Supply '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'psu', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power Supply '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/sp.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/sp.pm index 446afa5eb..06eef859d 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/sp.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/sp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,35 +23,31 @@ package centreon::common::emc::navisphere::mode::spcomponents::sp; use strict; use warnings; -my @conditions = ( - ['^(?!(Present|Valid)$)' => 'CRITICAL'], -); +sub load { }; sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking sp"); $self->{components}->{sp} = {name => 'sp', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'sp')); + return if ($self->check_filter(section => 'sp')); # SP A State: Present while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { my $instance = $1; my $state = $2; - next if ($self->check_exclude(section => 'sp', instance => $instance)); + next if ($self->check_filter(section => 'sp', instance => $instance)); $self->{components}->{sp}->{total}++; $self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.", $instance, $state) ); - foreach (@conditions) { - if ($state =~ /$$_[0]/i) { - $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("sp '%s' state is %s", - $instance, $state)); - last; - } + my $exit = $self->get_severity(section => 'sp', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("sp '%s' state is %s", + $instance, $state)); } } } diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/spinfo.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/spinfo.pm index 66e36925d..518b80f4e 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spinfo.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spinfo.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/fastpath/mode/components/fan.pm b/centreon-plugins/centreon/common/fastpath/mode/components/fan.pm new file mode 100644 index 000000000..0309c741f --- /dev/null +++ b/centreon-plugins/centreon/common/fastpath/mode/components/fan.pm @@ -0,0 +1,90 @@ +# +# Copyright 2016 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 centreon::common::fastpath::mode::components::fan; + +use strict; +use warnings; + +my %map_fan_status = ( + 1 => 'notpresent', + 2 => 'operational', + 3 => 'failed', + 4 => 'powering', + 5 => 'nopower', + 6 => 'notpowering', + 7 => 'incompatible', +); + +my $mapping = { + boxServicesFanItemState => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1.3', map => \%map_fan_status }, + boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1.4' }, +}; +my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_boxServicesFansEntry, begin => $mapping->{boxServicesFanItemState}->{oid} }; +} + +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')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesFansEntry}})) { + next if ($oid !~ /^$mapping->{boxServicesFanItemState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_boxServicesFansEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + if ($result->{boxServicesFanItemState} =~ /notPresent/i) { + $self->absent_problem(section => 'fan', instance => $instance); + next; + } + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s, speed = %s]", + $instance, $result->{boxServicesFanItemState}, $instance, defined($result->{boxServicesFanSpeed}) ? $result->{boxServicesFanSpeed} : 'unknown')); + $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{boxServicesFanItemState}); + 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->{boxServicesFanItemState})); + next; + } + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{boxServicesFanSpeed}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' is '%s' rpm", $instance, $result->{boxServicesFanSpeed})); + } + $self->{output}->perfdata_add(label => 'fan_' . $instance, unit => 'rpm', + value => $result->{boxServicesFanSpeed}, + warning => $warn, + critical => $crit, min => 0 + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/fastpath/mode/components/psu.pm b/centreon-plugins/centreon/common/fastpath/mode/components/psu.pm new file mode 100644 index 000000000..5b3a7f1d1 --- /dev/null +++ b/centreon-plugins/centreon/common/fastpath/mode/components/psu.pm @@ -0,0 +1,78 @@ +# +# Copyright 2016 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 centreon::common::fastpath::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'notpresent', + 2 => 'operational', + 3 => 'failed', + 4 => 'powering', + 5 => 'nopower', + 6 => 'notpowering', + 7 => 'incompatible', +); + +my $mapping = { + boxServicesPowSupplyItemState => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.7.1.3', map => \%map_status }, +}; +my $oid_boxServicesPowSuppliesEntry = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.7.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_boxServicesPowSuppliesEntry, begin => $mapping->{boxServicesPowSupplyItemState}->{oid} }; +} + +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')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesPowSuppliesEntry}})) { + next if ($oid !~ /^$mapping->{boxServicesPowSupplyItemState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_boxServicesPowSuppliesEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + if ($result->{boxServicesPowSupplyItemState} =~ /notPresent/i) { + $self->absent_problem(section => 'psu', instance => $instance); + next; + } + + $self->{components}->{psu}->{total}++; + $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]", + $instance, $result->{boxServicesPowSupplyItemState}, $instance)); + $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{boxServicesPowSupplyItemState}); + 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->{boxServicesPowSupplyItemState})); + next; + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/fastpath/mode/components/temperature.pm b/centreon-plugins/centreon/common/fastpath/mode/components/temperature.pm new file mode 100644 index 000000000..10c5b98ab --- /dev/null +++ b/centreon-plugins/centreon/common/fastpath/mode/components/temperature.pm @@ -0,0 +1,99 @@ +# +# Copyright 2016 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 centreon::common::fastpath::mode::components::temperature; + +use strict; +use warnings; + +my %map_temp_status = ( + 0 => 'low', + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', + 4 => 'shutdown', + 5 => 'notpresent', + 6 => 'notoperational', +); + +my $mapping1 = { + boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.3', map => \%map_temp_status }, + boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.4' }, +}; +my $mapping2 = { + boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.4', map => \%map_temp_status }, + boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.5' }, +}; +my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_boxServicesTempSensorsEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + my ($result, $exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesTempSensorsEntry}})) { + next if ($oid !~ /^$mapping2->{boxServicesTempSensorState}->{oid}\.(.*)$/); + my $instance = $1; + + if (defined($self->{results}->{$oid_boxServicesTempSensorsEntry}->{$mapping2->{boxServicesTempSensorTemperature}->{oid} . '.' . $instance})) { + $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_boxServicesTempSensorsEntry}, instance => $instance); + } else { + $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$oid_boxServicesTempSensorsEntry}, instance => $instance); + } + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + if ($result->{boxServicesTempSensorState} =~ /notPresent/i) { + $self->absent_problem(section => 'temperature', instance => $instance); + next; + } + + $self->{components}->{temperature}->{total}++; + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s, temperature = %s]", + $instance, $result->{boxServicesTempSensorState}, $instance, defined($result->{boxServicesTempSensorTemperature}) ? $result->{boxServicesTempSensorTemperature} : 'unknown')); + $exit = $self->get_severity(section => 'temperature', value => $result->{boxServicesTempSensorState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{boxServicesTempSensorState})); + next; + } + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{boxServicesTempSensorTemperature}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is '%s' C", $instance, $result->{boxServicesTempSensorTemperature})); + } + $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + value => $result->{boxServicesTempSensorTemperature}, + warning => $warn, + critical => $crit, min => 0 + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/centreon/common/fastpath/mode/cpu.pm b/centreon-plugins/centreon/common/fastpath/mode/cpu.pm index 63fa7207f..588fb1f15 100644 --- a/centreon-plugins/centreon/common/fastpath/mode/cpu.pm +++ b/centreon-plugins/centreon/common/fastpath/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_agentSwitchCpuProcessTotalUtilization1 = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0'; diff --git a/centreon-plugins/centreon/common/fastpath/mode/environment.pm b/centreon-plugins/centreon/common/fastpath/mode/environment.pm index bebab34b8..9c84c05e3 100644 --- a/centreon-plugins/centreon/common/fastpath/mode/environment.pm +++ b/centreon-plugins/centreon/common/fastpath/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,50 +20,50 @@ package centreon::common::fastpath::mode::environment; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1'; -my $oid_boxServicesFanItemState = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1.3'; -my $oid_boxServicesFanSpeed = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1.4'; -my $oid_boxServicesPowSuppliesEntry = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.7.1'; -my $oid_boxServicesPowSupplyItemState = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.7.1.3'; -my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1'; -my $oid_boxServicesTempSensorTemperature1 = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.4'; # oid for 6200 series -my $oid_boxServicesTempSensorTemperature2 = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.5'; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['notpresent', 'OK'], + ['operational', 'OK'], + ['failed', 'CRITICAL'], + ['powering', 'WARNING'], + ['nopower', 'CRITICAL'], + ['notpowering', 'CRITICAL'], + ['incompatible', 'CRITICAL'], + ], + temperature => [ + ['low', 'WARNING'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notpresent', 'OK'], + ['notoperational', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::fastpath::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature']; +} -my $thresholds = { - psu => [ - ['notpresent', 'OK'], - ['operational', 'OK'], - ['failed', 'CRITICAL'], - ['powering', 'WARNING'], - ['nopower', 'CRITICAL'], - ['notpowering', 'CRITICAL'], - ['incompatible', 'CRITICAL'], - ], - fan => [ - ['notpresent', 'OK'], - ['operational', 'OK'], - ['failed', 'CRITICAL'], - ['powering', 'WARNING'], - ['nopower', 'CRITICAL'], - ['notpowering', 'CRITICAL'], - ['incompatible', 'CRITICAL'], - ], -}; - -my %map_states = ( - 1 => 'notpresent', - 2 => 'operational', - 3 => 'failed', - 4 => 'powering', - 5 => 'nopower', - 6 => 'notpowering', - 7 => 'incompatible', -); +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -73,291 +73,35 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => 'all' }, - "absent-problem:s" => { name => 'absent' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning-temperature:s" => { name => 'warning_temperature' }, - "critical-temperature:s" => { name => 'critical_temperature' }, }); - - $self->{components} = {}; - $self->{no_components} = undef; + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning_temperature', value => $self->{option_results}->{warning_temperature})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning temperature threshold '" . $self->{option_results}->{warning_temperature} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_temperature', value => $self->{option_results}->{critical_temperature})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical temperature threshold '" . $self->{option_results}->{critical_temperature} . "'."); - $self->{output}->option_exit(); - } - - 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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-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}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - # There is a bug with get_leef and snmpv1. - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ - { oid => $oid_boxServicesFansEntry }, - { oid => $oid_boxServicesPowSuppliesEntry }, - { oid => $oid_boxServicesTempSensorsEntry }, - ]); - - if ($self->{option_results}->{component} eq 'all') { - $self->check_fan(); - $self->check_psu(); - $self->check_temperature(); - } elsif ($self->{option_results}->{component} eq 'fan') { - $self->check_fan(); - } elsif ($self->{option_results}->{component} eq 'psu') { - $self->check_psu(); - } elsif ($self->{option_results}->{component} eq 'temperature') { - $self->check_temperature(); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - 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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -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 check_fan { - my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking fans"); - $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesFansEntry}})) { - next if ($oid !~ /^$oid_boxServicesFanItemState\.(.*)/); - my $instance = $1; - my $fan_state = $self->{results}->{$oid_boxServicesFansEntry}->{$oid_boxServicesFanItemState . '.' . $instance}; - my $fan_speed = $self->{results}->{$oid_boxServicesFansEntry}->{$oid_boxServicesFanSpeed . '.' . $instance}; - - next if ($self->check_exclude(section => 'fan', instance => $instance)); - next if ($map_states{$fan_state} eq 'notPresent' && - $self->absent_problem(section => 'fan', instance => $instance)); - - $self->{components}->{fan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Fan '%s' state is %s.", - $instance, $map_states{$fan_state})); - my $exit = $self->get_severity(section => 'fan', value => $map_states{$fan_state}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Fan '%s' state is %s.", $instance, $map_states{$fan_state})); - } - - $self->{output}->perfdata_add(label => "Fan_$instance", - unit => 'rpm', - value => $fan_speed, - min => 0); - } -} - -sub check_psu { - my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking power supplies"); - $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesPowSuppliesEntry}})) { - next if ($oid !~ /^$oid_boxServicesPowSupplyItemState\.(.*)/); - my $instance = $1; - my $psu_state = $self->{results}->{$oid_boxServicesPowSuppliesEntry}->{$oid_boxServicesPowSupplyItemState . '.' . $instance}; - - next if ($self->check_exclude(section => 'psu', instance => $instance)); - next if ($map_states{$psu_state} eq 'notPresent' && - $self->absent_problem(section => 'psu', instance => $instance)); - - $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Power supply '%s' state is %s.", - $instance, $map_states{$psu_state})); - my $exit = $self->get_severity(section => 'psu', value => $map_states{$psu_state}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power supply '%s' state is %s.", $instance, $map_states{$psu_state})); - } - } -} - -sub check_temperature { - my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking temperature sensors"); - $self->{components}->{temperature} = {name => 'temperature sensors', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesTempSensorsEntry}})) { - my $instance; - if ($oid =~ /^$oid_boxServicesTempSensorTemperature1\.(.*)/) { - $instance = $1; - } elsif ($oid =~ /^$oid_boxServicesTempSensorTemperature2\.(.*)\.(.*)/) { - $instance = $1 . '.' . $2; - } else { - next; - } - my $temperature; - - if (defined($self->{results}->{$oid_boxServicesTempSensorsEntry}->{$oid_boxServicesTempSensorTemperature1 . '.' . $instance})) { - $temperature = $self->{results}->{$oid_boxServicesTempSensorsEntry}->{$oid_boxServicesTempSensorTemperature1 . '.' . $instance}; - } else { - $temperature = $self->{results}->{$oid_boxServicesTempSensorsEntry}->{$oid_boxServicesTempSensorTemperature2 . '.' . $instance}; - } - - next if ($self->check_exclude(section => 'temperature', instance => $instance)); - - $instance =~ s/(\d+)\.//; - - $self->{components}->{temperature}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Temperature sensor '%s' : %sc.", - $instance, $temperature)); - my $exit = $self->{perfdata}->threshold_check(value => $temperature, threshold => [ { label => 'critical_temperature', 'exit_litteral' => 'critical' }, { label => 'warning_temperature', exit_litteral => 'warning' } ]); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature sensor '%s' : %sc.", $instance, $temperature)); - } - - $self->{output}->perfdata_add(label => "Temperature_$instance", - unit => 'c', - value => $temperature); - } -} - 1; __END__ =head1 MODE -Check environment (FASTPATH-BOXSERVICES-MIB) (Fans, Power Supplies, Temperature). +Check Hardware (Fans, Power Supplies, Temperature) (FASTPATH-BOXSERVICES-MIB). =over 8 =item B<--component> -Which component to check (Default: 'all'). -Can be: 'psu', 'fan', 'temperature'. +Which component to check (Default: '.*'). +Can be: 'fan', 'psu', 'temperature'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='fan#fan2_unit1#' +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +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=psu +Can be specific or global: --absent-problem=psu,1 =item B<--no-component> @@ -366,18 +110,20 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). -Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)' +Example: --threshold-overload='psu,CRITICAL,^(?!(operational)$)' -=item B<--warning-temperature> +=item B<--warning> -Warning threshold for temperature in celsius. +Set warning threshold for 'temperature', 'fan' (syntax: type,regexp,threshold) +Example: --warning='fan,1.1,5000' -=item B<--critical-temperature> +=item B<--critical> -Critical threshold for temperature in celsius. +Set critical threshold for 'temperature', 'fan' (syntax: type,regexp,threshold) +Example: --critical='fan,.*,2000' =back -=cut +=cut \ No newline at end of file diff --git a/centreon-plugins/centreon/common/fastpath/mode/memory.pm b/centreon-plugins/centreon/common/fastpath/mode/memory.pm index e8527fab0..6d0ea1fcd 100644 --- a/centreon-plugins/centreon/common/fastpath/mode/memory.pm +++ b/centreon-plugins/centreon/common/fastpath/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_agentSwitchCpuProcessMemFree = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0'; # in KB diff --git a/centreon-plugins/centreon/common/force10/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/force10/snmp/mode/components/fan.pm index 0f0cc9c0f..a2e3f7377 100644 --- a/centreon-plugins/centreon/common/force10/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/force10/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -42,9 +42,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, { oid => $mapping->{mseries}->{OperStatus}->{oid} }, { oid => $mapping->{zseries}->{OperStatus}->{oid} }; } diff --git a/centreon-plugins/centreon/common/force10/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/force10/snmp/mode/components/psu.pm index 853f25d6f..15c098a06 100644 --- a/centreon-plugins/centreon/common/force10/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/force10/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -50,9 +50,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} }, { oid => $mapping->{mseries}->{OperStatus}->{oid} }, { oid => $mapping->{zseries}->{OperStatus}->{oid} }; } diff --git a/centreon-plugins/centreon/common/force10/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/force10/snmp/mode/components/temperature.pm index 7e38f45bd..e549b3e35 100644 --- a/centreon-plugins/centreon/common/force10/snmp/mode/components/temperature.pm +++ b/centreon-plugins/centreon/common/force10/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping = { my $oid_deviceSensorValueEntry = '.1.3.6.1.4.1.3417.2.1.1.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{sseries}->{Temp}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{sseries}->{Temp}->{oid} }, { oid => $mapping->{mseries}->{Temp}->{oid} }; } diff --git a/centreon-plugins/centreon/common/force10/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/force10/snmp/mode/cpu.pm index e308a6a56..9db4b06f4 100644 --- a/centreon-plugins/centreon/common/force10/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/force10/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/force10/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/force10/snmp/mode/hardware.pm index 65b78494c..f2bbfc618 100644 --- a/centreon-plugins/centreon/common/force10/snmp/mode/hardware.pm +++ b/centreon-plugins/centreon/common/force10/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,31 +20,49 @@ package centreon::common::force10::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - fan => [ - ['up', 'OK'], - ['absent', 'OK'], - ['down', 'CRITICAL'], - ], - psu => [ - ['up', 'OK'], - ['absent', 'OK'], - ['down', 'CRITICAL'], - - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['notPresent', 'OK'], - ['notFunctioning', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(psu|fan)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['up', 'OK'], + ['absent', 'OK'], + ['down', 'CRITICAL'], + ], + psu => [ + ['up', 'OK'], + ['absent', 'OK'], + ['down', 'CRITICAL'], + + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['notPresent', 'OK'], + ['notFunctioning', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::force10::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -53,241 +71,12 @@ sub new { $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' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $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 }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if ($section !~ /^temperature$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'temperature'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::force10::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 = "centreon::common::force10::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_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ diff --git a/centreon-plugins/centreon/common/force10/snmp/mode/memory.pm b/centreon-plugins/centreon/common/force10/snmp/mode/memory.pm index 9843d1429..7153def46 100644 --- a/centreon-plugins/centreon/common/force10/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/force10/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm index bb3055681..ab665e677 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -67,7 +67,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{result} = $self->{snmp}->get_multiple_table(oids => [ diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/cpu.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/cpu.pm index dfced7a4f..b39d18dc0 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/cpu.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -102,7 +102,6 @@ sub cpu_ha { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $table_oids = [ { oid => $oid_fgProcessorUsage }, { oid => $oid_fgSysCpuUsage } ]; diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/disk.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/disk.pm index 4abfbe481..6a06e2986 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/disk.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_fgSysDiskUsage = '.1.3.6.1.4.1.12356.101.4.1.6.0'; # in MB diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/hardware.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/hardware.pm index 2afebd3b6..697009092 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/hardware.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -51,7 +51,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/ipsstats.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/ipsstats.pm index f9a71d36f..1f88f7c3c 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/ipsstats.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/ipsstats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -154,7 +154,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/listvirtualdomains.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/listvirtualdomains.pm index cdb28a49f..992bc0161 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/listvirtualdomains.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/listvirtualdomains.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -77,7 +77,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -101,7 +100,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/memory.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/memory.pm index 92958e8a5..45c1dd18d 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/memory.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -100,7 +100,6 @@ sub memory_ha { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_fgSystemInfo = '.1.3.6.1.4.1.12356.101.4.1'; diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm index 1c6d2c140..65a2bc4e9 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -94,7 +94,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_fgSysSesCount = '.1.3.6.1.4.1.12356.101.4.1.8.0'; diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/virus.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/virus.pm index 297e63dd2..127663f97 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/virus.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/virus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -105,7 +105,6 @@ sub manage_selection { 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(); diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/vpn.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/vpn.pm new file mode 100644 index 000000000..cd6ae4cff --- /dev/null +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/vpn.pm @@ -0,0 +1,287 @@ +# +# Copyright 2016 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 centreon::common::fortinet::fortigate::mode::vpn; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_state_output { + my ($self, %options) = @_; + + my $msg = sprintf("state is '%s'", $self->{result_values}->{state}); + return $msg; +} + +sub custom_state_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'vdstats', type => 1, cb_prefix_output => 'prefix_vd_output', message_multiple => 'All virtual domains are OK' }, + { name => 'vpn', type => 1, cb_prefix_output => 'prefix_vpn_output', message_multiple => 'All VPNs states are OK' }, + ]; + $self->{maps_counters}->{vdstats} = [ + { label => 'users', set => { + key_values => [ { name => 'users' }, { name => 'display' } ], + output_template => 'Logged users: %s', + perfdatas => [ + { label => 'users', value => 'users_absolute', template => '%d', + min => 0, unit => 'users', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'sessions', set => { + key_values => [ { name => 'sessions' }, { name => 'display' } ], + output_template => 'Active web sessions: %s', + perfdatas => [ + { label => 'sessions', value => 'sessions_absolute', template => '%d', + min => 0, unit => 'sessions', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'tunnels', set => { + key_values => [ { name => 'tunnels' }, { name => 'display' } ], + output_template => 'Active Tunnels: %s', + perfdatas => [ + { label => 'active_tunnels', value => 'tunnels_absolute', template => '%d', + min => 0, unit => 'tunnels', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; + + $self->{maps_counters}->{vpn} = [ + { label => 'state', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => \&custom_state_calc, + closure_custom_output => \&custom_state_output, + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&custom_threshold_output, + } + }, + { label => 'traffic-in', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + per_second => 1, output_change_bytes => 1, + output_template => 'Traffic In: %s %s/s', + perfdatas => [ + { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'traffic-out', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + per_second => 1, output_change_bytes => 1, + output_template => 'Traffic Out: %s %s/s', + perfdatas => [ + { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + } + ]; +} + +sub prefix_vd_output { + my ($self, %options) = @_; + + return "Virtual domain '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_vpn_output { + my ($self, %options) = @_; + + return "Link '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-vpn:s" => { name => 'filter_vpn' }, + "filter-vdomain:s" => { name => 'filter_vdomain' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} eq "down"' }, + }); + return $self; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(); + $instance_mode = $self; +} + +my %map_status = ( + 1 => 'down', + 2 => 'up', +); + +my $mapping = { + fgVpnTunEntPhase2Name => { oid => '.1.3.6.1.4.1.12356.101.12.2.2.1.3' }, + fgVpnTunEntInOctets => { oid => '.1.3.6.1.4.1.12356.101.12.2.2.1.18' }, + fgVpnTunEntOutOctets => { oid => '.1.3.6.1.4.1.12356.101.12.2.2.1.19' }, + fgVpnTunEntStatus => { oid => '.1.3.6.1.4.1.12356.101.12.2.2.1.20', map => \%map_status }, +}; + +my $mapping2 = { + fgVpnSslStatsLoginUsers => { oid => '.1.3.6.1.4.1.12356.101.12.2.3.1.2' }, + fgVpnSslStatsActiveWebSessions => { oid => '.1.3.6.1.4.1.12356.101.12.2.3.1.4' }, + fgVpnSslStatsActiveTunnels => { oid => '.1.3.6.1.4.1.12356.101.12.2.3.1.6' }, +}; + +my $oid_fgVpnTunTable = '.1.3.6.1.4.1.12356.101.12.2.2.1'; +my $oid_fgVpnSslStatsTable = '.1.3.6.1.4.1.12356.101.12.2.3'; +my $oid_fgVdEntName = '.1.3.6.1.4.1.12356.101.3.2.1.1.2'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{cache_name} = "fortigate_" . $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->{results} = $options{snmp}->get_multiple_table(oids => [ + { oid => $oid_fgVdEntName }, + { oid => $oid_fgVpnTunTable }, + { oid => $oid_fgVpnSslStatsTable }, + ], + , nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}->{ $oid_fgVdEntName }}) { + $oid =~ /^$oid_fgVdEntName\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_fgVpnSslStatsTable}, instance => $instance); + my $vdomain_name = $self->{results}->{$oid_fgVdEntName}->{$oid_fgVdEntName.'.'.$instance}; + if (defined($self->{option_results}->{filter_vdomain}) && $self->{option_results}->{filter_vdomain} ne '' && + $vdomain_name !~ /$self->{option_results}->{filter_vdomain}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $vdomain_name . "': no matching filter.", debug => 1); + next; + } + $self->{vdstats}->{$vdomain_name} = { users => $result->{fgVpnSslStatsLoginUsers}, + sessions => $result->{fgVpnSslStatsActiveWebSessions}, + tunnels => $result->{fgVpnSslStatsActiveTunnels}, + display => $vdomain_name }; + } + + foreach my $oid (sort keys %{$self->{results}->{$oid_fgVpnTunTable}}) { + next if ($oid !~ /^$mapping->{fgVpnTunEntStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fgVpnTunTable}, instance => $instance); + if (defined($self->{option_results}->{filter_vpn}) && $self->{option_results}->{filter_vpn} ne '' && + $result->{fgVpnTunEntPhase2Name} !~ /$self->{option_results}->{filter_vpn}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $result->{fgVpnTunEntPhase2Name} . "': no matching filter.", debug => 1); + next; + } + $self->{vpn}->{$result->{fgVpnTunEntPhase2Name}} = { state => $result->{fgVpnTunEntStatus}, + traffic_in => $result->{fgVpnTunEntInOctets}, + traffic_out => $result->{fgVpnTunEntOutOctets}, + display => $result->{fgVpnTunEntPhase2Name} }; + } +} + +1; + +__END__ + +=head1 MODE + +Check Vdomain statistics and VPN state and traffic + +=over 8 + +=item B<--filter-*> + +Filter name with regexp. Can be ('vdomain', 'vpn') + +=item B<--warning-*> + +Warning on counters. Can be ('users', 'sessions', 'tunnels', 'traffic-in', 'traffic-out') + +=item B<--critical-*> + +Warning on counters. Can be ('users', 'sessions', 'tunnels', 'traffic-in', 'traffic-out') + +=item B<--warning-status> + +Set warning threshold for status. Use "%{state}" as a special variable. +Useful to be notified when tunnel is up "%{state} eq 'up'" + +=item B<--critical-status> + +Set critical threshold for status. Use "%{state}" as a special variable. +Useful to be notified when tunnel is up "%{state} eq 'up'" + +=back + +=cut diff --git a/centreon-plugins/centreon/common/jvm/mode/classcount.pm b/centreon-plugins/centreon/common/jvm/mode/classcount.pm index 8ae442e1d..5511a8356 100644 --- a/centreon-plugins/centreon/common/jvm/mode/classcount.pm +++ b/centreon-plugins/centreon/common/jvm/mode/classcount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/jvm/mode/cpuload.pm b/centreon-plugins/centreon/common/jvm/mode/cpuload.pm index c21dbe295..f94eef8b8 100644 --- a/centreon-plugins/centreon/common/jvm/mode/cpuload.pm +++ b/centreon-plugins/centreon/common/jvm/mode/cpuload.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/jvm/mode/fdusage.pm b/centreon-plugins/centreon/common/jvm/mode/fdusage.pm index 72ceabb19..e3f3c2f5c 100644 --- a/centreon-plugins/centreon/common/jvm/mode/fdusage.pm +++ b/centreon-plugins/centreon/common/jvm/mode/fdusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm b/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm index 0f948f91d..37b11ee8a 100644 --- a/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm +++ b/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/jvm/mode/memory.pm b/centreon-plugins/centreon/common/jvm/mode/memory.pm index ce9df77de..e2a09b1fa 100644 --- a/centreon-plugins/centreon/common/jvm/mode/memory.pm +++ b/centreon-plugins/centreon/common/jvm/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,11 +20,110 @@ package centreon::common::jvm::mode::memory; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'heap', type => 0 }, + { name => 'nonheap', type => 0 }, + ]; + + $self->{maps_counters}->{heap} = [ + { label => 'heap', set => { + key_values => [ { name => 'used' }, { name => 'max' }, { name => 'label' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + $self->{maps_counters}->{nonheap} = [ + { label => 'nonheap', set => { + key_values => [ { name => 'used' }, { name => 'max' }, { name => 'label' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +my $instance_mode; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $use_th = 1; + $use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0); + + my $value_perf = $self->{result_values}->{used}; + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) { + $total_options{total} = $self->{result_values}->{max}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $self->{result_values}->{label}, unit => 'B', + value => $value_perf, + warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, + critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, + min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + # Cannot use percent without total + return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%'); + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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 $msg; + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + if ($self->{result_values}->{max} > 0) { + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{max}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{max} - $self->{result_values}->{used}); + $msg = sprintf("%s Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $self->{result_values}->{label}, + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used}); + } else { + $msg = sprintf("%s Used: %s", $self->{result_values}->{label}, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}); + } + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{label} = $options{new_datas}->{$self->{label} . '_label'}; + $self->{result_values}->{max} = $options{new_datas}->{$self->{instance} . '_max'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + + if ($self->{result_values}->{max} > 0) { + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{max}; + } + + return 0; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -32,75 +131,30 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "warning-heap:s" => { name => 'warning_heap' }, - "critical-heap:s" => { name => 'critical_heap' }, - "warning-nonheap:s" => { name => 'warning_nonheap' }, - "critical-nonheap:s" => { name => 'critical_nonheap' }, + { + "units:s" => { name => 'units', default => '%' }, }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning-heap', value => $self->{option_results}->{warning_heap})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-heap threshold '" . $self->{option_results}->{warning_heap} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-heap', value => $self->{option_results}->{critical_heap})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-heap threshold '" . $self->{option_results}->{critical_heap} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-nonheap', value => $self->{option_results}->{warning_nonheap})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap threshold '" . $self->{option_results}->{warning_nonheap} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-nonheap', value => $self->{option_results}->{critical_nonheap})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap threshold '" . $self->{option_results}->{critical_nonheap} . "'."); - $self->{output}->option_exit(); - } + $self->SUPER::check_options(%options); + + $instance_mode = $self; } -sub run { +sub manage_selection { my ($self, %options) = @_; - $self->{connector} = $options{custom}; $self->{request} = [ { mbean => "java.lang:type=Memory" } ]; - my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); + my $result = $options{custom}->get_attributes(request => $self->{request}, nothing_quit => 1); - my $prct_heap = $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used} / $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max} * 100; - my $prct_nonheap = $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used} / $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max} * 100; - - my $exit1 = $self->{perfdata}->threshold_check(value => $prct_heap, - threshold => [ { label => 'critical-heap', exit_litteral => 'critical' }, { label => 'warning-heap', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $prct_nonheap, - threshold => [ { label => 'critical-nonheap', exit_litteral => 'critical' }, { label => 'warning-nonheap', exit_litteral => 'warning'} ]); - my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("HeapMemory Usage: %.2f%% - NonHeapMemoryUsage : %.2f%%", - $prct_heap, $prct_nonheap)); - - $self->{output}->perfdata_add(label => 'HeapMemoryUsage', unit => 'B', - value => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-heap', total => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-heap', total => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, cast_int => 1), - min => 0, max => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max}); - - $self->{output}->perfdata_add(label => 'NonHeapMemoryUsage', unit => 'B', - value => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-nonheap', total => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-nonheap', total => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, cast_int => 1), - min => 0, max => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max}); - - $self->{output}->display(); - $self->{output}->exit(); - + $self->{heap} = { label => 'HeapMemory', used => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, max => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max} }; + $self->{nonheap} = { label => 'NonHeapMemoryUsage', used => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, max => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max} }; } 1; @@ -132,6 +186,10 @@ Threshold warning of NonHeap memory usage Threshold critical of NonHeap memory usage +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + =back =cut diff --git a/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm b/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm index 55564e4df..927e93ec3 100644 --- a/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm +++ b/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/jvm/mode/threads.pm b/centreon-plugins/centreon/common/jvm/mode/threads.pm index 0edc8ba23..2502a0ce6 100644 --- a/centreon-plugins/centreon/common/jvm/mode/threads.pm +++ b/centreon-plugins/centreon/common/jvm/mode/threads.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/dell/compellent/hbausage.pm b/centreon-plugins/centreon/common/powershell/dell/compellent/hbausage.pm new file mode 100644 index 000000000..2105b539b --- /dev/null +++ b/centreon-plugins/centreon/common/powershell/dell/compellent/hbausage.pm @@ -0,0 +1,108 @@ +# +# Copyright 2016 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 centreon::common::powershell::dell::compellent::hbausage; + +use strict; +use warnings; +use centreon::plugins::misc; + +sub get_powershell { + my (%options) = @_; + my $no_ps = (defined($options{no_ps})) ? 1 : 0; + + return '' if ($no_ps == 1); + + my $ps = ' +$culture = new-object "System.Globalization.CultureInfo" "en-us" +[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture +$ProgressPreference = "SilentlyContinue" +$ErrorActionPreference = "Stop" + +$scuser = "' . $options{cem_user} . '" +$scpass = ConvertTo-SecureString "' . $options{cem_password} . '" -AsPlainText -Force +$schost = "' . $options{cem_host} . '" +$scport = "' . $options{cem_port} . '" +$connName = "EMDefault" + +Function display_hba_information { + $conn = Connect-DellApiConnection -HostName $schost -Port $scport -User $scuser -password $scpass -Save $connName +'; + if (defined($options{filter_sc}) && $options{filter_sc} ne '') { + $ps .= '$storageCenters = Get-DellStorageCenter -ConnectionName $connName -Name "' . $options{filter_sc} . '" +'; + } else { + $ps .= '$storageCenters = Get-DellStorageCenter -ConnectionName $connName +'; + } + + $ps .= ' + $historical = New-DellHistoricalFilter -FilterTime "Other" -StartTime "' . $options{start_time} . '" -EndTime "' . $options{end_time} . '" + foreach ($sc in $storageCenters) { + $hbaList = Get-DellScServerHba -ConnectionName $connName -StorageCenter $sc + + foreach ($hba in $hbaList) { + $usageList = Get-DellScServerHbaHistoricalIoUsage -ConnectionName $connName -Instance $hba -HistoricalFilter $historical + + write-host ("[sc={0}]" -f $hba.ScName) -NoNewline + write-host ("[name={0}]" -f $hba.Name) -NoNewline + + $attrs = @{ReadKbPerSecond = 0; WriteKbPerSecond = 0; ReadIops = 0; WriteIops = 0; ReadLatency = 0; WriteLatency = 0; } + $count = 0 + foreach ($usage in $usageList) { + foreach ($item in $($attrs.GetEnumerator() | sort -Property Key)) { + $attrs[$item.Key] += ($usage | Select -ExpandProperty $item.Key) + } + $count++ + } + + foreach ($item in $attrs.GetEnumerator() | sort -Property Key) { + write-host ("[{0}={1}]" -f $item.Key, ($item.Value / $count)) -NoNewline + } + write-host + } + } +} + +Try { + Import-Module "' . $options{sdk_path_dll} . '" + display_hba_information +} Catch { + Write-Host $Error[0].Exception + $ret = Remove-DellSavedApiConnection -Name $connName + exit 1 +} + +$ret = Remove-DellSavedApiConnection -Name $connName +exit 0 +'; + + return centreon::plugins::misc::powershell_encoded($ps); +} + +1; + +__END__ + +=head1 DESCRIPTION + +Method to get compellent hba informations. + +=cut \ No newline at end of file diff --git a/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm b/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm new file mode 100644 index 000000000..c8bd176e0 --- /dev/null +++ b/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm @@ -0,0 +1,121 @@ +# +# Copyright 2016 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 centreon::common::powershell::dell::compellent::volumeusage; + +use strict; +use warnings; +use centreon::plugins::misc; + +sub get_powershell { + my (%options) = @_; + my $no_ps = (defined($options{no_ps})) ? 1 : 0; + + return '' if ($no_ps == 1); + + my $ps = ' +$culture = new-object "System.Globalization.CultureInfo" "en-us" +[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture +$ProgressPreference = "SilentlyContinue" +$ErrorActionPreference = "Stop" + +$scuser = "' . $options{cem_user} . '" +$scpass = ConvertTo-SecureString "' . $options{cem_password} . '" -AsPlainText -Force +$schost = "' . $options{cem_host} . '" +$scport = "' . $options{cem_port} . '" +$connName = "EMDefault" + +Function display_volume_information { + $conn = Connect-DellApiConnection -HostName $schost -Port $scport -User $scuser -password $scpass -Save $connName +'; + if (defined($options{filter_sc}) && $options{filter_sc} ne '') { + $ps .= '$storageCenters = Get-DellStorageCenter -ConnectionName $connName -Name "' . $options{filter_sc} . '" +'; + } else { + $ps .= '$storageCenters = Get-DellStorageCenter -ConnectionName $connName +'; + } + + $ps .= ' + foreach ($sc in $storageCenters) { + $volumeList = Get-DellScVolume -ConnectionName $connName -StorageCenter $sc + foreach ($vol in $volumeList) { +'; + if (defined($options{filter_vol}) && $options{filter_vol} ne '') { + $ps .= 'if (-Not ($vol -match "' . $options{filter_vol} . '")) { continue } +'; + } + + $ps .= '$volusage = Get-DellScVolumeStorageUsageAssociation -ConnectionName $connName -Instance $vol + $usage = Get-DellScVolumeStorageUsage -ConnectionName $connName -Instance $volusage + + write-host ("[sc={0}]" -f $sc.Name) -NoNewline + write-host ("[volume={0}]" -f $usage.Name) -NoNewline + write-host ("[configuredSpace={0}]" -f $usage.ConfiguredSpace.GetByteSize()) -NoNewline + write-host ("[freeSpace={0}]" -f $usage.FreeSpace.GetByteSize()) -NoNewline + write-host ("[activeSpace={0}]" -f $usage.ActiveSpace.GetByteSize()) -NoNewline + write-host ("[raidOverhead={0}]" -f $usage.RaidOverhead.GetByteSize()) -NoNewline + write-host ("[totalDiskSpace={0}]" -f $usage.TotalDiskSpace.GetByteSize()) -NoNewline + write-host ("[replaySpace={0}]" -f $usage.replaySpace.GetByteSize()) + } +'; + + if (defined($options{filter_vol}) && $options{filter_vol} ne '') { + $ps .= 'continue +'; + } + + $ps .= '$diskList = Get-DellScDisk -ConnectionName $connName -StorageCenter $sc + foreach ($disk in $diskList) { + $diskusage = Get-DellScDiskStorageUsageAssociation -ConnectionName $connName -Instance $disk + $usage = Get-DellScDiskStorageUsage -ConnectionName $connName -Instance $diskusage + write-host ("[sc={0}]" -f $sc.Name) -NoNewline + write-host ("[disk={0}]" -f $disk.Name) -NoNewline + write-host ("[spare={0}]" -f $disk.Spare) -NoNewline + write-host ("[allocatedSpace={0}]" -f $usage.AllocatedSpace.GetByteSize()) + } + } +} + +Try { + Import-Module "' . $options{sdk_path_dll} . '" + display_volume_information +} Catch { + Write-Host $Error[0].Exception + $ret = Remove-DellSavedApiConnection -Name $connName + exit 1 +} + +$ret = Remove-DellSavedApiConnection -Name $connName +exit 0 +'; + + return centreon::plugins::misc::powershell_encoded($ps); +} + +1; + +__END__ + +=head1 DESCRIPTION + +Method to get compellent volume informations. + +=cut \ No newline at end of file diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/activesyncmailbox.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/activesyncmailbox.pm index 90a64cdf1..60c85682e 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/activesyncmailbox.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/activesyncmailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/databases.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/databases.pm index 0f589833c..e4a842564 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/databases.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/databases.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/imapmailbox.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/imapmailbox.pm index 0bb2f6bac..2b90af5e8 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/imapmailbox.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/imapmailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/listdatabases.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/listdatabases.pm index 448acf0aa..c50015f81 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/listdatabases.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/listdatabases.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/mapimailbox.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/mapimailbox.pm index 17b5fd514..761c08143 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/mapimailbox.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/mapimailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/outlookwebservices.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/outlookwebservices.pm index eeda8ab4a..a8b1956a2 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/outlookwebservices.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/outlookwebservices.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/owamailbox.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/owamailbox.pm index 74df5c949..17567819e 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/owamailbox.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/owamailbox.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/powershell.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/powershell.pm index 9433a061c..48ce78767 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/powershell.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/powershell.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/queues.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/queues.pm index 6729980a8..ddae7acc4 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/queues.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/queues.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -63,6 +63,8 @@ sub check { my $checked = 0; $self->{output}->output_add(long_msg => $options{stdout}); + + $self->{perfdatas_queues} = {}; while ($options{stdout} =~ /\[identity=(.*?)\]\[deliverytype=(.*?)\]\[status=(.*?)\]\[isvalid=(.*?)\]\[messagecount=(.*?)\]\[\[error=(.*?)\]\]/msg) { $self->{data} = {}; ($self->{data}->{identity}, $self->{data}->{deliverytype}, $self->{data}->{status}, $self->{data}->{isvalid}, $self->{data}->{messagecount}, $self->{data}->{error}) = @@ -94,12 +96,21 @@ sub check { } if ($self->{data}->{messagecount} =~ /^(\d+)/) { - $self->{output}->perfdata_add(label => 'queue_length_' . $self->{data}->{identity}, - value => $1, - min => 0); + my $num = $1; + my $identity = $self->{data}->{identity}; + + $identity = $1 if ($self->{data}->{identity} =~ /^(.*\\)[0-9]+$/); + $self->{perfdatas_queues}->{$identity} = 0 if (!defined($self->{perfdatas_queues}->{$identity})); + $self->{perfdatas_queues}->{$identity} += $num; } } + foreach (keys %{$self->{perfdatas_queues}}) { + $self->{output}->perfdata_add(label => 'queue_length_' . $_, + value => $self->{perfdatas_queues}->{$_}, + min => 0); + } + if ($checked == 0) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => 'Cannot find informations'); diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/replicationhealth.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/replicationhealth.pm index 5d16a6195..2188505c1 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/replicationhealth.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/replicationhealth.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -89,7 +89,7 @@ sub check { } if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $status, - short_msg => sprintf("Replicatin test '%s' status on '%s' is '%s' [error: %s]", + short_msg => sprintf("Replication test '%s' status on '%s' is '%s' [error: %s]", $self->{data}->{check}, $self->{data}->{server}, $self->{data}->{result}, $self->{data}->{error})); } } @@ -108,4 +108,4 @@ __END__ Method to check Exchange 2010 queues. -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/centreon/common/powershell/exchange/2010/services.pm b/centreon-plugins/centreon/common/powershell/exchange/2010/services.pm index 4ba740476..dc90505ab 100644 --- a/centreon-plugins/centreon/common/powershell/exchange/2010/services.pm +++ b/centreon-plugins/centreon/common/powershell/exchange/2010/services.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm b/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm index 9667328f5..e3fe7077c 100644 --- a/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm +++ b/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/protocols/sql/mode/connectiontime.pm b/centreon-plugins/centreon/common/protocols/sql/mode/connectiontime.pm index e431636e6..b2680dfe5 100644 --- a/centreon-plugins/centreon/common/protocols/sql/mode/connectiontime.pm +++ b/centreon-plugins/centreon/common/protocols/sql/mode/connectiontime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/protocols/sql/mode/sql.pm b/centreon-plugins/centreon/common/protocols/sql/mode/sql.pm index 3f7fe246a..a8e0df4e3 100644 --- a/centreon-plugins/centreon/common/protocols/sql/mode/sql.pm +++ b/centreon-plugins/centreon/common/protocols/sql/mode/sql.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/radlan/mode/cpu.pm b/centreon-plugins/centreon/common/radlan/mode/cpu.pm index e25d7e4a1..a142ec6a4 100644 --- a/centreon-plugins/centreon/common/radlan/mode/cpu.pm +++ b/centreon-plugins/centreon/common/radlan/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rlCpuUtilEnable = '.1.3.6.1.4.1.89.1.6.0'; diff --git a/centreon-plugins/centreon/common/radlan/mode/environment.pm b/centreon-plugins/centreon/common/radlan/mode/environment.pm index 5e7978150..54625eaeb 100644 --- a/centreon-plugins/centreon/common/radlan/mode/environment.pm +++ b/centreon-plugins/centreon/common/radlan/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,12 +95,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -110,7 +110,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # There is a bug with get_leef and snmpv1. @@ -303,4 +302,4 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/centreon/common/smcli/custom/custom.pm b/centreon-plugins/centreon/common/smcli/custom/custom.pm index ca63dc34a..791645476 100644 --- a/centreon-plugins/centreon/common/smcli/custom/custom.pm +++ b/centreon-plugins/centreon/common/smcli/custom/custom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/smcli/mode/healthstatus.pm b/centreon-plugins/centreon/common/smcli/mode/healthstatus.pm index a17978492..c6f7129ee 100644 --- a/centreon-plugins/centreon/common/smcli/mode/healthstatus.pm +++ b/centreon-plugins/centreon/common/smcli/mode/healthstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/ca.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/ca.pm index 46d4533e9..f2074a401 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/ca.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/ca.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,9 +28,9 @@ use warnings; my $oid_chassisSystemLedAlarm = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.7'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_chassisSystemLedAlarm }; + push @{$self->{request}}, { oid => $oid_chassisSystemLedAlarm }; } sub check { @@ -38,7 +38,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis alarm"); $self->{components}->{ca} = {name => 'chassis alarm', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'ca')); + return if ($self->check_filter(section => 'ca')); foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemLedAlarm}}) { $oid =~ /^$oid_chassisSystemLedAlarm\.(.*)$/; @@ -46,7 +46,7 @@ sub check { my $instance = $array_name; my $ca_state = $self->{results}->{$oid_chassisSystemLedAlarm}->{$oid}; - next if ($self->check_exclude(section => 'ca', instance => $instance)); + next if ($self->check_filter(section => 'ca', instance => $instance)); $self->{components}->{ca}->{total}++; $self->{output}->output_add(long_msg => sprintf("Chassis alarm '%s' is %s.", diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/fan.pm index a6f5d40cf..3e1a85c07 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,9 +28,9 @@ use warnings; my $oid_arrayFanEntry_speed = '.1.3.6.1.4.1.35897.1.2.2.3.18.1.3'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_arrayFanEntry_speed }; + push @{$self->{request}}, { oid => $oid_arrayFanEntry_speed }; } sub check { @@ -38,7 +38,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid (keys %{$self->{results}->{$oid_arrayFanEntry_speed}}) { $oid =~ /^$oid_arrayFanEntry_speed\.(.*)$/; @@ -46,7 +46,7 @@ sub check { my $instance = $array_name . '-' . $fan_name; my $fan_state = $self->{results}->{$oid_arrayFanEntry_speed}->{$oid}; - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($fan_state =~ /Absent/i && $self->absent_problem(section => 'fan', instance => $instance)); diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/gfc.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/gfc.pm index e1ee67a82..61fd5e653 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/gfc.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/gfc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -31,9 +31,9 @@ my $oid_enable = '.1.3.6.1.4.1.35897.1.2.1.10.1.4'; my $oid_portState = '.1.3.6.1.4.1.35897.1.2.1.10.1.8'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_globalTargetFcEntry }; + push @{$self->{request}}, { oid => $oid_globalTargetFcEntry }; } sub check { @@ -41,7 +41,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking global fc"); $self->{components}->{gfc} = {name => 'global fc', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'gfc')); + return if ($self->check_filter(section => 'gfc')); foreach my $oid (keys %{$self->{results}->{$oid_globalTargetFcEntry}}) { next if ($oid !~ /^$oid_wwn\.(.*)$/); @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Skipping instance '$wwn' (not enable)")); next; } - next if ($self->check_exclude(section => 'gfc', instance => $wwn)); + next if ($self->check_filter(section => 'gfc', instance => $wwn)); $self->{components}->{gfc}->{total}++; $self->{output}->output_add(long_msg => sprintf("Global FC '%s' is %s.", diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/lfc.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/lfc.pm index d3c56bbb1..db333c315 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/lfc.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/lfc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -31,9 +31,9 @@ my $oid_enable = '.1.3.6.1.4.1.35897.1.2.1.6.1.3'; my $oid_portState = '.1.3.6.1.4.1.35897.1.2.1.6.1.7'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_localTargetFcEntry }; + push @{$self->{request}}, { oid => $oid_localTargetFcEntry }; } sub check { @@ -41,7 +41,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking local fc"); $self->{components}->{lfc} = {name => 'local fc', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'lfc')); + return if ($self->check_filter(section => 'lfc')); foreach my $oid (keys %{$self->{results}->{$oid_localTargetFcEntry}}) { next if ($oid !~ /^$oid_wwn\.(.*)$/); @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => sprintf("Skipping instance '$wwn' (not enable)")); next; } - next if ($self->check_exclude(section => 'lfc', instance => $wwn)); + next if ($self->check_filter(section => 'lfc', instance => $wwn)); $self->{components}->{lfc}->{total}++; $self->{output}->output_add(long_msg => sprintf("Local FC '%s' is %s.", diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/psu.pm index 23dd5510e..3197922a9 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,10 +29,9 @@ my $oid_chassisSystemPowerPSUA = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.17'; my $oid_chassisSystemPowerPSUB = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.18'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_chassisSystemPowerPSUA }; - push @{$options{request}}, { oid => $oid_chassisSystemPowerPSUB }; + push @{$self->{request}}, { oid => $oid_chassisSystemPowerPSUA }, { oid => $oid_chassisSystemPowerPSUB }; } sub psu { @@ -45,7 +44,7 @@ sub psu { my $psu_state = $options{value}; - return if ($self->check_exclude(section => 'psu', instance => $instance)); + return if ($self->check_filter(section => 'psu', instance => $instance)); return if ($psu_state =~ /Absent/i && $self->absent_problem(section => 'psu', instance => $instance)); @@ -64,7 +63,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemPowerPSUA}}) { psu($self, oid => $oid, oid_short => $oid_chassisSystemPowerPSUA, value => $self->{results}->{$oid_chassisSystemPowerPSUA}->{$oid}, diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm index c724a7251..f1662f663 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,11 +30,10 @@ my $oid_chassisSystemTempController = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.21'; my $oid_arrayVimmEntry_temp = '.1.3.6.1.4.1.35897.1.2.2.3.16.1.12'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_arrayVimmEntry_temp }; - push @{$options{request}}, { oid => $oid_chassisSystemTempAmbient }; - push @{$options{request}}, { oid => $oid_chassisSystemTempController }; + push @{$self->{request}}, { oid => $oid_arrayVimmEntry_temp }, { oid => $oid_chassisSystemTempAmbient }, + { oid => $oid_chassisSystemTempController }; } sub temperature { @@ -47,7 +46,7 @@ sub temperature { my $temperature = $options{value}; - return if ($self->check_exclude(section => 'temperature', instance => $instance)); + return if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s degree centigrade.", @@ -68,7 +67,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemTempAmbient}}) { temperature($self, oid => $oid, oid_short => $oid_chassisSystemTempAmbient, value => $self->{results}->{$oid_chassisSystemTempAmbient}->{$oid}, diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/vimm.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/vimm.pm index 8f0189ea9..724dcafab 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/vimm.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/vimm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -39,10 +39,9 @@ my %map_vimm_present = ( ); sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_arrayVimmEntry_present }; - push @{$options{request}}, { oid => $oid_arrayVimmEntry_failed }; + push @{$self->{request}}, { oid => $oid_arrayVimmEntry_present }, { oid => $oid_arrayVimmEntry_failed }; } sub check { @@ -50,7 +49,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking vimms"); $self->{components}->{vimm} = {name => 'vimms', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'vimm')); + return if ($self->check_filter(section => 'vimm')); foreach my $oid (keys %{$self->{results}->{$oid_arrayVimmEntry_present}}) { next if ($oid !~ /^$oid_arrayVimmEntry_present\.(.*)$/); @@ -59,7 +58,7 @@ sub check { my ($dummy, $array_name, $vimm_name) = $self->convert_index(value => $1); my $instance = $array_name . '-' . $vimm_name; - next if ($self->check_exclude(section => 'vimm', instance => $instance)); + next if ($self->check_filter(section => 'vimm', instance => $instance)); next if ($map_vimm_present{$present} =~ /Absent/i && $self->absent_problem(section => 'vimm', instance => $instance)); diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/violin/snmp/mode/hardware.pm index f264e3e5b..46537288b 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/hardware.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,55 +20,77 @@ package centreon::common::violin::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; my $thresholds = { - vimm => [ - ['not failed', 'OK'], - ['failed', 'CRITICAL'], - ], - ca => [ - ['ON', 'CRITICAL'], - ['OFF', 'OK'], - ], - psu => [ - ['OFF', 'CRITICAL'], - ['Absent', 'OK'], - ['ON', 'OK'], - ], - fan => [ - ['OFF', 'CRITICAL'], - ['Absent', 'OK'], - ['Low', 'OK'], - ['Medium', 'OK'], - ['High', 'WARNING'], - ], - gfc => [ - ['Online', 'OK'], - ['Unconfigured', 'OK'], - ['Unknown', 'UNKNOWN'], - ['Not\s*Supported', 'WARNING'], - ['Dead', 'CRITICAL'], - ['Lost', 'CRITICAL'], - ['Failover\s*Failed', 'CRITICAL'], - ['Failover', 'WARNING'], - ], - lfc => [ - ['Online', 'OK'], - ['Unconfigured', 'OK'], - ['Unknown', 'UNKNOWN'], - ['Not\s*Supported', 'WARNING'], - ['Dead', 'CRITICAL'], - ['Lost', 'CRITICAL'], - ['Failover\s*Failed', 'CRITICAL'], - ['Failover', 'WARNING'], - ], + }; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(vimm|ca|psu|fan|gfc|lfc)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + vimm => [ + ['not failed', 'OK'], + ['failed', 'CRITICAL'], + ], + ca => [ + ['ON', 'CRITICAL'], + ['OFF', 'OK'], + ], + psu => [ + ['OFF', 'CRITICAL'], + ['Absent', 'OK'], + ['ON', 'OK'], + ], + fan => [ + ['OFF', 'CRITICAL'], + ['Absent', 'OK'], + ['Low', 'OK'], + ['Medium', 'OK'], + ['High', 'WARNING'], + ], + gfc => [ + ['Online', 'OK'], + ['Unconfigured', 'OK'], + ['Unknown', 'UNKNOWN'], + ['Not\s*Supported', 'WARNING'], + ['Dead', 'CRITICAL'], + ['Lost', 'CRITICAL'], + ['Failover\s*Failed', 'CRITICAL'], + ['Failover', 'WARNING'], + ], + lfc => [ + ['Online', 'OK'], + ['Unconfigured', 'OK'], + ['Unknown', 'UNKNOWN'], + ['Not\s*Supported', 'WARNING'], + ['Dead', 'CRITICAL'], + ['Lost', 'CRITICAL'], + ['Failover\s*Failed', 'CRITICAL'], + ['Failover', 'WARNING'], + ], + }; + + $self->{components_path} = 'centreon::common::violin::snmp::mode::components'; + $self->{components_module} = ['ca', 'psu', 'fan', 'vimm', 'temperature', 'gfc', 'lfc']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -76,202 +98,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "absent-problem:s" => { name => 'absent' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ('temperature', $1, $2); - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('ca', 'psu', 'fan', 'vimm', 'temperature', 'gfc', 'lfc'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::violin::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 = "centreon::common::violin::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}); -} - -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 convert_index { my ($self, %options) = @_; @@ -306,15 +138,15 @@ Check components (Fans, Power Supplies, Temperatures, Chassis alarm, vimm, globa Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'ca', 'vimm', 'lfc', 'gfc', 'temperature'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#41239F00647-A#' +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,41239F00647-A =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#41239F00647-fan02# +Can be specific or global: --absent-problem=fan,41239F00647-fan02 =item B<--no-component> @@ -323,19 +155,19 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='gfc,CRITICAL,^(?!(Online)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: regexp,treshold) -Example: --warning='41239F00647-vimm46,20' --warning='41239F00647-vimm5.*,30' +Set warning threshold for temperatures (syntax: type,regexp,threshold) +Example: --warning='temperature,41239F00647-vimm46,20' --warning='temperature,41239F00647-vimm5.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: regexp,treshold) -Example: --critical='41239F00647-vimm46,25' --warning='41239F00647-vimm5.*,35' +Set critical threshold for temperatures (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,25' --warning='temperature,.*,35' =back diff --git a/centreon-plugins/centreon/plugins/alternative/FatPackerOptions.pm b/centreon-plugins/centreon/plugins/alternative/FatPackerOptions.pm new file mode 100644 index 000000000..c8a6b0a67 --- /dev/null +++ b/centreon-plugins/centreon/plugins/alternative/FatPackerOptions.pm @@ -0,0 +1,64 @@ +# +# Copyright 2016 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 centreon::plugins::alternative::FatPackerOptions; + +use base qw(centreon::plugins::options); + +use strict; +use warnings; +use Pod::Usage; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + +sub display_help { + my ($self, %options) = @_; + + my $stdout; + foreach (@{$self->{pod_package}}) { + + { + my $pp = $_->{package} . ".pm"; + $pp =~ s{::}{/}g; + my $content_class = $INC{$pp}->{$pp}; + open my $str_fh, '<', \$content_class; + + local *STDOUT; + open STDOUT, '>', \$stdout; + pod2usage(-exitval => 'NOEXIT', -input => $str_fh, + -verbose => 99, + -sections => $_->{sections}); + + close $str_fh; + } + + $self->{output}->add_option_msg(long_msg => $stdout) if (defined($stdout)); + } +} + +1; + +__END__ diff --git a/centreon-plugins/centreon/plugins/alternative/Getopt.pm b/centreon-plugins/centreon/plugins/alternative/Getopt.pm index 62ede9f01..6d920a1a9 100644 --- a/centreon-plugins/centreon/plugins/alternative/Getopt.pm +++ b/centreon-plugins/centreon/plugins/alternative/Getopt.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/plugins/dbi.pm b/centreon-plugins/centreon/plugins/dbi.pm index 1fd4ddc7a..b8bfc90b0 100644 --- a/centreon-plugins/centreon/plugins/dbi.pm +++ b/centreon-plugins/centreon/plugins/dbi.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/plugins/http.pm b/centreon-plugins/centreon/plugins/http.pm index 35af3e64f..4f540d675 100644 --- a/centreon-plugins/centreon/plugins/http.pm +++ b/centreon-plugins/centreon/plugins/http.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -153,10 +153,11 @@ sub set_proxy { if (defined($options{request}->{proxypac}) && $options{request}->{proxypac} ne '') { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'HTTP::ProxyPAC', error_msg => "Cannot load module 'HTTP::ProxyPAC'."); - my $pac; + my ($pac, $pac_uri); eval { if ($options{request}->{proxypac} =~ /^(http|https):\/\//) { - $pac = HTTP::ProxyPAC->new(URI->new($options{request}->{proxypac})); + $pac_uri = URI->new($options{request}->{proxypac}); + $pac = HTTP::ProxyPAC->new($pac_uri); } else { $pac = HTTP::ProxyPAC->new($options{request}->{proxypac}); } @@ -167,7 +168,9 @@ sub set_proxy { } my $res = $pac->find_proxy($options{url}); if (defined($res->direct) && $res->direct != 1) { - $self->{ua}->proxy(['http', 'https'], $res->proxy); + my $proxy_uri = URI->new($res->proxy); + $proxy_uri->userinfo($pac_uri->userinfo) if (defined($pac_uri->userinfo)); + $self->{ua}->proxy(['http', 'https'], $proxy_uri->as_string); } } if (defined($options{request}->{proxyurl}) && $options{request}->{proxyurl} ne '') { @@ -202,7 +205,9 @@ sub request { my ($response, $content); my ($req, $url); - if (defined($request_options->{port}) && $request_options->{port} =~ /^[0-9]+$/) { + if (defined($request_options->{full_url})) { + $url = $request_options->{full_url}; + } elsif (defined($request_options->{port}) && $request_options->{port} =~ /^[0-9]+$/) { $url = $request_options->{proto}. "://" . $request_options->{hostname} . ':' . $request_options->{port} . $request_options->{url_path}; } else { $url = $request_options->{proto}. "://" . $request_options->{hostname} . $request_options->{url_path}; @@ -301,7 +306,8 @@ sub request { $self->{output}->exit(); } - $self->{headers} = $response->headers; + $self->{headers} = $response->headers(); + $self->{response} = $response; return $response->content; } @@ -311,4 +317,10 @@ sub get_header { return $self->{headers}; } +sub get_response { + my ($self, %options) = @_; + + return $self->{response}; +} + 1; diff --git a/centreon-plugins/centreon/plugins/misc.pm b/centreon-plugins/centreon/plugins/misc.pm index 463a95ddc..a32abb0b7 100644 --- a/centreon-plugins/centreon/plugins/misc.pm +++ b/centreon-plugins/centreon/plugins/misc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -24,6 +24,16 @@ use strict; use warnings; use utf8; +sub execute { + my (%options) = @_; + + if ($^O eq 'MSWin32') { + return windows_execute(%options, timeout => $options{options}->{timeout}); + } else { + return unix_execute(%options); + } +} + sub windows_execute { my (%options) = @_; my $result; @@ -109,7 +119,7 @@ sub windows_execute { return ($stdout, $result->{$pid}->{exitcode}); } -sub execute { +sub unix_execute { my (%options) = @_; my $cmd = ''; my $args = []; @@ -204,11 +214,13 @@ sub execute { sub mymodule_load { my (%options) = @_; my $file; - ($file = $options{module} . ".pm") =~ s{::}{/}g; - + ($file = ($options{module} =~ /\.pm$/ ? $options{module} : $options{module} . ".pm")) =~ s{::}{/}g; + eval { local $SIG{__DIE__} = 'IGNORE'; require $file; + $file =~ s{/}{::}g; + $file =~ s/\.pm$//; }; if ($@) { return 1 if (defined($options{no_quit}) && $options{no_quit} == 1); @@ -216,7 +228,7 @@ sub mymodule_load { $options{output}->add_option_msg(short_msg => $options{error_msg}); $options{output}->option_exit(); } - return 0; + return wantarray ? (0, $file) : 0; } sub backtick { @@ -362,8 +374,10 @@ sub change_seconds { { unit => 'm', value => 60 }, { unit => 's', value => 1 }, ]; + my %values = ('y' => 1, 'M' => 2, 'w' => 3, 'd' => 4, 'h' => 5, 'm' => 6, 's' => 7); foreach (@$periods) { + next if (defined($options{start}) && $values{$_->{unit}} < $values{$options{start}}); my $count = int($options{value} / $_->{value}); next if ($count == 0); diff --git a/centreon-plugins/centreon/plugins/mode.pm b/centreon-plugins/centreon/plugins/mode.pm index c2b5dcba4..6a12b565c 100644 --- a/centreon-plugins/centreon/plugins/mode.pm +++ b/centreon-plugins/centreon/plugins/mode.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/plugins/options.pm b/centreon-plugins/centreon/plugins/options.pm index 6cae0cc3b..bbbc59b03 100644 --- a/centreon-plugins/centreon/plugins/options.pm +++ b/centreon-plugins/centreon/plugins/options.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -61,7 +61,7 @@ sub set_sanity { $centreon::plugins::alternative::Getopt::warn_message = 1; } - $self->{sanity} == 1; + $self->{sanity} = 1; } sub set_output { @@ -79,9 +79,10 @@ sub display_help { { local *STDOUT; open STDOUT, '>', \$stdout; - pod2usage(-exitval => 'NOEXIT', -input => pod_where({-inc => 1}, $_->{package}), + my $where = pod_where({-inc => 1}, $_->{package}); + pod2usage(-exitval => 'NOEXIT', -input => $where, -verbose => 99, - -sections => $_->{sections}); + -sections => $_->{sections}) if (defined($where)); } $self->{output}->add_option_msg(long_msg => $stdout) if (defined($stdout)); diff --git a/centreon-plugins/centreon/plugins/output.pm b/centreon-plugins/centreon/plugins/output.pm index d60e116a6..59a76a87a 100644 --- a/centreon-plugins/centreon/plugins/output.pm +++ b/centreon-plugins/centreon/plugins/output.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; - # $options->{options} = options object if (!defined($options{options})) { print "Class Output: Need to specify 'options' argument to load.\n"; exit 3; @@ -40,6 +39,7 @@ sub new { "range-perfdata:s" => { name => 'range_perfdata' }, "filter-perfdata:s" => { name => 'filter_perfdata' }, "change-perfdata:s@" => { name => 'change_perfdata' }, + "filter-uom:s" => { name => 'filter_uom' }, "verbose" => { name => 'verbose' }, "debug" => { name => 'debug' }, "opt-exit:s" => { name => 'opt_exit', default => 'unknown' }, @@ -282,6 +282,8 @@ sub output_json { my %values = (); foreach my $key (keys %$perf) { + $perf->{$key} = '' if (defined($self->{option_results}->{filter_uom}) && $key eq 'unit' && + $perf->{$key} !~ /$self->{option_results}->{filter_uom}/); $values{$key} = $perf->{$key}; } @@ -372,6 +374,8 @@ sub output_xml { $child_perfdata = $self->{xml_output}->createElement("perfdata"); $child_plugin_perfdata->addChild($child_perfdata); foreach my $key (keys %$perf) { + $perf->{$key} = '' if (defined($self->{option_results}->{filter_uom}) && $key eq 'unit' && + $perf->{$key} !~ /$self->{option_results}->{filter_uom}/); my $child = $self->{xml_output}->createElement($key); $child->appendText($perf->{$key}); $child_perfdata->addChild($child); @@ -412,6 +416,8 @@ sub output_txt { foreach my $perf (@{$self->{perfdatas}}) { next if (defined($self->{option_results}->{filter_perfdata}) && $perf->{label} !~ /$self->{option_results}->{filter_perfdata}/); + $perf->{unit} = '' if (defined($self->{option_results}->{filter_uom}) && + $perf->{unit} !~ /$self->{option_results}->{filter_uom}/); $self->range_perfdata(ranges => [\$perf->{warning}, \$perf->{critical}]); print " '" . $perf->{label} . "'=" . $perf->{value} . $perf->{unit} . ";" . $perf->{warning} . ";" . $perf->{critical} . ";" . $perf->{min} . ";" . $perf->{max}; } @@ -776,6 +782,10 @@ Syntax: regexp_matching,regexp_substitute Change perfdata range thresholds display: 1 = start value equals to '0' is removed, 2 = threshold range is not display. +=item B<--filter-uom> + +Filter UOM that match the regexp. + =item B<--opt-exit> Exit code for an option error, usage (default: unknown). diff --git a/centreon-plugins/centreon/plugins/perfdata.pm b/centreon-plugins/centreon/plugins/perfdata.pm index a1cf3f046..c857737fb 100644 --- a/centreon-plugins/centreon/plugins/perfdata.pm +++ b/centreon-plugins/centreon/plugins/perfdata.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon/plugins/script.pm b/centreon-plugins/centreon/plugins/script.pm index bba0658ab..91dec7855 100644 --- a/centreon-plugins/centreon/plugins/script.pm +++ b/centreon-plugins/centreon/plugins/script.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -22,7 +22,6 @@ package centreon::plugins::script; use strict; use warnings; -use centreon::plugins::options; use centreon::plugins::output; use centreon::plugins::misc; use FindBin; @@ -31,7 +30,8 @@ use Pod::Find qw(pod_where); my %handlers = (DIE => {}); -my $global_version = 20151218; +my $global_version = 20160902; +my $alternative_fatpacker = 0; sub new { my $class = shift; @@ -84,7 +84,13 @@ sub get_plugin { ###### # Need to load global 'Output' and 'Options' ###### - $self->{options} = centreon::plugins::options->new(); + if ($alternative_fatpacker == 0) { + require centreon::plugins::options; + $self->{options} = centreon::plugins::options->new(); + } else { + require centreon::plugins::alternative::FatPackerOptions; + $self->{options} = centreon::plugins::alternative::FatPackerOptions->new(); + } $self->{output} = centreon::plugins::output->new(options => $self->{options}); $self->{options}->set_output(output => $self->{output}); @@ -122,7 +128,17 @@ sub display_local_help { if ($self->{help}) { local *STDOUT; open STDOUT, '>', \$stdout; - pod2usage(-exitval => "NOEXIT", -input => pod_where({-inc => 1}, __PACKAGE__)); + + if ($alternative_fatpacker == 0) { + pod2usage(-exitval => "NOEXIT", -input => pod_where({-inc => 1}, __PACKAGE__)); + } else { + my $pp = __PACKAGE__ . ".pm"; + $pp =~ s{::}{/}g; + my $content_class = $INC{$pp}->{$pp}; + open my $str_fh, '<', \$content_class; + pod2usage(-exitval => "NOEXIT", -input => $str_fh); + close $str_fh; + } } $self->{output}->add_option_msg(long_msg => $stdout) if (defined($stdout)); @@ -257,8 +273,9 @@ sub run { $self->check_relaunch(); - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{plugin}, - error_msg => "Cannot load module --plugin."); + (undef, $self->{plugin}) = + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{plugin}, + error_msg => "Cannot load module --plugin."); my $plugin = $self->{plugin}->new(options => $self->{options}, output => $self->{output}); $plugin->init(help => $self->{help}, version => $self->{version}); diff --git a/centreon-plugins/centreon/plugins/script_custom.pm b/centreon-plugins/centreon/plugins/script_custom.pm index 38650e334..92e1672db 100644 --- a/centreon-plugins/centreon/plugins/script_custom.pm +++ b/centreon-plugins/centreon/plugins/script_custom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -115,8 +115,8 @@ sub init { error_msg => "Cannot load module --mode."); $self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, - error_msg => "Cannot load module --dyn-mode."); + (undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, + error_msg => "Cannot load module --dyn-mode."); $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); diff --git a/centreon-plugins/centreon/plugins/script_simple.pm b/centreon-plugins/centreon/plugins/script_simple.pm index 5a6a994e8..208a5ece5 100644 --- a/centreon-plugins/centreon/plugins/script_simple.pm +++ b/centreon-plugins/centreon/plugins/script_simple.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -86,8 +86,8 @@ sub init { error_msg => "Cannot load module --mode."); $self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, - error_msg => "Cannot load module --dyn-mode."); + (undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, + error_msg => "Cannot load module --dyn-mode."); $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); diff --git a/centreon-plugins/centreon/plugins/script_snmp.pm b/centreon-plugins/centreon/plugins/script_snmp.pm index 2a4567629..d04dbb017 100644 --- a/centreon-plugins/centreon/plugins/script_snmp.pm +++ b/centreon-plugins/centreon/plugins/script_snmp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -91,8 +91,8 @@ sub init { error_msg => "Cannot load module --mode."); $self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, - error_msg => "Cannot load module --dyn-mode."); + (undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, + error_msg => "Cannot load module --dyn-mode."); $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); diff --git a/centreon-plugins/centreon/plugins/script_sql.pm b/centreon-plugins/centreon/plugins/script_sql.pm index c82cf1778..bce150a78 100644 --- a/centreon-plugins/centreon/plugins/script_sql.pm +++ b/centreon-plugins/centreon/plugins/script_sql.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -107,8 +107,8 @@ sub init { error_msg => "Cannot load module --mode."); $self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, - error_msg => "Cannot load module --dyn-mode."); + (undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, + error_msg => "Cannot load module --dyn-mode."); $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); diff --git a/centreon-plugins/centreon/plugins/script_wsman.pm b/centreon-plugins/centreon/plugins/script_wsman.pm index 789747149..f4734d205 100644 --- a/centreon-plugins/centreon/plugins/script_wsman.pm +++ b/centreon-plugins/centreon/plugins/script_wsman.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -91,8 +91,8 @@ sub init { error_msg => "Cannot load module --mode."); $self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, - error_msg => "Cannot load module --dyn-mode."); + (undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, + error_msg => "Cannot load module --dyn-mode."); $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); diff --git a/centreon-plugins/centreon/plugins/snmp.pm b/centreon-plugins/centreon/plugins/snmp.pm index 4bcf9f7b1..448a4cada 100644 --- a/centreon-plugins/centreon/plugins/snmp.pm +++ b/centreon-plugins/centreon/plugins/snmp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -679,7 +679,7 @@ sub check_options { if (!defined($options{option_results}->{snmp_security_name})) { - $self->{output}->add_option_msg(short_msg => "Missing paramater Security Name."); + $self->{output}->add_option_msg(short_msg => "Missing parameter Security Name."); $self->{output}->option_exit(); } @@ -761,8 +761,10 @@ sub map_instance { my ($self, %options) = @_; my $results = {}; + my $instance = ''; + $instance = '.' . $options{instance} if (defined($options{instance})); foreach my $name (keys %{$options{mapping}}) { - my $entry = $options{mapping}->{$name}->{oid} . '.' . $options{instance}; + my $entry = $options{mapping}->{$name}->{oid} . $instance; if (defined($options{results}->{$entry})) { $results->{$name} = $options{results}->{$entry}; } elsif (defined($options{results}->{$options{mapping}->{$name}->{oid}}->{$entry})) { diff --git a/centreon-plugins/centreon/plugins/statefile.pm b/centreon-plugins/centreon/plugins/statefile.pm index bd5b14350..e77be2031 100644 --- a/centreon-plugins/centreon/plugins/statefile.pm +++ b/centreon-plugins/centreon/plugins/statefile.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -82,12 +82,12 @@ sub check_options { } sub error { - my ($self) = shift; + my ($self) = shift; - if (@_) { + if (@_) { $self->{error} = $_[0]; - } - return $self->{error}; + } + return $self->{error}; } sub read { diff --git a/centreon-plugins/centreon/plugins/templates/counter.pm b/centreon-plugins/centreon/plugins/templates/counter.pm index a239541e8..3bda7758b 100644 --- a/centreon-plugins/centreon/plugins/templates/counter.pm +++ b/centreon-plugins/centreon/plugins/templates/counter.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -116,7 +116,7 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - foreach my $key (keys %{$self->{maps_counters}}) { + foreach my $key (keys %{$self->{maps_counters}}) { foreach (@{$self->{maps_counters}->{$key}}) { $_->{obj}->init(option_results => $self->{option_results}); } @@ -146,6 +146,7 @@ sub run_global { my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{config}->{name}}); + next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check})); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); $long_msg_append = $message_separator; @@ -181,7 +182,7 @@ sub run_global { short_msg => "${prefix_output}${short_msg}${suffix_output}" ); } else { - $self->{output}->output_add(short_msg => "${prefix_output}${long_msg}${suffix_output}"); + $self->{output}->output_add(short_msg => "${prefix_output}${long_msg}${suffix_output}") if ($long_msg ne ''); } } @@ -189,13 +190,16 @@ sub run_instances { my ($self, %options) = @_; return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1); + my $display_status_lo = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0; + my $resume = defined($options{resume}) && $options{resume} == 1 ? 1 : 0; + $self->{lproblems} = 0; $self->{multiple} = 1; if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) { $self->{multiple} = 0; } - if ($self->{multiple} == 1) { + if ($self->{multiple} == 1 && $resume == 0) { $self->{output}->output_add(severity => 'OK', short_msg => $options{config}->{message_multiple}); } @@ -215,7 +219,7 @@ sub run_instances { my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{config}->{name}}->{$id}); - + next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check})); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); $long_msg_append = $message_separator; @@ -229,6 +233,7 @@ sub run_instances { $long_msg_append = $message_separator; if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { + $self->{lproblems}++; $short_msg .= $short_msg_append . $output; $short_msg_append = $message_separator; } @@ -245,8 +250,13 @@ sub run_instances { if (defined($options{config}->{cb_suffix_output})); $suffix_output = '' if (!defined($suffix_output)); - $self->{output}->output_add(long_msg => "${prefix_output}${long_msg}${suffix_output}"); my $exit = $self->{output}->get_most_critical(status => [ @exits ]); + $self->{output}->output_add(long_msg => ($display_status_lo == 1 ? lc($exit) . ': ' : '') . "${prefix_output}${long_msg}${suffix_output}"); + if ($resume == 1) { + $self->{most_critical_instance} = $self->{output}->get_most_critical(status => [ $self->{most_critical_instance}, $exit ]); + next; + } + if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { $self->{output}->output_add(severity => $exit, short_msg => "${prefix_output}${short_msg}${suffix_output}" @@ -259,6 +269,57 @@ sub run_instances { } } +sub run_group { + my ($self, %options) = @_; + + my $multiple = 1; + if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => $options{config}->{message_multiple}); + } + + my ($global_exit, $total_problems) = ([], 0); + foreach my $id (sort keys %{$self->{$options{config}->{name}}}) { + $self->{most_critical_instance} = 'ok'; + if (defined($options{config}->{cb_long_output})) { + $self->{output}->output_add(long_msg => $self->call_object_callback(method_name => $options{config}->{cb_long_output}, + instance_value => $self->{$options{config}->{name}}->{$id})); + } + + foreach my $group (@{$options{config}->{group}}) { + $self->{$group->{name}} = $self->{$options{config}->{name}}->{$id}->{$group->{name}}; + + # we resume datas + $self->run_instances(config => $group, display_status_long_output => 1, resume => 1); + + push @{$global_exit}, $self->{most_critical_instance}; + $total_problems += $self->{lproblems}; + + my $prefix_output; + $prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$id}) + if (defined($options{config}->{cb_prefix_output})); + $prefix_output = '' if (!defined($prefix_output)); + + if ($multiple == 0) { + $self->{output}->output_add(severity => $self->{most_critical_instance}, + short_msg => "${prefix_output}$self->{lproblems} problem(s) detected"); + } + } + } + + if ($multiple == 1) { + my $exit = $self->{output}->get_most_critical(status => [ @{$global_exit} ]); + if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { + $self->{output}->output_add(severity => $exit, + short_msg => "$total_problems problem(s) detected"); + } + } +} + sub run { my ($self, %options) = @_; @@ -276,6 +337,8 @@ sub run { $self->run_global(config => $entry); } elsif ($entry->{type} == 1) { $self->run_instances(config => $entry); + } elsif ($entry->{type} == 2) { + $self->run_group(config => $entry); } } diff --git a/centreon-plugins/centreon/plugins/templates/hardware.pm b/centreon-plugins/centreon/plugins/templates/hardware.pm index 1e3b21d35..d01a5e600 100644 --- a/centreon-plugins/centreon/plugins/templates/hardware.pm +++ b/centreon-plugins/centreon/plugins/templates/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -39,6 +39,7 @@ sub set_system { #$self->{cb_hook1} = 'callbackname'; # before the loads #$self->{cb_hook2} = 'callbackname'; # between loads and requests #$self->{cb_hook3} = 'callbackname'; # after requests + #$self->{cb_hook4} = 'callbackname'; # after output # Example for threshold: #$self->{thresholds} = { @@ -198,7 +199,7 @@ sub check_options { $self->{output}->option_exit(); } $self->call_object_callback(method_name => $self->{cb_threshold_numeric_check_section_option}, - section => $section, option_value => $val); + section => $section, option_name => $option, option_value => $val); my $position = 0; if (defined($self->{numeric_threshold}->{$section})) { @@ -215,12 +216,9 @@ sub check_options { } } -sub run { +sub load_components { my ($self, %options) = @_; - - $self->{loaded} = 0; - $self->call_object_callback(method_name => $self->{cb_hook1}, - %options); + foreach (@{$self->{components_module}}) { if (/$self->{option_results}->{component}/) { my $mod_name = $self->{components_path} . "::$_"; @@ -233,15 +231,10 @@ sub run { } } } - - if ($self->{loaded} == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - $self->call_object_callback(method_name => $self->{cb_hook2}, - %options); - +} + +sub exec_components { + my ($self, %options) = @_; foreach (@{$self->{components_module}}) { if (/$self->{option_results}->{component}/) { @@ -250,9 +243,23 @@ sub run { $func->($self); } } +} + +sub run { + my ($self, %options) = @_; + + $self->{loaded} = 0; + $self->call_object_callback(method_name => $self->{cb_hook1}, %options); + + $self->load_components(%options); + if ($self->{loaded} == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } - $self->call_object_callback(method_name => $self->{cb_hook3}, - %options); + $self->call_object_callback(method_name => $self->{cb_hook2}, %options); + $self->exec_components(%options); + $self->call_object_callback(method_name => $self->{cb_hook3}, %options); my $total_components = 0; my $display_by_component = ''; @@ -277,6 +284,8 @@ sub run { short_msg => 'No components are checked.'); } + $self->call_object_callback(method_name => $self->{cb_hook4}, %options); + $self->{output}->display(); $self->{output}->exit(); } diff --git a/centreon-plugins/centreon/plugins/values.pm b/centreon-plugins/centreon/plugins/values.pm index e94c10b59..a0bddcd01 100644 --- a/centreon-plugins/centreon/plugins/values.pm +++ b/centreon-plugins/centreon/plugins/values.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -22,9 +22,9 @@ package centreon::plugins::values; use strict; use warnings; - -# le label de perfdata: on peut le surcharger (au lieu du label) -# le warning/critical: on peut surcharger +# Warning message with sprintf and too much arguments. +# Really annoying. Need to disable that warning +no if ($^V gt v5.22.0), 'warnings' => 'redundant'; sub new { my ($class, %options) = @_; @@ -139,7 +139,7 @@ sub output { return $self->{closure_custom_output}->($self); } my $first = ${${$self->{key_values}}[0]}{name}; - my ($value, $unit) = ($self->{result_values}->{$first . '_absolute'}, $self->{result_values}->{output_absolute_unit}); + my ($value, $unit) = ($self->{result_values}->{$first . '_absolute'}, $self->{output_absolute_unit}); if (!defined($self->{output_use})) { if ($self->{per_second} == 1) { diff --git a/centreon-plugins/centreon/plugins/wsman.pm b/centreon-plugins/centreon/plugins/wsman.pm index 791874c00..911e7cfa5 100644 --- a/centreon-plugins/centreon/plugins/wsman.pm +++ b/centreon-plugins/centreon/plugins/wsman.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/centreon_plugins.pl b/centreon-plugins/centreon_plugins.pl index b0184ea71..95ae52cc0 100644 --- a/centreon-plugins/centreon_plugins.pl +++ b/centreon-plugins/centreon_plugins.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/changelog b/centreon-plugins/changelog index 3c577a6f2..5ca6549db 100644 --- a/centreon-plugins/changelog +++ b/centreon-plugins/changelog @@ -1,3 +1,107 @@ +2016-09-02 Quentin Garnier + * Plugin added: to check HP-UX SNMP (#13) + * Plugin added: to check Hitachi HNAS + * Plugin added: to check Overland Neo Series + * Plugin added: to check Quantum Scalar + * Plugin added: to check HP Storeonce SSH + * Fix: [pdu emerson]{global-status} wrong status + +2016-08-03 Quentin Garnier + * Plugin added: to check IBM Storwize (#438) + * Plugin added: to check Sonus SBC + * Plugin added: to check Aerohive + * Plugin added: to check Digi routers + * Plugin added: to check telnet sessions + * Plugin added: to check china clever PDU + * Plugin added: to check Cisco Voice Gateway + * Some minor fix and enhancement + +2016-06-27 Quentin Garnier + * Update FAQ: build a standalone perl script + * Plugin added: to check Lenovo S Series (#412) + * Plugin added: to check Digi AnywhereUSB + * Mode added: [netasq] 'ha-nodes' + * Mode removed: [netasq] 'ha-status' + * Fix: [dell n4000]{environment} wrong temperature (#397) + * Fix: [netapp]{cache-age} not working (#422) + * Fix: [cisco wlc]{ap-users} wrong total + * Fix: [tomcat]{memory} problem with java 8 + * Fix: [netapp]{filesys} no values (#415) + +2016-05-24 Quentin Garnier + * Can use '/' instead '::' for plugin option (#380) + * Mode added: [pacemaker] 'constraints' + * Mode added: [netbackup] 'tape-usage' + * Mode added: [oracle] 'data-files-status' + * Mode added: [netasq] 'connections' + * Enhancement: [cisco wlc]{ap-users} get users by AP (#375) + * Enhancement: [oracle]{tablespace} can use free size left + * Fix: [pdu apc]{load} incorrect values (#408) + * Fix: [mscs] Issue with old versions + * Fix: [postgres]{timesync} threshold issue + * Fix: [ntp]{offset} time formula issue + * Fix: [github]{issues} Get only issue + * Fix: [netasq]{memory} Use BSD memory check + * Fix: [tomcat]{applications} Issue on Windows (#356) + +2016-03-24 Quentin Garnier + * Plugin added: to check AKCP SensorProbe + * Plugin added: to check Juniper ISG + * Plugin added: to check OSPF protocol + * Plugin added: to check Microsoft Cluster Service + * Plugin added: to check Dell Compellent in SNMP and Powershell SDK + * Enhancement: [snmp_standard]{string-value} Many changes (#228) + * Fix: [raritan] OnOff sending errors (#348) + +2016-02-20 Quentin Garnier + * Add a class for FatPacker system + +2016-02-17 Quentin Garnier + * Plugin added: to check Kemp + * Plugin added: to check Netbackup + * Plugin added: to check Ucopia Wireless Controller + * Plugin added: to check Emerson Liebert PDU + * Plugin added: to check Microsoft Lync 2013 + * Plugin added: to check TemPERHum sensors + * Mode added: [mysql] 'table-size' + * Mode added: [centreon] 'count-services' + * Mode added: [iDrac] 'hardware' (for iDrac 8) + * Enhancement: [xtremio] hardened code + * Enhancement: [cisco asa]{sessions} better metrics (#315) + * Enhancement: [freebsd]{memory} More real values + * Fix: [oracle]{tablespace-usage} Usage more than 100% + * Fix: [clariion]{disks} Last disks was missing + * Fix: [mssql]{failed-jobs} wrong thresholds + +2016-01-22 Quentin Garnier + * Plugin added: Add a plugin to check Juniper Trapeze in SNMP + * Plugin added: Add a plugin to check Dell ML6000 in SNMP + * Plugin added: Add a plugin to check UPS APC in SNMP + * Plugin added: Add a plugin to check HP VC in SNMP + * Major fix on sanity mechanism for options + * Add option '--filter-uom' in core library (#220) + * Add some new classes for code refactoring + * Add 'get_header' method in http library + * Fix 'proxypac' in http library (#263) + * Mode added: [github] 'stats' + * Mode added: [netapp] 'cache-age' + * Mode added: [datadomain] 'replication' + * Enhancement: [cisco standard]{ipsla} hardened code + * Enhancement: [github]{issues} change api call method (#257) + * Enhancement: [selenium]{scenario} add echo command (#258) + * Enhancement: [protocol x509]{validity} add SNI support (#241) + * Enhancement: [snmp_standard]{interfaces} add option '--force-counters32' (#213) + * Enhancement: [protocol x509]{validity} add support for alternative subject names (#277) + * Enhancement: [juniper sa]{users} add filter (#192) + * Enhancement: [cisco wlc]{ap-users} add users by ssid (#227) + * Enhancement: [juniper ssg]{sessions} better counters (#233) + * Enhancement: [vmware connector]{time-host} new options + * Enhancement: [extreme]{hardware} add poe status + * Enhancement: [vplex]{directors} hardened code + * Fix: [bluecoat]{hardware} problem with sensor + * Fix: [cisco ucs]{equipment} fix severity for iocard (#283) + * Fix: [exchange 2010]{queues} perdata infinity not raising anymore + 2015-12-18 Quentin Garnier * Plugin added: Add a plugin to check VMWare ESX with WSMAN * Configuration: centreon-plugins don't use GetOptions anymore (custom library instead) diff --git a/centreon-plugins/cloud/aws/custom/awscli.pm b/centreon-plugins/cloud/aws/custom/awscli.pm index 4ed939bbe..44e1ec131 100644 --- a/centreon-plugins/cloud/aws/custom/awscli.pm +++ b/centreon-plugins/cloud/aws/custom/awscli.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/cloudwatch.pm b/centreon-plugins/cloud/aws/mode/cloudwatch.pm index e0cd03634..56d8d2ddc 100644 --- a/centreon-plugins/cloud/aws/mode/cloudwatch.pm +++ b/centreon-plugins/cloud/aws/mode/cloudwatch.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/instancestate.pm b/centreon-plugins/cloud/aws/mode/instancestate.pm index 966d68565..90565688a 100644 --- a/centreon-plugins/cloud/aws/mode/instancestate.pm +++ b/centreon-plugins/cloud/aws/mode/instancestate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/list.pm b/centreon-plugins/cloud/aws/mode/list.pm index a732bee56..d86374b34 100644 --- a/centreon-plugins/cloud/aws/mode/list.pm +++ b/centreon-plugins/cloud/aws/mode/list.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpu.pm b/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpu.pm index 221427073..a42df116f 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpu.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditbalance.pm b/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditbalance.pm index 4158f2dc8..54b46514f 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditbalance.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditbalance.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditusage.pm b/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditusage.pm index 7b41e2696..f08ed5d7f 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditusage.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/ec2instancecpucreditusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm b/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm index 3eea9ef7f..414bdb09d 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/metrics/rdsinstancecpu.pm b/centreon-plugins/cloud/aws/mode/metrics/rdsinstancecpu.pm index 48b8f88ec..286a0387a 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/rdsinstancecpu.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/rdsinstancecpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/mode/metrics/s3bucketsize.pm b/centreon-plugins/cloud/aws/mode/metrics/s3bucketsize.pm index 799ff2f41..238779af3 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/s3bucketsize.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/s3bucketsize.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/aws/plugin.pm b/centreon-plugins/cloud/aws/plugin.pm index 30eafebb6..08127019f 100644 --- a/centreon-plugins/cloud/aws/plugin.pm +++ b/centreon-plugins/cloud/aws/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/blockio.pm b/centreon-plugins/cloud/docker/mode/blockio.pm index 553908a83..b21a6446f 100644 --- a/centreon-plugins/cloud/docker/mode/blockio.pm +++ b/centreon-plugins/cloud/docker/mode/blockio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/containerstate.pm b/centreon-plugins/cloud/docker/mode/containerstate.pm index 301c46bfd..8d38e896c 100644 --- a/centreon-plugins/cloud/docker/mode/containerstate.pm +++ b/centreon-plugins/cloud/docker/mode/containerstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -84,12 +84,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); diff --git a/centreon-plugins/cloud/docker/mode/cpu.pm b/centreon-plugins/cloud/docker/mode/cpu.pm index 74a0506ae..b0f3d1f9e 100644 --- a/centreon-plugins/cloud/docker/mode/cpu.pm +++ b/centreon-plugins/cloud/docker/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/image.pm b/centreon-plugins/cloud/docker/mode/image.pm index 5ad1c22fd..0c257213e 100644 --- a/centreon-plugins/cloud/docker/mode/image.pm +++ b/centreon-plugins/cloud/docker/mode/image.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/info.pm b/centreon-plugins/cloud/docker/mode/info.pm index 40a164058..16d84779e 100644 --- a/centreon-plugins/cloud/docker/mode/info.pm +++ b/centreon-plugins/cloud/docker/mode/info.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/listcontainers.pm b/centreon-plugins/cloud/docker/mode/listcontainers.pm index 2db673617..e96baaf62 100644 --- a/centreon-plugins/cloud/docker/mode/listcontainers.pm +++ b/centreon-plugins/cloud/docker/mode/listcontainers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/memory.pm b/centreon-plugins/cloud/docker/mode/memory.pm index 8222a8d53..f4300210a 100644 --- a/centreon-plugins/cloud/docker/mode/memory.pm +++ b/centreon-plugins/cloud/docker/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/mode/traffic.pm b/centreon-plugins/cloud/docker/mode/traffic.pm index a869e3b46..1318c6a5e 100644 --- a/centreon-plugins/cloud/docker/mode/traffic.pm +++ b/centreon-plugins/cloud/docker/mode/traffic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/cloud/docker/plugin.pm b/centreon-plugins/cloud/docker/plugin.pm index ebb582a4c..ebb0824a4 100644 --- a/centreon-plugins/cloud/docker/plugin.pm +++ b/centreon-plugins/cloud/docker/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.2'; %{$self->{modes}} = ( diff --git a/centreon-plugins/database/firebird/mode/longqueries.pm b/centreon-plugins/database/firebird/mode/longqueries.pm index 99d639474..24b63c5df 100644 --- a/centreon-plugins/database/firebird/mode/longqueries.pm +++ b/centreon-plugins/database/firebird/mode/longqueries.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/firebird/mode/memory.pm b/centreon-plugins/database/firebird/mode/memory.pm index e97fddb60..910a82d36 100644 --- a/centreon-plugins/database/firebird/mode/memory.pm +++ b/centreon-plugins/database/firebird/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/firebird/mode/pages.pm b/centreon-plugins/database/firebird/mode/pages.pm index e81927743..ab7ab2c80 100644 --- a/centreon-plugins/database/firebird/mode/pages.pm +++ b/centreon-plugins/database/firebird/mode/pages.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/firebird/mode/queries.pm b/centreon-plugins/database/firebird/mode/queries.pm index 21ac8b928..4bb0034d6 100644 --- a/centreon-plugins/database/firebird/mode/queries.pm +++ b/centreon-plugins/database/firebird/mode/queries.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/firebird/mode/users.pm b/centreon-plugins/database/firebird/mode/users.pm index 3b7a3b18b..88a693aae 100644 --- a/centreon-plugins/database/firebird/mode/users.pm +++ b/centreon-plugins/database/firebird/mode/users.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/firebird/plugin.pm b/centreon-plugins/database/firebird/plugin.pm index b49f6728a..623c88362 100644 --- a/centreon-plugins/database/firebird/plugin.pm +++ b/centreon-plugins/database/firebird/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/database/informix/mode/archivelevel0.pm b/centreon-plugins/database/informix/mode/archivelevel0.pm index e1b13196d..ac35c0fc1 100644 --- a/centreon-plugins/database/informix/mode/archivelevel0.pm +++ b/centreon-plugins/database/informix/mode/archivelevel0.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/checkpoints.pm b/centreon-plugins/database/informix/mode/checkpoints.pm index 3ce2e12f9..9377032e7 100644 --- a/centreon-plugins/database/informix/mode/checkpoints.pm +++ b/centreon-plugins/database/informix/mode/checkpoints.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/chunkstates.pm b/centreon-plugins/database/informix/mode/chunkstates.pm index 9b6d0ebca..9c898c748 100644 --- a/centreon-plugins/database/informix/mode/chunkstates.pm +++ b/centreon-plugins/database/informix/mode/chunkstates.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/dbspacesusage.pm b/centreon-plugins/database/informix/mode/dbspacesusage.pm index 1553cf8d8..c89a23685 100644 --- a/centreon-plugins/database/informix/mode/dbspacesusage.pm +++ b/centreon-plugins/database/informix/mode/dbspacesusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/globalcache.pm b/centreon-plugins/database/informix/mode/globalcache.pm index 413981219..119c8f403 100644 --- a/centreon-plugins/database/informix/mode/globalcache.pm +++ b/centreon-plugins/database/informix/mode/globalcache.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/listdatabases.pm b/centreon-plugins/database/informix/mode/listdatabases.pm index 55b07720c..c2fc8710d 100644 --- a/centreon-plugins/database/informix/mode/listdatabases.pm +++ b/centreon-plugins/database/informix/mode/listdatabases.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -88,7 +88,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{sql} = $options{sql}; $self->manage_selection(); diff --git a/centreon-plugins/database/informix/mode/listdbspaces.pm b/centreon-plugins/database/informix/mode/listdbspaces.pm index 6e8938ae3..696050482 100644 --- a/centreon-plugins/database/informix/mode/listdbspaces.pm +++ b/centreon-plugins/database/informix/mode/listdbspaces.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -88,7 +88,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{sql} = $options{sql}; $self->manage_selection(); diff --git a/centreon-plugins/database/informix/mode/lockoverflow.pm b/centreon-plugins/database/informix/mode/lockoverflow.pm index 98122ec63..a5ff74643 100644 --- a/centreon-plugins/database/informix/mode/lockoverflow.pm +++ b/centreon-plugins/database/informix/mode/lockoverflow.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/logfilesusage.pm b/centreon-plugins/database/informix/mode/logfilesusage.pm index dd68da06b..f560b12a4 100644 --- a/centreon-plugins/database/informix/mode/logfilesusage.pm +++ b/centreon-plugins/database/informix/mode/logfilesusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/longtxs.pm b/centreon-plugins/database/informix/mode/longtxs.pm index 1e6febfcb..5921151fa 100644 --- a/centreon-plugins/database/informix/mode/longtxs.pm +++ b/centreon-plugins/database/informix/mode/longtxs.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/sessions.pm b/centreon-plugins/database/informix/mode/sessions.pm index 7dc4a12df..d95c7233c 100644 --- a/centreon-plugins/database/informix/mode/sessions.pm +++ b/centreon-plugins/database/informix/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/mode/tablelocks.pm b/centreon-plugins/database/informix/mode/tablelocks.pm index f30eb9051..a80c0730d 100644 --- a/centreon-plugins/database/informix/mode/tablelocks.pm +++ b/centreon-plugins/database/informix/mode/tablelocks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/informix/plugin.pm b/centreon-plugins/database/informix/plugin.pm index e571239d7..6d7400e59 100644 --- a/centreon-plugins/database/informix/plugin.pm +++ b/centreon-plugins/database/informix/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,7 +30,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/database/mssql/mode/backupage.pm b/centreon-plugins/database/mssql/mode/backupage.pm index 1157c4bba..958655ad0 100644 --- a/centreon-plugins/database/mssql/mode/backupage.pm +++ b/centreon-plugins/database/mssql/mode/backupage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/mode/blockedprocesses.pm b/centreon-plugins/database/mssql/mode/blockedprocesses.pm index 61ee349b1..7db96af45 100644 --- a/centreon-plugins/database/mssql/mode/blockedprocesses.pm +++ b/centreon-plugins/database/mssql/mode/blockedprocesses.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/mode/cachehitratio.pm b/centreon-plugins/database/mssql/mode/cachehitratio.pm index ed32969db..69348e39b 100644 --- a/centreon-plugins/database/mssql/mode/cachehitratio.pm +++ b/centreon-plugins/database/mssql/mode/cachehitratio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/mode/connectedusers.pm b/centreon-plugins/database/mssql/mode/connectedusers.pm index 887906682..95949106d 100644 --- a/centreon-plugins/database/mssql/mode/connectedusers.pm +++ b/centreon-plugins/database/mssql/mode/connectedusers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/mode/databasessize.pm b/centreon-plugins/database/mssql/mode/databasessize.pm index ecfcac5f5..8a0b5cd7d 100644 --- a/centreon-plugins/database/mssql/mode/databasessize.pm +++ b/centreon-plugins/database/mssql/mode/databasessize.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,50 +20,129 @@ package database::mssql::mode::databasessize; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +my $instance_mode; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'database', type => 1, cb_prefix_output => 'prefix_database_output', message_multiple => 'All databases are OK' }, + ]; + + $self->{maps_counters}->{database} = [ + { label => 'database', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' }, { name => 'display' } ], + 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 $label = 'db_' . $self->{result_values}->{display} . '_used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'db_' . $self->{result_values}->{display} . '_free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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}->{prct_used} = $options{new_datas}->{$self->{instance} . '_prct_used'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'}; + + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + 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 => - { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - "filter:s" => { name => 'filter', }, - "free" => { name => 'free', }, + { + "filter-database:s" => { name => 'filter_database' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, }); - return $self; } +sub prefix_database_output { + my ($self, %options) = @_; + + return "Database '" . $options{instance_value}->{display} . "' "; +} + sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%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(); - } + $instance_mode = $self; } -sub run { +sub manage_selection { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; - - $self->{output}->output_add(severity => 'OK', - short_msg => "All databases are ok."); - $self->{sql}->connect(); $self->{sql}->query(query => q{DBCC SQLPERF(LOGSPACE)}); @@ -71,7 +150,7 @@ sub run { my @databases_selected; foreach my $row (@$result) { - next if (defined($self->{option_results}->{filter}) && $$row[0] !~ /$self->{option_results}->{filter}/); + next if (defined($self->{option_results}->{filter_database}) && $$row[0] !~ /$self->{option_results}->{filter_database}/); push @databases_selected, $$row[0]; } @@ -83,44 +162,17 @@ sub run { my $size = convert_bytes($size_brut); my $free_brut = $$row[2]; my $free = convert_bytes($free_brut); - my $use = $size - $free; - my $percent_use = ($use / $size) * 100; - my $percent_free = 100 - $percent_use; - my ($use_value, $use_unit) = $self->{perfdata}->change_bytes(value => $use); - $self->{output}->output_add(long_msg => sprintf("DB '%s' Size: %s Used: %.2f %s (%.2f%%) Free: %s (%.2f%%)", $database, $size_brut, $use_value, $use_unit, $percent_use, $free_brut, $percent_free)); - if (defined($self->{option_results}->{free})) { - my $exit_code = $self->{perfdata}->threshold_check(value => $percent_free, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("DB '%s' Size: %s Free: %s (%.2f%%)", $database, $size_brut, $free_brut, $percent_use)); - } - $self->{output}->perfdata_add(label => sprintf("db_%s_free",$database), - unit => 'B', - value => int($free), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $size, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $size, cast_int => 1), - min => 0, - max => int($size)); - } else { - my $exit_code = $self->{perfdata}->threshold_check(value => $percent_use, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("DB '%s' Size: %s Used: %.2f %s (%.2f%%)", $database, $size_brut, $use_value, $use_unit, $percent_use)); - } - $self->{output}->perfdata_add(label => sprintf("db_%s_used",$database), - unit => 'B', - value => int($use), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $size, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $size, cast_int => 1), - min => 0, - max => int($size)); - } + my $used = $size - $free; + my $percent_used = ($used / $size) * 100; + + $self->{database}->{$database} = { used => $used, + free => $free, + total => $size, + prct_used => $percent_used, + display => lc $database }; + } } - - - $self->{output}->display(); - $self->{output}->exit(); } sub convert_bytes { @@ -144,25 +196,29 @@ __END__ =head1 MODE -Check MSSQL databases size. +Check MSSQL Database usage =over 8 -=item B<--warning> +=item B<--warning-database> -Threshold warning in percent used. +Threshold warning. -=item B<--critical> +=item B<--critical-database> -Threshold critical in percent used. +Threshold critical. -=item B<--filter> +=item B<--filter-database> -Filter database. +Filter database by name. Can be a regex + +=item B<--units> + +Default is '%', can be 'B' =item B<--free> -Check free space instead of used space. +Perfdata show free space =back diff --git a/centreon-plugins/database/mssql/mode/deadlocks.pm b/centreon-plugins/database/mssql/mode/deadlocks.pm index 8a629dcac..466e4555e 100644 --- a/centreon-plugins/database/mssql/mode/deadlocks.pm +++ b/centreon-plugins/database/mssql/mode/deadlocks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/mode/failedjobs.pm b/centreon-plugins/database/mssql/mode/failedjobs.pm index f58b566bd..dba5a75e9 100644 --- a/centreon-plugins/database/mssql/mode/failedjobs.pm +++ b/centreon-plugins/database/mssql/mode/failedjobs.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,11 +66,11 @@ 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', value => $self->{option_results}->{warning_duration})) == 0) { + if (($self->{perfdata}->threshold_validate(label => 'warning-duration', value => $self->{option_results}->{warning_duration})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning duration threshold '" . $self->{option_results}->{warning_duration} . "'."); $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical_duration})) == 0) { + if (($self->{perfdata}->threshold_validate(label => 'critical-duration', value => $self->{option_results}->{critical_duration})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical duration threshold '" . $self->{option_results}->{critical_duration} . "'."); $self->{output}->option_exit(); } @@ -132,7 +132,7 @@ sub run { $count_failed++; push (@job_failed, $job_name); } else { - my $exit_code1 = $self->{perfdata}->threshold_check(value => $run_duration, threshold => [ { label => 'critical_duration', 'exit_litteral' => 'critical' }, { label => 'warning_duration', exit_litteral => 'warning' } ]); + my $exit_code1 = $self->{perfdata}->threshold_check(value => $run_duration, threshold => [ { label => 'critical-duration', exit_litteral => 'critical' }, { label => 'warning-duration', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit_code1, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit_code1, short_msg => sprintf("Job '%s' duration : %d minutes", $job_name, $run_duration)); @@ -141,7 +141,7 @@ sub run { $self->{output}->output_add(long_msg => sprintf("Job '%s' status %s [Runtime : %s %s] [Duration : %d minutes]", $job_name, $states{$run_status}, $run_date, $run_time, $run_duration)); } - my $exit_code2 = $self->{perfdata}->threshold_check(value => $count_failed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code2 = $self->{perfdata}->threshold_check(value => $count_failed, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if(!defined($self->{option_results}->{skip}) && $count == 0) { $self->{output}->output_add(severity => 'Unknown', short_msg => "No job found."); diff --git a/centreon-plugins/database/mssql/mode/lockswaits.pm b/centreon-plugins/database/mssql/mode/lockswaits.pm index 2604f5d3e..e3932b3da 100644 --- a/centreon-plugins/database/mssql/mode/lockswaits.pm +++ b/centreon-plugins/database/mssql/mode/lockswaits.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/mode/transactions.pm b/centreon-plugins/database/mssql/mode/transactions.pm index dfc6d4140..729595dda 100644 --- a/centreon-plugins/database/mssql/mode/transactions.pm +++ b/centreon-plugins/database/mssql/mode/transactions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mssql/plugin.pm b/centreon-plugins/database/mssql/plugin.pm index 4c816ae0c..b6716d359 100644 --- a/centreon-plugins/database/mssql/plugin.pm +++ b/centreon-plugins/database/mssql/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/database/mysql/mode/databasessize.pm b/centreon-plugins/database/mysql/mode/databasessize.pm index 06e4dcc8f..35dd8d555 100644 --- a/centreon-plugins/database/mysql/mode/databasessize.pm +++ b/centreon-plugins/database/mysql/mode/databasessize.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/innodbbufferpoolhitrate.pm b/centreon-plugins/database/mysql/mode/innodbbufferpoolhitrate.pm index 1fc7dbfac..5b2df3703 100644 --- a/centreon-plugins/database/mysql/mode/innodbbufferpoolhitrate.pm +++ b/centreon-plugins/database/mysql/mode/innodbbufferpoolhitrate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/longqueries.pm b/centreon-plugins/database/mysql/mode/longqueries.pm index 062d28277..acbb587b1 100644 --- a/centreon-plugins/database/mysql/mode/longqueries.pm +++ b/centreon-plugins/database/mysql/mode/longqueries.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/myisamkeycachehitrate.pm b/centreon-plugins/database/mysql/mode/myisamkeycachehitrate.pm index f2f5177ef..13c92e10e 100644 --- a/centreon-plugins/database/mysql/mode/myisamkeycachehitrate.pm +++ b/centreon-plugins/database/mysql/mode/myisamkeycachehitrate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/openfiles.pm b/centreon-plugins/database/mysql/mode/openfiles.pm index 8c5e0504a..c58b94174 100644 --- a/centreon-plugins/database/mysql/mode/openfiles.pm +++ b/centreon-plugins/database/mysql/mode/openfiles.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/qcachehitrate.pm b/centreon-plugins/database/mysql/mode/qcachehitrate.pm index e9efe77e0..af625825f 100644 --- a/centreon-plugins/database/mysql/mode/qcachehitrate.pm +++ b/centreon-plugins/database/mysql/mode/qcachehitrate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/queries.pm b/centreon-plugins/database/mysql/mode/queries.pm index 2e2f27c34..3773bfff0 100644 --- a/centreon-plugins/database/mysql/mode/queries.pm +++ b/centreon-plugins/database/mysql/mode/queries.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/replicationmastermaster.pm b/centreon-plugins/database/mysql/mode/replicationmastermaster.pm index a68fe7cc5..7b10e6777 100644 --- a/centreon-plugins/database/mysql/mode/replicationmastermaster.pm +++ b/centreon-plugins/database/mysql/mode/replicationmastermaster.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/replicationmasterslave.pm b/centreon-plugins/database/mysql/mode/replicationmasterslave.pm index 94f4e59ba..b8988adbe 100644 --- a/centreon-plugins/database/mysql/mode/replicationmasterslave.pm +++ b/centreon-plugins/database/mysql/mode/replicationmasterslave.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,18 +45,17 @@ sub check_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(); + $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 { my ($self, %options) = @_; - # $options{sql} = sqlmode object if (ref($options{sql}) ne 'ARRAY') { $self->{output}->add_option_msg(short_msg => "Need to use --multiple options."); @@ -232,7 +231,7 @@ sub run { my $slave_position = $result2->{Read_Master_Log_Pos}; # 'Read_Master_Log_Pos' my $num_sec_lates = $result2->{Seconds_Behind_Master}; - my $exit_code_sec = $self->{perfdata}->threshold_check(value => $num_sec_lates, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code_sec = $self->{perfdata}->threshold_check(value => $num_sec_lates, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit_code_sec, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit_code_sec, short_msg => sprintf("Slave has %d seconds latency behind master", $num_sec_lates)); @@ -262,51 +261,63 @@ sub run { $position_status_error .= " Slave replication has connection issue with the master."; } elsif (($master_file ne $slave_file || $master_position != $slave_position) && $slave_sql_thread_warning == 0) { $position_status = -1; - $position_status_error .= " Slave replication is late but it's progressing.."; + $position_status_error .= " Slave replication is late but it's progressing."; } elsif (($master_file ne $slave_file || $master_position != $slave_position) && $slave_sql_thread_ok == 0) { $position_status = -1; - $position_status_error .= " Slave replication is late but it's progressing.."; + $position_status_error .= " Slave replication is late but it's progressing."; + } else { + $master_file =~ /(\d+)$/; + my $master_bin_num = $1; + $slave_file =~ /(\d+)$/; + my $slave_bin_num = $1; + my $diff_binlog = abs($master_bin_num - $slave_bin_num); + + # surely of missconfiguration of the plugin + if ($diff_binlog > 1 && $num_sec_lates < 10) { + $position_status = -3; + $position_status_error .= " Surely a configuration problem of the plugin (not good master and slave server used)"; + } } } } - - $self->replication_add($slave_status, "Slave Thread Status", $slave_status_error); - $self->replication_add($position_status, "Position Status", $position_status_error); + $self->replication_add($position_status, "Position Status", $position_status_error); $self->{output}->display(); $self->{output}->exit(); } sub replication_add { - my ($self, $lstate, $str_display, $lerr) = @_; - my $status; + my ($self, $lstate, $str_display, $lerr) = @_; + my $status; my $status_msg; - if ($lstate == 0) { - $status = 'OK'; - } elsif ($lstate == -1) { - $status = 'WARNING'; - } elsif ($lstate == -2) { - $status = 'CRITICAL'; + if ($lstate == 0) { + $status = 'OK'; + } elsif ($lstate == -1) { + $status = 'WARNING'; + } elsif ($lstate == -2) { + $status = 'CRITICAL'; $status_msg = 'SKIP'; - } else { - $status = 'CRITICAL'; - } + } elsif ($lstate == -3) { + $status = 'UNKNOWN'; + } else { + $status = 'CRITICAL'; + } my $output; - if (defined($lerr) && $lerr ne "") { - $output = $str_display . " [" . (defined($status_msg) ? $status_msg : $status) . "] [" . $lerr . "]"; - } else { - $output = $str_display . " [" . (defined($status_msg) ? $status_msg : $status) . "]"; - } + if (defined($lerr) && $lerr ne "") { + $output = $str_display . " [" . (defined($status_msg) ? $status_msg : $status) . "] [" . $lerr . "]"; + } else { + $output = $str_display . " [" . (defined($status_msg) ? $status_msg : $status) . "]"; + } if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $status, short_msg => $output); } - $self->{output}->output_add(long_msg => $output); + $self->{output}->output_add(long_msg => $output); } 1; diff --git a/centreon-plugins/database/mysql/mode/slowqueries.pm b/centreon-plugins/database/mysql/mode/slowqueries.pm index 757152826..ce4f308d7 100644 --- a/centreon-plugins/database/mysql/mode/slowqueries.pm +++ b/centreon-plugins/database/mysql/mode/slowqueries.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/tablessize.pm b/centreon-plugins/database/mysql/mode/tablessize.pm new file mode 100644 index 000000000..da2699bd9 --- /dev/null +++ b/centreon-plugins/database/mysql/mode/tablessize.pm @@ -0,0 +1,149 @@ +# +# Copyright 2016 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 database::mysql::mode::tablessize; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'table', type => 1, cb_prefix_output => 'prefix_table_output', message_multiple => 'All tables sizes are ok' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total Size : %s%s', + output_change_bytes => 1, + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + unit => 'B', min => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{table} = [ + { label => 'table', set => { + key_values => [ { name => 'size' }, { name => 'display' } ], + output_template => 'size : %s%s', + output_change_bytes => 1, + perfdatas => [ + { label => 'table', value => 'size_absolute', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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-db:s" => { name => 'filter_db' }, + "filter-table:s" => { name => 'filter_table' }, + }); + return $self; +} + +sub prefix_table_output { + my ($self, %options) = @_; + + return "Table '" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => "SELECT table_schema AS DB, table_name AS NAME, ROUND(data_length + index_length) + FROM information_schema.TABLES"); + my $result = $self->{sql}->fetchall_arrayref(); + + if (!($self->{sql}->is_version_minimum(version => '5'))) { + $self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported."); + $self->{output}->option_exit(); + } + + $self->{global} = { total => 0 }; + $self->{table} = {}; + + foreach my $row (@$result) { + next if (!defined($$row[2])); + if (defined($self->{option_results}->{filter_table}) && $self->{option_results}->{filter_table} ne '' && + $$row[1] !~ /$self->{option_results}->{filter_table}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_db}) && $self->{option_results}->{filter_db} ne '' && + $$row[0] !~ /$self->{option_results}->{filter_db}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1); + next + } + $self->{table}->{$$row[0].'.'.$$row[1]} = { size => $$row[2], display => $$row[0].'.'.$$row[1] }; + $self->{global}->{total} += $$row[2] if defined($self->{table}->{$$row[0].'.'.$$row[1]}); + } +} + +1; + +__END__ + +=head1 MODE + +Check size of one (or more) table from one (or more) databases + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--filter-db> + +Filter DB name (can be a regexp). + +=item B<--filter-table> + +Filter table name (can be a regexp). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'total', 'table' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'total', 'table' + +=back + +=cut diff --git a/centreon-plugins/database/mysql/mode/threadsconnected.pm b/centreon-plugins/database/mysql/mode/threadsconnected.pm index 1444272e9..46c4e8e79 100644 --- a/centreon-plugins/database/mysql/mode/threadsconnected.pm +++ b/centreon-plugins/database/mysql/mode/threadsconnected.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mode/uptime.pm b/centreon-plugins/database/mysql/mode/uptime.pm index ac64a4998..5adc32ce3 100644 --- a/centreon-plugins/database/mysql/mode/uptime.pm +++ b/centreon-plugins/database/mysql/mode/uptime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/mysqlcmd.pm b/centreon-plugins/database/mysql/mysqlcmd.pm index eb6567bb3..8f1eeadcd 100644 --- a/centreon-plugins/database/mysql/mysqlcmd.pm +++ b/centreon-plugins/database/mysql/mysqlcmd.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/mysql/plugin.pm b/centreon-plugins/database/mysql/plugin.pm index d21516ec7..642a59745 100644 --- a/centreon-plugins/database/mysql/plugin.pm +++ b/centreon-plugins/database/mysql/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( @@ -47,6 +46,7 @@ sub new { 'sql' => 'centreon::common::protocols::sql::mode::sql', 'threads-connected' => 'database::mysql::mode::threadsconnected', 'uptime' => 'database::mysql::mode::uptime', + 'tables-size' => 'database::mysql::mode::tablessize', ); $self->{sql_modes}{mysqlcmd} = 'database::mysql::mysqlcmd'; diff --git a/centreon-plugins/database/oracle/mode/asmdiskgroupusage.pm b/centreon-plugins/database/oracle/mode/asmdiskgroupusage.pm index b9ecbdbea..39404c9ff 100644 --- a/centreon-plugins/database/oracle/mode/asmdiskgroupusage.pm +++ b/centreon-plugins/database/oracle/mode/asmdiskgroupusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/connectedusers.pm b/centreon-plugins/database/oracle/mode/connectedusers.pm index f469fbbf3..aa298eb81 100644 --- a/centreon-plugins/database/oracle/mode/connectedusers.pm +++ b/centreon-plugins/database/oracle/mode/connectedusers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/corruptedblocks.pm b/centreon-plugins/database/oracle/mode/corruptedblocks.pm index 8cccbc539..4b9bc2795 100644 --- a/centreon-plugins/database/oracle/mode/corruptedblocks.pm +++ b/centreon-plugins/database/oracle/mode/corruptedblocks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/datacachehitratio.pm b/centreon-plugins/database/oracle/mode/datacachehitratio.pm index d9dcb8e22..c65661775 100644 --- a/centreon-plugins/database/oracle/mode/datacachehitratio.pm +++ b/centreon-plugins/database/oracle/mode/datacachehitratio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/datafilesstatus.pm b/centreon-plugins/database/oracle/mode/datafilesstatus.pm new file mode 100644 index 000000000..78ed67f56 --- /dev/null +++ b/centreon-plugins/database/oracle/mode/datafilesstatus.pm @@ -0,0 +1,218 @@ +# +# Copyright 2016 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 database::oracle::mode::datafilesstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'df', type => 1, cb_prefix_output => 'prefix_df_output', message_multiple => 'All data files are ok' }, + ]; + + $self->{maps_counters}->{df} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + { label => 'online-status', threshold => 0, set => { + key_values => [ { name => 'online_status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_online_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label_th}}) && $instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label_th}} ne '' && + eval "$instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label_th}}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label_th}}) && $instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label_th}} ne '' && + eval "$instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label_th}}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg = $self->{result_values}->{label_display} . ' : ' . $self->{result_values}->{$self->{result_values}->{label_th}}; + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{label_display} = 'Status'; + $self->{result_values}->{label_th} = 'status'; + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub custom_online_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{label_display} = 'Online Status'; + $self->{result_values}->{label_th} = 'online_status'; + $self->{result_values}->{online_status} = $options{new_datas}->{$self->{instance} . '_online_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + 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-tablespace:s" => { name => 'filter_tablespace' }, + "filter-data-file:s" => { name => 'filter_data_file' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '' }, + "warning-online-status:s" => { name => 'warning_online_status', default => '%{online_status} =~ /sysoff/i' }, + "critical-online-status:s" => { name => 'critical_online_status', default => '%{online_status} =~ /offline|recover/i' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'warning_online_status', 'critical_online_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub prefix_df_output { + my ($self, %options) = @_; + + return "Data file '" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $options{sql}->connect(); + $options{sql}->query(query => "SELECT file_name, tablespace_name, status, online_status + FROM dba_data_files"); + my $result = $options{sql}->fetchall_arrayref(); + + $self->{df} = {}; + foreach my $row (@$result) { + if (defined($self->{option_results}->{filter_data_file}) && $self->{option_results}->{filter_data_file} ne '' && + $$row[0] !~ /$self->{option_results}->{filter_data_file}/) { + $self->{output}->output_add(long_msg => "skipping '" . $$row[0] . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_tablespace}) && $self->{option_results}->{filter_tablespace} ne '' && + $$row[1] !~ /$self->{option_results}->{filter_tablespace}/) { + $self->{output}->output_add(long_msg => "skipping '" . $$row[1] . "': no matching filter.", debug => 1); + next + } + $self->{df}->{$$row[1] . '/' . $$row[0]} = { status => $$row[2], online_status => $$row[3], display => $$row[1] . '/' . $$row[0] }; + } +} + +1; + +__END__ + +=head1 MODE + +Check data files status. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--filter-tablespace> + +Filter tablespace name (can be a regexp). + +=item B<--filter-data-file> + +Filter data file name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: none). +Can used special variables like: %{display}, %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: none). +Can used special variables like: %{display}, %{status} + +=item B<--warning-online-status> + +Set warning threshold for online status (Default: '%{online_status} =~ /sysoff/i'). +Can used special variables like: %{display}, %{online_status} + +=item B<--critical-online-status> + +Set critical threshold for online status (Default: '%{online_status} =~ /offline|recover/i'). +Can used special variables like: %{display}, %{online_status} + +=back + +=cut diff --git a/centreon-plugins/database/oracle/mode/processusage.pm b/centreon-plugins/database/oracle/mode/processusage.pm index c6b9bf9b1..33bbefc9b 100644 --- a/centreon-plugins/database/oracle/mode/processusage.pm +++ b/centreon-plugins/database/oracle/mode/processusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/rmanbackupage.pm b/centreon-plugins/database/oracle/mode/rmanbackupage.pm index fef424a8f..5a04879d9 100644 --- a/centreon-plugins/database/oracle/mode/rmanbackupage.pm +++ b/centreon-plugins/database/oracle/mode/rmanbackupage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -112,9 +112,6 @@ sub run { my $label = $_; $label =~ s/ /-/g; foreach my $row (@$result) { - - next if (defined($already_checked->{$$row[0]})); - if (defined($self->{option_results}->{incremental_level})) { # 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 @@ -123,11 +120,14 @@ sub run { next if (/db incr/ && $$row[0] =~ /db incr/i && defined($$row[2]) && $$row[2] == 0); # it's a full. we skip. next if ($$row[0] !~ /$_/i); } - - $already_checked->{$$row[0]} = 1; + } else { next if ($$row[0] !~ /$_/i); } + + next if (defined($already_checked->{$$row[0]})); + + $already_checked->{$$row[0]} = 1; $count_backups++; $executed = 1; diff --git a/centreon-plugins/database/oracle/mode/rmanbackupproblems.pm b/centreon-plugins/database/oracle/mode/rmanbackupproblems.pm index c80c6cd2c..a08284501 100644 --- a/centreon-plugins/database/oracle/mode/rmanbackupproblems.pm +++ b/centreon-plugins/database/oracle/mode/rmanbackupproblems.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/rmanonlinebackupage.pm b/centreon-plugins/database/oracle/mode/rmanonlinebackupage.pm index fa59c52dc..f8826b4ea 100644 --- a/centreon-plugins/database/oracle/mode/rmanonlinebackupage.pm +++ b/centreon-plugins/database/oracle/mode/rmanonlinebackupage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/sessionusage.pm b/centreon-plugins/database/oracle/mode/sessionusage.pm index 11fd8220a..3758ac315 100644 --- a/centreon-plugins/database/oracle/mode/sessionusage.pm +++ b/centreon-plugins/database/oracle/mode/sessionusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/mode/tablespaceusage.pm b/centreon-plugins/database/oracle/mode/tablespaceusage.pm index e0df54b48..0c5ce8ef3 100644 --- a/centreon-plugins/database/oracle/mode/tablespaceusage.pm +++ b/centreon-plugins/database/oracle/mode/tablespaceusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,54 +20,151 @@ package database::oracle::mode::tablespaceusage; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +my $instance_mode; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'tablespace', type => 1, cb_prefix_output => 'prefix_tablespace_output', message_multiple => 'All tablespaces are OK' }, + ]; + + $self->{maps_counters}->{tablespace} = [ + { label => 'tablespace', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' }, { name => 'display' } ], + 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 $label = 'tbs_' . $self->{result_values}->{display} . '_usage'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'tbs_' . $self->{result_values}->{display} . '_free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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}->{prct_used} = $options{new_datas}->{$self->{instance} . '_prct_used'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'}; + + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + 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 => - { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - "filter:s" => { name => 'filter', }, - "skip:s" => { name => 'skip', }, - "free" => { name => 'free', }, + { + "filter-tablespace:s" => { name => 'filter_tablespace' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + "skip" => { name => 'skip' }, }); - return $self; } +sub prefix_tablespace_output { + my ($self, %options) = @_; + + return "Tablespace '" . $options{instance_value}->{display} . "' "; +} + sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%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(); - } + $instance_mode = $self; } -sub run { +sub manage_selection { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; - - $self->{output}->output_add(severity => 'OK', - short_msg => "All tablespaces are ok."); - $self->{sql}->connect(); + my $query; - if ($self->{sql}->is_version_minimum(version => '9')) { + if ($self->{sql}->is_version_minimum(version => '11')) { + $query = q{ + SELECT + tum.tablespace_name "Tablespace", + t.status "Status", + t.contents "Type", + t.extent_management "Extent Mgmt", + tum.used_space*t.block_size bytes, + tum.tablespace_size*t.block_size bytes_max + FROM + DBA_TABLESPACE_USAGE_METRICS tum + INNER JOIN + dba_tablespaces t on tum.tablespace_name=t.tablespace_name + WHERE + t.contents<>'UNDO' + OR (t.contents='UNDO' AND t.tablespace_name =(SELECT value FROM v$parameter WHERE name='undo_tablespace')) + }; + } elsif ($self->{sql}->is_version_minimum(version => '9')) { $query = q{ SELECT a.tablespace_name "Tablespace", @@ -82,7 +179,7 @@ sub run { SELECT a.tablespace_name, SUM(a.bytes) bytes, - SUM(DECODE(a.autoextensible, 'YES', a.maxbytes, 'NO', a.bytes)) maxbytes + SUM(DECODE(a.autoextensible, 'YES', CASE WHEN (a.bytes > a.maxbytes) THEN 0 ELSE a.maxbytes END, 'NO', a.bytes)) maxbytes FROM dba_data_files a GROUP BY @@ -123,7 +220,7 @@ sub run { b.contents "Type", b.extent_management "Extent Mgmt", sum(a.bytes_free + a.bytes_used) bytes, -- allocated - SUM(DECODE(d.autoextensible, 'YES', d.maxbytes, 'NO', d.bytes)) bytes_max, + SUM(DECODE(d.autoextensible, 'YES', CASE WHEN (d.bytes > d.maxbytes) THEN 0 ELSE d.maxbytes END, 'NO', d.bytes)) bytes_max, SUM(a.bytes_free + a.bytes_used - NVL(c.bytes_used, 0)) bytes_free FROM sys.v_$TEMP_SPACE_HEADER a, @@ -259,22 +356,33 @@ sub run { $self->{sql}->query(query => $query); my $result = $self->{sql}->fetchall_arrayref(); + $self->{tablespace} = {}; + foreach my $row (@$result) { my ($name, $status, $type, $extentmgmt, $bytes, $bytes_max, $bytes_free) = @$row; - next if (defined($self->{option_results}->{filter}) && $name !~ /$self->{option_results}->{filter}/); - next if (defined($self->{option_results}->{skip}) && $status =~ /offline/i); - - if (!defined($bytes)) { - # seems corrupted, cannot get value - $self->{output}->output_add(severity => 'UNKNOWN', - short_msg => sprintf("tbs '%s' cannot get data", $name)); + + if (defined($self->{option_results}->{filter_tablespace}) && $self->{option_results}->{filter_tablespace} ne '' && + $name !~ /$self->{option_results}->{filter_tablespace}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter.", debug => 1); next; } - - $status = lc $status; - $type = lc $type; + if (!defined($bytes)) { + # seems corrupted, cannot get value + $self->{output}->output_add(long_msg => sprintf("tbs '%s' cannot get data", $name), debug => 1); + next; + } + if (defined($self->{option_results}->{skip}) && $status eq 'OFFLINE') { + $self->{output}->output_add(long_msg => "Skipping '" . $name . "': tbs is offline", debug => 1); + next; + } + my ($percent_used, $percent_free, $used, $free, $size); - if ((!defined($bytes_max)) || ($bytes_max == 0)) { + if ($self->{sql}->is_version_minimum(version => '11')) { + $percent_used = $bytes / $bytes_max * 100; + $size = $bytes_max; + $free = $bytes_max - $bytes; + $used = $bytes; + } elsif ((!defined($bytes_max)) || ($bytes_max == 0)) { $percent_used = ($bytes - $bytes_free) / $bytes * 100; $size = $bytes; $free = $bytes_free; @@ -285,44 +393,14 @@ sub run { $free = $bytes_free + ($bytes_max - $bytes); $used = $size - $free; } - $percent_free = 100 - $percent_used; - my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used); - my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free); - my ($size_value, $size_unit) = $self->{perfdata}->change_bytes(value => $size); - $self->{output}->output_add(long_msg => sprintf("tbs '%s' Used: %.2f%s (%.2f%%) Free: %.2f%s (%.2f%%) Size: %.2f%s", - $name, $used_value, $used_unit, $percent_used, $free_value, $free_unit, $percent_free, $size_value, $size_unit)); - if (defined($self->{option_results}->{free})) { - my $exit_code = $self->{perfdata}->threshold_check(value => $percent_free, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("tbs '%s' Free: %.2f%s (%.2f%%) Size: %.2f%s", $name, $free_value, $free_unit, $percent_free, $size_value, $size_unit)); - } - $self->{output}->perfdata_add(label => sprintf("tbs_%s_free",lc $name), - unit => 'B', - value => $free, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $size, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $size, cast_int => 1), - min => 0, - max => $size); - } else { - my $exit_code = $self->{perfdata}->threshold_check(value => $percent_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("tbs '%s' Used: %.2f%s (%.2f%%) Size: %.2f%s", $name, $used_value, $used_unit, $percent_used, $size_value, $size_unit)); - } - $self->{output}->perfdata_add(label => sprintf("tbs_%s_usage",lc $name), - unit => 'B', - value => $used, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $size, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $size, cast_int => 1), - min => 0, - max => $size); - } + $self->{tablespace}->{$name} = { used => $used, + free => $free, + total => $size, + prct_used => $percent_used, + display => lc $name }; } - $self->{output}->display(); - $self->{output}->exit(); } 1; @@ -335,26 +413,30 @@ Check Oracle tablespaces usage. =over 8 -=item B<--warning> +=item B<--warning-tablespace> Threshold warning. -=item B<--critical> +=item B<--critical-tablespace> Threshold critical. -=item B<--filter> +=item B<--filter-tablespace> -Filter tablespace. +Filter tablespace by name. Can be a regex + +=item B<--units> + +Default is '%', can be 'B' + +=item B<--free> + +Perfdata show free space =item B<--skip> Skip offline tablespaces. -=item B<--free> - -Check free space instead of used space. - =back =cut diff --git a/centreon-plugins/database/oracle/mode/tnsping.pm b/centreon-plugins/database/oracle/mode/tnsping.pm index 11db3b138..2f23da672 100644 --- a/centreon-plugins/database/oracle/mode/tnsping.pm +++ b/centreon-plugins/database/oracle/mode/tnsping.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/oracle/plugin.pm b/centreon-plugins/database/oracle/plugin.pm index 677b74910..24a6d39a3 100644 --- a/centreon-plugins/database/oracle/plugin.pm +++ b/centreon-plugins/database/oracle/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( @@ -37,6 +36,7 @@ sub new { 'connection-time' => 'centreon::common::protocols::sql::mode::connectiontime', 'connected-users' => 'database::oracle::mode::connectedusers', 'corrupted-blocks' => 'database::oracle::mode::corruptedblocks', + 'data-files-status' => 'database::oracle::mode::datafilesstatus', 'datacache-hitratio' => 'database::oracle::mode::datacachehitratio', 'process-usage' => 'database::oracle::mode::processusage', 'rman-backup-problems' => 'database::oracle::mode::rmanbackupproblems', diff --git a/centreon-plugins/database/postgres/mode/backends.pm b/centreon-plugins/database/postgres/mode/backends.pm index df8664f6b..dae77678e 100644 --- a/centreon-plugins/database/postgres/mode/backends.pm +++ b/centreon-plugins/database/postgres/mode/backends.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/mode/hitratio.pm b/centreon-plugins/database/postgres/mode/hitratio.pm index 7264fd07c..c9b3e482b 100644 --- a/centreon-plugins/database/postgres/mode/hitratio.pm +++ b/centreon-plugins/database/postgres/mode/hitratio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/mode/listdatabases.pm b/centreon-plugins/database/postgres/mode/listdatabases.pm index 5599bdbc7..90055fb7a 100644 --- a/centreon-plugins/database/postgres/mode/listdatabases.pm +++ b/centreon-plugins/database/postgres/mode/listdatabases.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -87,7 +87,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{sql} = $options{sql}; $self->manage_selection(); diff --git a/centreon-plugins/database/postgres/mode/locks.pm b/centreon-plugins/database/postgres/mode/locks.pm index cf6101e7a..f89ebddce 100644 --- a/centreon-plugins/database/postgres/mode/locks.pm +++ b/centreon-plugins/database/postgres/mode/locks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/mode/querytime.pm b/centreon-plugins/database/postgres/mode/querytime.pm index 9b010f046..780ffc99d 100644 --- a/centreon-plugins/database/postgres/mode/querytime.pm +++ b/centreon-plugins/database/postgres/mode/querytime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/mode/statistics.pm b/centreon-plugins/database/postgres/mode/statistics.pm index e213c0df9..a8a72e6b5 100644 --- a/centreon-plugins/database/postgres/mode/statistics.pm +++ b/centreon-plugins/database/postgres/mode/statistics.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/mode/tablespace.pm b/centreon-plugins/database/postgres/mode/tablespace.pm index 7a9235c7b..dd2c58e68 100644 --- a/centreon-plugins/database/postgres/mode/tablespace.pm +++ b/centreon-plugins/database/postgres/mode/tablespace.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/mode/timesync.pm b/centreon-plugins/database/postgres/mode/timesync.pm index 9fa87b9bf..94b3bb798 100644 --- a/centreon-plugins/database/postgres/mode/timesync.pm +++ b/centreon-plugins/database/postgres/mode/timesync.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -74,7 +74,7 @@ SELECT extract(epoch FROM now()) AS epok } my $diff = $result - $ltime; - my $exit_code = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $diff, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("%.3fs time diff between servers", $diff)); diff --git a/centreon-plugins/database/postgres/mode/vacuum.pm b/centreon-plugins/database/postgres/mode/vacuum.pm index 811158941..752b86bc4 100644 --- a/centreon-plugins/database/postgres/mode/vacuum.pm +++ b/centreon-plugins/database/postgres/mode/vacuum.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/database/postgres/plugin.pm b/centreon-plugins/database/postgres/plugin.pm index 58f2d08cb..e7cd4e852 100644 --- a/centreon-plugins/database/postgres/plugin.pm +++ b/centreon-plugins/database/postgres/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/database/postgres/psqlcmd.pm b/centreon-plugins/database/postgres/psqlcmd.pm index d2f66d240..5261205dd 100644 --- a/centreon-plugins/database/postgres/psqlcmd.pm +++ b/centreon-plugins/database/postgres/psqlcmd.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/docs/en/developer/guide.rst b/centreon-plugins/docs/en/developer/guide.rst index 75a99b12e..41dc32334 100644 --- a/centreon-plugins/docs/en/developer/guide.rst +++ b/centreon-plugins/docs/en/developer/guide.rst @@ -7,7 +7,16 @@ This document introduces the best practices in the development of "centreon-plug As all plugins are written in Perl, “there is more than one way to do it”. But to avoid reinventing the wheel, you should first take a look at the “example” directory, you will get an overview of how to build your own plugin and associated modes. -The lastest version is available on following git repository: http://git.centreon.com/centreon-plugins.git +There are 3 chapters: + +* :ref:`Quick Start `: Howto create file structure. +* :ref:`Libraries Reference `: API description. +* :ref:`Code Style Guidelines `: Follow it. +* :ref:`Model Classes Usage `: description of classes you should use for your plugin. + +The lastest version is available on following git repository: https://github.com/centreon/centreon-plugins.git + +.. _quick-start: *********** Quick Start @@ -218,7 +227,7 @@ For example, Warning and Critical thresholds must be validate in **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(); - } + } 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(); @@ -295,6 +304,8 @@ Once plugin and modes are developed, you can commit (commit messages in english) git commit -m "Add new plugin for XXXX refs #" git push +.. _libraries_reference: + ******************* Libraries reference ******************* @@ -1436,7 +1447,6 @@ This is an example of how to use **fetchrow_hashref** method: Output displays Postgres databases. - ***************** Complete examples ***************** @@ -1468,40 +1478,25 @@ Then, edit **plugin.pm** and add the following lines: .. code-block:: perl - ################################################################################ - # Copyright 2005-2015 MERETHIS - # Centreon is developped by : Julien Mathis and Romain Le Merlus under - # GPL Licence 2.0. # - # This program is free software; you can redistribute it and/or modify it under - # the terms of the GNU General Public License as published by the Free Software - # Foundation ; either version 2 of the License. + # Copyright 2016 Centreon (http://www.centreon.com/) # - # This program is distributed in the hope that it will be useful, but WITHOUT ANY - # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. See the GNU General Public License for more details. + # Centreon is a full-fledged industry-strength solution that meets + # the needs in IT infrastructure and application monitoring for + # service performance. # - # You should have received a copy of the GNU General Public License along with - # this program; if not, see . + # 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 # - # Linking this program statically or dynamically with other modules is making a - # combined work based on this program. Thus, the terms and conditions of the GNU - # General Public License cover the whole combination. + # http://www.apache.org/licenses/LICENSE-2.0 # - # As a special exception, the copyright holders of this program give MERETHIS - # permission to link this program with independent modules to produce an executable, - # regardless of the license terms of these independent modules, and to copy and - # distribute the resulting executable under terms of MERETHIS choice, provided that - # MERETHIS also meet, for each linked independent module, the terms and conditions - # of the license of that module. An independent module is a module which is not - # derived from this program. If you modify this program, you may extend this - # exception to your version of the program, but you are not obliged to do so. If you - # do not wish to do so, delete this exception statement from your version. + # 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. # - # For more information : contact@centreon.com - # Authors : your name - # - #################################################################################### # Path to the plugin package apps::pfsense::snmp::plugin; @@ -1573,40 +1568,25 @@ Edit **memorydroppedpackets.pm** and add the following lines: .. code-block:: perl - ################################################################################ - # Copyright 2005-2015 MERETHIS - # Centreon is developped by : Julien Mathis and Romain Le Merlus under - # GPL Licence 2.0. # - # This program is free software; you can redistribute it and/or modify it under - # the terms of the GNU General Public License as published by the Free Software - # Foundation ; either version 2 of the License. + # Copyright 2016 Centreon (http://www.centreon.com/) # - # This program is distributed in the hope that it will be useful, but WITHOUT ANY - # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. See the GNU General Public License for more details. + # Centreon is a full-fledged industry-strength solution that meets + # the needs in IT infrastructure and application monitoring for + # service performance. # - # You should have received a copy of the GNU General Public License along with - # this program; if not, see . + # 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 # - # Linking this program statically or dynamically with other modules is making a - # combined work based on this program. Thus, the terms and conditions of the GNU - # General Public License cover the whole combination. + # http://www.apache.org/licenses/LICENSE-2.0 # - # As a special exception, the copyright holders of this program give MERETHIS - # permission to link this program with independent modules to produce an executable, - # regardless of the license terms of these independent modules, and to copy and - # distribute the resulting executable under terms of MERETHIS choice, provided that - # MERETHIS also meet, for each linked independent module, the terms and conditions - # of the license of that module. An independent module is a module which is not - # derived from this program. If you modify this program, you may extend this - # exception to your version of the program, but you are not obliged to do so. If you - # do not wish to do so, delete this exception statement from your version. + # 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. # - # For more information : contact@centreon.com - # Authors : your name - # - #################################################################################### # Path to the plugin package apps::pfsense::snmp::mode::memorydroppedpackets; @@ -1797,4 +1777,460 @@ Output may display: OK: Dropped packets due to memory limitations : 0.00 /s | dropped_packets_Per_Sec=0.00;0;;1;2 +.. _code_style_guidelines: +********************* +Code Style Guidelines +********************* + +------------ +Introduction +------------ + +Perl code from Pull-request must conform to the following style guidelines. If you find any code which doesn't conform, please fix it. + +----------- +Indentation +----------- + +Space should be used to indent all code blocks. Tabs should never be used to indent code blocks. Mixing tabs and spaces results in misaligned code blocks for other developers who prefer different indentation settings. +Please use 4 for indentation space width. + +.. code-block:: perl + + if ($1 > 1) { + ....return 1; + } else { + if ($i == -1) { + ....return 0; + } + return -1 + } + +-------- +Comments +-------- + +There should always be at least 1 space between the # character and the beginning of the comment. This makes it a little easier to read multi-line comments: + +.. code-block:: perl + + # Good comment + #Wrong comment + +--------------------------- +Subroutine & Variable Names +--------------------------- + +Whenever possible, use underscore to seperator words and don't use uppercase characters: + +.. code-block:: perl + + sub get_logs {} + my $start_time; + +Keys of hash table should be used alphanumeric and underscore characters only (and no quote!): + +.. code-block:: perl + + $dogs->{meapolitan_mastiff} = 10; + +--------------------------- +Curly Brackets, Parenthesis +--------------------------- + +There should be a space between every control/loop keyword and the opening parenthesis: + +.. code-block:: perl + + if ($i == 1) { + ... + } + while ($i == 2) { + ... + } + +------------------ +If/Else Statements +------------------ + +'else', 'elsif' should be on the same line after the previous closing curly brace: + +.. code-block:: perl + + if ($i == 1) { + ... + } else { + ... + } + +You can use single line if conditional: + +.. code-block:: perl + + next if ($i == 1); + + +.. _model_classes_usage: + +******************* +Model Classes Usage +******************* + +------------ +Introduction +------------ + +With the experience of plugin development, we have created two classes: + +* centreon::plugins::templates::counter +* centreon::plugins::templates::hardware + +It was developed to have a more consistent code and less redundant code. According to context, you should use one of two classes for modes. +Following classes can be used for whatever plugin type (SNMP, Custom, DBI,...). + +------------- +Class counter +------------- + +When to use it ? +---------------- + +If you have some counters (CPU Usage, Memory, Session...), you should use that class. +If you have only one global counter to check, it's maybe not useful to use it (but only for these case). + +Class methods +------------- + +List of methods: + +* **new**: class constructor. Overload if you need to add some specific options or to use a statefile. +* **check_options**: overload if you need to check your specific options. +* **manage_selection**: overload if *mandatory*. Method to get informations for the equipment. +* **set_counters**: overload if **mandatory**. Method to configure counters. + +Examples +-------- + +Example 1 +^^^^^^^^^ + +We want to develop the following SNMP plugin: + +* measure the current sessions and current SSL sessions usages. + +.. code-block:: perl + + package my::module::name; + + use base qw(centreon::plugins::templates::counter); + + use strict; + use warnings; + + sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'sessions', set => { + key_values => [ { name => 'sessions' } ], + output_template => 'Current sessions : %s', + perfdatas => [ + { label => 'sessions', value => 'sessions_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'sessions-ssl', set => { + key_values => [ { name => 'sessions_ssl' } ], + output_template => 'Current ssl sessions : %s', + perfdatas => [ + { label => 'sessions_ssl', value => 'sessions_ssl_absolute', template => '%s', + min => 0 }, + ], + } + }, + ]; + } + + sub manage_selection { + my ($self, %options) = @_; + + # OIDs are fake. Only for the example. + my ($oid_sessions, $oid_sessions_ssl) = ('.1.2.3.4.0', '.1.2.3.5.0'); + + my $result = $options{snmp}->get_leef(oids => [ $oid_sessions, $oid_sessions_ssl ], + nothing_quit => 1); + $self->{global} = { sessions => $result->{$oid_sessions}, + sessions_ssl => $result->{$oid_sessions_ssl} + }; + } + + +Output may display: +:: + + OK: Current sessions : 24 - Current ssl sessions : 150 | sessions=24;;;0; sessions_ssl=150;;;0; + +As you can see, we create two arrays of hash tables in **set_counters** method. We use arrays to order the output. + +* **maps_counters_type**: global configuration. Attributes list: + + * *name*: the name is really important. It will be used in hash **map_counters** and also in **manage_selection** as you can see. + * *type*: 0 or 1. With 0 value, the output will be written in the short output. With the value 1, it depends if we have one or multiple instances. + * *message_multiple*: only useful with *type* 1 value. The message will be displayed in short ouput if we have multiple instances selected. + * *message_separator*: the string displayed between counters (Default: ', '). + * *cb_prefix_output*, *cb_suffix_output*: name of a method (in a string) to callback. Methods will return a string to be displayed before or after **all** counters. + * *cb_init*: name of a method (in a string) to callback. Method will return 0 or 1. With 1 value, counters are not checked. + +* **maps_counters**: complex structure to configure counters. Attributes list: + + * *label*: name used for threshold options. + * *threshold*: if we set the value to 0. There is no threshold check options (can be used if you want to set and check option yourself). + * *set*: hash table: + + * *keys_values*: array of hashes. Set values used for the counter. Order is important (by default, the first value is used to check). + + * *name*: attribute name. Need to match with attributes in **manage_selection** method! + * *diff*: if we set the value to 1, we'll have the difference between two checks (need a statefile!). + + * *output_template*: string to display. '%s' will be replaced by the first value of *keys_values*. + * *output_use*: which value to be used in *output_template* (If not set, we use the first value of *keys_values*). + * *per_second*: if we set the value to 1, the *diff* values will be calculated per seconds. + * *output_change_bytes*: if we set the value to 1 or 2, we can use a second '%s' in *output_template* to display the unit. 1 = divide by 1024 (Bytes), 2 = divide by 1000 (bits). + * *perfdata*: array of hashes. To configure perfdatas + + * *label*: name displayed. + * *value*: value to used. It's the name from *keys_values* with a **suffix**: '_absolute' or '_per_second' (depends of other options). + * *template*: value format (could be for example: '%.3f'). + * *unit*: unit displayed. + * *min*, *max*: min and max displayed. You can use a value from *keys_values*. + * *label_extra_instance*: if we set the value to 1, perhaps we'll have a suffix concat with *label*. + * *instance_use*: which value from *keys_values* to be used. To be used if *label_extra_instance* is 1. + +Example 2 +^^^^^^^^^ + +We want to add the current number of sessions by virtual servers. + +.. code-block:: perl + + package my::module::name; + + use base qw(centreon::plugins::templates::counter); + + use strict; + use warnings; + + sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, + { name => 'vs', type => 1, cb_prefix_output => 'prefix_vs_output', message_multiple => 'All Virtual servers are ok' } + ]; + $self->{maps_counters}->{global} = [ + { label => 'total-sessions', set => { + key_values => [ { name => 'sessions' } ], + output_template => 'current sessions : %s', + perfdatas => [ + { label => 'total_sessions', value => 'sessions_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-sessions-ssl', set => { + key_values => [ { name => 'sessions_ssl' } ], + output_template => 'current ssl sessions : %s', + perfdatas => [ + { label => 'total_sessions_ssl', value => 'sessions_ssl_absolute', template => '%s', + min => 0 }, + ], + } + }, + ]; + + $self->{maps_counters}->{vs} = [ + { label => 'sessions', set => { + key_values => [ { name => 'sessions' }, { name => 'display' } ], + output_template => 'current sessions : %s', + perfdatas => [ + { label => 'sessions', value => 'sessions_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'sessions-ssl', set => { + key_values => [ { name => 'sessions_ssl' }, { name => 'display' } ], + output_template => 'current ssl sessions : %s', + perfdatas => [ + { label => 'sessions_ssl', value => 'sessions_ssl_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; + } + + sub prefix_vs_output { + my ($self, %options) = @_; + + return "Virtual server '" . $options{instance_value}->{display} . "' "; + } + + sub prefix_global_output { + my ($self, %options) = @_; + + return "Total "; + } + + sub manage_selection { + my ($self, %options) = @_; + + # OIDs are fake. Only for the example. + my ($oid_sessions, $oid_sessions_ssl) = ('.1.2.3.4.0', '.1.2.3.5.0'); + + my $result = $options{snmp}->get_leef(oids => [ $oid_sessions, $oid_sessions_ssl ], + nothing_quit => 1); + $self->{global} = { sessions => $result->{$oid_sessions}, + sessions_ssl => $result->{$oid_sessions_ssl} + }; + my $oid_table_vs = '.1.2.3.10'; + my $mapping = { + vsName => { oid => '.1.2.3.10.1' }, + vsSessions => { oid => '.1.2.3.10.2' }, + vsSessionsSsl => { oid => '.1.2.3.10.3' }, + }; + + $self->{vs} = {}; + $result = $options{snmp}->get_table(oid => $oid_table_vs, + nothing_quit => 1); + foreach my $oid (keys %{$result->{ $oid_table_vs }}) { + next if ($oid !~ /^$mapping->{vsName}->{oid}\.(.*)$/; + my $instance = $1; + my $data = $options{snmp}->map_instance(mapping => $mapping, results => $result->{$oid_table_vs}, instance => $instance); + + $self->{vs}->{$instance} = { display => $data->{vsName}, + sessions => $data->{vsSessions}, sessions_ssl => $data->{vsSessionsSsl}}; + } + } + +If we have at least 2 virtual servers: +:: + + OK: Total current sessions : 24, current ssl sessions : 150 - All Virtual servers are ok | total_sessions=24;;;0; total_sessions_ssl=150;;;0; sessions_foo1=11;;;0; sessions_ssl_foo1=70;;;0; sessions_foo2=13;;;0; sessions_ssl_foo2=80;;;0; + Virtual server 'foo1' current sessions : 11, current ssl sessions : 70 + Virtual server 'foo2' current sessions : 13, current ssl sessions : 80 + +Example 3 +^^^^^^^^^ + +The model can also be used to check strings (not only counters). So we want to check the status of a virtualserver. + +.. code-block:: perl + + package my::module::name; + + use base qw(centreon::plugins::templates::counter); + + use strict; + use warnings; + + my $instance_mode; + + sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'vs', type => 1, cb_prefix_output => 'prefix_vs_output', message_multiple => 'All Virtual server status are ok' } + ]; + $self->{maps_counters}->{vs} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; + } + + sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + + if ($self->{result_values}->{status} =~ /problem/) { + $status = 'critical'; + } + return $status; + } + + sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("status is '%s'", $self->{result_values}->{status}); + return $msg; + } + + sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; + } + + sub prefix_vs_output { + my ($self, %options) = @_; + + return "Virtual server '" . $options{instance_value}->{display} . "' "; + } + + sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + # Sometimes, you'll need to have access of the current object in the callback + $instance_mode = $self; + } + + sub manage_selection { + my ($self, %options) = @_; + + my $oid_table_vs = '.1.2.3.10'; + my $mapping = { + vsName => { oid => '.1.2.3.10.1' }, + vsStatus => { oid => '.1.2.3.10.4' }, + }; + + $self->{vs} = {}; + my $result = $options{snmp}->get_table(oid => $oid_table_vs, + nothing_quit => 1); + foreach my $oid (keys %{$result->{ $oid_table_vs }}) { + next if ($oid !~ /^$mapping->{vsName}->{oid}\.(.*)$/; + my $instance = $1; + my $data = $options{snmp}->map_instance(mapping => $mapping, results => $result->{$oid_table_vs}, instance => $instance); + + $self->{vs}->{$instance} = { display => $data->{vsName}, + status => $data->{vsStatus} }; + } + } + + +The following example show 4 new attributes: + +* *closure_custom_calc*: should be used to have a simple name (without '_absolute' or '_per_second'). Or to do some more complex calculation. +* *closure_custom_output*: should be used to have a more complex output (An example: want to display the total, free and used value at the same time). +* *closure_custom_perfdata*: should be used to manage yourself the perfdata. +* *closure_custom_threshold_check*: should be used to manage yourself the threshold check. + + +-------------- +Class hardware +-------------- + +TODO \ No newline at end of file diff --git a/centreon-plugins/docs/en/user/guide.rst b/centreon-plugins/docs/en/user/guide.rst index edbcdadf1..a6bca69b0 100644 --- a/centreon-plugins/docs/en/user/guide.rst +++ b/centreon-plugins/docs/en/user/guide.rst @@ -140,7 +140,7 @@ Headers of the table mean: * Experimental: The check is still in development. +-------------+--------------------+----------------------------+--------------------------------------------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ -| | | Transport | Protocol | | | | +| | | Transport | Protocol | | | | | Category | Check +-------+----------+---------+--------+--------+-------+-------+----------+ Experimental | Comment | Perl dependencies | | | | SSH | TELNET | WSMAN | SNMP | HTTP | WMI | JMX | custom | | | | +=============+====================+=======+==========+=========+========+========+=======+=======+==========+==============+=============================================================+========================================================================+ @@ -188,7 +188,7 @@ Headers of the table mean: | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Varnish | * | | | | | | | * | | Use varnish commands. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ -| | VMWare | | | | | | | | * | | Need 'centreon_esxd' connector from Merethis. | | +| | VMWare | | | | | | | | * | | Need 'centreon-vmware' connector from Centreon. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Pfsense | | | | * | | | | | | | | +-------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ @@ -224,9 +224,11 @@ Headers of the table mean: +-------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Informix | | | | | | | | * | | | DBI, DBD::Informix | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ -| | MS SQL | | | | | | | | * | | | DBI, DBD::Sybase | +| | Firebird | | | | | | | | * | | | DBI, DBD::Firebird | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ -| Database | MySQL | | | | | | | | * | | | DBI, DBD::mysql | +| | MS SQL | | | | | | | | * | | | DBI, DBD::Sybase | +| Database +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | MySQL | | | | | | | | * | | | DBI, DBD::mysql | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Oracle | | | | | | | | * | | | DBI, DBD::oracle, DateTime | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ @@ -234,12 +236,16 @@ Headers of the table mean: +-------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | ATS Apc | | | | * | | | | | * | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ -| | PDU Apc | | | | * | | | | | * | | | +| | PDU Apc | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | PDU Eaton | | | | * | | | | | * | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | PDU Raritan | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Standard Printers | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | Hwgste | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Sensorip | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Sensormetrix Em01 | | | | | * | | | | | | LWP::UserAgent, URI, HTTP::Cookies | @@ -266,12 +272,16 @@ Headers of the table mean: | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Sun hardware | * | * | | * | | | | * | | Can monitor many sun hardware. | Net::Telnet, SNMP | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | UPS APC | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | UPS Mge | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | UPS Standard | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | UPS Powerware | | | | * | | | | | | | | +-------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | 3com | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Alcatel Omniswitch | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Arkoon | | | | * | | | | | | | | @@ -306,10 +316,14 @@ Headers of the table mean: | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | HP Procurve | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | HP Virtual Connect | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Juniper | | | | * | | | | | | Can monitor 'SSG', 'SA', 'SRX', 'MAG', 'EX', 'Ggsn'. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Netasq | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | Oneaccess | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Palo Alto | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Radware Alteon | | | | * | | | | | * | | | @@ -348,6 +362,8 @@ Headers of the table mean: | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Dell TL2000 | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | Dell ML6000 | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | EMC Celerra | * | | | | | | | * | | Use appliance commands. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | EMC Clariion | | | | | | | | * | | Need 'navisphere' command. | | @@ -356,6 +372,12 @@ Headers of the table mean: | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | EMC Recoverypoint | * | | | | | | | * | | Use appliance commands. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | EMC Vplex | | | | | | * | | | | Use the JSON API. | JSON, LWP::UserAgent, URI, HTTP::Cookies | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | EMC Xtremio | | | | | | * | | | | Use the JSON API. | JSON, LWP::UserAgent, URI, HTTP::Cookies | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | Fujitsu Eternus DX | * | | | | | | | * | | Use appliance commands. | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | HP 3par | * | | | | | | | * | | Use appliance commands. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | HP Lefthand | | | | * | | | | | | | | @@ -376,6 +398,8 @@ Headers of the table mean: | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Netapp | | | | * | | | | | | | DateTime | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ +| | Nimble | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Panzura | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+-------------------------------------------------------------+------------------------------------------------------------------------+ | | Qnap | | | | * | | | | | | | | @@ -485,6 +509,8 @@ How can i check the plugin version ? You can check the version of plugins and modes with option ``--version``: :: + $ perl centreon_plugins.pl --version + Global Version: 20160524 $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --version Plugin Version: 0.1 $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=storage --version @@ -497,6 +523,58 @@ For example, we want to execute the mode only if the version >= 2.x: $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=storage --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --mode-version='2.x' UNKNOWN: Not good version for plugin mode. Excepted at least: 2.x. Get: 1.0 +------------------------------------- +Can i have one standalone Perl file ? +------------------------------------- + +We have done some tests and it will cost around 4% more of execution time. We are going to create a standalone Linux SNMP plugin. + +Download the Perl module ``App::FatPacker`` on metacpan: +:: + + # tar zxvf App-FatPacker-0.010005.tar.gz + # cd App-FatPacker-0.010005 + # perl Makefile.PL && make && make install + +Create a directory to build it: +:: + + # mkdir -p build/plugin + # cd build + +Clone ``centreon-plugins``: +:: + + # git clone https://github.com/centreon/centreon-plugins.git + +``fatpack`` includes ``pm`` files under the directory ``lib``: +:: + + # mkdir plugin/lib && cd centreon-plugins + +Copy the common files for all plugins: +:: + + # cp -R --parent centreon/plugins/{misc,mode,options,output,perfdata,script,statefile,values}.pm centreon/plugins/templates/ centreon/plugins/alternative/ ../plugin/lib/ + # cp centreon_plugins.pl ../plugin + # sed -i 's/alternative_fatpacker = 0/alternative_fatpacker = 1/' ../plugin/lib/centreon/plugins/script.pm + +Copy files for Linux SNMP plugin: +:: + + # cp -R --parent centreon/plugins/{script_snmp,snmp}.pm os/linux/snmp/ snmp_standard/mode/{cpu,cpudetailed,diskio,diskusage,inodes,interfaces,loadaverage,listdiskspath,listinterfaces,liststorages,memory,processcount,storage,swap,ntp,tcpcon,uptime}.pm ../plugin/lib/ + +Build the standalone Perl file: +:: + + # cd ../plugin + # fatpack file centreon_plugins.pl > centreon_linux_snmp.pl + +The plugin works in the same way: +:: + + # perl centreon_linux_snmp.pl --plugin os::linux::snmp::plugin --mode=processcount --snmp-community public --snmp-version 2c --hostname=127.0.0.1 --process-name='' --process-status='' --process-args='' + *************** Troubleshooting *************** diff --git a/centreon-plugins/docs/fr/developer/guide.rst b/centreon-plugins/docs/fr/developer/guide.rst index f38b5bfaf..7f54ffaa5 100644 --- a/centreon-plugins/docs/fr/developer/guide.rst +++ b/centreon-plugins/docs/fr/developer/guide.rst @@ -6,7 +6,7 @@ Ce document présente les bonnes pratiques pour le développement de "centreon-p Comme tous les plugins sont écrits en Perl, "There's more than one way to do it". Afib de ne pas réinventer la roue, vous devriez d'abord regarder le dossier “example”. Vous aurez alors un aperçu de la méthodologie pour construire votre propre plugin ainsi que ses modes associés. -La dernière version est disponible sur le dépôt git suivant: http://git.centreon.com/centreon-plugins.git +La dernière version est disponible sur le dépôt git suivant: https://github.com/centreon/centreon-plugins.git **************** Démarrage rapide @@ -1468,40 +1468,25 @@ Ensuite, éditer le fichier **plugin.pm** et ajouter les lignes suivantes : .. code-block:: perl - ################################################################################ - # Copyright 2005-2015 MERETHIS - # Centreon is developped by : Julien Mathis and Romain Le Merlus under - # GPL Licence 2.0. # - # This program is free software; you can redistribute it and/or modify it under - # the terms of the GNU General Public License as published by the Free Software - # Foundation ; either version 2 of the License. + # Copyright 2016 Centreon (http://www.centreon.com/) # - # This program is distributed in the hope that it will be useful, but WITHOUT ANY - # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. See the GNU General Public License for more details. + # Centreon is a full-fledged industry-strength solution that meets + # the needs in IT infrastructure and application monitoring for + # service performance. # - # You should have received a copy of the GNU General Public License along with - # this program; if not, see . + # 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 # - # Linking this program statically or dynamically with other modules is making a - # combined work based on this program. Thus, the terms and conditions of the GNU - # General Public License cover the whole combination. + # http://www.apache.org/licenses/LICENSE-2.0 # - # As a special exception, the copyright holders of this program give MERETHIS - # permission to link this program with independent modules to produce an executable, - # regardless of the license terms of these independent modules, and to copy and - # distribute the resulting executable under terms of MERETHIS choice, provided that - # MERETHIS also meet, for each linked independent module, the terms and conditions - # of the license of that module. An independent module is a module which is not - # derived from this program. If you modify this program, you may extend this - # exception to your version of the program, but you are not obliged to do so. If you - # do not wish to do so, delete this exception statement from your version. + # 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. # - # For more information : contact@centreon.com - # Authors : your name - # - #################################################################################### # Chemin vers le plugin package apps::pfsense::snmp::plugin; @@ -1573,40 +1558,25 @@ Editer le fichier **memorydroppedpackets.pm** et ajouter les lignes suivantes : .. code-block:: perl - ################################################################################ - # Copyright 2005-2015 MERETHIS - # Centreon is developped by : Julien Mathis and Romain Le Merlus under - # GPL Licence 2.0. # - # This program is free software; you can redistribute it and/or modify it under - # the terms of the GNU General Public License as published by the Free Software - # Foundation ; either version 2 of the License. + # Copyright 2016 Centreon (http://www.centreon.com/) # - # This program is distributed in the hope that it will be useful, but WITHOUT ANY - # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. See the GNU General Public License for more details. + # Centreon is a full-fledged industry-strength solution that meets + # the needs in IT infrastructure and application monitoring for + # service performance. # - # You should have received a copy of the GNU General Public License along with - # this program; if not, see . + # 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 # - # Linking this program statically or dynamically with other modules is making a - # combined work based on this program. Thus, the terms and conditions of the GNU - # General Public License cover the whole combination. + # http://www.apache.org/licenses/LICENSE-2.0 # - # As a special exception, the copyright holders of this program give MERETHIS - # permission to link this program with independent modules to produce an executable, - # regardless of the license terms of these independent modules, and to copy and - # distribute the resulting executable under terms of MERETHIS choice, provided that - # MERETHIS also meet, for each linked independent module, the terms and conditions - # of the license of that module. An independent module is a module which is not - # derived from this program. If you modify this program, you may extend this - # exception to your version of the program, but you are not obliged to do so. If you - # do not wish to do so, delete this exception statement from your version. + # 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. # - # For more information : contact@centreon.com - # Authors : your name - # - #################################################################################### # Chemin vers le mode package apps::pfsense::snmp::mode::memorydroppedpackets; diff --git a/centreon-plugins/docs/fr/user/guide.rst b/centreon-plugins/docs/fr/user/guide.rst index 826096647..6bdc66be1 100644 --- a/centreon-plugins/docs/fr/user/guide.rst +++ b/centreon-plugins/docs/fr/user/guide.rst @@ -140,7 +140,7 @@ Les en-têtes du tableau signifient : * Expérimental : Le point de contrôle est en cours de développement. +----------------+--------------------+----------------------------+--------------------------------------------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ -| | | Transport | Protocole | | | | +| | | Transport | Protocole | | | | | Categorie | Contrôle +-------+----------+---------+--------+--------+-------+-------+----------+ Experimental | Comment | Dépendances Perl | | | | SSH | TELNET | WSMAN | SNMP | HTTP | WMI | JMX | custom | | | | +================+====================+=======+==========+=========+========+========+=======+=======+==========+==============+===============================================================+========================================================================+ @@ -188,7 +188,7 @@ Les en-têtes du tableau signifient : | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Varnish | * | | | | | | | * | | Utilise les commandes varnish. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ -| | VMWare | | | | | | | | * | | Requiert le connecteur 'centreon_esxd' de Merethis. | | +| | VMWare | | | | | | | | * | | Requiert le connecteur 'centreon-vmware' de Centreon. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Pfsense | | | | * | | | | | | | | +----------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ @@ -224,6 +224,8 @@ Les en-têtes du tableau signifient : +----------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Informix | | | | | | | | * | | | DBI, DBD::Informix | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | Firebird | | | | | | | | * | | | DBI, DBD::Firebird | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | MS SQL | | | | | | | | * | | | DBI, DBD::Sybase | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | Bases de | MySQL | | | | | | | | * | | | DBI, DBD::mysql | @@ -234,12 +236,16 @@ Les en-têtes du tableau signifient : +----------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | ATS Apc | | | | * | | | | | * | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ -| | PDU Apc | | | | * | | | | | * | | | +| | PDU Apc | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | PDU Eaton | | | | * | | | | | * | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | PDU Raritan | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Standard Printers | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | Hwgste | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Sensorip | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Sensormetrix Em01 | | | | | * | | | | | | LWP::UserAgent, URI, HTTP::Cookies | @@ -266,12 +272,16 @@ Les en-têtes du tableau signifient : | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Sun hardware | * | * | | * | | | | * | | Peut superviser plusieurs types de matériel Sun. | Net::Telnet, SNMP | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | UPS APC | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | UPS Mge | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | UPS Standard | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | UPS Powerware | | | | * | | | | | | | | +----------------+--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | 3com | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Alcatel Omniswitch | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Arkoon | | | | * | | | | | | | | @@ -306,12 +316,16 @@ Les en-têtes du tableau signifient : | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | HP Procurve | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | HP Virtual Connect | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Juniper | | | | * | | | | | | Peut superviser: 'SSG', 'SA', 'SRX', 'MAG', 'EX', 'Ggsn'. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Palo Alto | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Netasq | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | Oneaccess | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Radware Alteon | | | | * | | | | | * | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Redback | | | | * | | | | | | | | @@ -348,6 +362,8 @@ Les en-têtes du tableau signifient : | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Dell TL2000 | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | Dell ML6000 | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | EMC Celerra | * | | | | | | | * | | Utilise les commandes de l'appliance. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | EMC Clariion | | | | | | | | * | | Requiert la commande 'navisphere'. | | @@ -356,6 +372,12 @@ Les en-têtes du tableau signifient : | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | EMC Recoverypoint | * | | | | | | | * | | Utilise les commandes de l'appliance. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | EMC Vplex | | | | | | * | | | | Utilise l'API JSON. | JSON, LWP::UserAgent, URI, HTTP::Cookies | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | EMC Xtremio | | | | | | * | | | | Utilise l'API JSON. | JSON, LWP::UserAgent, URI, HTTP::Cookies | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | Fujitsu Eternus DX | * | | | | | | | * | | Utilise les commandes de l'appliance. | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | HP 3par | * | | | | | | | * | | Utilise les commandes de l'appliance. | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | HP Lefthand | | | | * | | | | | | | | @@ -376,6 +398,8 @@ Les en-têtes du tableau signifient : | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Netapp | | | | * | | | | | | | DateTime | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ +| | Nimble | | | | * | | | | | | | | +| +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Panzura | | | | * | | | | | | | | | +--------------------+-------+----------+---------+--------+--------+-------+-------+----------+--------------+---------------------------------------------------------------+------------------------------------------------------------------------+ | | Qnap | | | | * | | | | | | | | @@ -485,6 +509,8 @@ Comment puis-je vérifier la version du plugin ? Vous pouvez vérifier la version des plugins et des modes avec l'option ``--version`` : :: + $ perl centreon_plugins.pl --version + Global Version: 20160524 $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --version Plugin Version: 0.1 $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=storage --version @@ -497,6 +523,59 @@ Par exemple, nous voulons exécuter le mode seulement si sa version >= 2.x : $ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=storage --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --mode-version='2.x' UNKNOWN: Not good version for plugin mode. Excepted at least: 2.x. Get: 1.0 +-------------------------------------------- +Comment puis-je avoir un seul fichier Perl ? +-------------------------------------------- + +Nous avons réalisé des tests et le temps d'éxecution est augmenté d'environ 4%. Nous allons créer un fichier unique pour la sonde Linux SNMP. + +Télécharger le module Perl ``App::FatPacker`` sur metacpan: +:: + + # tar zxvf App-FatPacker-0.010005.tar.gz + # cd App-FatPacker-0.010005 + # perl Makefile.PL && make && make install + +Créer un répertoire de construction: +:: + + # mkdir -p build/plugin + # cd build + +Cloner ``centreon-plugins``: +:: + + # git clone https://github.com/centreon/centreon-plugins.git + +``fatpack`` inclut les fichiers ``pm`` présent dans le répertoire ``lib``: +:: + + # mkdir plugin/lib && cd centreon-plugins + +Copier les fichiers communs à l'ensemble des sondes: +:: + + # cp -R --parent centreon/plugins/{misc,mode,options,output,perfdata,script,statefile,values}.pm centreon/plugins/templates/ centreon/plugins/alternative/ ../plugin/lib/ + # cp centreon_plugins.pl ../plugin + # sed -i 's/alternative_fatpacker = 0/alternative_fatpacker = 1/' ../plugin/lib/centreon/plugins/script.pm + +Copier les fichiers pour la sonde Linux SNMP: +:: + + # cp -R --parent centreon/plugins/{script_snmp,snmp}.pm os/linux/snmp/ snmp_standard/mode/{cpu,cpudetailed,diskio,diskusage,inodes,interfaces,loadaverage,listdiskspath,listinterfaces,liststorages,memory,processcount,storage,swap,ntp,tcpcon,uptime}.pm ../plugin/lib/ + +Construire le fichier Perl unique: +:: + + # cd ../plugin + # fatpack file centreon_plugins.pl > centreon_linux_snmp.pl + +La sonde fonctionne de la même façon: +:: + + # perl centreon_linux_snmp.pl --plugin os::linux::snmp::plugin --mode=processcount --snmp-community public --snmp-version 2c --hostname=127.0.0.1 --process-name='' --process-status='' --process-args='' + + ********* Dépannage ********* diff --git a/centreon-plugins/example/custommode/simple.pm b/centreon-plugins/example/custommode/simple.pm index 134047f2a..b60dbf009 100644 --- a/centreon-plugins/example/custommode/simple.pm +++ b/centreon-plugins/example/custommode/simple.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/example/mode/getvalue.pm b/centreon-plugins/example/mode/getvalue.pm index 392650816..5f0781007 100644 --- a/centreon-plugins/example/mode/getvalue.pm +++ b/centreon-plugins/example/mode/getvalue.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -62,7 +62,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); diff --git a/centreon-plugins/example/mode/launchcmd.pm b/centreon-plugins/example/mode/launchcmd.pm index 82d788de5..2dfedc748 100644 --- a/centreon-plugins/example/mode/launchcmd.pm +++ b/centreon-plugins/example/mode/launchcmd.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/example/mode/testcustom.pm b/centreon-plugins/example/mode/testcustom.pm index cd2f7b243..678001c2d 100644 --- a/centreon-plugins/example/mode/testcustom.pm +++ b/centreon-plugins/example/mode/testcustom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/example/plugin_command.pm b/centreon-plugins/example/plugin_command.pm index 1a1f0b342..ac305263b 100644 --- a/centreon-plugins/example/plugin_command.pm +++ b/centreon-plugins/example/plugin_command.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/example/plugin_custom.pm b/centreon-plugins/example/plugin_custom.pm index ce06d65c7..8bc5bc4ba 100644 --- a/centreon-plugins/example/plugin_custom.pm +++ b/centreon-plugins/example/plugin_custom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/example/plugin_snmp.pm b/centreon-plugins/example/plugin_snmp.pm index 4e1e6fab0..d7636039e 100644 --- a/centreon-plugins/example/plugin_snmp.pm +++ b/centreon-plugins/example/plugin_snmp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/ats/apc/mode/entity.pm b/centreon-plugins/hardware/ats/apc/mode/entity.pm index 5ef5deb4e..d483d7d01 100644 --- a/centreon-plugins/hardware/ats/apc/mode/entity.pm +++ b/centreon-plugins/hardware/ats/apc/mode/entity.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_atsStatusSwitchStatus = '.1.3.6.1.4.1.318.1.1.8.5.1.10.0'; diff --git a/centreon-plugins/hardware/ats/apc/mode/input.pm b/centreon-plugins/hardware/ats/apc/mode/input.pm index a9928e892..45b6d9f64 100644 --- a/centreon-plugins/hardware/ats/apc/mode/input.pm +++ b/centreon-plugins/hardware/ats/apc/mode/input.pm @@ -1,199 +1,198 @@ -# -# 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::ats::apc::mode::input; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -my %oids = ( - '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.3' => { counter => 'voltage', no_present => 0 }, # in mVolt outletVoltage - '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.6' => { counter => 'current', no_present => 0 }, # in mA outletCurrent - '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.9' => { counter => 'power', no_present => 0 }, # in Watt outletWatts -); - -my $oid_inputs = '.1.3.6.1.4.1.318.1.1.8.5.3.3.1'; - -my $maps_counters = { - voltage => { thresholds => { - warning_voltage => { label => 'warning-voltage', exit_value => 'warning' }, - critical_voltage => { label => 'critical-voltage', exit_value => 'critical' }, - }, - output_msg => 'Voltage : %d V', - factor => 1, unit => 'V', - }, - current => { thresholds => { - warning_current => { label => 'warning-current', exit_value => 'warning' }, - critical_current => { label => 'critical-current', exit_value => 'critical' }, - }, - output_msg => 'Current : %d A', - factor => 1, unit => 'A', - }, - power => { thresholds => { - warning_power => { label => 'warning-power', exit_value => 'warning' }, - critical_power => { label => 'critical-power', exit_value => 'critical' }, - }, - output_msg => 'Power : %d W', - factor => 1, unit => 'W', - }, -}; - -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 (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - $options{options}->add_options(arguments => { - $maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name }, - }); - } - } - - $self->{counters_value} = {}; - $self->{instances_done} = {}; - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'."); - $self->{output}->option_exit(); - } - } - } -} - -sub build_values { - my ($self, %options) = @_; - my $counters_value = {}; - my $instance = undef; - - foreach my $oid (keys %oids) { - #if ($options{current} =~ /^$oid_inputs\.(.*)/) { - if ($options{current} =~ /^$oid\.(.*)/) { - $instance = $1; - #$instance =~ s/1\.1\.3\.//g; - last; - } - } - - # Skip already done - if (!defined($instance) || defined($self->{instances_done}->{$instance})) { - return 0; - } - - $self->{instances_done}->{$instance} = 1; - $self->{counters_value}->{$instance} = {}; - foreach my $oid (keys %oids) { - my $full_oid = $oid . '.' . $instance; - $self->{counters_value}->{$instance}->{$oids{$oid}->{counter}} = defined($options{result}->{$oid . '.' . $instance}) ? $options{result}->{$oid . '.' . $instance} : 0; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $result = $self->{snmp}->get_table(oid => $oid_inputs, nothing_quit => 1); - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { - $self->build_values(current => $key, result => $result); - } - - my $num = scalar(keys %{$self->{instances_done}}); - foreach my $instance (keys %{$self->{instances_done}}) { - my $instance_input = $instance; - $instance_input =~ s/(\d+)\.\d+\.\d+/#$1/g; - - my @exits; - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} != 0) { - push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_}*$maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); - } - } - } - - my $exit = $self->{output}->get_most_critical(status => [ @exits ]); - my $extra_label = ''; - $extra_label = '_' . $instance_input if ($num > 1); - - my $str_input = "Input '$instance_input' "; - my $str_append = ''; - foreach (keys %{$maps_counters}) { - next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} <= 0); - - $str_input .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}); - $str_append = ', '; - my ($warning, $critical); - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - $warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning'); - $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); - } - - $self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit}, - value => sprintf("%.2f", $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}), - warning => $warning, - critical => $critical); - } - $self->{output}->output_add(severity => $exit, - short_msg => $str_input); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check Outlet metrics (voltage, current and power). - -=over 8 - -=item B<--warning-*> - -Threshold warning. -Can be: 'voltage', 'current', 'power'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'voltage', 'current', 'power'. - -=back - -=cut +# +# Copyright 2016 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::ats::apc::mode::input; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my %oids = ( + '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.3' => { counter => 'voltage', no_present => 0 }, # in mVolt outletVoltage + '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.6' => { counter => 'current', no_present => 0 }, # in mA outletCurrent + '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.9' => { counter => 'power', no_present => 0 }, # in Watt outletWatts +); + +my $oid_inputs = '.1.3.6.1.4.1.318.1.1.8.5.3.3.1'; + +my $maps_counters = { + voltage => { thresholds => { + warning_voltage => { label => 'warning-voltage', exit_value => 'warning' }, + critical_voltage => { label => 'critical-voltage', exit_value => 'critical' }, + }, + output_msg => 'Voltage : %d V', + factor => 1, unit => 'V', + }, + current => { thresholds => { + warning_current => { label => 'warning-current', exit_value => 'warning' }, + critical_current => { label => 'critical-current', exit_value => 'critical' }, + }, + output_msg => 'Current : %d A', + factor => 1, unit => 'A', + }, + power => { thresholds => { + warning_power => { label => 'warning-power', exit_value => 'warning' }, + critical_power => { label => 'critical-power', exit_value => 'critical' }, + }, + output_msg => 'Power : %d W', + factor => 1, unit => 'W', + }, +}; + +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 (keys %{$maps_counters}) { + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + $options{options}->add_options(arguments => { + $maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name }, + }); + } + } + + $self->{counters_value} = {}; + $self->{instances_done} = {}; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach (keys %{$maps_counters}) { + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'."); + $self->{output}->option_exit(); + } + } + } +} + +sub build_values { + my ($self, %options) = @_; + my $counters_value = {}; + my $instance = undef; + + foreach my $oid (keys %oids) { + #if ($options{current} =~ /^$oid_inputs\.(.*)/) { + if ($options{current} =~ /^$oid\.(.*)/) { + $instance = $1; + #$instance =~ s/1\.1\.3\.//g; + last; + } + } + + # Skip already done + if (!defined($instance) || defined($self->{instances_done}->{$instance})) { + return 0; + } + + $self->{instances_done}->{$instance} = 1; + $self->{counters_value}->{$instance} = {}; + foreach my $oid (keys %oids) { + my $full_oid = $oid . '.' . $instance; + $self->{counters_value}->{$instance}->{$oids{$oid}->{counter}} = defined($options{result}->{$oid . '.' . $instance}) ? $options{result}->{$oid . '.' . $instance} : 0; + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + my $result = $self->{snmp}->get_table(oid => $oid_inputs, nothing_quit => 1); + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + $self->build_values(current => $key, result => $result); + } + + my $num = scalar(keys %{$self->{instances_done}}); + foreach my $instance (keys %{$self->{instances_done}}) { + my $instance_input = $instance; + $instance_input =~ s/(\d+)\.\d+\.\d+/#$1/g; + + my @exits; + foreach (keys %{$maps_counters}) { + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} != 0) { + push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_}*$maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); + } + } + } + + my $exit = $self->{output}->get_most_critical(status => [ @exits ]); + my $extra_label = ''; + $extra_label = '_' . $instance_input if ($num > 1); + + my $str_input = "Input '$instance_input' "; + my $str_append = ''; + foreach (keys %{$maps_counters}) { + next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} <= 0); + + $str_input .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}); + $str_append = ', '; + my ($warning, $critical); + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + $warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning'); + $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); + } + + $self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit}, + value => sprintf("%.2f", $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}), + warning => $warning, + critical => $critical); + } + $self->{output}->output_add(severity => $exit, + short_msg => $str_input); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check Outlet metrics (voltage, current and power). + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'voltage', 'current', 'power'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'voltage', 'current', 'power'. + +=back + +=cut diff --git a/centreon-plugins/hardware/ats/apc/mode/psu.pm b/centreon-plugins/hardware/ats/apc/mode/psu.pm index 8606dd635..e6806803f 100644 --- a/centreon-plugins/hardware/ats/apc/mode/psu.pm +++ b/centreon-plugins/hardware/ats/apc/mode/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -51,7 +51,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_atsStatus5VPowerSupply = '.1.3.6.1.4.1.318.1.1.8.5.1.5.0'; diff --git a/centreon-plugins/hardware/ats/apc/mode/source.pm b/centreon-plugins/hardware/ats/apc/mode/source.pm index 5b2ac0607..a621e8132 100644 --- a/centreon-plugins/hardware/ats/apc/mode/source.pm +++ b/centreon-plugins/hardware/ats/apc/mode/source.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -71,7 +71,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_atsStatusSelectedSource = '.1.3.6.1.4.1.318.1.1.8.5.1.2.0'; diff --git a/centreon-plugins/hardware/ats/apc/plugin.pm b/centreon-plugins/hardware/ats/apc/plugin.pm index 8aab31562..4666c964b 100644 --- a/centreon-plugins/hardware/ats/apc/plugin.pm +++ b/centreon-plugins/hardware/ats/apc/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/pdu/apc/snmp/mode/components/humidity.pm b/centreon-plugins/hardware/pdu/apc/snmp/mode/components/humidity.pm index 5783d8741..aa1225fa8 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/mode/components/humidity.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/mode/components/humidity.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/pdu/apc/snmp/mode/components/psu.pm b/centreon-plugins/hardware/pdu/apc/snmp/mode/components/psu.pm index c62359606..f2557482c 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/mode/components/psu.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/pdu/apc/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/pdu/apc/snmp/mode/components/temperature.pm index f7b1af648..9e7ed5b5a 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/pdu/apc/snmp/mode/hardware.pm b/centreon-plugins/hardware/pdu/apc/snmp/mode/hardware.pm index a494e6368..b4150cd3b 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/pdu/apc/snmp/mode/load.pm b/centreon-plugins/hardware/pdu/apc/snmp/mode/load.pm index 0818bf90a..828a23217 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/mode/load.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/mode/load.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -158,6 +158,7 @@ sub run { } if (defined($result->{rPDULoadStatusLoad}) && $result->{rPDULoadStatusLoad} =~ /[0-9]/) { + $result->{rPDULoadStatusLoad} /= 10; my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'load', instance => $instance, value => $result->{rPDULoadStatusLoad}); if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit2, diff --git a/centreon-plugins/hardware/pdu/apc/snmp/mode/outlet.pm b/centreon-plugins/hardware/pdu/apc/snmp/mode/outlet.pm index 30d000113..347aafcb7 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/mode/outlet.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/mode/outlet.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm b/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm index 33f4f6de7..c35141274 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/pdu/clever/snmp/mode/psusage.pm b/centreon-plugins/hardware/pdu/clever/snmp/mode/psusage.pm new file mode 100644 index 000000000..0302bc2b0 --- /dev/null +++ b/centreon-plugins/hardware/pdu/clever/snmp/mode/psusage.pm @@ -0,0 +1,112 @@ +# +# Copyright 2016 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::pdu::clever::snmp::mode::psusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'power', set => { + key_values => [ { name => 'power' } ], + output_template => 'Input power : %s W', + perfdatas => [ + { label => 'power', value => 'power_absolute', template => '%s', + unit => 'W', min => 0 }, + ], + } + }, + { label => 'current', set => { + key_values => [ { name => 'current' } ], + output_template => 'Current : %s A', + perfdatas => [ + { label => 'current', value => 'current_absolute', template => '%s', + unit => 'A', min => 0 }, + ], + } + }, + { label => 'voltage', set => { + key_values => [ { name => 'voltage' } ], + output_template => 'Voltage : %s V', + perfdatas => [ + { label => 'voltage', value => 'voltage_absolute', template => '%s', + unit => 'V', 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 => + { + }); + + return $self; +} + +my $oid_current = '.1.3.6.1.4.1.30966.1.2.1.6.0'; +my $oid_voltage = '.1.3.6.1.4.1.30966.1.2.1.9.0'; + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{snmp}->get_leef(oids => [ $oid_current, $oid_voltage ], + nothing_quit => 1); + $self->{global} = { current => $result->{$oid_current}, voltage => $result->{$oid_voltage}, + power => $result->{$oid_current} * $result->{$oid_voltage} }; +} + +1; + +__END__ + +=head1 MODE + +Check power source usage. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'current', 'power', 'voltage'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'current', 'power', 'voltage'. + +=back + +=cut diff --git a/centreon-plugins/hardware/pdu/clever/snmp/plugin.pm b/centreon-plugins/hardware/pdu/clever/snmp/plugin.pm new file mode 100644 index 000000000..853c2afc6 --- /dev/null +++ b/centreon-plugins/hardware/pdu/clever/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::pdu::clever::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} = '0.1'; + %{$self->{modes}} = ( + 'ps-usage' => 'hardware::pdu::clever::snmp::mode::psusage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check China Clever PDU in SNMP. + +=cut diff --git a/centreon-plugins/hardware/pdu/eaton/mode/group.pm b/centreon-plugins/hardware/pdu/eaton/mode/group.pm index 4ac8b54c3..0f0585cb6 100644 --- a/centreon-plugins/hardware/pdu/eaton/mode/group.pm +++ b/centreon-plugins/hardware/pdu/eaton/mode/group.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -120,7 +120,6 @@ sub build_values { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $result = $self->{snmp}->get_table(oid => $oid_groups, nothing_quit => 1); diff --git a/centreon-plugins/hardware/pdu/eaton/mode/outlet.pm b/centreon-plugins/hardware/pdu/eaton/mode/outlet.pm index 4c2073de8..db037e05d 100644 --- a/centreon-plugins/hardware/pdu/eaton/mode/outlet.pm +++ b/centreon-plugins/hardware/pdu/eaton/mode/outlet.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -122,7 +122,6 @@ sub build_values { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; #my $oid_outletName = '.1.3.6.1.4.1.534.6.6.7.6.1.1.3'; diff --git a/centreon-plugins/hardware/pdu/eaton/plugin.pm b/centreon-plugins/hardware/pdu/eaton/plugin.pm index e6eb62b61..992270903 100644 --- a/centreon-plugins/hardware/pdu/eaton/plugin.pm +++ b/centreon-plugins/hardware/pdu/eaton/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm new file mode 100644 index 000000000..1eeb20634 --- /dev/null +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm @@ -0,0 +1,206 @@ +# +# Copyright 2016 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::pdu::emerson::snmp::mode::globalstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg = "status is '" . $self->{result_values}->{status} . "'"; + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'pdu', type => 1, cb_prefix_output => 'prefix_pdu_output', message_multiple => 'All PDU status are ok' } + ]; + + $self->{maps_counters}->{pdu} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /normalWithWarning/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /normalWithAlarm|abnormalOperation/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_pdu_output { + my ($self, %options) = @_; + + return "PDU '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %bitmap_status = ( + 1 => 'normalOperation', + 2 => 'startUp', + 8 => 'normalWithWarning', + 16 => 'normalWithAlarm', + 32 => 'abnormalOperation', +); +my $mapping = { + lgpPduEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.10' }, + lgpPduEntrySysStatus => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.25' }, +}; +my $oid_lgpPduEntry = '.1.3.6.1.4.1.476.1.42.3.8.20.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{pdu} = {}; + $self->{results} = $options{snmp}->get_table(oid => $oid_lgpPduEntry, + start => $mapping->{lgpPduEntryUsrLabel}->{oid}, + end => $mapping->{lgpPduEntrySysStatus}->{oid}, + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}}) { + next if ($oid !~ /^$mapping->{lgpPduEntrySysStatus}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + my $name = defined($result->{lgpPduEntryUsrLabel}) && $result->{lgpPduEntryUsrLabel} ne '' ? + $result->{lgpPduEntryUsrLabel} : $instance; + my $status = 'unknown'; + foreach (keys %bitmap_status) { + if ((int($result->{lgpPduEntrySysStatus}) & $_)) { + $status = $bitmap_status{$_}; + last; + } + } + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{pdu}->{$instance} = { display => $name, + status => $status }; + } + + if (scalar(keys %{$self->{pdu}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "Cannot found pdu."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check global status. + +=over 8 + +=item B<--filter-name> + +Filter PDU name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /normalWithWarning/i'). +Can used special variables like: %{status}, %{display}. + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /normalWithAlarm|abnormalOperation/i'). +Can used special variables like: %{status}, %{display} + +=back + +=cut diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm new file mode 100644 index 000000000..3e581086d --- /dev/null +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm @@ -0,0 +1,167 @@ +# +# Copyright 2016 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::pdu::emerson::snmp::mode::psusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ps', type => 1, cb_prefix_output => 'prefix_ps_output', message_multiple => 'All power sources are ok' }, + ]; + + $self->{maps_counters}->{ps} = [ + { label => 'power', set => { + key_values => [ { name => 'PwrTotal' }, { name => 'display' } ], + output_template => 'total input power : %s W', output_error_template => "total input power : %s", + perfdatas => [ + { label => 'power', value => 'PwrTotal_absolute', template => '%s', + unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'energy', set => { + key_values => [ { name => 'EnergyAccum', diff => 1 }, { name => 'display' } ], + output_template => 'Total energy : %.3f kWh', output_error_template => "Total energy : %s", + perfdatas => [ + { label => 'energy', value => 'EnergyAccum_absolute', template => '%.3f', + unit => 'kWh', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'current-neutral', set => { + key_values => [ { name => 'EcNeutral' }, { name => 'display' } ], + output_template => 'Current neutral : %s Amp AC RMS', output_error_template => "Current neutral : %s", + perfdatas => [ + { label => 'current_neutral', value => 'EcNeutral_absolute', template => '%s', + unit => 'AmpAcRMS', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_ps_output { + my ($self, %options) = @_; + + return "Power source '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +my $mapping = { + lgpPduPsEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.15' }, + lgpPduPsEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.50' }, # 0.1 Kilowatt-Hour + lgpPduPsEntryPwrTotal => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.65' }, # Watt + lgpPduPsEntryEcNeutral => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.70' }, # 0.1 Amp-AC-RMS +}; +my $oid_lgpPduEntryUsrLabel = '.1.3.6.1.4.1.476.1.42.3.8.20.1.10'; +my $oid_lgpPduPsEntry = '.1.3.6.1.4.1.476.1.42.3.8.30.20.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "pdu_emerson_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + $self->{ps} = {}; + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_lgpPduEntryUsrLabel }, + { oid => $oid_lgpPduPsEntry }, + ], + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}->{$oid_lgpPduPsEntry}}) { + next if ($oid !~ /^$mapping->{lgpPduPsEntryPwrTotal}->{oid}\.(\d+)\.(\d+)/); + my ($pdu_index, $ps_index) = ($1, $2); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_lgpPduPsEntry}, instance => $pdu_index . '.' . $ps_index); + my $pdu_name = defined($self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index}) && $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} ne '' ? + $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} : $pdu_index; + my $ps_name = defined($result->{lgpPduPsEntrySysAssignLabel}) && $result->{lgpPduPsEntrySysAssignLabel} ne '' ? + $result->{lgpPduPsEntrySysAssignLabel} : $ps_index; + my $name = $pdu_name . '/' . $ps_name; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{ps}->{$pdu_index . '.' . $ps_index} = { display => $name, + EnergyAccum => $result->{lgpPduPsEntryEnergyAccum} * 0.1, + PwrTotal => $result->{lgpPduPsEntryPwrTotal}, + EcNeutral => $result->{lgpPduPsEntryEcNeutral} * 0.1}; + } + + if (scalar(keys %{$self->{ps}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "Cannot found power sources."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check power source usage. + +=over 8 + +=item B<--filter-name> + +Filter power source name (can be a regexp). + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(power|energy)$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'power', 'energy', 'current-neutral'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'power', 'energy', 'current-neutral'. + +=back + +=cut diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/rbusage.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/rbusage.pm new file mode 100644 index 000000000..2de7a63d7 --- /dev/null +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/rbusage.pm @@ -0,0 +1,191 @@ +# +# Copyright 2016 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::pdu::emerson::snmp::mode::rbusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'rb', type => 1, cb_prefix_output => 'prefix_rb_output', message_multiple => 'All receptacle branches are ok' }, + ]; + + $self->{maps_counters}->{rb} = [ + { label => 'energy', set => { + key_values => [ { name => 'EnergyAccum', diff => 1 }, { name => 'display' } ], + output_template => 'total energy : %.3f kWh', output_error_template => "total energy : %s", + perfdatas => [ + { label => 'energy', value => 'EnergyAccum_absolute', template => '%.3f', + unit => 'kWh', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'power-real-neutral', set => { + key_values => [ { name => 'Pwr' }, { name => 'display' } ], + output_template => 'line-to-neutral real power : %s W', output_error_template => "line-to-neutral real power : %s", + perfdatas => [ + { label => 'power_real_neutral', value => 'Pwr_absolute', template => '%s', + unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'power-apparent-neutral', set => { + key_values => [ { name => 'Ap' }, { name => 'display' } ], + output_template => 'line-to-neutral apparent power : %s VA', output_error_template => "line-to-neutral apparent power : %s", + perfdatas => [ + { label => 'power_apparent_neutral', value => 'Ap_absolute', template => '%s', + unit => 'VA', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'current-neutral', set => { + key_values => [ { name => 'EcHundredths' }, { name => 'display' } ], + output_template => 'line-to-neutral current : %s Amp AC RMS', output_error_template => "line-to-neutral current : %s", + perfdatas => [ + { label => 'current_neutral', value => 'EcHundredths_absolute', template => '%s', + unit => 'AmpAcRMS', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'potential-neutral', set => { + key_values => [ { name => 'EpLNTenths' }, { name => 'display' } ], + output_template => 'line-to-neutral potential : %s VoltRMS', output_error_template => "line-to-neutral potential : %s", + perfdatas => [ + { label => 'potential_neutral', value => 'EpLNTenths_absolute', template => '%s', + unit => 'VoltRMS', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_rb_output { + my ($self, %options) = @_; + + return "Receptacle branch '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +my $mapping = { + lgpPduRbEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.8' }, + lgpPduRbEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.85' }, # 0.1 Kilowatt-Hour + lgpPduRbEntryEpLNTenths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.100' }, # 0.1 VoltRMS + lgpPduRbEntryPwr => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.115' }, # Watt + lgpPduRbEntryAp => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.120' }, # VoltAmp + lgpPduRbEntryEcHundredths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.130' }, # 0.01 Amp-AC-RMS +}; +my $oid_lgpPduEntryUsrLabel = '.1.3.6.1.4.1.476.1.42.3.8.20.1.10'; +my $oid_lgpPduRbEntry = '.1.3.6.1.4.1.476.1.42.3.8.40.20.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "pdu_emerson_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + $self->{rb} = {}; + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_lgpPduEntryUsrLabel }, + { oid => $oid_lgpPduRbEntry }, + ], + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}->{$oid_lgpPduRbEntry}}) { + next if ($oid !~ /^$mapping->{lgpPduRbEntryPwr}->{oid}\.(\d+)\.(\d+)/); + my ($pdu_index, $rb_index) = ($1, $2); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_lgpPduRbEntry}, instance => $pdu_index . '.' . $rb_index); + my $pdu_name = defined($self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index}) && $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} ne '' ? + $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} : $pdu_index; + my $rb_name = defined($result->{lgpPduRbEntryUsrLabel}) && $result->{lgpPduRbEntryUsrLabel} ne '' ? + $result->{lgpPduRbEntryUsrLabel} : $rb_index; + my $name = $pdu_name . '/' . $rb_name; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{rb}->{$pdu_index . '.' . $rb_index} = { display => $name, + EnergyAccum => $result->{lgpPduRbEntryEnergyAccum} * 0.1, + EpLNTenths => $result->{lgpPduRbEntryEpLNTenths} * 0.1, + Pwr => $result->{lgpPduRbEntryPwr}, + Ap => $result->{lgpPduRbEntryAp}, + EcHundredths => $result->{lgpPduRbEntryEcHundredths} * 0.01}; + } + + if (scalar(keys %{$self->{rb}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "Cannot found receptacle branches."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check receptacle branch usage. + +=over 8 + +=item B<--filter-name> + +Filter receptacle branch name (can be a regexp). + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(energy)$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'energy', 'power-real-neutral', 'power-apparent-neutral', +'current-neutral', 'potential-neutral'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'energy', 'power-real-neutral', 'power-apparent-neutral', +'current-neutral', 'potential-neutral'. + +=back + +=cut diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm b/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm new file mode 100644 index 000000000..f137dae18 --- /dev/null +++ b/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::pdu::emerson::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}} = ( + 'global-status' => 'hardware::pdu::emerson::snmp::mode::globalstatus', + 'ps-usage' => 'hardware::pdu::emerson::snmp::mode::psusage', + 'rb-usage' => 'hardware::pdu::emerson::snmp::mode::rbusage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Emerson Liebert PDU in SNMP. + +=cut diff --git a/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/resources.pm b/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/resources.pm index 6f545d14d..1e0043db7 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/resources.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/resources.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -191,7 +191,7 @@ $thresholds = { ], onoff => [ ['unavailable', 'UNKNOWN'], - ['ok', 'OK'], + ['on', 'OK'], ['off', 'OK'], ], contact => [ diff --git a/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/sensor.pm b/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/sensor.pm index 8b5a1d7de..c4aa2c28b 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/sensor.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/mode/components/sensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -25,9 +25,9 @@ use warnings; use hardware::pdu::raritan::snmp::mode::components::resources qw($mapping %raritan_type %map_type); sub load { - my (%options) = @_; + my ($self, %options) = @_; - push @{$options{request}}, { oid => $mapping->{$options{type} . '_label'}->{Label}->{oid} }, + push @{$self->{request}}, { oid => $mapping->{$options{type} . '_label'}->{Label}->{oid} }, { oid => $mapping->{$options{type}}->{Unit}->{oid} }, { oid => $mapping->{$options{type}}->{Decimal}->{oid} }, { oid => $mapping->{$options{type}}->{EnabledThresholds}->{oid} }, diff --git a/centreon-plugins/hardware/pdu/raritan/snmp/mode/inletsensors.pm b/centreon-plugins/hardware/pdu/raritan/snmp/mode/inletsensors.pm index 7faf3a50b..b6dae4dcb 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/mode/inletsensors.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/mode/inletsensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,210 +20,73 @@ package hardware::pdu::raritan::snmp::mode::inletsensors; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type); +sub set_system { + my ($self, %options) = @_; + + $self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = $thresholds; + + $self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components'; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1); +} + +sub check_numeric_section_option { + my ($self, %options) = @_; + + if (!defined($raritan_type{$options{section}})) { + $self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'."); + $self->{output}->option_exit(); + } +} + +sub load_components { + my ($self, %options) = @_; + + my $mod_name = $self->{components_path} . "::sensor"; + 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->($self, type => 'inlet'); + + $self->{loaded} = 1; +} + +sub exec_components { + my ($self, %options) = @_; + + my $mod_name = $self->{components_path} . "::sensor"; + my $func = $mod_name->can('check'); + $func->($self, component => $self->{option_results}->{component}, type => 'inlet'); +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "filter:s@" => { name => 'filter' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $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->{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 ($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 }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if (!defined($raritan_type{$section})) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - - my $mod_name = "hardware::pdu::raritan::snmp::mode::components::sensor"; - 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->(type => 'inlet', request => $snmp_request); - - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request, return_type => 1); - - $func = $mod_name->can('check'); - $func->($self, component => $self->{option_results}->{component}, type => 'inlet'); - - 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 sensors 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 sensors are checked.'); - } - - $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_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ diff --git a/centreon-plugins/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm b/centreon-plugins/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm index 666aeb569..f516d18df 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,210 +20,73 @@ package hardware::pdu::raritan::snmp::mode::ocprotsensors; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type); +sub set_system { + my ($self, %options) = @_; + + $self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = $thresholds; + + $self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components'; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1); +} + +sub check_numeric_section_option { + my ($self, %options) = @_; + + if (!defined($raritan_type{$options{section}})) { + $self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'."); + $self->{output}->option_exit(); + } +} + +sub load_components { + my ($self, %options) = @_; + + my $mod_name = $self->{components_path} . "::sensor"; + 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->($self, type => 'ocprot'); + + $self->{loaded} = 1; +} + +sub exec_components { + my ($self, %options) = @_; + + my $mod_name = $self->{components_path} . "::sensor"; + my $func = $mod_name->can('check'); + $func->($self, component => $self->{option_results}->{component}, type => 'ocprot'); +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "filter:s@" => { name => 'filter' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $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->{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 ($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 }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if (!defined($raritan_type{$section})) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - - my $mod_name = "hardware::pdu::raritan::snmp::mode::components::sensor"; - 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->(type => 'ocprot', request => $snmp_request); - - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request, return_type => 1); - - $func = $mod_name->can('check'); - $func->($self, component => $self->{option_results}->{component}, type => 'ocprot'); - - 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 sensors 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 sensors are checked.'); - } - - $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_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ diff --git a/centreon-plugins/hardware/pdu/raritan/snmp/mode/outletsensors.pm b/centreon-plugins/hardware/pdu/raritan/snmp/mode/outletsensors.pm index b6586f5a6..aee7b4456 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/mode/outletsensors.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/mode/outletsensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,12 +20,60 @@ package hardware::pdu::raritan::snmp::mode::outletsensors; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type); +sub set_system { + my ($self, %options) = @_; + + $self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = $thresholds; + + $self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components'; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1); +} + +sub check_numeric_section_option { + my ($self, %options) = @_; + + if (!defined($raritan_type{$options{section}})) { + $self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'."); + $self->{output}->option_exit(); + } +} + +sub load_components { + my ($self, %options) = @_; + + my $mod_name = $self->{components_path} . "::sensor"; + 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->($self, type => 'outlet'); + + $self->{loaded} = 1; +} + +sub exec_components { + my ($self, %options) = @_; + + my $mod_name = $self->{components_path} . "::sensor"; + my $func = $mod_name->can('check'); + $func->($self, component => $self->{option_results}->{component}, type => 'outlet'); +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -33,197 +81,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "filter:s@" => { name => 'filter' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $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->{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 ($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 }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if (!defined($raritan_type{$section})) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - - my $mod_name = "hardware::pdu::raritan::snmp::mode::components::sensor"; - 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->(type => 'outlet', request => $snmp_request); - - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request, return_type => 1); - - $func = $mod_name->can('check'); - $func->($self, component => $self->{option_results}->{component}, type => 'outlet'); - - 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 sensors 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 sensors are checked.'); - } - - $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_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ diff --git a/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm b/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm index cf9db830a..a81bb6aca 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( @@ -46,6 +45,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Rarian PDU in SNMP. +Check Raritan PDU in SNMP. =cut diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm index c91b505e7..a74b78778 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -54,7 +54,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{output}->output_add(severity => 'OK', diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markerimpression.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markerimpression.pm index 3a65646b2..9ed7b58ad 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markerimpression.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markerimpression.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -63,7 +63,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm index bae428ad9..a8ce3512b 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -69,7 +69,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_prtMarkerSuppliesColorantIndex = '.1.3.6.1.2.1.43.11.1.1.3'; @@ -104,8 +103,8 @@ sub run { my $current_value = $result2->{$oid_prtMarkerSuppliesLevel . '.' . $instance}; my $max_value = $result2->{$oid_prtMarkerSuppliesMaxCapacity . '.' . $instance}; - if (!defined($unit_managed{$unit})) { - $self->{output}->output_add(long_msg => "Skipping marker supply '$descr': unit not managed."); + if (!defined($unit) || !defined($unit_managed{$unit})) { + $self->{output}->output_add(long_msg => "Skipping marker supply '$descr': no unit or not managed."); next; } if ($current_value == -1) { diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm index 66ece27b0..63cb45730 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -62,7 +62,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_prtInputCurrentLevel = '.1.3.6.1.2.1.43.8.2.1.10'; diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/plugin.pm b/centreon-plugins/hardware/printers/standard/rfc3805/plugin.pm index e33fcd0d2..56db8e2c8 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/plugin.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/humidity.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/humidity.pm new file mode 100644 index 000000000..27d0376b6 --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/humidity.pm @@ -0,0 +1,106 @@ +# +# Copyright 2016 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::sensors::akcp::snmp::mode::components::humidity; + +use strict; +use warnings; +use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default1_status %map_online); + +my $mapping = { + hhmsSensorArrayHumidityDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.1' }, + hhmsSensorArrayHumidityPercent => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.3' }, + hhmsSensorArrayHumidityStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.4', map => \%map_default1_status }, + hhmsSensorArrayHumidityOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.5', map => \%map_online }, + hhmsSensorArrayHumidityHighWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.7' }, + hhmsSensorArrayHumidityHighCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.8' }, + hhmsSensorArrayHumidityLowWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.9' }, + hhmsSensorArrayHumidityLowCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.10' }, +}; +my $oid_hhmsSensorArrayHumidityEntry = '.1.3.6.1.4.1.3854.1.2.2.1.17.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_hhmsSensorArrayHumidityEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking humidities"); + $self->{components}->{humidity} = {name => 'humidities', total => 0, skip => 0}; + return if ($self->check_filter(section => 'humidity')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hhmsSensorArrayHumidityEntry}})) { + next if ($oid !~ /^$mapping->{hhmsSensorArrayHumidityOnline}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hhmsSensorArrayHumidityEntry}, instance => $instance); + + next if ($self->check_filter(section => 'humidity', instance => $instance)); + if ($result->{hhmsSensorArrayHumidityOnline} eq 'offline') { + $self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{hhmsSensorArrayHumidityDescription})); + next; + } + $self->{components}->{humidity}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]", + $result->{hhmsSensorArrayHumidityDescription}, $result->{hhmsSensorArrayHumidityStatus}, $instance, + $result->{hhmsSensorArrayHumidityPercent})); + + my $exit = $self->get_severity(label => 'default1', section => 'humidity', value => $result->{hhmsSensorArrayHumidityStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Humdity '%s' status is '%s'", $result->{hhmsSensorArrayHumidityDescription}, $result->{hhmsSensorArrayHumidityStatus})); + next; + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{hhmsSensorArrayHumidityPercent}); + if ($checked == 0) { + $result->{hhmsSensorArrayHumidityLowWarning} = (defined($result->{hhmsSensorArrayHumidityLowWarning}) && $result->{hhmsSensorArrayHumidityLowWarning} =~ /[0-9]/) ? + $result->{hhmsSensorArrayHumidityLowWarning} : ''; + $result->{hhmsSensorArrayHumidityLowCritical} = (defined($result->{hhmsSensorArrayHumidityLowCritical}) && $result->{hhmsSensorArrayHumidityLowCritical} =~ /[0-9]/) ? + $result->{hhmsSensorArrayHumidityLowCritical} : ''; + $result->{hhmsSensorArrayHumidityHighWarning} = (defined($result->{hhmsSensorArrayHumidityHighWarning}) && $result->{hhmsSensorArrayHumidityHighWarning} =~ /[0-9]/) ? + $result->{hhmsSensorArrayHumidityHighWarning} : ''; + $result->{hhmsSensorArrayHumidityHighCritical} = (defined($result->{hhmsSensorArrayHumidityHighCritical}) && $result->{hhmsSensorArrayHumidityHighCritical} =~ /[0-9]/) ? + $result->{hhmsSensorArrayHumidityHighCritical} : ''; + my $warn_th = $result->{hhmsSensorArrayHumidityLowWarning} . ':' . $result->{hhmsSensorArrayHumidityHighWarning}; + my $crit_th = $result->{hhmsSensorArrayHumidityLowCritical} . ':' . $result->{hhmsSensorArrayHumidityHighCritical}; + $self->{perfdata}->threshold_validate(label => 'warning-humidity-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-humidity-instance-' . $instance, value => $crit_th); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-humidity-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-humidity-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Humdity '%s' is %s %%", $result->{hhmsSensorArrayHumidityDescription}, $result->{hhmsSensorArrayHumidityPercent})); + } + $self->{output}->perfdata_add(label => 'humidity_' . $result->{hhmsSensorArrayHumidityDescription}, unit => '%', + value => $result->{hhmsSensorArrayHumidityPercent}, + warning => $warn, + critical => $crit, + min => 0, max => 100); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/resources.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/resources.pm new file mode 100644 index 000000000..413abeb9e --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/resources.pm @@ -0,0 +1,62 @@ +# +# Copyright 2016 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::sensors::akcp::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %map_default1_status; +our %map_default2_status; +our %map_online; +our %map_degree_type; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(%map_default1_status %map_default2_status %map_online %map_degree_type); + +%map_default1_status = ( + 1 => 'noStatus', + 2 => 'normal', + 3 => 'highWarning', + 4 => 'highCritical', + 5 => 'lowWarning', + 6 => 'lowCritical', + 7 => 'sensorError', +); + +%map_default2_status = ( + 1 => 'noStatus', + 2 => 'normal', + 4 => 'critical', + 7 => 'sensorError', +); + +%map_online = ( + 1 => 'online', + 2 => 'offline', +); + +%map_degree_type = ( + 0 => 'F', + 1 => 'C', +); + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/serial.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/serial.pm new file mode 100644 index 000000000..0b524dde0 --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/serial.pm @@ -0,0 +1,72 @@ +# +# Copyright 2016 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::sensors::akcp::snmp::mode::components::serial; + +use strict; +use warnings; +use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default2_status %map_online); + +my $mapping = { + hhmsSensorArraySerialDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.19.1.1' }, + hhmsSensorArraySerialStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.19.1.3', map => \%map_default2_status }, + hhmsSensorArraySerialOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.19.1.4', map => \%map_online }, +}; +my $oid_hhmsSensorArraySwitchEntry = '.1.3.6.1.4.1.3854.1.2.2.1.18.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_hhmsSensorArraySwitchEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking serials"); + $self->{components}->{serial} = {name => 'serials', total => 0, skip => 0}; + return if ($self->check_filter(section => 'serial')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hhmsSensorArraySwitchEntry}})) { + next if ($oid !~ /^$mapping->{hhmsSensorArraySerialOnline}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hhmsSensorArraySwitchEntry}, instance => $instance); + + next if ($self->check_filter(section => 'serial', instance => $instance)); + if ($result->{hhmsSensorArraySerialOnline} eq 'offline') { + $self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{hhmsSensorArraySerialDescription})); + next; + } + $self->{components}->{serial}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("serial '%s' status is '%s' [instance = %s]", + $result->{hhmsSensorArraySerialDescription}, $result->{hhmsSensorArraySerialStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default2', section => 'serial', value => $result->{hhmsSensorArraySerialStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Serial '%s' status is '%s'", $result->{hhmsSensorArraySerialDescription}, $result->{hhmsSensorArraySerialStatus})); + next; + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/switch.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/switch.pm new file mode 100644 index 000000000..d3b3f93dd --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/switch.pm @@ -0,0 +1,72 @@ +# +# Copyright 2016 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::sensors::akcp::snmp::mode::components::switch; + +use strict; +use warnings; +use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default2_status %map_online); + +my $mapping = { + hhmsSensorArraySwitchDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.18.1.1' }, + hhmsSensorArraySwitchStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.18.1.3', map => \%map_default2_status }, + hhmsSensorArraySwitchOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.18.1.4', map => \%map_online }, +}; +my $oid_hhmsSensorArraySwitchEntry = '.1.3.6.1.4.1.3854.1.2.2.1.18.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_hhmsSensorArraySwitchEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking switches"); + $self->{components}->{switch} = {name => 'switches', total => 0, skip => 0}; + return if ($self->check_filter(section => 'switch')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hhmsSensorArraySwitchEntry}})) { + next if ($oid !~ /^$mapping->{hhmsSensorArraySwitchOnline}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hhmsSensorArraySwitchEntry}, instance => $instance); + + next if ($self->check_filter(section => 'switch', instance => $instance)); + if ($result->{hhmsSensorArraySwitchOnline} eq 'offline') { + $self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{hhmsSensorArraySwitchDescription})); + next; + } + $self->{components}->{switch}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("switch '%s' status is '%s' [instance = %s]", + $result->{hhmsSensorArraySwitchDescription}, $result->{hhmsSensorArraySwitchStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default2', section => 'switch', value => $result->{hhmsSensorArraySwitchStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Switch '%s' status is '%s'", $result->{hhmsSensorArraySwitchDescription}, $result->{hhmsSensorArraySwitchStatus})); + next; + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..20a4894ba --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/components/temperature.pm @@ -0,0 +1,107 @@ +# +# Copyright 2016 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::sensors::akcp::snmp::mode::components::temperature; + +use strict; +use warnings; +use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default1_status %map_online %map_degree_type); + +my $mapping = { + hhmsSensorArrayTempDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.1' }, + hhmsSensorArrayTempDegree => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.3' }, + hhmsSensorArrayTempStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.4', map => \%map_default1_status }, + hhmsSensorArrayTempOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.5', map => \%map_online }, + hhmsSensorArrayTempHighWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.7' }, + hhmsSensorArrayTempHighCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.8' }, + hhmsSensorArrayTempLowWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.9' }, + hhmsSensorArrayTempLowCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.10' }, + hhmsSensorArrayTempDegreeType => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.12', map => \%map_degree_type }, +}; +my $oid_hhmsSensorArrayTempEntry = '.1.3.6.1.4.1.3854.1.2.2.1.16.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_hhmsSensorArrayTempEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hhmsSensorArrayTempEntry}})) { + next if ($oid !~ /^$mapping->{hhmsSensorArrayTempOnline}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hhmsSensorArrayTempEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + if ($result->{hhmsSensorArrayTempOnline} eq 'offline') { + $self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{hhmsSensorArrayTempDescription})); + next; + } + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]", + $result->{hhmsSensorArrayTempDescription}, $result->{hhmsSensorArrayTempStatus}, $instance, + $result->{hhmsSensorArrayTempDegree})); + + my $exit = $self->get_severity(label => 'default1', section => 'temperature', value => $result->{hhmsSensorArrayTempStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $result->{hhmsSensorArrayTempDescription}, $result->{hhmsSensorArrayTempStatus})); + next; + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{hhmsSensorArrayTempDegree}); + if ($checked == 0) { + $result->{hhmsSensorArrayTempLowWarning} = (defined($result->{hhmsSensorArrayTempLowWarning}) && $result->{hhmsSensorArrayTempLowWarning} =~ /[0-9]/) ? + $result->{hhmsSensorArrayTempLowWarning} : ''; + $result->{hhmsSensorArrayTempLowCritical} = (defined($result->{hhmsSensorArrayTempLowCritical}) && $result->{hhmsSensorArrayTempLowCritical} =~ /[0-9]/) ? + $result->{hhmsSensorArrayTempLowCritical} : ''; + $result->{hhmsSensorArrayTempHighWarning} = (defined($result->{hhmsSensorArrayTempHighWarning}) && $result->{hhmsSensorArrayTempHighWarning} =~ /[0-9]/) ? + $result->{hhmsSensorArrayTempHighWarning} : ''; + $result->{hhmsSensorArrayTempHighCritical} = (defined($result->{hhmsSensorArrayTempHighCritical}) && $result->{hhmsSensorArrayTempHighCritical} =~ /[0-9]/) ? + $result->{hhmsSensorArrayTempHighCritical} : ''; + my $warn_th = $result->{hhmsSensorArrayTempLowWarning} . ':' . $result->{hhmsSensorArrayTempHighWarning}; + my $crit_th = $result->{hhmsSensorArrayTempLowCritical} . ':' . $result->{hhmsSensorArrayTempHighCritical}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Temperature '%s' is %s %s", $result->{hhmsSensorArrayTempDescription}, $result->{hhmsSensorArrayTempDegree}, $result->{hhmsSensorArrayTempDegreeType})); + } + $self->{output}->perfdata_add(label => 'temperature_' . $result->{hhmsSensorArrayTempDescription}, unit => $result->{hhmsSensorArrayTempDegreeType}, + value => $result->{hhmsSensorArrayTempDegree}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm new file mode 100644 index 000000000..02c20526e --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm @@ -0,0 +1,121 @@ +# +# Copyright 2016 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::sensors::akcp::snmp::mode::sensors; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|humidity|switch|serial)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default1 => [ + ['noStatus', 'OK'], + ['normal', 'OK'], + ['highWarning', 'WARNING'], + ['highCritical', 'CRITICAL'], + ['lowWarning', 'WARNING'], + ['lowCritical', 'CRITICAL'], + ['sensorError', 'CRITICAL'], + ], + default2 => [ + ['noStatus', 'OK'], + ['normal', 'OK'], + ['critical', 'CRITICAL'], + ['sensorError', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::sensors::akcp::snmp::mode::components'; + $self->{components_module} = ['temperature', 'humidity', 'switch', 'serial']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check sensors. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'temperature', 'humidity', 'switch', 'serial'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,101 + +=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='psu,CRITICAL,^(?!(presentOK)$)' + +=item B<--warning> + +Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold) +Example: --warning='temperature,1,30' + +=item B<--critical> + +Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold) +Example: --warning='temperature,1,50' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/plugin.pm b/centreon-plugins/hardware/sensors/akcp/snmp/plugin.pm new file mode 100644 index 000000000..ca4f3e967 --- /dev/null +++ b/centreon-plugins/hardware/sensors/akcp/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::sensors::akcp::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}} = ( + 'sensors' => 'hardware::sensors::akcp::snmp::mode::sensors', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check AKCP sensors in SNMP. + +=cut diff --git a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm index 305621907..87a05108c 100644 --- a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/hwgste/snmp/plugin.pm b/centreon-plugins/hardware/sensors/hwgste/snmp/plugin.pm index 3c08e97f7..96b39e8cc 100644 --- a/centreon-plugins/hardware/sensors/hwgste/snmp/plugin.pm +++ b/centreon-plugins/hardware/sensors/hwgste/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/humidity.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/humidity.pm index 24e6224a6..9aebe168a 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/humidity.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/humidity.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/sp.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/sp.pm index 9481c3cf1..835239bdf 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/sp.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/sp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/switch.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/switch.pm index fd52733ea..fd39f4188 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/switch.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/switch.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/temperature.pm index bf2ea7fd3..af6cec712 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm index 7bbd87fa3..a5a4a8f0a 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -122,7 +122,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $snmp_request = []; @@ -290,12 +289,12 @@ Example: --threshold-overload='temperature,CRITICAL,^(?!(normal)$)' =item B<--warning> -Set warning threshold for temperatures and humidity (syntax: type,regexp,treshold) +Set warning threshold for temperatures and humidity (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' --warning='humidity,.*,90' =item B<--critical> -Set critical threshold for temperature and humidity (syntax: type,regexp,treshold) +Set critical threshold for temperature and humidity (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back diff --git a/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm index 5e1d427ed..f3c8c3d59 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/contact.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/contact.pm index 14cfbc495..b67ac1477 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/contact.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/contact.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/flood.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/flood.pm index dcf881b31..322b023f4 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/flood.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/flood.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm index 1314f296e..c6f3e3ccc 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm index ac6d982dd..e678dcabc 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm index 12b1f56b8..c9618d322 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm index 96225fc42..a0c28ce30 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm index 1f3a2a2b1..e0debdb11 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm index dc259c937..a10d5973f 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; -# $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/components/sensors.pm b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/components/sensors.pm index 31793eca3..7fd62269b 100644 --- a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/components/sensors.pm +++ b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/components/sensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm index 040134c48..db98f25d6 100644 --- a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -109,7 +109,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $snmp_request = []; @@ -257,12 +256,12 @@ Example: --threshold-overload='output,CRITICAL,^(?!(off)$)' =item B<--warning> -Set warning threshold for temperatures and humidity (syntax: type,regexp,treshold) +Set warning threshold for temperatures and humidity (syntax: type,regexp,threshold) Example: --warning='sensors,Int. Temp,30' --warning='sensors,Fuel Level,50:' =item B<--critical> -Set critical threshold for temperature and humidity (syntax: type,regexp,treshold) +Set critical threshold for temperature and humidity (syntax: type,regexp,threshold) Example: --warning='sensors,Int. Temp,35' --warning='sensors,Fuel Level,40:' =back diff --git a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm index 5eb49e8b6..85d9a8ae8 100644 --- a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm +++ b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/sensors/temperhum/local/mode/environment.pm b/centreon-plugins/hardware/sensors/temperhum/local/mode/environment.pm new file mode 100644 index 000000000..e07e88bf6 --- /dev/null +++ b/centreon-plugins/hardware/sensors/temperhum/local/mode/environment.pm @@ -0,0 +1,192 @@ +# +# Copyright 2016 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::sensors::temperhum::local::mode::environment; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'drive', type => 1, cb_prefix_output => 'prefix_device_output', message_multiple => 'All measures are OK' }, + ]; + + $self->{maps_counters}->{drive} = [ + { label => 'humidity', set => { + key_values => [ { name => 'humidity' }, { name => 'display' } ], + output_template => 'Humidity: %.2f%%', + perfdatas => [ + { label => 'humidity', value => 'humidity_absolute', template => '%.2f', + unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + }, + }, + { label => 'temperature', set => { + key_values => [ { name => 'temperature' }, { name => 'dewpoint' }, { name => 'display' } ], + output_template => 'Temperature: %.2f C', + perfdatas => [ + { label => 'temperature', value => 'temperature_absolute', template => '%.2f', + unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + }, + }, + { label => 'dew-point', set => { + key_values => [ { name => 'dewpoint' }, { name => 'display' } ], + output_template => 'Dew Point : %.2f C', + perfdatas => [ + { label => 'dew_point', value => 'dewpoint_absolute', template => '%.2f', + unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'delta', set => { + key_values => [ { name => 'delta' }, { name => 'display' } ], + output_template => 'Delta (Temp - Dew) : %.2f C', + perfdatas => [ + { label => 'delta', value => 'delta_absolute', template => '%.2f', + unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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 => + { + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'tempered' }, + "command-path:s" => { name => 'command_path', default => '/opt/PCsensor/TEMPered/utils/' }, + "command-options:s" => { name => 'command_options' }, + "filter-drive:s" => { name => 'filter_drive', default => '.*' }, + }); + return $self; +} + +sub prefix_device_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{drive} = {}; + my $stdout = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + + foreach (split(/\n/, $stdout)) { + next if !/(\/dev\/[a-z0-9]+).*temperature\s(\d*\.?\d+).*relative\shumidity\s(\d*\.?\d+).*dew\spoint\s(\d*\.?\d+)/; + my ($drive, $temp, $hum, $dew) = ($1, $2, $3, $4); + next if ($drive !~ /$self->{option_results}->{filter_drive}/); + $self->{drive}->{$drive} = { humidity => $hum, temperature => $temp, dewpoint => $dew, delta => ($temp - $dew), display => $drive }; + } + + if (scalar(keys %{$self->{drive}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No informations gathered, please check your filters"); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check metrics from TemPerHum sensors + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'tempered'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: '/usr/sbin'). + +=item B<--command-options> + +Command options (Default: '-u'). + +=item B<--filter-drive> +Filter by drive name (e.g --filter-drive raw4) + +=item B<--warning-*> +Threshold Warning +Can be: 'temperature', 'humidity', 'dew-point', 'delta' + +=item B<--critical-*> +Threshold Critical +Can be: 'temperature', 'humidity', 'dew-point', 'delta' + +=back + +=cut diff --git a/centreon-plugins/hardware/sensors/temperhum/local/plugin.pm b/centreon-plugins/hardware/sensors/temperhum/local/plugin.pm new file mode 100644 index 000000000..720308fdb --- /dev/null +++ b/centreon-plugins/hardware/sensors/temperhum/local/plugin.pm @@ -0,0 +1,43 @@ +# +# Copyright 2016 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::sensors::temperhum::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'environment' => 'hardware::sensors::temperhum::local::mode::environment', + ); + return $self;} +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check temperature, humidity and dew point for TemPerHum Sensors (the plugin can use SSH). + +=cut diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm index 716f4b22d..e313f366a 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -100,7 +100,6 @@ sub get_timestamp { 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(); diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/blade.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/blade.pm index b5cba0ee6..03ec3b9d0 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/blade.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/blade.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsComputeBladeDn = '.1.3.6.1.4.1.9.9.719.1.9.2.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsComputeBladePresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsComputeBladePresence}->{oid} }, { oid => $mapping2->{cucsComputeBladeOperState}->{oid} }, { oid => $oid_cucsComputeBladeDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking blades"); $self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'blade')); + return if ($self->check_filter(section => 'blade')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsComputeBladeDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsComputeBladeOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'blade', instance => $blade_dn)); - next if ($self->check_exclude(section => 'blade', instance => $blade_dn)); + next if ($self->check_filter(section => 'blade', instance => $blade_dn)); $self->{output}->output_add(long_msg => sprintf("blade '%s' state is '%s' [presence: %s].", $blade_dn, $result2->{cucsComputeBladeOperState}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/chassis.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/chassis.pm index c395b04d6..ece6e0b51 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/chassis.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/chassis.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -32,9 +32,9 @@ my $mapping1 = { my $oid_cucsEquipmentChassisDn = '.1.3.6.1.4.1.9.9.719.1.15.7.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentChassisOperState}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentChassisOperState}->{oid} }, { oid => $oid_cucsEquipmentChassisDn }; } @@ -43,7 +43,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis"); $self->{components}->{chassis} = {name => 'chassis', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'chassis')); + return if ($self->check_filter(section => 'chassis')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentChassisDn}})) { $oid =~ /\.(\d+)$/; @@ -52,7 +52,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsEquipmentChassisOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'chassis', instance => $chassis_dn)); - next if ($self->check_exclude(section => 'chassis', instance => $chassis_dn)); + next if ($self->check_filter(section => 'chassis', instance => $chassis_dn)); $self->{components}->{chassis}->{total}++; diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/cpu.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/cpu.pm index 04194ef13..0b622c9f5 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/cpu.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsProcessorUnitDn = '.1.3.6.1.4.1.9.9.719.1.41.9.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsProcessorUnitPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsProcessorUnitPresence}->{oid} }, { oid => $mapping2->{cucsProcessorUnitOperState}->{oid} }, { oid => $oid_cucsProcessorUnitDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking cpus"); $self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'cpu')); + return if ($self->check_filter(section => 'cpu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsProcessorUnitDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsProcessorUnitOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'cpu', instance => $cpu_dn)); - next if ($self->check_exclude(section => 'cpu', instance => $cpu_dn)); + next if ($self->check_filter(section => 'cpu', instance => $cpu_dn)); $self->{output}->output_add(long_msg => sprintf("cpu '%s' state is '%s' [presence: %s].", $cpu_dn, $result2->{cucsProcessorUnitOperState}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/fan.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/fan.pm index 5fd1ce740..bf6102d32 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/fan.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentFanDn = '.1.3.6.1.4.1.9.9.719.1.15.12.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentFanPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentFanPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentFanOperState}->{oid} }, { oid => $oid_cucsEquipmentFanDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentFanDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentFanOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'fan', instance => $fan_dn)); - next if ($self->check_exclude(section => 'fan', instance => $fan_dn)); + next if ($self->check_filter(section => 'fan', instance => $fan_dn)); $self->{output}->output_add(long_msg => sprintf("fan '%s' state is '%s' [presence: %s].", $fan_dn, $result2->{cucsEquipmentFanOperState}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/fex.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/fex.pm index 953912bea..c27ef32f3 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/fex.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/fex.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentFexDn = '.1.3.6.1.4.1.9.9.719.1.15.19.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentFexPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentFexPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentFexOperState}->{oid} }, { oid => $oid_cucsEquipmentFexDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fabric extenders"); $self->{components}->{fex} = {name => 'fabric extenders', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fex')); + return if ($self->check_filter(section => 'fex')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentFexDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentFexOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'fex', instance => $fex_dn)); - next if ($self->check_exclude(section => 'fex', instance => $fex_dn)); + next if ($self->check_filter(section => 'fex', instance => $fex_dn)); $self->{output}->output_add(long_msg => sprintf("Fabric extender '%s' state is '%s' [presence: %s].", $fex_dn, $result2->{cucsEquipmentFexOperState}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/iocard.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/iocard.pm index 174bfc86e..4bac57dbd 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/iocard.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/iocard.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentIOCardDn = '.1.3.6.1.4.1.9.9.719.1.15.30.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentIOCardPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentIOCardPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentIOCardOperState}->{oid} }, { oid => $oid_cucsEquipmentIOCardDn }; } @@ -46,7 +46,7 @@ sub check { # In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB' $self->{output}->output_add(long_msg => "Checking io cards"); $self->{components}->{iocard} = {name => 'io cards', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'iocard')); + return if ($self->check_filter(section => 'iocard')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentIOCardDn}})) { $oid =~ /\.(\d+)$/; @@ -56,7 +56,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentIOCardOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'iocard', instance => $iocard_dn)); - next if ($self->check_exclude(section => 'iocard', instance => $iocard_dn)); + next if ($self->check_filter(section => 'iocard', instance => $iocard_dn)); $self->{output}->output_add(long_msg => sprintf("IO cards '%s' state is '%s' [presence: %s].", $iocard_dn, $result2->{cucsEquipmentIOCardOperState}, @@ -74,7 +74,7 @@ sub check { $self->{components}->{iocard}->{total}++; - $exit = $self->get_severity(section => 'default.operability', label => 'iocard.operability', value => $result2->{cucsEquipmentIOCardOperState}); + $exit = $self->get_severity(section => 'iocard.operability', label => 'default.operability', value => $result2->{cucsEquipmentIOCardOperState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("IO cards '%s' state is '%s'.", diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/localdisk.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/localdisk.pm index 44104d87e..c8d3dd399 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/localdisk.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/localdisk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsStorageLocalDiskDn = '.1.3.6.1.4.1.9.9.719.1.45.4.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} }, { oid => $mapping2->{cucsStorageLocalDiskOperability}->{oid} }, { oid => $oid_cucsStorageLocalDiskDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking local disks"); $self->{components}->{localdisk} = {name => 'local disks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'localdisk')); + return if ($self->check_filter(section => 'localdisk')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsStorageLocalDiskDn}})) { $oid =~ /\.(\d+)$/; @@ -55,7 +55,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsStorageLocalDiskOperability}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'localdisk', instance => $localdisk_dn)); - next if ($self->check_exclude(section => 'localdisk', instance => $localdisk_dn)); + next if ($self->check_filter(section => 'localdisk', instance => $localdisk_dn)); $self->{output}->output_add(long_msg => sprintf("local disk '%s' state is '%s' [presence: %s].", $localdisk_dn, $result2->{cucsStorageLocalDiskOperability}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/memory.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/memory.pm index ae442a0ee..4b8902126 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/memory.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsMemoryUnitDn = '.1.3.6.1.4.1.9.9.719.1.30.11.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsMemoryUnitPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsMemoryUnitPresence}->{oid} }, { oid => $mapping2->{cucsMemoryUnitOperState}->{oid} }, { oid => $oid_cucsMemoryUnitDn }; } @@ -45,7 +45,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking memories"); $self->{components}->{memory} = {name => 'memories', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'memory')); + return if ($self->check_filter(section => 'memory')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsMemoryUnitDn}})) { $oid =~ /\.(\d+)$/; @@ -56,7 +56,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsMemoryUnitOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'memory', instance => $memory_dn)); - next if ($self->check_exclude(section => 'memory', instance => $memory_dn)); + next if ($self->check_filter(section => 'memory', instance => $memory_dn)); $self->{output}->output_add(long_msg => sprintf("memory '%s' state is '%s' [presence: %s].", $memory_dn, $result2->{cucsMemoryUnitOperState}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/psu.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/psu.pm index 26a2bdec6..9727a1eaf 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/psu.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping2 = { my $oid_cucsEquipmentPsuDn = '.1.3.6.1.4.1.9.9.719.1.15.56.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping1->{cucsEquipmentPsuPresence}->{oid} }, + push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentPsuPresence}->{oid} }, { oid => $mapping2->{cucsEquipmentPsuOperState}->{oid} }, { oid => $oid_cucsEquipmentPsuDn }; } @@ -46,7 +46,7 @@ sub check { # In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB' $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentPsuDn}})) { $oid =~ /\.(\d+)$/; @@ -56,7 +56,7 @@ sub check { my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentPsuOperState}->{oid}}, instance => $instance); next if ($self->absent_problem(section => 'psu', instance => $psu_dn)); - next if ($self->check_exclude(section => 'psu', instance => $psu_dn)); + next if ($self->check_filter(section => 'psu', instance => $psu_dn)); $self->{output}->output_add(long_msg => sprintf("power supply '%s' state is '%s' [presence: %s].", $psu_dn, $result2->{cucsEquipmentPsuOperState}, diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/components/resources.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/components/resources.pm index d8beeb34a..57ed70b8c 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/components/resources.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/components/resources.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/equipment.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/equipment.pm index 91d7e45ac..9bbb29a11 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/equipment.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/equipment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,194 +20,45 @@ package hardware::server::cisco::ucs::mode::equipment; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use hardware::server::cisco::ucs::mode::components::resources qw($thresholds); +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|chassis|iocard|blade|fex|cpu|memory|localdisk)\.(presence|operability|overall_status)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = $thresholds; + + $self->{components_path} = 'hardware::server::cisco::ucs::mode::components'; + $self->{components_module} = ['fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "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->{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 !~ /^(fan|psu|chassis|iocard|blade|fex|cpu|memory|localdisk)\.(presence|operability|overall_status)$/) { - $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 = ('fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::cisco::ucs::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 = "hardware::server::cisco::ucs::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_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - 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__ @@ -223,10 +74,10 @@ Check Hardware (Fans, Power supplies, chassis, io cards, blades, fabric extender Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan) -Can be specific or global: --exclude=fan#/sys/chassis-7/fan-module-1-7/fan-1# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,/sys/chassis-7/fan-module-1-7/fan-1 =item B<--absent-problem> diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm index 12c116552..1d0ca611e 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -105,7 +105,6 @@ sub get_timestamp { 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(); diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/serviceprofile.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/serviceprofile.pm index 6efa7a54c..3774d1075 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/serviceprofile.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/serviceprofile.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -62,7 +62,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cucsLsBindingDn = '.1.3.6.1.4.1.9.9.719.1.26.2.1.2'; diff --git a/centreon-plugins/hardware/server/cisco/ucs/plugin.pm b/centreon-plugins/hardware/server/cisco/ucs/plugin.pm index 5abe8583b..c13247b49 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/plugin.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/chassis.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/chassis.pm index cd287a6a5..1eb78f5f9 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/chassis.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/chassis.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/health.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/health.pm index 7269cdc01..48791fca0 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/health.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/health.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/psu.pm index aaa1a1f10..976767c14 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/psu.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/temperature.pm index 38ac2c213..768036564 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm index a7fd26e5c..a5df1bf37 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -128,7 +128,6 @@ sub display_system_information { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $snmp_request = [ { oid => $oid_drsProductShortName }, { oid => $oid_drsChassisServiceTag }, { oid => $oid_drsFirmwareVersion } ]; @@ -293,14 +292,14 @@ Example: --threshold-overload='health,CRITICAL,^(?!(ok)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,treshold) +Set warning threshold for temperatures (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,treshold) +Set critical threshold for temperatures (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm index c5de2d59d..38b6dfc03 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm new file mode 100644 index 000000000..ad1d0ead1 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm @@ -0,0 +1,122 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::amperage; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state %map_amperage_type); + +my $mapping = { + amperageProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.4', map => \%map_state }, + amperageProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.5', map => \%map_probe_status }, + amperageProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.6' }, + amperageProbeType => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.7', map => \%map_amperage_type }, + amperageProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.8' }, + amperageProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.10' }, + amperageProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.11' }, + amperageProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.12' }, + amperageProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.13' }, +}; +my $oid_amperageProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.30.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_amperageProbeTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking amperages"); + $self->{components}->{amperage} = {name => 'amperages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'amperage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_amperageProbeTableEntry}})) { + next if ($oid !~ /^$mapping->{amperageProbeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_amperageProbeTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'amperage', instance => $instance)); + $self->{components}->{amperage}->{total}++; + + my ($divisor, $unit) = (1000, 'A'); + if ($result->{amperageProbeType} =~ /amperageProbeTypeIsPowerSupplyAmps|amperageProbeTypeIsSystemAmps/) { + $divisor = 10; + } elsif ($result->{amperageProbeType} =~ /amperageProbeTypeIsPowerSupplyWatts|amperageProbeTypeIsSystemWatts/) { + $unit = 'W'; + } + $result->{amperageProbeReading} = (defined($result->{amperageProbeReading})) ? $result->{amperageProbeReading} / $divisor : 'unknown'; + $self->{output}->output_add(long_msg => sprintf("amperage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{amperageProbeLocationName}, $result->{amperageProbeStatus}, $instance, + $result->{amperageProbeStateSettings}, $result->{amperageProbeReading})); + + my $exit = $self->get_severity(label => 'default.state', section => 'amperage.state', value => $result->{amperageProbeStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Amperage '%s' state is '%s'", $result->{amperageProbeLocationName}, $result->{amperageProbeStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'probe.status', section => 'amperage.status', value => $result->{amperageProbeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Amperage '%s' status is '%s'", $result->{amperageProbeLocationName}, $result->{amperageProbeStatus})); + } + + next if ($result->{amperageProbeType} =~ /amperageProbeTypeIsDiscrete/); + + if (defined($result->{amperageProbeReading}) && $result->{amperageProbeReading} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'amperage', instance => $instance, value => $result->{amperageProbeReading}); + if ($checked == 0) { + $result->{amperageProbeLowerNonCriticalThreshold} = (defined($result->{amperageProbeLowerNonCriticalThreshold}) && $result->{amperageProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeLowerNonCriticalThreshold} / $divisor : ''; + $result->{amperageProbeLowerCriticalThreshold} = (defined($result->{amperageProbeLowerCriticalThreshold}) && $result->{amperageProbeLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeLowerCriticalThreshold} / $divisor : ''; + $result->{amperageProbeUpperNonCriticalThreshold} = (defined($result->{amperageProbeUpperNonCriticalThreshold}) && $result->{amperageProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeUpperNonCriticalThreshold} / $divisor : ''; + $result->{amperageProbeUpperCriticalThreshold} = (defined($result->{amperageProbeUpperCriticalThreshold}) && $result->{amperageProbeUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeUpperCriticalThreshold} / $divisor : ''; + my $warn_th = $result->{amperageProbeLowerNonCriticalThreshold} . ':' . $result->{amperageProbeUpperNonCriticalThreshold}; + my $crit_th = $result->{amperageProbeLowerCriticalThreshold} . ':' . $result->{amperageProbeUpperCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-amperage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-amperage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{amperageProbeReading}, threshold => [ { label => 'critical-amperage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-amperage-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-amperage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-amperage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Amperage '%s' is %s %s", $result->{amperageProbeLocationName}, $result->{amperageProbeReading}, $unit)); + } + $self->{output}->perfdata_add(label => 'amperage_' . $result->{amperageProbeLocationName}, unit => $unit, + value => $result->{amperageProbeReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm new file mode 100644 index 000000000..73a99338b --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm @@ -0,0 +1,113 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::coolingdevice; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); + +my $mapping = { + coolingDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.4', map => \%map_state }, + coolingDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.5', map => \%map_probe_status }, + coolingDeviceReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.6' }, + coolingDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.8' }, + coolingDeviceUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, + coolingDeviceUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, + coolingDeviceLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, + coolingDeviceLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.13' }, +}; +my $oid_coolingDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.12.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_coolingDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cooling devices"); + $self->{components}->{coolingdevice} = {name => 'cooling devices', total => 0, skip => 0}; + return if ($self->check_filter(section => 'coolingdevice')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'coolingdevice', instance => $instance)); + $self->{components}->{coolingdevice}->{total}++; + + $result->{coolingDeviceReading} = (defined($result->{coolingDeviceReading})) ? $result->{coolingDeviceReading} : 'unknown'; + $self->{output}->output_add(long_msg => sprintf("cooling device '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus}, $instance, + $result->{coolingDeviceStateSettings}, $result->{coolingDeviceReading})); + + my $exit = $self->get_severity(label => 'default.state', section => 'coolingdevice.state', value => $result->{coolingDeviceStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling device '%s' state is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'probe.status', section => 'coolingdevice.status', value => $result->{coolingDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling device '%s' status is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus})); + } + + if (defined($result->{coolingDeviceReading}) && $result->{coolingDeviceReading} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'coolingdevice', instance => $instance, value => $result->{coolingDeviceReading}); + if ($checked == 0) { + $result->{coolingDeviceLowerNonCriticalThreshold} = (defined($result->{coolingDeviceLowerNonCriticalThreshold}) && $result->{coolingDeviceLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceLowerNonCriticalThreshold} / 10 : ''; + $result->{coolingDeviceLowerCriticalThreshold} = (defined($result->{coolingDeviceLowerCriticalThreshold}) && $result->{coolingDeviceLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceLowerCriticalThreshold} / 10 : ''; + $result->{coolingDeviceUpperNonCriticalThreshold} = (defined($result->{coolingDeviceUpperNonCriticalThreshold}) && $result->{coolingDeviceUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceUpperNonCriticalThreshold} / 10 : ''; + $result->{coolingDeviceUpperCriticalThreshold} = (defined($result->{coolingDeviceUpperCriticalThreshold}) && $result->{coolingDeviceUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceUpperCriticalThreshold} : ''; + my $warn_th = $result->{coolingDeviceLowerNonCriticalThreshold} . ':' . $result->{coolingDeviceUpperNonCriticalThreshold}; + my $crit_th = $result->{coolingDeviceLowerCriticalThreshold} . ':' . $result->{coolingDeviceUpperCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-coolingdevice-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-coolingdevice-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{coolingDeviceReading}, threshold => [ { label => 'critical-coolingdevice-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-coolingdevice-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-coolingdevice-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-coolingdevice-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling device '%s' is %s rpm", $result->{coolingDeviceLocationName}, $result->{coolingDeviceReading})); + } + $self->{output}->perfdata_add(label => 'fan_' . $result->{coolingDeviceLocationName}, unit => 'rpm', + value => $result->{coolingDeviceReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm new file mode 100644 index 000000000..6968331a6 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::coolingunit; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + coolingUnitStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.10.1.4', map => \%map_state }, + coolingUnitName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.10.1.7' }, + coolingUnitStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.10.1.8', map => \%map_status }, +}; +my $oid_coolingUnitTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_coolingUnitTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cooling units"); + $self->{components}->{coolingunit} = {name => 'cooling units', total => 0, skip => 0}; + return if ($self->check_filter(section => 'coolingunit')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingUnitTableEntry}})) { + next if ($oid !~ /^$mapping->{coolingUnitStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingUnitTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'coolingunit', instance => $instance)); + $self->{components}->{coolingunit}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cooling unit '%s' status is '%s' [instance = %s] [state = %s]", + $result->{coolingUnitName}, $result->{coolingUnitStatus}, $instance, + $result->{coolingUnitStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'coolingunit.state', value => $result->{coolingUnitStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling unit '%s' state is '%s'", $result->{coolingUnitName}, $result->{coolingUnitStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'coolingunit.status', value => $result->{coolingUnitStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling unit '%s' status is '%s'", $result->{coolingUnitName}, $result->{coolingUnitStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/fru.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/fru.pm new file mode 100644 index 000000000..f69778544 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/fru.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::fru; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + fruInformationStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.2000.10.1.3', map => \%map_status }, + fruSerialNumberName => { oid => '.1.3.6.1.4.1.674.10892.5.4.2000.10.1.7' }, +}; +my $oid_fruTableEntry = '.1.3.6.1.4.1.674.10892.5.4.2000.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fruTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fru"); + $self->{components}->{fru} = {name => 'fru', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fru')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fruTableEntry}})) { + next if ($oid !~ /^$mapping->{fruInformationStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fruTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fru', instance => $instance)); + $self->{components}->{fru}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fru '%s' status is '%s' [instance = %s]", + $result->{fruSerialNumberName}, $result->{fruInformationStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default.status', section => 'fru.status', value => $result->{fruInformationStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fru '%s' status is '%s'", $result->{fruSerialNumberName}, $result->{fruInformationStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm new file mode 100644 index 000000000..00d08f636 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::memory; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + memoryDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.50.1.4', map => \%map_state }, + memoryDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.50.1.5', map => \%map_status }, + memoryDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.50.1.8' }, +}; +my $oid_memoryDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_memoryDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking memories"); + $self->{components}->{memory} = {name => 'memories', total => 0, skip => 0}; + return if ($self->check_filter(section => 'memory')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_memoryDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{memoryDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'memory', instance => $instance)); + $self->{components}->{memory}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("memory '%s' status is '%s' [instance = %s] [state = %s]", + $result->{memoryDeviceLocationName}, $result->{memoryDeviceStatus}, $instance, + $result->{memoryDeviceStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'memory.state', value => $result->{memoryDeviceStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' state is '%s'", $result->{memoryDeviceLocationName}, $result->{memoryDeviceStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'memory.status', value => $result->{memoryDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' status is '%s'", $result->{memoryDeviceLocationName}, $result->{memoryDeviceStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm new file mode 100644 index 000000000..e83342b77 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::network; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + networkDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.90.1.3', map => \%map_status }, + networkDeviceProductName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.90.1.6' }, +}; +my $oid_networkDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.90.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_networkDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking networks"); + $self->{components}->{network} = {name => 'networks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'network')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_networkDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{networkDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_networkDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'network', instance => $instance)); + $self->{components}->{network}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("network '%s' status is '%s' [instance = %s]", + $result->{networkDeviceProductName}, $result->{networkDeviceStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default.status', section => 'network.status', value => $result->{networkDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Network '%s' status is '%s'", $result->{networkDeviceProductName}, $result->{networkDeviceStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm new file mode 100644 index 000000000..497e99352 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::pci; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + pCIDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.80.1.4', map => \%map_state }, + pCIDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.80.1.5', map => \%map_status }, + pCIDeviceDescriptionName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.80.1.9' }, +}; +my $oid_pCIDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.80.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_pCIDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking pci"); + $self->{components}->{pci} = {name => 'pci', total => 0, skip => 0}; + return if ($self->check_filter(section => 'pci')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_pCIDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{pCIDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_pCIDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'pci', instance => $instance)); + $self->{components}->{pci}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("pci '%s' status is '%s' [instance = %s] [state = %s]", + $result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStatus}, $instance, + $result->{pCIDeviceStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'pci.state', value => $result->{pCIDeviceStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PCI '%s' state is '%s'", $result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'pci.status', value => $result->{pCIDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PCI '%s' status is '%s'", $result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm new file mode 100644 index 000000000..3e7d42eac --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::pdisk; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_pdisk_state); + +my $mapping = { + physicalDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.4', map => \%map_pdisk_state }, + physicalDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24', map => \%map_status }, + physicalDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.54' }, +}; +my $oid_physicalDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_physicalDiskTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking physical disks"); + $self->{components}->{pdisk} = {name => 'physical disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'pdisk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_physicalDiskTableEntry}})) { + next if ($oid !~ /^$mapping->{physicalDiskComponentStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_physicalDiskTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'pdisk', instance => $instance)); + $self->{components}->{pdisk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power unit '%s' status is '%s' [instance = %s] [state = %s]", + $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}, $instance, + $result->{physicalDiskState})); + + my $exit = $self->get_severity(section => 'pdisk.state', value => $result->{physicalDiskState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power unit '%s' state is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskState})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'pdisk.status', value => $result->{physicalDiskComponentStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power unit '%s' status is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm new file mode 100644 index 000000000..bc2a896ad --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::processor; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + processorDeviceStatusStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.32.1.4', map => \%map_state }, + processorDeviceStatusStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.32.1.5', map => \%map_status }, + processorDeviceStatusLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.32.1.7' }, +}; +my $oid_processorDeviceStatusTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.32.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_processorDeviceStatusTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking processors"); + $self->{components}->{processor} = {name => 'processors', total => 0, skip => 0}; + return if ($self->check_filter(section => 'processor')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_processorDeviceStatusTableEntry}})) { + next if ($oid !~ /^$mapping->{processorDeviceStatusStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_processorDeviceStatusTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'processor', instance => $instance)); + $self->{components}->{processor}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("processor '%s' status is '%s' [instance = %s] [state = %s]", + $result->{processorDeviceStatusLocationName}, $result->{processorDeviceStatusStatus}, $instance, + $result->{processorDeviceStatusStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'processor.state', value => $result->{processorDeviceStatusStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Processor '%s' state is '%s'", $result->{processorDeviceStatusLocationName}, $result->{processorDeviceStatusStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'processor.status', value => $result->{processorDeviceStatusStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Processor '%s' status is '%s'", $result->{processorDeviceStatusLocationName}, $result->{processorDeviceStatusStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm new file mode 100644 index 000000000..c866a1720 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::psu; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + powerSupplyStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.12.1.5', map => \%map_status }, + powerSupplyLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.12.1.8' }, +}; +my $oid_powerSupplyTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.12.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerSupplyTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyTableEntry}})) { + next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyTableEntry}, 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]", + $result->{powerSupplyLocationName}, $result->{powerSupplyStatus}, $instance, + )); + + + my $exit = $self->get_severity(label => 'default.status', section => 'psu.status', value => $result->{powerSupplyStatus}); + 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'", $result->{powerSupplyLocationName}, $result->{powerSupplyStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm new file mode 100644 index 000000000..d42aead49 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::punit; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + powerUnitStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.10.1.4', map => \%map_state }, + powerUnitName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.10.1.7' }, + powerUnitStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.10.1.8', map => \%map_status }, +}; +my $oid_powerUnitTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerUnitTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power units"); + $self->{components}->{punit} = {name => 'power units', total => 0, skip => 0}; + return if ($self->check_filter(section => 'punit')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerUnitTableEntry}})) { + next if ($oid !~ /^$mapping->{powerUnitStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerUnitTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'punit', instance => $instance)); + $self->{components}->{punit}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power unit '%s' status is '%s' [instance = %s] [state = %s]", + $result->{powerUnitName}, $result->{powerUnitStatus}, $instance, + $result->{powerUnitStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'punit.state', value => $result->{powerUnitStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power unit '%s' state is '%s'", $result->{powerUnitName}, $result->{powerUnitStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'punit.status', value => $result->{powerUnitStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power unit '%s' status is '%s'", $result->{powerUnitName}, $result->{powerUnitStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm new file mode 100644 index 000000000..c90f092c0 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm @@ -0,0 +1,108 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %map_state; +our %map_status; +our %map_probe_status; +our %map_amperage_type; +our %map_pdisk_state; +our %map_vdisk_state; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(%map_probe_status %map_state %map_status %map_amperage_type %map_pdisk_state %map_vdisk_state); + +%map_probe_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'nonCriticalUpper', + 5 => 'criticalUpper', + 6 => 'nonRecoverableUpper', + 7 => 'nonCriticalLower', + 8 => 'criticalLower', + 9 => 'nonRecoverableLower', + 10 => 'failed', +); + +%map_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'nonCritical', + 5 => 'critical', + 6 => 'nonRecoverable', +); + +%map_state = ( + 1 => 'unknown', + 2 => 'enabled', + 4 => 'notReady', + 6 => 'enabledAndNotReady', +); + +%map_pdisk_state = ( + 1 => 'unknown', + 2 => 'ready', + 3 => 'online', + 4 => 'foreign', + 5 => 'offline', + 6 => 'blocked', + 7 => 'failed', + 8 => 'non-raid', + 9 => 'removed', +); + +%map_vdisk_state = ( + 1 => 'unknown', + 2 => 'online', + 3 => 'failed', + 4 => 'degraded', +); + +%map_amperage_type = ( + 1 => 'amperageProbeTypeIsOther', + 2 => 'amperageProbeTypeIsUnknown', + 3 => 'amperageProbeTypeIs1Point5Volt', + 4 => 'amperageProbeTypeIs3Point3volt', + 5 => 'amperageProbeTypeIs5Volt', + 6 => 'amperageProbeTypeIsMinus5Volt', + 7 => 'amperageProbeTypeIs12Volt', + 8 => 'amperageProbeTypeIsMinus12Volt', + 9 => 'amperageProbeTypeIsIO', + 10 => 'amperageProbeTypeIsCore', + 11 => 'amperageProbeTypeIsFLEA', + 12 => 'amperageProbeTypeIsBattery', + 13 => 'amperageProbeTypeIsTerminator', + 14 => 'amperageProbeTypeIs2Point5Volt', + 15 => 'amperageProbeTypeIsGTL', + 16 => 'amperageProbeTypeIsDiscrete', + 23 => 'amperageProbeTypeIsPowerSupplyAmps', + 24 => 'amperageProbeTypeIsPowerSupplyWatts', + 25 => 'amperageProbeTypeIsSystemAmps', + 26 => 'amperageProbeTypeIsSystemWatts', +); + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/slot.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/slot.pm new file mode 100644 index 000000000..6635f6b07 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/slot.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::slot; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + systemSlotStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1200.10.1.5', map => \%map_status }, + systemSlotSlotExternalSlotName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1200.10.1.8' }, +}; +my $oid_systemSlotTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1200.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_systemSlotTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking slots"); + $self->{components}->{slot} = {name => 'slots', total => 0, skip => 0}; + return if ($self->check_filter(section => 'slot')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_systemSlotTableEntry}})) { + next if ($oid !~ /^$mapping->{systemSlotStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemSlotTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'slot', instance => $instance)); + $self->{components}->{slot}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("slot '%s' status is '%s' [instance = %s]", + $result->{systemSlotSlotExternalSlotName}, $result->{systemSlotStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default.status', section => 'slot.status', value => $result->{systemSlotStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Slot '%s' status is '%s'", $result->{systemSlotSlotExternalSlotName}, $result->{systemSlotStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm new file mode 100644 index 000000000..13d76bb0e --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::storagebattery; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + batteryComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.15.1.6', map => \%map_status }, + batteryFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.15.1.20' }, +}; +my $oid_batteryTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.15.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_batteryTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking storage batteries"); + $self->{components}->{storagebattery} = {name => 'storage batteries', total => 0, skip => 0}; + return if ($self->check_filter(section => 'storagebattery')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_batteryTableEntry}})) { + next if ($oid !~ /^$mapping->{batteryComponentStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_batteryTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'storagebattery', instance => $instance)); + $self->{components}->{storagebattery}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("storage battery '%s' status is '%s' [instance = %s]", + $result->{batteryFQDD}, $result->{batteryComponentStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default.status', section => 'storagebattery.status', value => $result->{batteryComponentStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Storage battery '%s' status is '%s'", $result->{batteryFQDD}, $result->{batteryComponentStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm new file mode 100644 index 000000000..f25df4572 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::storagectrl; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + controllerComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.38', map => \%map_status }, + controllerFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.78' }, +}; +my $oid_controllerTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_controllerTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking storage controllers"); + $self->{components}->{storagectrl} = {name => 'storage controllers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'storagectrl')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_controllerTableEntry}})) { + next if ($oid !~ /^$mapping->{controllerComponentStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_controllerTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'storagectrl', instance => $instance)); + $self->{components}->{storagectrl}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("storage controller '%s' status is '%s' [instance = %s]", + $result->{controllerFQDD}, $result->{controllerComponentStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default.status', section => 'storagectrl.status', value => $result->{controllerComponentStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Storage controllers '%s' status is '%s'", $result->{controllerFQDD}, $result->{controllerComponentStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm new file mode 100644 index 000000000..6d595dee8 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::systembattery; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + systemBatteryStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.50.1.4', map => \%map_state }, + systemBatteryStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.50.1.5', map => \%map_status }, + systemBatteryLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.50.1.7' }, +}; +my $oid_systemBatteryTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_systemBatteryTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking system batteries"); + $self->{components}->{systembattery} = {name => 'system batteries', total => 0, skip => 0}; + return if ($self->check_filter(section => 'systembattery')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_systemBatteryTableEntry}})) { + next if ($oid !~ /^$mapping->{systemBatteryStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemBatteryTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'systembattery', instance => $instance)); + $self->{components}->{systembattery}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("system battery '%s' status is '%s' [instance = %s] [state = %s]", + $result->{systemBatteryLocationName}, $result->{systemBatteryStatus}, $instance, + $result->{systemBatteryStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'systembattery.state', value => $result->{systemBatteryStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System battery '%s' state is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'systembattery.status', value => $result->{systemBatteryStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System battery '%s' status is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm index d3c8a9a2f..fca6c432d 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -22,25 +22,8 @@ package hardware::server::dell::idrac::snmp::mode::components::temperature; use strict; use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); -my %map_temp_status = ( - 1 => 'other', - 2 => 'unknown', - 3 => 'ok', - 4 => 'nonCriticalUpper', - 5 => 'criticalUpper', - 6 => 'nonRecoverableUpper', - 7 => 'nonCriticalLower', - 8 => 'criticalLower', - 9 => 'nonRecoverableLower', - 10 => 'failed', -); -my %map_temp_state = ( - 1 => 'unknown', - 2 => 'enabled', - 4 => 'notReady', - 6 => 'enabledAndNotReady', -); my %map_temp_type = ( 1 => 'temperatureProbeTypeIsOther', 2 => 'temperatureProbeTypeIsUnknown', @@ -49,22 +32,22 @@ my %map_temp_type = ( ); my $mapping = { - temperatureProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.4', map => \%map_temp_state }, - temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.5', map => \%map_temp_status }, + temperatureProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.4', map => \%map_state }, + temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.5', map => \%map_probe_status }, temperatureProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.6' }, temperatureProbeType => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.7', map => \%map_temp_type }, temperatureProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.8' }, temperatureProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, - temperatureProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, - temperatureProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, - temperatureProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, + temperatureProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, + temperatureProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, + temperatureProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.13' }, }; my $oid_temperatureProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.20.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_temperatureProbeTableEntry, begin => $mapping->{temperatureProbeStateSettings}->{oid}, end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} }; + push @{$self->{request}}, { oid => $oid_temperatureProbeTableEntry, begin => $mapping->{temperatureProbeStateSettings}->{oid}, end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} }; } sub check { @@ -72,29 +55,29 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureProbeTableEntry}})) { next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureProbeTableEntry}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $result->{temperatureProbeReading} = (defined($result->{temperatureProbeReading})) ? $result->{temperatureProbeReading} / 10 : 'unknown'; - $self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStatus}, $instance, $result->{temperatureProbeStateSettings}, $result->{temperatureProbeReading})); - my $exit = $self->get_severity(section => 'temperature-state', value => $result->{temperatureProbeStateSettings}); + my $exit = $self->get_severity(label => 'default.state', section => 'temperature.state', value => $result->{temperatureProbeStateSettings}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' state is '%s'", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStateSettings})); next; } - $exit = $self->get_severity(section => 'temperature-status', value => $result->{temperatureProbeStatus}); + $exit = $self->get_severity(label => 'probe.status', section => 'temperature.status', value => $result->{temperatureProbeStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' status is '%s'", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStatus})); @@ -103,7 +86,15 @@ sub check { if (defined($result->{temperatureProbeReading}) && $result->{temperatureProbeReading} =~ /[0-9]/) { my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureProbeReading}); if ($checked == 0) { - my $warn_th = $result->{temperatureProbeLowerNonCriticalThreshold} . ':' . $result->{temperatureProbeUpperCriticalThreshold}; + $result->{temperatureProbeLowerNonCriticalThreshold} = (defined($result->{temperatureProbeLowerNonCriticalThreshold}) && $result->{temperatureProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeLowerNonCriticalThreshold} / 10 : ''; + $result->{temperatureProbeLowerCriticalThreshold} = (defined($result->{temperatureProbeLowerCriticalThreshold}) && $result->{temperatureProbeLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeLowerCriticalThreshold} / 10 : ''; + $result->{temperatureProbeUpperNonCriticalThreshold} = (defined($result->{temperatureProbeUpperNonCriticalThreshold}) && $result->{temperatureProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeUpperNonCriticalThreshold} / 10 : ''; + $result->{temperatureProbeUpperCriticalThreshold} = (defined($result->{temperatureProbeUpperCriticalThreshold}) && $result->{temperatureProbeUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeUpperCriticalThreshold} / 10 : ''; + my $warn_th = $result->{temperatureProbeLowerNonCriticalThreshold} . ':' . $result->{temperatureProbeUpperNonCriticalThreshold}; my $crit_th = $result->{temperatureProbeLowerCriticalThreshold} . ':' . $result->{temperatureProbeUpperCriticalThreshold}; $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); @@ -111,14 +102,14 @@ sub check { $exit = $self->{perfdata}->threshold_check(value => $result->{temperatureProbeReading}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); - $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance) + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); } if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{temperatureProbeLocationName}, $result->{temperatureProbeReading})); } - $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + $self->{output}->perfdata_add(label => 'temp_' . $result->{temperatureProbeLocationName}, unit => 'C', value => $result->{temperatureProbeReading}, warning => $warn, critical => $crit, diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm new file mode 100644 index 000000000..ecf397788 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::vdisk; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_vdisk_state); + +my $mapping = { + virtualDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.4', map => \%map_vdisk_state }, + virtualDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.35' }, +}; +my $oid_virtualDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_virtualDiskTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking virtual disks"); + $self->{components}->{vdisk} = {name => 'virtual disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'vdisk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_virtualDiskTableEntry}})) { + next if ($oid !~ /^$mapping->{virtualDiskState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_virtualDiskTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'vdisk', instance => $instance)); + $self->{components}->{vdisk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("virtual disk '%s' state is '%s' [instance = %s]", + $result->{virtualDiskFQDD}, $result->{virtualDiskState}, $instance, + )); + + my $exit = $self->get_severity(section => 'vdisk.state', value => $result->{virtualDiskState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Virtual disk '%s' state is '%s'", $result->{virtualDiskFQDD}, $result->{virtualDiskState})); + next; + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm new file mode 100644 index 000000000..67cee6160 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm @@ -0,0 +1,113 @@ +# +# Copyright 2016 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::dell::idrac::snmp::mode::components::voltage; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); + +my $mapping = { + voltageProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.4', map => \%map_state }, + voltageProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.5', map => \%map_probe_status }, + voltageProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.6' }, + voltageProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.8' }, + voltageProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.10' }, + voltageProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.11' }, + voltageProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.12' }, + voltageProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.13' }, +}; +my $oid_voltageProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.20.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_voltageProbeTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking voltages"); + $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'voltage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_voltageProbeTableEntry}})) { + next if ($oid !~ /^$mapping->{voltageProbeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_voltageProbeTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + $result->{voltageProbeReading} = (defined($result->{voltageProbeReading})) ? $result->{voltageProbeReading} / 1000 : 'unknown'; + $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{voltageProbeLocationName}, $result->{voltageProbeStatus}, $instance, + $result->{voltageProbeStateSettings}, $result->{voltageProbeReading})); + + my $exit = $self->get_severity(label => 'default.state', section => 'voltage.state', value => $result->{voltageProbeStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' state is '%s'", $result->{voltageProbeLocationName}, $result->{voltageProbeStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'probe.status', section => 'voltage.status', value => $result->{voltageProbeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' status is '%s'", $result->{voltageProbeLocationName}, $result->{voltageProbeStatus})); + } + + if (defined($result->{voltageProbeReading}) && $result->{voltageProbeReading} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltageProbeReading}); + if ($checked == 0) { + $result->{voltageProbeLowerNonCriticalThreshold} = (defined($result->{voltageProbeLowerNonCriticalThreshold}) && $result->{voltageProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeLowerNonCriticalThreshold} / 1000 : ''; + $result->{voltageProbeLowerCriticalThreshold} = (defined($result->{voltageProbeLowerCriticalThreshold}) && $result->{voltageProbeLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeLowerCriticalThreshold} / 1000 : ''; + $result->{voltageProbeUpperNonCriticalThreshold} = (defined($result->{voltageProbeUpperNonCriticalThreshold}) && $result->{voltageProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeUpperNonCriticalThreshold} / 1000 : ''; + $result->{voltageProbeUpperCriticalThreshold} = (defined($result->{voltageProbeUpperCriticalThreshold}) && $result->{voltageProbeUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeUpperCriticalThreshold} / 1000 : ''; + my $warn_th = $result->{voltageProbeLowerNonCriticalThreshold} . ':' . $result->{voltageProbeUpperNonCriticalThreshold}; + my $crit_th = $result->{voltageProbeLowerCriticalThreshold} . ':' . $result->{voltageProbeUpperCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{voltageProbeReading}, threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' is %s V", $result->{voltageProbeLocationName}, $result->{voltageProbeReading})); + } + $self->{output}->perfdata_add(label => 'voltage_' . $result->{voltageProbeLocationName}, unit => 'V', + value => $result->{voltageProbeReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm index 10bf944fb..0accf84a8 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -54,7 +54,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_drsGlobalSystemStatus = '.1.3.6.1.4.1.674.10892.2.2.1.0'; diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm index f91ff3754..e542b3346 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,33 +20,78 @@ package hardware::server::dell::idrac::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - 'temperature-state' => [ - ['unknown', 'UNKNOWN'], - ['enabled', 'OK'], - ['notReady', 'WARNING'], - ['enabledAndNotReady', 'WARNING'], - ['.*', 'UNKNOWN'], - ], - 'temperature-status' => [ - ['other', 'UNKNOWN'], - ['unknown', 'UNKNOWN'], - ['ok', 'OK'], - ['nonCriticalUpper', 'WARNING'], - ['criticalUpper', 'CRITICAL'], - ['nonCriticalLower', 'WARNING'], - ['criticalLower', 'CRITICAL'], - ['nonRecoverableLower', 'CRITICAL'], - ['failed', 'CRITICAL'], - ['.*', 'UNKNOWN'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|amperage|coolingdevice)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + 'default.state' => [ + ['unknown', 'UNKNOWN'], + ['enabled', 'OK'], + ['notReady', 'WARNING'], + ['enabledAndNotReady', 'WARNING'], + ], + 'default.status' => [ + ['other', 'UNKNOWN'], + ['unknown', 'UNKNOWN'], + ['ok', 'OK'], + ['nonCritical', 'WARNING'], + ['critical', 'CRITICAL'], + ['nonRecoverable', 'CRITICAL'], + ], + 'probe.status' => [ + ['other', 'UNKNOWN'], + ['unknown', 'UNKNOWN'], + ['ok', 'OK'], + ['nonCriticalUpper', 'WARNING'], + ['criticalUpper', 'CRITICAL'], + ['nonCriticalLower', 'WARNING'], + ['criticalLower', 'CRITICAL'], + ['nonRecoverableLower', 'CRITICAL'], + ['failed', 'CRITICAL'], + ], + 'pdisk.state' => [ + ['unknown', 'UNKNOWN'], + ['ready', 'OK'], + ['online', 'OK'], + ['foreign', 'OK'], + ['offline', 'WARNING'], + ['blocked', 'WARNING'], + ['failed', 'CRITICAL'], + ['non-raid', 'OK'], + ['removed', 'OK'], + ], + 'vdisk.state' => [ + ['unknown', 'UNKNOWN'], + ['online', 'OK'], + ['failed', 'CRITICAL'], + ['degraded', 'WARNING'], + ], + }; + + $self->{components_path} = 'hardware::server::dell::idrac::snmp::mode::components'; + $self->{components_module} = ['psu', 'punit', 'temperature', 'voltage', 'amperage', + 'systembattery', 'coolingunit', 'coolingdevice', 'processor', 'memory', 'pci', 'network', + 'slot', 'fru', 'storagectrl', 'storagebattery', 'pdisk', 'vdisk']; + + $self->{regexp_threshold_overload_check_section_option} = + '^(' . join('|', @{$self->{components_module}}). ')$'; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -56,209 +101,32 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, }); - - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(temperature)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('temperature'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::dell::idrac::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 = "hardware::server::dell::idrac::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ =head1 MODE -Check hardware components (temperatures,...). -Mode is in WIP. +Check hardware components. =over 8 =item B<--component> Which component to check (Default: '.*'). -Can be: 'temperature', +Can be: 'psu', 'punit', 'temperature', 'voltage', 'amperage', +'systembattery', 'coolingunit', 'coolingdevice', 'processor', 'memory', 'pci', 'network', +'slot', 'fru', 'storagectrl', 'storagebattery', 'pdisk', 'vdisk'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='temperature#1.1#' +Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=psu) +Can also exclude specific instance: --filter=temperature,1.1 =item B<--no-component> @@ -267,18 +135,18 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). -Example: --threshold-overload='temperature-state,CRITICAL,^(?!(enabled)$)' +Example: --threshold-overload='temperature.state,CRITICAL,^(?!(enabled)$)' =item B<--warning> -Set warning threshold for temperature (syntax: type,regexp,treshold) +Set warning threshold (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperature (syntax: type,regexp,treshold) +Set critical threshold (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm index 7a3cc5e1d..7e9b52983 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/battery.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/battery.pm index f9f4443c9..96170f3f9 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/battery.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/battery.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm index a453fda48..70348c467 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cachebattery.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/connector.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/connector.pm index 34eede51f..9ede88f80 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/connector.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/connector.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/controller.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/controller.pm index f05e37e83..a2876cf1c 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/controller.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/controller.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm index 28dc2eb23..c51909502 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/esmlog.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/esmlog.pm index da6ff2475..4a8a4ed9b 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/esmlog.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/esmlog.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/fan.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/fan.pm index e29d6bf4f..1a2d4e71b 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/fan.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/globalstatus.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/globalstatus.pm index aee0ebb5d..c3cdd8455 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/globalstatus.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/logicaldrive.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/logicaldrive.pm index 81bb675ad..2559bc33b 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/logicaldrive.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/logicaldrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/memory.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/memory.pm index 120e2017f..09a46c6f9 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/memory.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm index f5a812909..4a65860e0 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/psu.pm index 18aaf5856..17ca56240 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/psu.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm index 0a3fd9de5..f5289e6c8 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm index 4f2b6055b..28e1dcd2f 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -228,7 +228,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # In '10892-MIB' diff --git a/centreon-plugins/hardware/server/dell/openmanage/snmp/plugin.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/plugin.pm index bf8a1dbda..cc228cf32 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/blade.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/blade.pm index 78b16990c..ea3ae4fae 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/blade.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/blade.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/enclosure.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/enclosure.pm index 4dfd012dd..8b5322288 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/enclosure.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/enclosure.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fan.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fan.pm index 1f9621173..80603e445 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fan.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fuse.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fuse.pm index d313e8669..45b3413ba 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fuse.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/fuse.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/manager.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/manager.pm index 9003bc53c..c06bd9fec 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/manager.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/manager.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/network.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/network.pm index a493b4a1c..d03945333 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/network.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/network.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm index 47c15cea9..b79b43a0c 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm index a6f52a41c..3e679d740 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm index 2d0ce726d..b6508df7b 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -104,12 +104,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -139,7 +139,6 @@ sub global { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; if ($self->{option_results}->{component} eq 'all') { @@ -283,4 +282,4 @@ Example: --threshold-overload='temperature,OK,other' =back =cut - \ No newline at end of file + diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm index ca07c5ae2..76a5e92bb 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/cpu.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/cpu.pm index 10a7f87b4..8207baa0e 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/cpu.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daacc.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daacc.pm index 647df7eb2..c3b60c6b8 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daacc.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daacc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dactl.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dactl.pm index 39c56d7a6..488589be8 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dactl.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dactl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daldrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daldrive.pm index 9aa55aa76..08b8c0d2d 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daldrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/daldrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dapdrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dapdrive.pm index e83460b1f..4cfe535c4 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dapdrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/dapdrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fan.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fan.pm index 3c7841b95..29bfe845a 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fan.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalacc.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalacc.pm index 6ceece824..1eca01e41 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalacc.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalacc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalctl.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalctl.pm index d27610e56..f21cb36fc 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalctl.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaexternalctl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcahostctl.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcahostctl.pm index 727521b4f..def3ab6d3 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcahostctl.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcahostctl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaldrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaldrive.pm index 6e67816d8..e01302d36 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaldrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcaldrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcapdrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcapdrive.pm index ffee76a7a..ef13fbbb0 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcapdrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/fcapdrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idectl.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idectl.pm index ea2fcc542..900c3c31a 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idectl.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idectl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/ideldrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/ideldrive.pm index fea39b477..765cc1778 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/ideldrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/ideldrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idepdrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idepdrive.pm index 14fca2c83..6a385b4fd 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idepdrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/idepdrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/lnic.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/lnic.pm index 8806ffe5c..5d6cd0235 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/lnic.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/lnic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pc.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pc.pm index 891cd3790..95f0c4c9b 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pc.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pnic.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pnic.pm index 9e126c5b8..ec0637ed5 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pnic.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/pnic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/psu.pm index a4e4d205b..5e6a68167 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/psu.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasctl.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasctl.pm index b07433ee0..7d75de032 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasctl.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasctl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasldrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasldrive.pm index 41583a516..990fc2ddf 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasldrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/sasldrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/saspdrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/saspdrive.pm index 9fe04a97f..94ae8210d 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/saspdrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/saspdrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsictl.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsictl.pm index 12c9144dc..163c180c9 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsictl.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsictl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsildrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsildrive.pm index ad69e83b0..260e3d5a4 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsildrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsildrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsipdrive.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsipdrive.pm index 8e2af967b..6787b744a 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsipdrive.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/scsipdrive.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/temperature.pm index f89b9a52c..3d413efbe 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm index e4994779b..7e7b0ca91 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -98,7 +98,6 @@ sub get_severity { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cpqHeMibCondition = '.1.3.6.1.4.1.232.6.1.3.0'; diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/hardware.pm index 34bff9347..b0eb8a6f2 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -315,7 +315,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->get_system_information(); diff --git a/centreon-plugins/hardware/server/hp/proliant/snmp/plugin.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/plugin.pm index 85d1097e9..73441b46d 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm index eabf896d3..8388847eb 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -40,9 +40,9 @@ my $oids = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_temperature, end => $oid_end }; + push @{$self->{request}}, { oid => $oid_temperature, end => $oid_end }; } sub check { @@ -50,7 +50,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking ambient"); $self->{components}->{ambient} = {name => 'ambient', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'ambient')); + return if ($self->check_filter(section => 'ambient')); my @sensors = ('mm', 'frontpanel', 'frontpanel2'); my $label = 'bladecenter'; @@ -68,7 +68,7 @@ sub check { } my $value = $1; - next if ($self->check_exclude(section => 'ambient', instance => $temp)); + next if ($self->check_filter(section => 'ambient', instance => $temp)); $self->{components}->{ambient}->{total}++; $self->{output}->output_add(long_msg => sprintf("ambient '%s' is %s degree centigrade.", diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm index 2f020405a..add7e90c6 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blade.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,9 +59,9 @@ my $mapping = { my $oid_bladeSystemStatusEntry = '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_bladeSystemStatusEntry, start => $mapping->{bladeId}->{oid}, end => $mapping->{bladeName}->{oid} }; + push @{$self->{request}}, { oid => $oid_bladeSystemStatusEntry, start => $mapping->{bladeId}->{oid}, end => $mapping->{bladeName}->{oid} }; } sub check { @@ -69,33 +69,36 @@ sub check { $self->{output}->output_add(long_msg => "Checking blades"); $self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'blade')); + return if ($self->check_filter(section => 'blade')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeSystemStatusEntry}})) { next if ($oid !~ /^$mapping->{bladeExists}->{oid}\.(.*)$/); my $instance = $1; 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 ($self->check_filter(section => 'blade', instance => $result->{bladeId})); if ($result->{bladeExists} =~ /false/i) { $self->{output}->output_add(long_msg => "skipping blade '" . $instance . "' : not exits"); next; } $self->{components}->{blade}->{total}++; + $result->{bladeName} = defined($result->{bladeName}) ? $result->{bladeName} : '-'; if ($result->{bladePowerState} =~ /off/) { - $self->{output}->output_add(long_msg => sprintf("Blade '%s' power state is %s", - $result->{bladeId}, $result->{bladePowerState})); + $self->{output}->output_add(long_msg => sprintf("Blade '%s/%s' power state is %s", + $result->{bladeName}, $result->{bladeId}, $result->{bladePowerState}, + )); next; } - $self->{output}->output_add(long_msg => sprintf("Blade '%s' state is %s [power state: %s]", - $result->{bladeId}, $result->{bladeHealthState}, $result->{bladePowerState})); + $self->{output}->output_add(long_msg => sprintf("Blade '%s/%s' state is %s [power state: %s]", + $result->{bladeName}, $result->{bladeId}, $result->{bladeHealthState}, $result->{bladePowerState}, + )); my $exit = $self->get_severity(section => 'blade', value => $result->{bladeHealthState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Blade '%s' state is %s", - $result->{bladeId}, $result->{bladeHealthState})); + short_msg => sprintf("Blade '%s/%s' state is %s", + $result->{bladeName}, $result->{bladeId}, $result->{bladeHealthState})); } } } diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm index b03b7c565..8f0eb1581 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/blower.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,9 +45,9 @@ my $entry_controller_state = '30'; my $count = 4; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_blowers }; + push @{$self->{request}}, { oid => $oid_blowers }; } sub check { @@ -55,7 +55,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking blowers"); $self->{components}->{blower} = {name => 'blowers', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'blower')); + return if ($self->check_filter(section => 'blower')); for (my $i = 0; $i < $count; $i++) { my $instance = $i + 1; @@ -64,7 +64,7 @@ sub check { my $blower_speed = defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_speed + $i) . '.0'}) ? $self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_speed + $i) . '.0'} : 'unknown'; my $ctrl_state = defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_controller_state + $i) . '.0'}) ? $map_controller_state{$self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_controller_state + $i) . '.0'}} : undef; - next if ($self->check_exclude(section => 'blower', instance => $instance)); + next if ($self->check_filter(section => 'blower', instance => $instance)); next if ($blower_speed =~ /No Blower/i && $self->absent_problem(section => 'blower', instance => $instance)); $self->{components}->{blower}->{total}++; @@ -94,7 +94,7 @@ sub check { next if (!defined($ctrl_state)); - next if ($self->check_exclude(section => 'blowerctrl', instance => $instance)); + next if ($self->check_filter(section => 'blowerctrl', instance => $instance)); next if ($ctrl_state =~ /notPresent/i && $self->absent_problem(section => 'blowerctrl', instance => $instance)); $self->{output}->output_add(long_msg => sprintf("Blower controller '%s' state is %s.", diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm index a3c90d7a2..6136e4c72 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisfan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -38,9 +38,9 @@ my $mapping = { my $oid_chassisFansEntry = '.1.3.6.1.4.1.2.3.51.2.2.3.50.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_chassisFansEntry }; + push @{$self->{request}}, { oid => $oid_chassisFansEntry }; } sub check { @@ -48,14 +48,14 @@ sub check { $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')); + return if ($self->check_filter(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)); + next if ($self->check_filter(section => 'chassisfan', instance => $instance)); $self->{components}->{chassisfan}->{total}++; $self->{output}->output_add(long_msg => sprintf("Chassis fan '%s' is %s rpm [status: %s, instance: %s]", diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm index db8b4a56a..2c806e1b1 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/chassisstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,9 +64,9 @@ my %map_test_state = ( ); sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_mmBistAndChassisStatus, end => $oid_bistLogicalNetworkLink }; + push @{$self->{request}}, { oid => $oid_mmBistAndChassisStatus, end => $oid_bistLogicalNetworkLink }; } sub check { @@ -74,7 +74,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking chassis status"); $self->{components}->{chassisstatus} = {name => 'chassis-status', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'chassisstatus')); + return if ($self->check_filter(section => 'chassisstatus')); foreach my $name (sort keys %{$oids}) { if (!defined($self->{results}->{$oid_mmBistAndChassisStatus}->{$oids->{$name}})) { @@ -84,7 +84,7 @@ sub check { } my $value = $map_test_state{$self->{results}->{$oid_mmBistAndChassisStatus}->{$oids->{$name}}}; - next if ($self->check_exclude(section => 'chassisstatus', instance => $name)); + next if ($self->check_filter(section => 'chassisstatus', instance => $name)); $self->{components}->{chassisstatus}->{total}++; $self->{output}->output_add(long_msg => sprintf("Chassis status '%s' state is %s", diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm index 918cd655a..971ba0a45 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -43,9 +43,9 @@ my $mapping = { my $oid_fanPackEntry = '.1.3.6.1.4.1.2.3.51.2.2.6.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_fanPackEntry }; + push @{$self->{request}}, { oid => $oid_fanPackEntry }; } sub check { @@ -53,7 +53,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fanpack"); $self->{components}->{fanpack} = {name => 'fanpacks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fanpack')); + return if ($self->check_filter(section => 'fanpack')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanPackEntry}})) { next if ($oid !~ /^$mapping->{fanPackState}->{oid}\.(.*)$/); @@ -64,7 +64,7 @@ sub check { $self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits"); next; } - next if ($self->check_exclude(section => 'fanpack', instance => $instance)); + next if ($self->check_filter(section => 'fanpack', instance => $instance)); $self->{components}->{fanpack}->{total}++; $self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %s rpm [status: %s, instance: %s]", diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm index dd4fd6135..72c5998ce 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/powermodule.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -44,9 +44,9 @@ my $mapping = { my $oid_powerModuleHealthEntry = '.1.3.6.1.4.1.2.3.51.2.2.4.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_powerModuleHealthEntry, start => $mapping->{powerModuleExists}->{oid} }; + push @{$self->{request}}, { oid => $oid_powerModuleHealthEntry, start => $mapping->{powerModuleExists}->{oid} }; } sub check { @@ -54,14 +54,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power modules"); $self->{components}->{powermodule} = {name => 'power modules', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'powermodule')); + return if ($self->check_filter(section => 'powermodule')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerModuleHealthEntry}})) { next if ($oid !~ /^$mapping->{powerModuleState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerModuleHealthEntry}, instance => $instance); - next if ($self->check_exclude(section => 'powermodule', instance => $instance)); + next if ($self->check_filter(section => 'powermodule', instance => $instance)); next if ($result->{powerModuleExists} =~ /No/i && $self->absent_problem(section => 'powermodule', instance => $instance)); $self->{components}->{powermodule}->{total}++; diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm index 3d6c6b3f2..64b1251b1 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/switchmodule.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -36,9 +36,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{smHealthState}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{smHealthState}->{oid} }; } sub check { @@ -46,14 +46,14 @@ sub check { $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')); + return if ($self->check_filter(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); - next if ($self->check_exclude(section => 'switchmodule', instance => $instance)); + next if ($self->check_filter(section => 'switchmodule', instance => $instance)); $self->{components}->{switchmodule}->{total}++; $self->{output}->output_add(long_msg => sprintf("Switch module '%s' status is %s [instance: %s]", diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm index 4f4958292..db1b381e4 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/components/systemhealth.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my %map_systemhealth_state = ( ); sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_systemHealthStat }; + push @{$self->{request}}, { oid => $oid_systemHealthStat }; } sub check { @@ -44,8 +44,11 @@ sub check { $self->{output}->output_add(long_msg => "Checking system health"); $self->{components}->{systemhealth} = {name => 'system-health', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'systemhealth')); + return if ($self->check_filter(section => 'systemhealth')); + return if (!defined($self->{results}->{$oid_systemHealthStat}->{$oid_systemHealthStat . '.0'}) || + !defined($map_systemhealth_state{$self->{results}->{$oid_systemHealthStat}->{$oid_systemHealthStat . '.0'}})); + my $value = $map_systemhealth_state{$self->{results}->{$oid_systemHealthStat}->{$oid_systemHealthStat . '.0'}}; $self->{components}->{systemhealth}->{total}++; diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm index 1d939c6e7..70b1cfab2 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,74 +20,92 @@ package hardware::server::ibm::bladecenter::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - chassisstatus => [ - ['testSucceeded', 'OK'], - ['testFailed', 'CRITICAL'], - ], - systemhealth => [ - ['normal', 'OK'], - ['systemLevel', 'WARNING'], - ['nonCritical', 'WARNING'], - ['critical', 'CRITICAL'], - ], - powermodule => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['notAvailable', 'UNKNOWN'], - ], - 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'], - ['flashing', 'WARNING'], - ['communicationError', 'CRITICAL'], - ['notPresent', 'UNKNOWN'], - ], - blade => [ - ['unknown', 'UNKNOWN'], - ['good', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['kernelMode', 'WARNING'], - ['discovering', 'WARNING'], - ['commError', 'CRITICAL'], - ['noPower', 'WARNING'], - ['flashing', 'WARNING'], - ['initFailure', 'CRITICAL'], - ['insufficientPower', 'CRITICAL'], - ['powerDenied', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(blower|ambient|fanpack|chassisfan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + chassisstatus => [ + ['testSucceeded', 'OK'], + ['testFailed', 'CRITICAL'], + ], + systemhealth => [ + ['normal', 'OK'], + ['systemLevel', 'WARNING'], + ['nonCritical', 'WARNING'], + ['critical', 'CRITICAL'], + ], + powermodule => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['notAvailable', 'UNKNOWN'], + ], + 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'], + ['flashing', 'WARNING'], + ['communicationError', 'CRITICAL'], + ['notPresent', 'UNKNOWN'], + ], + blade => [ + ['unknown', 'UNKNOWN'], + ['good', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['kernelMode', 'WARNING'], + ['discovering', 'WARNING'], + ['commError', 'CRITICAL'], + ['noPower', 'WARNING'], + ['flashing', 'WARNING'], + ['initFailure', 'CRITICAL'], + ['insufficientPower', 'CRITICAL'], + ['powerDenied', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::server::ibm::bladecenter::snmp::mode::components'; + $self->{components_module} = ['ambient', 'powermodule', 'blade', 'blower', 'fanpack', 'chassisfan', 'systemhealth', 'chassisstatus', 'switchmodule']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -96,211 +114,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $self->{product_name} = undef; - $self->{serial} = undef; - $self->{romversion} = undef; - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - 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; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - 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::$_"; - 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 = "hardware::server::ibm::bladecenter::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ @@ -317,15 +136,15 @@ Which component to check (Default: 'all'). Can be: 'ambient', 'powermodule', 'fanpack', 'chassisfan', 'blower', 'blade', 'systemhealth', 'chassisstatus', 'switchmodule'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=blower,powermodule) -Can also exclude specific instance: --exclude=blower#1#,powermodule#2# +Exclude some parts (comma seperated list) (Example: --filter=blower --filter=powermodule) +Can also exclude specific instance: --filter=blower,1 =item B<--absent-problem> Return an error if an entity is not 'notAvailable' (default is skipping) (comma seperated list) -Can be specific or global: --absent-problem=powermodule#2# +Can be specific or global: --absent-problem=powermodule,2 =item B<--no-component> @@ -334,18 +153,18 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='blade,OK,unknown' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,treshold) +Set warning threshold (syntax: type,regexp,threshold) Example: --warning='ambient,mm,30' --warning='ambient,frontpanel,35' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,treshold) +Set critical threshold (syntax: type,regexp,threshold) Example: --critical='blower,1,50' =back diff --git a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm index 0842efad6..86748556e 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/ibm/hmc/ssh/mode/hardwareerrors.pm b/centreon-plugins/hardware/server/ibm/hmc/ssh/mode/hardwareerrors.pm index e8ca810e5..557ebe4a0 100644 --- a/centreon-plugins/hardware/server/ibm/hmc/ssh/mode/hardwareerrors.pm +++ b/centreon-plugins/hardware/server/ibm/hmc/ssh/mode/hardwareerrors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm b/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm index 6708a48ed..5e097bb3a 100644 --- a/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm +++ b/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/fan.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/fan.pm index 7e1451c0d..eea058f0c 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/fan.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/globalstatus.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/globalstatus.pm index e823506a2..b6d27bdb9 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/globalstatus.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/temperature.pm index 843f1a6d6..e3cd3a535 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/voltage.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/voltage.pm index 0a4c16300..21dc6ad5b 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/voltage.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/environment.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/environment.pm index a7b616e69..4d7d93ab0 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/environment.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -61,7 +61,6 @@ sub global { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; if ($self->{option_results}->{component} eq 'all') { diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/eventlog.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/eventlog.pm index b52c57680..e4a8d8521 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/eventlog.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/eventlog.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,7 +64,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/plugin.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/plugin.pm index 9978e241e..945df32d6 100644 --- a/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/disk.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/disk.pm index b87a889ee..ce8e8c80c 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/disk.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/fan.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/fan.pm index 0f7269a1f..953879388 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/fan.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/psu.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/psu.pm index 19ca73346..f4b696b96 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/psu.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/resources.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/resources.pm index 55ea093f1..cff03c05d 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/resources.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/resources.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/sensors.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/sensors.pm index fb639041f..b5523027c 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/sensors.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/sensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/si.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/si.pm index 8247712d1..9551de36d 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/si.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/si.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/temperature.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/temperature.pm index c21ddbf2c..e19b64d26 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/temperature.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/voltage.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/voltage.pm index d97a84d5a..67f852afc 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/voltage.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/components/showenvironment/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/lib/telnet.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/lib/telnet.pm index 13d4ade92..c1bae8d37 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/lib/telnet.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/lib/telnet.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm index 68ea4a0cf..5b4032742 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm index 078833ce2..3d95160e7 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm index 8afbfefbf..47bfe4709 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showboards.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showboards.pm index 268bd6774..a5164c789 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showboards.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showboards.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showenvironment.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showenvironment.pm index f60cd8273..8cb60f72b 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showenvironment.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showenvironment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -91,12 +91,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaults.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaults.pm index d0799bf82..54871f9a4 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaults.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaults.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaulty.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaulty.pm index 377d31e9b..daf996f9b 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaulty.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showfaulty.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showstatus.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showstatus.pm index 22f00c78f..33d9d0a6b 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showstatus.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/mode/showstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -73,12 +73,12 @@ sub check_options { $self->{overload_th} = []; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($status, $filter) = ($1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } push @{$self->{overload_th}}, {filter => $filter, status => $status}; diff --git a/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm index 53879d413..1e75cb330 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/server/sun/mseries/mode/domains.pm b/centreon-plugins/hardware/server/sun/mseries/mode/domains.pm index f0d19f6fa..afc3b87f0 100644 --- a/centreon-plugins/hardware/server/sun/mseries/mode/domains.pm +++ b/centreon-plugins/hardware/server/sun/mseries/mode/domains.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -54,7 +54,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_scfDomainErrorStatus = '.1.3.6.1.4.1.211.1.15.3.1.1.5.2.1.15'; diff --git a/centreon-plugins/hardware/server/sun/mseries/mode/hardware.pm b/centreon-plugins/hardware/server/sun/mseries/mode/hardware.pm index d23931459..4b747f801 100644 --- a/centreon-plugins/hardware/server/sun/mseries/mode/hardware.pm +++ b/centreon-plugins/hardware/server/sun/mseries/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -156,7 +156,6 @@ sub check_exclude { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_scfComponentErrorStatus = '.1.3.6.1.4.1.211.1.15.3.1.1.12.2.1.14'; diff --git a/centreon-plugins/hardware/server/sun/mseries/plugin.pm b/centreon-plugins/hardware/server/sun/mseries/plugin.pm index a2b417ede..919d870b0 100644 --- a/centreon-plugins/hardware/server/sun/mseries/plugin.pm +++ b/centreon-plugins/hardware/server/sun/mseries/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/hardware/server/sun/sfxxk/mode/boards.pm b/centreon-plugins/hardware/server/sun/sfxxk/mode/boards.pm index 80b1136f5..76d4f8584 100644 --- a/centreon-plugins/hardware/server/sun/sfxxk/mode/boards.pm +++ b/centreon-plugins/hardware/server/sun/sfxxk/mode/boards.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/sfxxk/mode/environment.pm b/centreon-plugins/hardware/server/sun/sfxxk/mode/environment.pm index a02bc988b..a4b5ea468 100644 --- a/centreon-plugins/hardware/server/sun/sfxxk/mode/environment.pm +++ b/centreon-plugins/hardware/server/sun/sfxxk/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/sfxxk/mode/failover.pm b/centreon-plugins/hardware/server/sun/sfxxk/mode/failover.pm index 1e5587d2d..6023329e2 100644 --- a/centreon-plugins/hardware/server/sun/sfxxk/mode/failover.pm +++ b/centreon-plugins/hardware/server/sun/sfxxk/mode/failover.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm b/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm index 6b499dff7..9d34441ea 100644 --- a/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm +++ b/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm new file mode 100644 index 000000000..021ccf08f --- /dev/null +++ b/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm @@ -0,0 +1,259 @@ +# +# Copyright 2016 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::ups::apc::snmp::mode::batterystatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("Battery status is '%s' [battery needs replace: %s]", $self->{result_values}->{status}, $self->{result_values}->{replace}); + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_upsBasicBatteryStatus'}; + $self->{result_values}->{replace} = $options{new_datas}->{$self->{instance} . '_upsAdvBatteryReplaceIndicator'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'upsBasicBatteryStatus' }, { name => 'upsAdvBatteryReplaceIndicator' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + { label => 'load', set => { + key_values => [ { name => 'upsAdvBatteryCapacity' } ], + output_template => 'Remaining capacity : %s %%', + perfdatas => [ + { label => 'load', value => 'upsAdvBatteryCapacity_absolute', template => '%s', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'time', set => { + key_values => [ { name => 'upsAdvBatteryRunTimeRemaining' } ], + output_template => 'Remaining time : %.2f minutes', + perfdatas => [ + { label => 'load_time', value => 'upsAdvBatteryRunTimeRemaining_absolute', template => '%.2f', + min => 0, unit => 'm' }, + ], + } + }, + { label => 'current', set => { + key_values => [ { name => 'upsAdvBatteryCurrent' } ], + output_template => 'Current : %s A', + perfdatas => [ + { label => 'current', value => 'upsAdvBatteryCurrent_absolute', template => '%s', + min => 0, unit => 'A' }, + ], + } + }, + { label => 'voltage', set => { + key_values => [ { name => 'upsAdvBatteryActualVoltage' } ], + output_template => 'Voltage : %s V', + perfdatas => [ + { label => 'voltage', value => 'upsAdvBatteryActualVoltage_absolute', template => '%s', + unit => 'V' }, + ], + } + }, + { label => 'temperature', set => { + key_values => [ { name => 'upsAdvBatteryTemperature' } ], + output_template => 'Temperature : %s C', + perfdatas => [ + { label => 'temperature', value => 'upsAdvBatteryTemperature_absolute', template => '%s', + unit => 'C'}, + ], + } + }, + ]; +} + +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 => + { + "unknown-status:s" => { name => 'unknown_status', default => '%{status} =~ /unknown/i' }, + "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /batteryLow/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{replace} =~ /yes/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_battery_status = ( + 1 => 'unknown', + 2 => 'batteryNormal', + 3 => 'batteryLow', +); +my %map_replace_status = ( + 1 => 'no', + 2 => 'yes', +); + +my $mapping = { + upsBasicBatteryStatus => { oid => '.1.3.6.1.4.1.318.1.1.1.2.1.1', map => \%map_battery_status }, + upsBasicBatteryTimeOnBattery => { oid => '.1.3.6.1.4.1.318.1.1.1.2.1.2' }, +}; +my $mapping2 = { + upsAdvBatteryCapacity => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.1' }, + upsAdvBatteryTemperature => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.2' }, + upsAdvBatteryRunTimeRemaining => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.3' }, + upsAdvBatteryReplaceIndicator => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.4', map => \%map_replace_status }, + upsAdvBatteryActualVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.8' }, + upsAdvBatteryCurrent => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.9' }, +}; +my $oid_upsBasicBattery = '.1.3.6.1.4.1.318.1.1.1.2.1'; +my $oid_upsAdvBattery = '.1.3.6.1.4.1.318.1.1.1.2.2'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = {}; + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_upsBasicBattery }, + { oid => $oid_upsAdvBattery }, + ], + nothing_quit => 1); + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_upsBasicBattery}, instance => '0'); + my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_upsAdvBattery}, instance => '0'); + + $result2->{upsAdvBatteryRunTimeRemaining} = sprintf("%.0f", $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60) if (defined($result2->{upsAdvBatteryRunTimeRemaining})); + + foreach my $name (keys %{$mapping}) { + $self->{global}->{$name} = $result->{$name}; + } + foreach my $name (keys %{$mapping2}) { + $self->{global}->{$name} = $result2->{$name}; + } +} + +1; + +__END__ + +=head1 MODE + +Check Battery Status and battery charge remaining. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status|load$' + +=item B<--unknown-status> + +Set warning threshold for status (Default: '%{status} =~ /unknown/i'). +Can used special variables like: %{status}, %{replace} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /batteryLow/i'). +Can used special variables like: %{status}, %{replace} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{replace} =~ /yes/i'). +Can used special variables like: %{status}, %{replace} + +=item B<--warning-*> + +Threshold warning. +Can be: 'load', 'voltage', 'current', 'temperature', 'time'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'load', 'voltage', 'current', 'temperature', 'time'. + +=back + +=cut diff --git a/centreon-plugins/hardware/ups/apc/snmp/plugin.pm b/centreon-plugins/hardware/ups/apc/snmp/plugin.pm new file mode 100644 index 000000000..5ecaf6988 --- /dev/null +++ b/centreon-plugins/hardware/ups/apc/snmp/plugin.pm @@ -0,0 +1,46 @@ +# +# 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::ups::apc::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} = '0.1'; + %{$self->{modes}} = ( + 'battery-status' => 'hardware::ups::apc::snmp::mode::batterystatus', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check UPS APC through SNMP (POWERNET-MIB) + +=cut diff --git a/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm index 93f5416b4..f223c8f5e 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -69,7 +69,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_upsmgBattery = '.1.3.6.1.4.1.705.1.5'; diff --git a/centreon-plugins/hardware/ups/mge/snmp/mode/environment.pm b/centreon-plugins/hardware/ups/mge/snmp/mode/environment.pm index 48b70b4b3..4c157a606 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/environment.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -118,7 +118,6 @@ sub manage_counters { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/hardware/ups/mge/snmp/mode/inputlines.pm b/centreon-plugins/hardware/ups/mge/snmp/mode/inputlines.pm index 6d823b6fa..15d6a39c2 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/inputlines.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/inputlines.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -161,7 +161,6 @@ sub manage_counters { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/hardware/ups/mge/snmp/mode/outputlines.pm b/centreon-plugins/hardware/ups/mge/snmp/mode/outputlines.pm index e35f099d1..ae2f0a6ae 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/outputlines.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/outputlines.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -193,7 +193,6 @@ sub manage_counters { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/hardware/ups/mge/snmp/mode/outputsource.pm b/centreon-plugins/hardware/ups/mge/snmp/mode/outputsource.pm index e1d1db114..34cccd84e 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/outputsource.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/outputsource.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -62,7 +62,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $result = $self->{snmp}->get_table(oid => $oid_upsmgOutput, start => $oid_upsmgOutputOnBatteryEntry, nothing_quit => 1); diff --git a/centreon-plugins/hardware/ups/mge/snmp/plugin.pm b/centreon-plugins/hardware/ups/mge/snmp/plugin.pm index 698331f89..5c685a232 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/ups/powerware/snmp/mode/alarms.pm b/centreon-plugins/hardware/ups/powerware/snmp/mode/alarms.pm index f6b1b1fd0..109611366 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/alarms.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/alarms.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -99,7 +99,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/hardware/ups/powerware/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/powerware/snmp/mode/batterystatus.pm index e7def40a2..002d01185 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/batterystatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,7 +64,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_xupsBattery = '.1.3.6.1.4.1.534.1.2'; diff --git a/centreon-plugins/hardware/ups/powerware/snmp/mode/environment.pm b/centreon-plugins/hardware/ups/powerware/snmp/mode/environment.pm index ba5a550fa..80c0c4714 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/environment.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -121,7 +121,6 @@ sub manage_counters { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/hardware/ups/powerware/snmp/mode/inputlines.pm b/centreon-plugins/hardware/ups/powerware/snmp/mode/inputlines.pm index b516f101b..8fffa3153 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/inputlines.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/inputlines.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -181,7 +181,6 @@ sub manage_counters { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/hardware/ups/powerware/snmp/mode/outputlines.pm b/centreon-plugins/hardware/ups/powerware/snmp/mode/outputlines.pm index 46e970478..fddc1270a 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/outputlines.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/outputlines.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -195,7 +195,6 @@ sub manage_counters { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/hardware/ups/powerware/snmp/mode/outputsource.pm b/centreon-plugins/hardware/ups/powerware/snmp/mode/outputsource.pm index 9e4e4c665..72d16040c 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/outputsource.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/outputsource.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -69,12 +69,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ('osource', $1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -84,7 +84,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $result = $self->{snmp}->get_leef(oids => [$oid_xupsOutputSource], nothing_quit => 1); diff --git a/centreon-plugins/hardware/ups/powerware/snmp/plugin.pm b/centreon-plugins/hardware/ups/powerware/snmp/plugin.pm index cbce7cf9c..c17114159 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/alarms.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/alarms.pm index 2aaad3e4d..b90721176 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/alarms.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/alarms.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,7 +45,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_upsAlarmsPresent = '.1.3.6.1.2.1.33.1.6.1.0'; diff --git a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm index 3c4ecc8e9..6cf0446e2 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -63,7 +63,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_upsBattery = '.1.3.6.1.2.1.33.1.2'; diff --git a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm index c32268205..579e594c7 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,48 +20,63 @@ package hardware::ups::standard::rfc1628::snmp::mode::inputlines; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -my %oids = ( - '.1.3.6.1.2.1.33.1.3.3.1.2' => { counter => 'frequence' }, # in dH upsInputFrequency - '.1.3.6.1.2.1.33.1.3.3.1.3' => { counter => 'voltage' }, # in Volt upsInputVoltage - '.1.3.6.1.2.1.33.1.3.3.1.4' => { counter => 'current' }, # in dA upsInputCurrent - '.1.3.6.1.2.1.33.1.3.3.1.5' => { counter => 'power' }, # in Watt upsInputTruePower -); +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'line', type => 1, cb_prefix_output => 'prefix_line_output', message_multiple => 'All input lines are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{line} = [ + { label => 'frequence', set => { + key_values => [ { name => 'upsInputFrequency' }, { name => 'display' } ], + output_template => 'Frequence : %.2f Hz', + perfdatas => [ + { label => 'frequence', value => 'upsInputFrequency_absolute', template => '%s', + unit => 'Hz', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'voltage', set => { + key_values => [ { name => 'upsInputVoltage' }, { name => 'display' } ], + output_template => 'Voltage : %.2f V', + perfdatas => [ + { label => 'voltage', value => 'upsInputVoltage_absolute', template => '%s', + unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'current', set => { + key_values => [ { name => 'upsInputCurrent' }, { name => 'display' } ], + output_template => 'Current : %.2f A', + perfdatas => [ + { label => 'current', value => 'upsInputCurrent_absolute', template => '%s', + unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'power', set => { + key_values => [ { name => 'upsInputTruePower' }, { name => 'display' } ], + output_template => 'Power : %.2f W', + perfdatas => [ + { label => 'power', value => 'upsInputTruePower_absolute', template => '%s', + unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} -my $maps_counters = { - frequence => { thresholds => { - warning_frequence => { label => 'warning-frequence', exit_value => 'warning' }, - critical_frequence => { label => 'critical-frequence', exit_value => 'critical' }, - }, - output_msg => 'Frequence : %.2f Hz', - factor => 0.1, unit => 'Hz', - }, - voltage => { thresholds => { - warning_voltage => { label => 'warning-voltage', exit_value => 'warning' }, - critical_voltage => { label => 'critical-voltage', exit_value => 'critical' }, - }, - output_msg => 'Voltage : %.2f V', - factor => 1, unit => 'V', - }, - current => { thresholds => { - warning_current => { label => 'warning-current', exit_value => 'warning' }, - critical_current => { label => 'critical-current', exit_value => 'critical' }, - }, - output_msg => 'Current : %.2f A', - factor => 0.1, unit => 'A', - }, - power => { thresholds => { - warning_power => { label => 'warning-power', exit_value => 'warning' }, - critical_power => { label => 'critical-power', exit_value => 'critical' }, - }, - output_msg => 'Power : %.2f W', - factor => 1, unit => 'W', - }, -}; +sub prefix_line_output { + my ($self, %options) = @_; + + return "Input Line '" . $options{instance_value}->{display} . "' "; +} sub new { my ($class, %options) = @_; @@ -72,110 +87,33 @@ sub new { $options{options}->add_options(arguments => { }); - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - $options{options}->add_options(arguments => { - $maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name }, - }); - } - } - - $self->{counters_value} = {}; - $self->{instances_done} = {}; + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); +my $oids = { + '.1.3.6.1.2.1.33.1.3.3.1.2' => { name => 'upsInputFrequency', factor => 0.1 }, # in dH + '.1.3.6.1.2.1.33.1.3.3.1.3' => { name => 'upsInputVoltage', factor => 1 }, # in Volt + '.1.3.6.1.2.1.33.1.3.3.1.4' => { name => 'upsInputCurrent', factor => 0.1 }, # in dA + '.1.3.6.1.2.1.33.1.3.3.1.5' => { name => 'upsInputTruePower', factor => 1 }, # in Watt +}; - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'."); - $self->{output}->option_exit(); - } - } - } -} - -sub build_values { +sub manage_selection { my ($self, %options) = @_; - my $counters_value = {}; - my $instance = undef; - - foreach my $oid (keys %oids) { - if ($options{current} =~ /^$oid\.(.*)/) { - $instance = $1; - last; - } - } - - # Skip already done - if (!defined($instance) || defined($self->{instances_done}->{$instance})) { - return 0; - } - - $self->{instances_done}->{$instance} = 1; - $self->{counters_value}->{$instance} = {}; - foreach my $oid (keys %oids) { - $self->{counters_value}->{$instance}->{$oids{$oid}->{counter}} = defined($options{result}->{$oid . '.' . $instance}) ? $options{result}->{$oid . '.' . $instance} : 0; - } -} -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - my $oid_upsInputEntry = '.1.3.6.1.2.1.33.1.3.3.1'; - my $result = $self->{snmp}->get_table(oid => $oid_upsInputEntry, nothing_quit => 1); - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { - $self->build_values(current => $key, result => $result); - } - - my $num = scalar(keys %{$self->{instances_done}}); - foreach my $instance (keys %{$self->{instances_done}}) { - my $instance_output = $instance; - $instance_output =~ s/\./#/g; + my $results = $options{snmp}->get_table(oid => $oid_upsInputEntry, nothing_quit => 1); + + $self->{line} = {}; + foreach my $oid (keys %{$results}) { + next if ($oid !~ /^(.*)\.(.*?)\.(.*?)$/); + my ($base, $instance) = ($1 . '.' . $2, $3); + next if (!defined($oids->{$base})); + next if ($results->{$oid} !~ /\d/ || $results->{$oid} == 0); - my @exits; - foreach (keys %{$maps_counters}) { - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} =~ /\d/ && $self->{counters_value}->{$instance}->{$_} != 0) { - push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); - } - } - } - - my $exit = $self->{output}->get_most_critical(status => [ @exits ]); - my $extra_label = ''; - $extra_label = '_' . $instance_output if ($num > 1); - - my $str_output = "Input Line '$instance_output' "; - my $str_append = ''; - foreach (keys %{$maps_counters}) { - next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} !~ /\d/ || $self->{counters_value}->{$instance}->{$_} == 0); - - $str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}); - $str_append = ', '; - my ($warning, $critical); - foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { - $warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning'); - $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); - } - - $self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit}, - value => sprintf("%.2f", $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}), - warning => $warning, - critical => $critical); - } - $self->{output}->output_add(severity => $exit, - short_msg => $str_output); + $self->{line}->{$instance} = { display => $instance } if (!defined($self->{line}->{$instance})); + $self->{line}->{$instance}->{$oids->{$base}->{name}} = $results->{$oid} * $oids->{$base}->{factor}; } - - $self->{output}->display(); - $self->{output}->exit(); } 1; @@ -188,6 +126,11 @@ Check Input lines metrics (frequence, voltage, current and true power). =over 8 +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^power$' + =item B<--warning-*> Threshold warning. diff --git a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm index d1efb86c4..dba10370c 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -165,7 +165,6 @@ sub stdev { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_upsOutputEntry = '.1.3.6.1.2.1.33.1.4.4.1'; diff --git a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputsource.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputsource.pm index c56fea38f..800f171e2 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputsource.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputsource.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_upsOutputSource = '.1.3.6.1.2.1.33.1.4.1.0'; diff --git a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/plugin.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/plugin.pm index 9afa4fcea..d7c5a53d1 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/3com/snmp/mode/components/fan.pm b/centreon-plugins/network/3com/snmp/mode/components/fan.pm index 0c91df2cf..5c8939566 100644 --- a/centreon-plugins/network/3com/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/3com/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/3com/snmp/mode/components/psu.pm b/centreon-plugins/network/3com/snmp/mode/components/psu.pm index 9fda71e7b..99a4093bc 100644 --- a/centreon-plugins/network/3com/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/3com/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/3com/snmp/mode/cpu.pm b/centreon-plugins/network/3com/snmp/mode/cpu.pm index af8b72602..8191a5234 100644 --- a/centreon-plugins/network/3com/snmp/mode/cpu.pm +++ b/centreon-plugins/network/3com/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/3com/snmp/mode/hardware.pm b/centreon-plugins/network/3com/snmp/mode/hardware.pm index a4bb080b3..e8c1ff33a 100644 --- a/centreon-plugins/network/3com/snmp/mode/hardware.pm +++ b/centreon-plugins/network/3com/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/3com/snmp/mode/memory.pm b/centreon-plugins/network/3com/snmp/mode/memory.pm index c54fdd0d5..f2ddf4ab4 100644 --- a/centreon-plugins/network/3com/snmp/mode/memory.pm +++ b/centreon-plugins/network/3com/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/3com/snmp/plugin.pm b/centreon-plugins/network/3com/snmp/plugin.pm index 132c0a2ff..53e48b2d6 100644 --- a/centreon-plugins/network/3com/snmp/plugin.pm +++ b/centreon-plugins/network/3com/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/aerohive/snmp/mode/connectedusers.pm b/centreon-plugins/network/aerohive/snmp/mode/connectedusers.pm new file mode 100644 index 000000000..e4839dd42 --- /dev/null +++ b/centreon-plugins/network/aerohive/snmp/mode/connectedusers.pm @@ -0,0 +1,142 @@ +# +# Copyright 2016 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::aerohive::snmp::mode::connectedusers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total Users : %s', + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + unit => 'users', min => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{ssid} = [ + { label => 'ssid', set => { + key_values => [ { name => 'total' }, { name => 'display' } ], + output_template => 'users : %s', + perfdatas => [ + { label => 'ssid', value => 'total_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_ssid_output { + my ($self, %options) = @_; + + return "SSID '" . $options{instance_value}->{display} . "' "; +} + +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-ssid:s" => { name => 'filter_ssid' }, + }); + + return $self; +} + +my $oid_ahSSIDNAME = '.1.3.6.1.4.1.26928.1.1.1.2.1.1.1.2'; +my $oid_ahClientSSID = '.1.3.6.1.4.1.26928.1.1.1.2.1.2.1.10'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = { total => 0 }; + $self->{ssid} = {}; + + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_ahSSIDNAME }, + { oid => $oid_ahClientSSID }, + ], + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}->{ $oid_ahSSIDNAME }}) { + my $ssid = $self->{results}->{ $oid_ahSSIDNAME }->{$oid}; + if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' && + $ssid !~ /$self->{option_results}->{filter_ssid}/) { + $self->{output}->output_add(long_msg => "skipping ssid " . $ssid . " : no matching filter.", debug => 1); + next; + } + $self->{ssid}->{$ssid} = { display => $ssid, total => 0 } if (!defined($self->{ssid}->{$ssid})); + } + + foreach my $oid (keys %{$self->{results}->{ $oid_ahClientSSID }}) { + $self->{global}->{total}++; + my $ssid = $self->{results}->{ $oid_ahClientSSID }->{$oid}; + $self->{ssid}->{$ssid}->{total}++ if (defined($self->{ssid}->{$ssid})); + } + +} + +1; + +__END__ + +=head1 MODE + +Check number of connected users (total and by SSID). + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='ssid$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'total', 'ssid' + +=item B<--critical-*> + +Threshold critical. +Can be: 'total', 'ssid' + +=item B<--filter-ssid> + +Filter by SSID (can be a regexp). + +=back + +=cut diff --git a/centreon-plugins/network/aerohive/snmp/plugin.pm b/centreon-plugins/network/aerohive/snmp/plugin.pm new file mode 100644 index 000000000..02a736b20 --- /dev/null +++ b/centreon-plugins/network/aerohive/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::aerohive::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}} = ( + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'connected-users' => 'network::aerohive::snmp::mode::connectedusers', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check aerohive equipment in SNMP + +=cut diff --git a/centreon-plugins/network/alcatel/common/mode/components/backplane.pm b/centreon-plugins/network/alcatel/common/mode/components/backplane.pm index 805f01b89..86bbddbd5 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/backplane.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/backplane.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/chassis.pm b/centreon-plugins/network/alcatel/common/mode/components/chassis.pm index eb6119884..13104cd9d 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/chassis.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/chassis.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/container.pm b/centreon-plugins/network/alcatel/common/mode/components/container.pm index 3ad399a0d..e4b0e561c 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/container.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/container.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/fan.pm b/centreon-plugins/network/alcatel/common/mode/components/fan.pm index 94e71a221..72ed84b52 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/fan.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/module.pm b/centreon-plugins/network/alcatel/common/mode/components/module.pm index 802e61a43..a6a1ac992 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/module.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/module.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/other.pm b/centreon-plugins/network/alcatel/common/mode/components/other.pm index 3c4fb24be..52f07d024 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/other.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/other.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/port.pm b/centreon-plugins/network/alcatel/common/mode/components/port.pm index 352791bf0..3d8a638d9 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/port.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/port.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm b/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm index 3d215e61b..75a6591ba 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,7 +95,7 @@ sub check { foreach (@oper_conditions) { if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { $self->{output}->output_add(severity => $$_[1], - short_msg => sprintf("power supply '%s/%s/%s' oeprationnal status is %s", + short_msg => sprintf("power supply '%s/%s/%s' operationnal status is %s", $name, $descr, $instance, $phys_oper_status{$oper_status})); last; } @@ -103,4 +103,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/centreon-plugins/network/alcatel/common/mode/components/resources.pm b/centreon-plugins/network/alcatel/common/mode/components/resources.pm index 99686e066..f8032e6fd 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/resources.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/resources.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/sensor.pm b/centreon-plugins/network/alcatel/common/mode/components/sensor.pm index c33efa030..77c627711 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/sensor.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/sensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/stack.pm b/centreon-plugins/network/alcatel/common/mode/components/stack.pm index d388fca0c..2ec77518d 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/stack.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/stack.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/components/unknown.pm b/centreon-plugins/network/alcatel/common/mode/components/unknown.pm index c3fed10aa..ae3e3fcd8 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/unknown.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/unknown.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/common/mode/cpu.pm b/centreon-plugins/network/alcatel/common/mode/cpu.pm index fd5127dea..11863cf23 100644 --- a/centreon-plugins/network/alcatel/common/mode/cpu.pm +++ b/centreon-plugins/network/alcatel/common/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,7 +95,6 @@ sub check_cpu { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_healthDeviceCpu1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.14'; # it's '.0' but it's for walk multiple diff --git a/centreon-plugins/network/alcatel/common/mode/flashmemory.pm b/centreon-plugins/network/alcatel/common/mode/flashmemory.pm index 0c299fcf9..da23ce927 100644 --- a/centreon-plugins/network/alcatel/common/mode/flashmemory.pm +++ b/centreon-plugins/network/alcatel/common/mode/flashmemory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_chasSupervisionFlashMemEntry = '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.9.1'; diff --git a/centreon-plugins/network/alcatel/common/mode/hardware.pm b/centreon-plugins/network/alcatel/common/mode/hardware.pm index 182c0794e..7d5cfe461 100644 --- a/centreon-plugins/network/alcatel/common/mode/hardware.pm +++ b/centreon-plugins/network/alcatel/common/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -137,7 +137,6 @@ sub component { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{results} = $self->{snmp}->get_multiple_table(oids => [ diff --git a/centreon-plugins/network/alcatel/common/mode/memory.pm b/centreon-plugins/network/alcatel/common/mode/memory.pm index b7e6e76be..7b9c90966 100644 --- a/centreon-plugins/network/alcatel/common/mode/memory.pm +++ b/centreon-plugins/network/alcatel/common/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,7 +95,6 @@ sub check_memory { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_healthDeviceMemory1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.10'; # it's '.0' but it's for walk multiple diff --git a/centreon-plugins/network/alcatel/isam/snmp/mode/vlantraffic.pm b/centreon-plugins/network/alcatel/isam/snmp/mode/vlantraffic.pm index 5eed96cf3..ef326e8e1 100644 --- a/centreon-plugins/network/alcatel/isam/snmp/mode/vlantraffic.pm +++ b/centreon-plugins/network/alcatel/isam/snmp/mode/vlantraffic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/isam/snmp/plugin.pm b/centreon-plugins/network/alcatel/isam/snmp/plugin.pm index a61fb8ce8..0b6dc033c 100644 --- a/centreon-plugins/network/alcatel/isam/snmp/plugin.pm +++ b/centreon-plugins/network/alcatel/isam/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm b/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm index 356ead358..1779f1ad3 100644 --- a/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm +++ b/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.5'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/alcatel/oxe/snmp/mode/domainusage.pm b/centreon-plugins/network/alcatel/oxe/snmp/mode/domainusage.pm index 72bc90ec7..16c57e5bc 100644 --- a/centreon-plugins/network/alcatel/oxe/snmp/mode/domainusage.pm +++ b/centreon-plugins/network/alcatel/oxe/snmp/mode/domainusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxrole.pm b/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxrole.pm index e44caafdd..feb0e3e6c 100644 --- a/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxrole.pm +++ b/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxrole.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxstate.pm b/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxstate.pm index 42ed5eca0..c7007d96b 100644 --- a/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxstate.pm +++ b/centreon-plugins/network/alcatel/oxe/snmp/mode/pbxstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/alcatel/oxe/snmp/plugin.pm b/centreon-plugins/network/alcatel/oxe/snmp/plugin.pm index 9628ab4b8..cad635675 100644 --- a/centreon-plugins/network/alcatel/oxe/snmp/plugin.pm +++ b/centreon-plugins/network/alcatel/oxe/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/arkoon/plugin.pm b/centreon-plugins/network/arkoon/plugin.pm index 2cda06cba..975992c18 100644 --- a/centreon-plugins/network/arkoon/plugin.pm +++ b/centreon-plugins/network/arkoon/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/aruba/standard/snmp/plugin.pm b/centreon-plugins/network/aruba/standard/snmp/plugin.pm index eb7d82c95..a52067a3f 100644 --- a/centreon-plugins/network/aruba/standard/snmp/plugin.pm +++ b/centreon-plugins/network/aruba/standard/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/atrica/snmp/mode/connections.pm b/centreon-plugins/network/atrica/snmp/mode/connections.pm index 05283c40a..667d3e69a 100644 --- a/centreon-plugins/network/atrica/snmp/mode/connections.pm +++ b/centreon-plugins/network/atrica/snmp/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/atrica/snmp/mode/listconnections.pm b/centreon-plugins/network/atrica/snmp/mode/listconnections.pm index 3798d233d..0576c6ba6 100644 --- a/centreon-plugins/network/atrica/snmp/mode/listconnections.pm +++ b/centreon-plugins/network/atrica/snmp/mode/listconnections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/atrica/snmp/plugin.pm b/centreon-plugins/network/atrica/snmp/plugin.pm index ffdf9064f..da1181895 100644 --- a/centreon-plugins/network/atrica/snmp/plugin.pm +++ b/centreon-plugins/network/atrica/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/bluecoat/snmp/mode/clientconnections.pm b/centreon-plugins/network/bluecoat/snmp/mode/clientconnections.pm index e96fdb85c..7ad28f9c4 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/clientconnections.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/clientconnections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.3.1.0', diff --git a/centreon-plugins/network/bluecoat/snmp/mode/clientrequests.pm b/centreon-plugins/network/bluecoat/snmp/mode/clientrequests.pm index 77a38ddf0..18c53c8fe 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/clientrequests.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/clientrequests.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,137 +20,112 @@ package network::bluecoat::snmp::mode::clientrequests; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::statefile; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_output' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'hits', set => { + key_values => [ { name => 'client_http_requests', diff => 1 }, { name => 'client_http_hits', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'hits' }, + output_template => 'Hits = %.2f %%', output_use => 'hits_prct', + perfdatas => [ + { label => 'hits', value => 'hits_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'partial-hits', set => { + key_values => [ { name => 'client_http_requests', diff => 1 }, { name => 'client_http_partial_hits', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'partial_hits' }, + output_template => 'Partial Hits = %.2f %%', output_use => 'partial_hits_prct', + perfdatas => [ + { label => 'partial_hits', value => 'partial_hits_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'misses', set => { + key_values => [ { name => 'client_http_requests', diff => 1 }, { name => 'client_http_misses', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'misses' }, + output_template => 'Misses = %.2f %%', output_use => 'misses_prct', + perfdatas => [ + { label => 'misses', value => 'misses_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'errors', set => { + key_values => [ { name => 'client_http_requests', diff => 1 }, { name => 'client_http_errors', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'errors' }, + output_template => 'Errors = %.2f %%', output_use => 'errors_prct', + perfdatas => [ + { label => 'errors', value => 'errors_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Client Requests: "; +} + +sub custom_data_calc { + my ($self, %options) = @_; + + my $label = $options{extra_options}->{label_ref}; + my $delta_value = $options{new_datas}->{$self->{instance} . '_client_http_' . $label} - $options{old_datas}->{$self->{instance} . '_client_http_' . $label}; + my $delta_total = $options{new_datas}->{$self->{instance} . '_client_http_requests'} - $options{old_datas}->{$self->{instance} . '_client_http_requests'}; + + $self->{result_values}->{$label . '_prct'} = 0; + if ($delta_total > 0) { + $self->{result_values}->{$label . '_prct'} = $delta_value * 100 / $delta_total; + } + return 0; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning-errors:s" => { name => 'warning_errors' }, - "critical-errors:s" => { name => 'critical_errors' }, - "warning-misses:s" => { name => 'warning_misses' }, - "critical-misses:s" => { name => 'critical_misses' }, }); - $self->{statefile_value} = centreon::plugins::statefile->new(%options); - + return $self; } -sub check_options { +sub manage_selection { my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning_errors', value => $self->{option_results}->{warning_errors})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning 'errors' threshold '" . $self->{option_results}->{warning_errors} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_errors', value => $self->{option_results}->{critical_errors})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical 'errors' threshold '" . $self->{option_results}->{critical_errors} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning_misses', value => $self->{option_results}->{warning_misses})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning 'misses' threshold '" . $self->{option_results}->{warning_misses} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_misses', value => $self->{option_results}->{critical_misses})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical 'misses' threshold '" . $self->{option_results}->{critical_misses} . "'."); - $self->{output}->option_exit(); - } - - $self->{statefile_value}->check_options(%options); -} -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - $self->{snmp_port} = $self->{snmp}->get_port(); - - if ($self->{snmp}->is_snmpv1()) { + if ($options{snmp}->is_snmpv1()) { $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); $self->{output}->option_exit(); } + my $result = $options{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.1.1.0', + '.1.3.6.1.4.1.3417.2.11.3.1.1.2.0', + '.1.3.6.1.4.1.3417.2.11.3.1.1.3.0', + '.1.3.6.1.4.1.3417.2.11.3.1.1.4.0', + '.1.3.6.1.4.1.3417.2.11.3.1.1.5.0'], nothing_quit => 1); - $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); - my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.1.1.0', - '.1.3.6.1.4.1.3417.2.11.3.1.1.2.0', - '.1.3.6.1.4.1.3417.2.11.3.1.1.3.0', - '.1.3.6.1.4.1.3417.2.11.3.1.1.4.0', - '.1.3.6.1.4.1.3417.2.11.3.1.1.5.0'], nothing_quit => 1); - - my $new_datas = {}; - my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp'); - my $old_client_http_requests = $self->{statefile_value}->get(name => 'client_http_requests'); - my $old_client_http_hits = $self->{statefile_value}->get(name => 'client_http_hits'); - my $old_client_http_partial_hits = $self->{statefile_value}->get(name => 'client_http_partial_hits'); - my $old_client_http_misses = $self->{statefile_value}->get(name => 'client_http_misses'); - my $old_client_http_errors = $self->{statefile_value}->get(name => 'client_http_errors'); - - $new_datas->{last_timestamp} = time(); - $new_datas->{client_http_requests} = $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.1.0'}; - $new_datas->{client_http_hits} = $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.2.0'}; - $new_datas->{client_http_partial_hits} = $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.3.0'}; - $new_datas->{client_http_misses} = $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.4.0'}; - $new_datas->{client_http_errors} = $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.5.0'}; + $self->{cache_name} = "bluecoat_" . $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->{statefile_value}->write(data => $new_datas); - - if (!defined($old_timestamp) || !defined($old_client_http_misses)) { - $self->{output}->output_add(severity => 'OK', - short_msg => "Buffer creation..."); - $self->{output}->display(); - $self->{output}->exit(); - } - - if ($new_datas->{client_http_requests} < $old_client_http_requests) { - # We set 0. Has reboot. - $old_client_http_requests = 0; - $old_client_http_hits = 0; - $old_client_http_partial_hits = 0; - $old_client_http_misses = 0; - $old_client_http_errors = 0; - } - - my $delta_http_requests = $new_datas->{client_http_requests} - $old_client_http_requests; - my $prct_misses = sprintf("%.2f", ($new_datas->{client_http_misses} - $old_client_http_misses) * 100 / $delta_http_requests); - my $prct_hits = sprintf("%.2f", ($new_datas->{client_http_hits} - $old_client_http_hits) * 100 / $delta_http_requests); - my $prct_partial_hits = sprintf("%.2f", ($new_datas->{client_http_partial_hits} - $old_client_http_partial_hits) * 100 / $delta_http_requests); - my $prct_errors = sprintf("%.2f", ($new_datas->{client_http_errors} - $old_client_http_errors) * 100 / $delta_http_requests); - - my $exit1 = $self->{perfdata}->threshold_check(value => $prct_errors, threshold => [ { label => 'critical_errors', 'exit_litteral' => 'critical' }, { label => 'warning_errors', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $prct_misses, threshold => [ { label => 'critical_misses', 'exit_litteral' => 'critical' }, { label => 'warning_misses', exit_litteral => 'warning' } ]); - my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - - $self->{output}->output_add(severity => $exit, - short_msg => "Client Requests: Hits = $prct_hits%, Partial Hits = $prct_partial_hits%, Misses = $prct_misses%, Errors = $prct_errors%"); - $self->{output}->perfdata_add(label => 'hits', unit => '%', - value => $prct_hits, - min => 0); - $self->{output}->perfdata_add(label => 'partial_hits', unit => '%', - value => $prct_partial_hits, - min => 0); - $self->{output}->perfdata_add(label => 'misses', unit => '%', - value => $prct_misses, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_misses'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_misses'), - min => 0); - $self->{output}->perfdata_add(label => 'errors', unit => '%', - value => $prct_errors, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_errors'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_errors'), - min => 0); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{global} = { client_http_requests => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.1.0'}, + client_http_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.2.0'}, + client_http_partial_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.3.0'}, + client_http_misses => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.4.0'}, + client_http_errors => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.5.0'} }; } 1; @@ -163,21 +138,20 @@ Check http client requests (in percent by type: hit, partial, misses, errors) =over 8 -=item B<--warning-errors> +=item B<--filter-counters> -Threshold warning of client http errors in percent. +Only display some counters (regexp can be used). +Example: --filter-counters='errors' -=item B<--critical-errors> +=item B<--warning-*> -Threshold critical of client http errors in percent. +Threshold warning. +Can be: errors (%), hits (%), partial-hits (%), misses (%). -=item B<--warning-misses> +=item B<--critical-*> -Threshold warning of client http misses in percent. - -=item B<--critical-misses> - -Threshold critial of client http misses in percent. +Threshold critical. +Can be: errors (%), hits (%), partial-hits (%), misses (%). =back diff --git a/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm b/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm index 857d3fa6a..abc9d3f77 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -70,7 +70,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/bluecoat/snmp/mode/components/disk.pm b/centreon-plugins/network/bluecoat/snmp/mode/components/disk.pm index 4f481c016..27926b54f 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/components/disk.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/components/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -44,9 +44,9 @@ my $mapping = { my $oid_deviceDiskValueEntry = '.1.3.6.1.4.1.3417.2.2.1.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_deviceDiskValueEntry }; + push @{$self->{request}}, { oid => $oid_deviceDiskValueEntry }; } sub check { diff --git a/centreon-plugins/network/bluecoat/snmp/mode/components/sensor.pm b/centreon-plugins/network/bluecoat/snmp/mode/components/sensor.pm index 73caaff1a..cc257cfd4 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/components/sensor.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/components/sensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,9 +66,9 @@ my $mapping = { my $oid_deviceSensorValueEntry = '.1.3.6.1.4.1.3417.2.1.1.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_deviceSensorValueEntry }; + push @{$self->{request}}, { oid => $oid_deviceSensorValueEntry }; } sub check { diff --git a/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm b/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm index 5fe803d9d..6252f2d40 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -60,7 +60,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/bluecoat/snmp/mode/disk.pm b/centreon-plugins/network/bluecoat/snmp/mode/disk.pm index 061e815e1..f0d8aa4ef 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/disk.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $disk_num = 1; diff --git a/centreon-plugins/network/bluecoat/snmp/mode/hardware.pm b/centreon-plugins/network/bluecoat/snmp/mode/hardware.pm index af39b7603..e96ca16e9 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/hardware.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,48 +20,66 @@ package network::bluecoat::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - sensor_opstatus => [ - ['ok', 'OK'], - ['unavailable', 'UNKNOWN'], - ['nonoperational', 'UNKNOWN'], - ], - sensor => [ - ['ok', 'OK'], - ['unknown', 'UNKNOWN'], - ['nonInstalled', 'OK'], - ['voltageLowWarning', 'WARNING'], - ['voltageLowCritical', 'CRITICAL'], - ['noPower', 'CRITICAL'], - ['voltageHighWarning', 'WARNING'], - ['voltageHighCritical', 'CRITICAL'], - ['voltageHighSevere', 'CRITICAL'], - ['temperatureHighWarning', 'WARNING'], - ['temperatureHighCritical', 'CRITICAL'], - ['temperatureHighSevere', 'CRITICAL'], - ['fanSlowWarning', 'WARNING'], - ['fanSlowCritical', 'CRITICAL'], - ['fanStopped', 'CRITICAL'], - ], - disk => [ - ['present', 'OK'], - ['initializing', 'OK'], - ['inserted', 'OK'], - ['offline', 'WARNING'], - ['removed', 'WARNING'], - ['notpresent', 'OK'], - ['empty', 'WARNING'], - ['ioerror', 'CRITICAL'], - ['unusable', 'CRITICAL'], - ['unknown', 'UNKNOWN'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(sensor|disk|sensor_opstatus)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^sensor$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + sensor_opstatus => [ + ['ok', 'OK'], + ['unavailable', 'UNKNOWN'], + ['nonoperational', 'UNKNOWN'], + ], + sensor => [ + ['ok', 'OK'], + ['unknown', 'UNKNOWN'], + ['nonInstalled', 'OK'], + ['voltageLowWarning', 'WARNING'], + ['voltageLowCritical', 'CRITICAL'], + ['noPower', 'CRITICAL'], + ['voltageHighWarning', 'WARNING'], + ['voltageHighCritical', 'CRITICAL'], + ['voltageHighSevere', 'CRITICAL'], + ['temperatureHighWarning', 'WARNING'], + ['temperatureHighCritical', 'CRITICAL'], + ['temperatureHighSevere', 'CRITICAL'], + ['fanSlowWarning', 'WARNING'], + ['fanSlowCritical', 'CRITICAL'], + ['fanStopped', 'CRITICAL'], + ], + disk => [ + ['present', 'OK'], + ['initializing', 'OK'], + ['inserted', 'OK'], + ['offline', 'WARNING'], + ['removed', 'WARNING'], + ['notpresent', 'OK'], + ['empty', 'WARNING'], + ['ioerror', 'CRITICAL'], + ['unusable', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ], + }; + + $self->{components_path} = 'network::bluecoat::snmp::mode::components'; + $self->{components_module} = ['sensor', 'disk']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -70,241 +88,12 @@ sub new { $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' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $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 !~ /^sensor|disk|sensor_opstatus$/) { - $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 }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if ($section !~ /^sensor$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('sensor', 'disk'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::bluecoat::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::bluecoat::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_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ diff --git a/centreon-plugins/network/bluecoat/snmp/mode/memory.pm b/centreon-plugins/network/bluecoat/snmp/mode/memory.pm index 02b419830..735e8cedb 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/memory.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -57,7 +57,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; if ($self->{snmp}->is_snmpv1()) { diff --git a/centreon-plugins/network/bluecoat/snmp/mode/serverconnections.pm b/centreon-plugins/network/bluecoat/snmp/mode/serverconnections.pm index 2c98aab3c..f481729d7 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/serverconnections.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/serverconnections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.3.4.0', diff --git a/centreon-plugins/network/bluecoat/snmp/plugin.pm b/centreon-plugins/network/bluecoat/snmp/plugin.pm index d7b2e119f..df6376531 100644 --- a/centreon-plugins/network/bluecoat/snmp/plugin.pm +++ b/centreon-plugins/network/bluecoat/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/brocade/mode/cpu.pm b/centreon-plugins/network/brocade/mode/cpu.pm index f9ab98863..36dce2469 100644 --- a/centreon-plugins/network/brocade/mode/cpu.pm +++ b/centreon-plugins/network/brocade/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_swFwFabricWatchLicense = '.1.3.6.1.4.1.1588.2.1.1.1.10.1.0'; diff --git a/centreon-plugins/network/brocade/mode/hardware.pm b/centreon-plugins/network/brocade/mode/hardware.pm index 1a87364fe..c16bf7225 100644 --- a/centreon-plugins/network/brocade/mode/hardware.pm +++ b/centreon-plugins/network/brocade/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -66,7 +66,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_swFirmwareVersion = '.1.3.6.1.4.1.1588.2.1.1.1.1.6.0'; diff --git a/centreon-plugins/network/brocade/mode/memory.pm b/centreon-plugins/network/brocade/mode/memory.pm index 2d2bff50b..85dace029 100644 --- a/centreon-plugins/network/brocade/mode/memory.pm +++ b/centreon-plugins/network/brocade/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_swFwFabricWatchLicense = '.1.3.6.1.4.1.1588.2.1.1.1.10.1.0'; diff --git a/centreon-plugins/network/brocade/plugin.pm b/centreon-plugins/network/brocade/plugin.pm index 0a1743275..b51bc0930 100644 --- a/centreon-plugins/network/brocade/plugin.pm +++ b/centreon-plugins/network/brocade/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/checkpoint/mode/components/fan.pm b/centreon-plugins/network/checkpoint/mode/components/fan.pm index 3bee03320..3ff663400 100644 --- a/centreon-plugins/network/checkpoint/mode/components/fan.pm +++ b/centreon-plugins/network/checkpoint/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -37,9 +37,9 @@ my $mapping = { my $oid_fanSpeedSensorEntry = '.1.3.6.1.4.1.2620.1.6.7.8.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_fanSpeedSensorEntry, start => $mapping->{fanSpeedSensorName}->{oid}, end => $mapping->{fanSpeedSensorStatus}->{oid} }; + push @{$self->{request}}, { oid => $oid_fanSpeedSensorEntry, start => $mapping->{fanSpeedSensorName}->{oid}, end => $mapping->{fanSpeedSensorStatus}->{oid} }; } sub check { @@ -47,14 +47,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanSpeedSensorEntry}})) { next if ($oid !~ /^$mapping->{fanSpeedSensorStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanSpeedSensorEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($result->{fanSpeedSensorName} !~ /^[0-9a-zA-Z ]+$/); # sometimes there is some wrong values in hex $self->{components}->{fan}->{total}++; diff --git a/centreon-plugins/network/checkpoint/mode/components/psu.pm b/centreon-plugins/network/checkpoint/mode/components/psu.pm index f3801f1b0..480c83303 100644 --- a/centreon-plugins/network/checkpoint/mode/components/psu.pm +++ b/centreon-plugins/network/checkpoint/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,9 +29,9 @@ my $mapping = { my $oid_powerSupplyStatus = '.1.3.6.1.4.1.2620.1.6.7.9.1.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_powerSupplyStatus }; + push @{$self->{request}}, { oid => $oid_powerSupplyStatus }; } sub check { @@ -39,14 +39,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyStatus}})) { next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyStatus}, instance => $instance); - next if ($self->check_exclude(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'", diff --git a/centreon-plugins/network/checkpoint/mode/components/temperature.pm b/centreon-plugins/network/checkpoint/mode/components/temperature.pm index 60d24298b..2e4431951 100644 --- a/centreon-plugins/network/checkpoint/mode/components/temperature.pm +++ b/centreon-plugins/network/checkpoint/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -37,9 +37,9 @@ my $mapping = { my $oid_tempertureSensorEntry = '.1.3.6.1.4.1.2620.1.6.7.8.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_tempertureSensorEntry, start => $mapping->{tempertureSensorName}->{oid}, end => $mapping->{tempertureSensorStatus}->{oid} }; + push @{$self->{request}}, { oid => $oid_tempertureSensorEntry, start => $mapping->{tempertureSensorName}->{oid}, end => $mapping->{tempertureSensorStatus}->{oid} }; } sub check { @@ -47,14 +47,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_tempertureSensorEntry}})) { next if ($oid !~ /^$mapping->{tempertureSensorStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_tempertureSensorEntry}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); next if ($result->{tempertureSensorName} !~ /^[0-9a-zA-Z ]+$/); # sometimes there is some wrong values in hex $self->{components}->{temperature}->{total}++; diff --git a/centreon-plugins/network/checkpoint/mode/components/voltage.pm b/centreon-plugins/network/checkpoint/mode/components/voltage.pm index edc9aeb8b..da1d9158d 100644 --- a/centreon-plugins/network/checkpoint/mode/components/voltage.pm +++ b/centreon-plugins/network/checkpoint/mode/components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -37,9 +37,9 @@ my $mapping = { my $oid_voltageSensorEntry = '.1.3.6.1.4.1.2620.1.6.7.8.3.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_voltageSensorEntry, start => $mapping->{voltageSensorName}->{oid}, end => $mapping->{voltageSensorStatus}->{oid} }; + push @{$self->{request}}, { oid => $oid_voltageSensorEntry, start => $mapping->{voltageSensorName}->{oid}, end => $mapping->{voltageSensorStatus}->{oid} }; } sub check { @@ -47,14 +47,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking voltages"); $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'voltage')); + return if ($self->check_filter(section => 'voltage')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_voltageSensorEntry}})) { next if ($oid !~ /^$mapping->{voltageSensorStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_voltageSensorEntry}, instance => $instance); - next if ($self->check_exclude(section => 'voltage', instance => $instance)); + next if ($self->check_filter(section => 'voltage', instance => $instance)); next if ($result->{voltageSensorName} !~ /^[0-9a-zA-Z ]+$/); # sometimes there is some wrong values in hex $self->{components}->{voltage}->{total}++; diff --git a/centreon-plugins/network/checkpoint/mode/connections.pm b/centreon-plugins/network/checkpoint/mode/connections.pm index ee1b19ed6..d51b20adc 100644 --- a/centreon-plugins/network/checkpoint/mode/connections.pm +++ b/centreon-plugins/network/checkpoint/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_fwNumCom = '.1.3.6.1.4.1.2620.1.1.25.3.0'; diff --git a/centreon-plugins/network/checkpoint/mode/cpu.pm b/centreon-plugins/network/checkpoint/mode/cpu.pm index a2b47c221..9e545cd9f 100644 --- a/centreon-plugins/network/checkpoint/mode/cpu.pm +++ b/centreon-plugins/network/checkpoint/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_procUsrTime = '.1.3.6.1.4.1.2620.1.6.7.2.1.0'; diff --git a/centreon-plugins/network/checkpoint/mode/hardware.pm b/centreon-plugins/network/checkpoint/mode/hardware.pm index 95a058b2e..5bd361789 100644 --- a/centreon-plugins/network/checkpoint/mode/hardware.pm +++ b/centreon-plugins/network/checkpoint/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,176 +20,65 @@ package network::checkpoint::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - temperature => [ - ['true', 'CRITICAL'], - ['reading error', 'CRITICAL'], - ['false', 'OK'], - ], - voltage => [ - ['true', 'CRITICAL'], - ['reading error', 'CRITICAL'], - ['false', 'OK'], - ], - fan => [ - ['true', 'CRITICAL'], - ['reading error', 'CRITICAL'], - ['false', 'OK'], - ], - psu => [ - ['up', 'OK'], - ['down', 'CRITICAL'], - ['.*', 'UNKNOWN'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|voltage|fan|psu)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + temperature => [ + ['true', 'CRITICAL'], + ['reading error', 'CRITICAL'], + ['false', 'OK'], + ], + voltage => [ + ['true', 'CRITICAL'], + ['reading error', 'CRITICAL'], + ['false', 'OK'], + ], + fan => [ + ['true', 'CRITICAL'], + ['reading error', 'CRITICAL'], + ['false', 'OK'], + ], + psu => [ + ['up', 'OK'], + ['down', 'CRITICAL'], + ['.*', 'UNKNOWN'], + ], + }; + + $self->{components_path} = 'network::checkpoint::mode::components'; + $self->{components_module} = ['voltage', 'fan', 'temperature', 'psu']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-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}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('voltage', 'fan', 'temperature', 'psu'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::checkpoint::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::checkpoint::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - 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) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -205,15 +94,10 @@ Check hardware (fans, power supplies, temperatures, voltages). Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'temperature', 'voltage'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#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#1# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=psu,1 =item B<--no-component> @@ -222,7 +106,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,CRITICAL,^(?!(false)$)' diff --git a/centreon-plugins/network/checkpoint/mode/hastate.pm b/centreon-plugins/network/checkpoint/mode/hastate.pm index 11bda359d..61fa3f2cd 100644 --- a/centreon-plugins/network/checkpoint/mode/hastate.pm +++ b/centreon-plugins/network/checkpoint/mode/hastate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -47,7 +47,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_haInstalled = '.1.3.6.1.4.1.2620.1.5.2.0'; diff --git a/centreon-plugins/network/checkpoint/mode/memory.pm b/centreon-plugins/network/checkpoint/mode/memory.pm index 4d400434c..bd82b0baa 100644 --- a/centreon-plugins/network/checkpoint/mode/memory.pm +++ b/centreon-plugins/network/checkpoint/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_memTotalReal64 = '.1.3.6.1.4.1.2620.1.6.7.4.3.0'; diff --git a/centreon-plugins/network/checkpoint/plugin.pm b/centreon-plugins/network/checkpoint/plugin.pm index 267b065fd..2bd1c1635 100644 --- a/centreon-plugins/network/checkpoint/plugin.pm +++ b/centreon-plugins/network/checkpoint/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.5'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/cisco/WaaS/mode/sessions.pm b/centreon-plugins/network/cisco/WaaS/mode/sessions.pm index 800fe6459..a09191205 100644 --- a/centreon-plugins/network/cisco/WaaS/mode/sessions.pm +++ b/centreon-plugins/network/cisco/WaaS/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # Nombre de licences diff --git a/centreon-plugins/network/cisco/WaaS/plugin.pm b/centreon-plugins/network/cisco/WaaS/plugin.pm index 1f0c2c879..7d883d2cd 100644 --- a/centreon-plugins/network/cisco/WaaS/plugin.pm +++ b/centreon-plugins/network/cisco/WaaS/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.5'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/cisco/asa/mode/failover.pm b/centreon-plugins/network/cisco/asa/mode/failover.pm index e76d5fb4e..74e5ad9ff 100644 --- a/centreon-plugins/network/cisco/asa/mode/failover.pm +++ b/centreon-plugins/network/cisco/asa/mode/failover.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,10 +20,119 @@ package network::cisco::asa::mode::failover; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("Primary unit is '%s' [details: '%s'], Secondary unit is '%s' [details : '%s']", + $self->{result_values}->{primaryState}, $self->{result_values}->{primaryDetails}, + $self->{result_values}->{secondaryState}, $self->{result_values}->{secondaryDetails}); + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{primaryStateLast} = $options{old_datas}->{$self->{instance} . '_primary_state'}; + $self->{result_values}->{primaryState} = $options{new_datas}->{$self->{instance} . '_primary_state'}; + $self->{result_values}->{secondaryStateLast} = $options{old_datas}->{$self->{instance} . '_secondary_state'}; + $self->{result_values}->{secondaryState} = $options{new_datas}->{$self->{instance} . '_secondary_state'}; + $self->{result_values}->{primaryDetails} = $options{new_datas}->{$self->{instance} . '_primary_details'}; + $self->{result_values}->{secondaryDetails} = $options{new_datas}->{$self->{instance} . '_secondary_details'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'active-units', set => { + key_values => [ { name => 'active_units' } ], + output_template => 'Active units : %s', + perfdatas => [ + { label => 'active_units', value => 'active_units_absolute', template => '%s', + min => 0, max => 2 }, + ], + } + }, + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'primary_state' }, { name => 'secondary_state' }, { name => 'primary_details' }, { name => 'secondary_details' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} my %map_failover = ( 1 => 'other', @@ -38,64 +147,30 @@ my %map_failover = ( 10 => 'standby' # can be ); -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = {}; - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "dont-warn-notstandby" => { name => 'dont_warn_notstandby' }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $active_units = 0; - my $exit = 'ok'; # primary is '.6' index and secondary is '.7' index (it's like that. '.4' is the global interface) my $oid_cfwHardwareStatusValue_primary = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.6'; my $oid_cfwHardwareStatusValue_secondary = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.7'; my $oid_cfwHardwareStatusDetail_primary = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.4.6'; my $oid_cfwHardwareStatusDetail_secondary = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.4.7'; - my $result = $self->{snmp}->get_leef(oids => [$oid_cfwHardwareStatusValue_primary, $oid_cfwHardwareStatusValue_secondary, - $oid_cfwHardwareStatusDetail_primary, $oid_cfwHardwareStatusDetail_secondary], nothing_quit => 1); + my $result = $options{snmp}->get_leef(oids => [$oid_cfwHardwareStatusValue_primary, $oid_cfwHardwareStatusValue_secondary, + $oid_cfwHardwareStatusDetail_primary, $oid_cfwHardwareStatusDetail_secondary], nothing_quit => 1); - if ($result->{$oid_cfwHardwareStatusValue_primary} == 9 || $result->{$oid_cfwHardwareStatusValue_primary} == 10 ) { - $active_units++; - } - if ($result->{$oid_cfwHardwareStatusValue_secondary} == 9 || $result->{$oid_cfwHardwareStatusValue_secondary} == 10 ) { - $active_units++; - } - if ($active_units == 0) { - $exit = 'critical'; - } elsif ($active_units == 1 && !defined($self->{option_results}->{dont_warn_notstandby})) { - # No redundant interface - $exit = 'warning'; - } + $self->{global}->{primary_state} = $map_failover{$result->{$oid_cfwHardwareStatusValue_primary}}; + $self->{global}->{primary_details} = $result->{$oid_cfwHardwareStatusDetail_primary}; + $self->{global}->{secondary_state} = $map_failover{$result->{$oid_cfwHardwareStatusValue_secondary}}; + $self->{global}->{secondary_details} = $result->{$oid_cfwHardwareStatusDetail_secondary}; + my $active_units = 0; + $active_units++ if ($result->{$oid_cfwHardwareStatusValue_primary} == 9 || $result->{$oid_cfwHardwareStatusValue_primary} == 10); + $active_units++ if ($result->{$oid_cfwHardwareStatusValue_secondary} == 9 || $result->{$oid_cfwHardwareStatusValue_secondary} == 10); + $self->{global}->{active_units} = $active_units; - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Primary unit is '%s' [details: '%s'], Secondary unit is '%s' [details : '%s']", - $map_failover{$result->{$oid_cfwHardwareStatusValue_primary}}, $result->{$oid_cfwHardwareStatusDetail_primary}, - $map_failover{$result->{$oid_cfwHardwareStatusValue_secondary}}, $result->{$oid_cfwHardwareStatusDetail_secondary})); - - $self->{output}->perfdata_add(label => "active_units", - value => $active_units, - min => 0, max => 2); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{cache_name} = "cisco_asa_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } 1; @@ -108,9 +183,30 @@ Check failover status on Cisco ASA (CISCO-UNIFIED-FIREWALL-MIB). =over 8 -=item B<--dont-warn-notstandby> +=item B<--filter-counters> -Don't return warning if a unit is active and the other unit is not in standby status. +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{primaryStateLast}, %{secondaryStateLast}, %{primaryState}, %{secondaryState} + +=item B<--critical-status> + +Set critical threshold for status. +Can used special variables like: %{primaryStateLast}, %{secondaryStateLast}, %{primaryState}, %{secondaryState} + +=item B<--warning-*> + +Threshold warning. +Can be: 'active-units'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'active-units'. =back diff --git a/centreon-plugins/network/cisco/asa/mode/sessions.pm b/centreon-plugins/network/cisco/asa/mode/sessions.pm deleted file mode 100644 index 0ecf7a794..000000000 --- a/centreon-plugins/network/cisco/asa/mode/sessions.pm +++ /dev/null @@ -1,154 +0,0 @@ -# -# 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::cisco::asa::mode::sessions; - -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-average:s" => { name => 'warning_average', default => '' }, - "critical-average:s" => { name => 'critical_average', default => '' }, - "warning-current:s" => { name => 'warning_current' }, - "critical-current:s" => { name => 'critical_current' }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - ($self->{warn_avg1m}, $self->{warn_avg5m}) = split /,/, $self->{option_results}->{warning_average}; - ($self->{crit_avg1m}, $self->{crit_avg5m}) = split /,/, $self->{option_results}->{critical_average}; - - if (($self->{perfdata}->threshold_validate(label => 'warn_avg1m', value => $self->{warn_avg1m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning average (1min) threshold '" . $self->{warn_avg1m} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn_avg5m', value => $self->{warn_avg5m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning average (5min) threshold '" . $self->{warn_avg5m} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit_avg1m', value => $self->{crit_avg1m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical average (1min) threshold '" . $self->{crit_avg1m} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit_avg5m', value => $self->{crit_avg5m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical average (5min) threshold '" . $self->{crit_avg5m} . "'."); - $self->{output}->option_exit(); - } - - if (($self->{perfdata}->threshold_validate(label => 'warning_current', value => $self->{option_results}->{warning_current})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning current threshold '" . $self->{option_results}->{warning_current} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_current', value => $self->{option_results}->{critical_current})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical current threshold '" . $self->{option_results}->{critical_current} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $oid_cufwConnGlobalNumActive = '.1.3.6.1.4.1.9.9.491.1.1.1.6.0'; - my $oid_cufwConnGlobalConnSetupRate1 = '.1.3.6.1.4.1.9.9.491.1.1.1.10.0'; - my $oid_cufwConnGlobalConnSetupRate5 = '.1.3.6.1.4.1.9.9.491.1.1.1.11.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_cufwConnGlobalNumActive, $oid_cufwConnGlobalConnSetupRate1, - $oid_cufwConnGlobalConnSetupRate5], nothing_quit => 1); - - my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_cufwConnGlobalConnSetupRate1}, - threshold => [ { label => 'crit_avg1m', 'exit_litteral' => 'critical' }, { label => 'warn_avg1m', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_cufwConnGlobalConnSetupRate5}, - threshold => [ { label => 'crit_avg5m', 'exit_litteral' => 'critical' }, { label => 'warn_avg5m', exit_litteral => 'warning' } ]); - my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Average Connections per seconds: %d (last 1min), %d (last 5min)", - $result->{$oid_cufwConnGlobalConnSetupRate1}, $result->{$oid_cufwConnGlobalConnSetupRate5})); - - $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_cufwConnGlobalNumActive}, - threshold => [ { label => 'critical_current', 'exit_litteral' => 'critical' }, { label => 'warning_current', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Current active connections: %d", - $result->{$oid_cufwConnGlobalNumActive})); - - $self->{output}->perfdata_add(label => "connections_1m", unit => 'con/s', - value => $result->{$oid_cufwConnGlobalConnSetupRate1}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_avg1m'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_avg1m'), - min => 0); - $self->{output}->perfdata_add(label => "connections_5m", unit => 'con/s', - value => $result->{$oid_cufwConnGlobalConnSetupRate1}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_avg1m'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_avg1m'), - min => 0); - $self->{output}->perfdata_add(label => "connections_current", - value => $result->{$oid_cufwConnGlobalNumActive}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_current'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_current'), - min => 0); - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check current/average connections on Cisco ASA (CISCO-UNIFIED-FIREWALL-MIB). - -=over 8 - -=item B<--warning-average> - -Threshold warning: averaged number of connections which the firewall establishing per second (1min,5min). - -=item B<--critical-average> - -Threshold critical: averaged number of connections which the firewall establishing per second (1min,5min). - -=item B<--warning-current> - -Threshold warning: number of connections which are currently active. - -=item B<--critical-current> - -Threshold critical: number of connections which are currently active. - -=back - -=cut - \ No newline at end of file diff --git a/centreon-plugins/network/cisco/asa/plugin.pm b/centreon-plugins/network/cisco/asa/plugin.pm index 2aa3c2e11..cabf77f22 100644 --- a/centreon-plugins/network/cisco/asa/plugin.pm +++ b/centreon-plugins/network/cisco/asa/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( @@ -37,7 +36,7 @@ sub new { 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'memory' => 'centreon::common::cisco::standard::snmp::mode::memory', - 'sessions' => 'network::cisco::asa::mode::sessions', + 'sessions' => 'centreon::common::cisco::standard::snmp::mode::sessions', ); return $self; diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/components/fan.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/components/fan.pm index 6e91a53f8..a8be0e5fb 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,9 +30,9 @@ my $mapping = { my $oid_fanEntry = '.1.3.6.1.4.1.15497.1.1.1.10.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_fanEntry, start => $mapping->{fanRPMs}->{oid} }; + push @{$self->{request}}, { oid => $oid_fanEntry, start => $mapping->{fanRPMs}->{oid} }; } sub check { @@ -40,14 +40,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanEntry}})) { next if ($oid !~ /^$mapping->{fanRPMs}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanEntry}, instance => $instance); - next if ($self->check_exclude(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' is '%s' rpm [instance = %s]", diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/components/psu.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/components/psu.pm index 782c11de5..8e7398dc1 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -37,9 +37,9 @@ my $mapping = { my $oid_powerSupplyEntry = '.1.3.6.1.4.1.15497.1.1.1.8.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_powerSupplyEntry, start => $mapping->{powerSupplyStatus}->{oid} }; + push @{$self->{request}}, { oid => $oid_powerSupplyEntry, start => $mapping->{powerSupplyStatus}->{oid} }; } sub check { @@ -47,14 +47,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyEntry}})) { next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); if ($result->{powerSupplyStatus} =~ /powerSupplyNotInstalled/i) { $self->absent_problem(section => 'psu', instance => $instance); next; diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/components/raid.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/components/raid.pm index 9b6a80b85..89640cf3d 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/components/raid.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/components/raid.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -36,9 +36,9 @@ my $mapping = { my $oid_raidEntry = '.1.3.6.1.4.1.15497.1.1.1.18.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_raidEntry, start => $mapping->{raidStatus}->{oid} }; + push @{$self->{request}}, { oid => $oid_raidEntry, start => $mapping->{raidStatus}->{oid} }; } sub check { @@ -46,14 +46,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking raids"); $self->{components}->{raid} = {name => 'raids', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'raid')); + return if ($self->check_filter(section => 'raid')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidEntry}})) { next if ($oid !~ /^$mapping->{raidStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidEntry}, instance => $instance); - next if ($self->check_exclude(section => 'raid', instance => $instance)); + next if ($self->check_filter(section => 'raid', instance => $instance)); $self->{components}->{raid}->{total}++; $self->{output}->output_add(long_msg => sprintf("Raid '%s' status is '%s' [instance = %s]", diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/components/temperature.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/components/temperature.pm index 8140b4c58..1164e2dc1 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -44,9 +44,9 @@ my $mapping = { my $oid_temperatureEntry = '.1.3.6.1.4.1.15497.1.1.1.9.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_temperatureEntry, start => $mapping->{degreesCelsius}->{oid} }; + push @{$self->{request}}, { oid => $oid_temperatureEntry, start => $mapping->{degreesCelsius}->{oid} }; } sub check { @@ -54,14 +54,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureEntry}})) { next if ($oid !~ /^$mapping->{degreesCelsius}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureEntry}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is '%s' degree centigrade [instance = %s]", diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/cpu.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/cpu.pm index d0c80ae3b..26f49cfa5 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/cpu.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,11 +20,39 @@ package network::cisco::ironport::snmp::mode::cpu; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'mail', set => { + key_values => [ { name => 'perCentCPUUtilization' } ], + output_template => 'CPU Mail usage is: %.2f%%', + perfdatas => [ + { label => 'cpu_mail', value => 'perCentCPUUtilization_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'websecurity', set => { + key_values => [ { name => 'cacheCpuUsage' } ], + output_template => 'CPU WebSecurity usage is: %.2f%%', + perfdatas => [ + { label => 'cpu_websecurity', value => 'cacheCpuUsage_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + ]; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -32,62 +60,24 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, + { }); return $self; } -sub check_options { +sub manage_selection { 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(); + my %oids = ( + perCentCPUUtilization => '.1.3.6.1.4.1.15497.1.1.1.2.0', + cacheCpuUsage => '.1.3.6.1.4.1.15497.1.2.3.1.2.0', + ); + my $result = $options{snmp}->get_leef(oids => [values %oids], nothing_quit => 1); + $self->{global} = {}; + foreach (keys %oids) { + $self->{global}->{$_} = $result->{$oids{$_}} if (defined($result->{$oids{$_}})); } - 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{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $oid_perCentCPUUtilization = '.1.3.6.1.4.1.15497.1.1.1.2.0'; - my $oid_cacheCpuUsage = '.1.3.6.1.4.1.15497.1.2.3.1.2.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_perCentCPUUtilization, $oid_cacheCpuUsage], nothing_quit => 1); - - if (defined($result->{$oid_perCentCPUUtilization})) { - my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_perCentCPUUtilization}, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("CPU Mail usage is: %.2f%%", $result->{$oid_perCentCPUUtilization})); - $self->{output}->perfdata_add(label => 'cpu_mail', unit => '%', - value => sprintf("%.2f", $result->{$oid_perCentCPUUtilization}), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => 100); - } - if (defined($result->{$oid_cacheCpuUsage})) { - my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_cacheCpuUsage}, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("CPU WebSecurity usage is: %.2f%%", $result->{$oid_cacheCpuUsage})); - $self->{output}->perfdata_add(label => 'cpu_websecurity', unit => '%', - value => sprintf("%.2f", $result->{$oid_cacheCpuUsage}), - 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(); } 1; @@ -97,16 +87,19 @@ __END__ =head1 MODE Check cpu usage of web security and mail (ASYNCOS-MAIL-MIB, ASYNCOSWEBSECURITYAPPLIANCE-MIB). +Use linux SNMP plugin for global CPU. =over 8 -=item B<--warning> +=item B<--warning-*> -Threshold warning in percent. +Threshold warning. +Can be: 'mail', 'websecurity'. -=item B<--critical> +=item B<--critical-*> -Threshold critical in percent. +Threshold critical. +Can be: 'mail', 'websecurity'. =back diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/hardware.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/hardware.pm index c7705df11..0204ea5bb 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/hardware.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,24 +20,43 @@ package network::cisco::ironport::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - psu => [ - ['powerSupplyNotInstalled', 'OK'], - ['powerSupplyHealthy', 'OK'], - ['powerSupplyNoAC', 'WARNING'], - ['powerSupplyFaulty', 'CRITICAL'], - ], - raid => [ - ['driveHealthy', 'OK'], - ['driveFailure', 'CRITICAL'], - ['driveRebuild', 'WARNING'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(raid|psu)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['powerSupplyNotInstalled', 'OK'], + ['powerSupplyHealthy', 'OK'], + ['powerSupplyNoAC', 'WARNING'], + ['powerSupplyFaulty', 'CRITICAL'], + ], + raid => [ + ['driveHealthy', 'OK'], + ['driveFailure', 'CRITICAL'], + ['driveRebuild', 'WARNING'], + ], + }; + + $self->{components_path} = 'network::cisco::ironport::snmp::mode::components'; + $self->{components_module} = ['fan', 'temperature', 'psu', 'raid']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -46,207 +65,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(temperature|fan)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature or fan)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'temperature', 'psu', 'raid'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::cisco::ironport::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::cisco::ironport::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ @@ -262,10 +86,10 @@ Check Hardware (Fans, Power Supplies, Temperatures, Raids). Which component to check (Default: '.*'). Can be: 'fan', 'temperature', 'psu', 'raid'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan,temperature) -Can also exclude specific instance: --exclude=fan#1#,temperature#2# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=temperature) +Can also exclude specific instance: --filter=fan,1 =item B<--absent-problem> @@ -279,7 +103,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='psu,CRITICAL,^(?!(powerSupplyHealthy)$)' diff --git a/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm index 4dd189203..096e08fbf 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_perCentMemoryUtilization = '.1.3.6.1.4.1.15497.1.1.1.1.0'; diff --git a/centreon-plugins/network/cisco/ironport/snmp/plugin.pm b/centreon-plugins/network/cisco/ironport/snmp/plugin.pm index 7cfce585a..1f653bb1e 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/cisco/smallbusiness/standard/snmp/plugin.pm b/centreon-plugins/network/cisco/smallbusiness/standard/snmp/plugin.pm index d86c42f5f..9288d0ba9 100644 --- a/centreon-plugins/network/cisco/smallbusiness/standard/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/smallbusiness/standard/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/cisco/standard/snmp/plugin.pm b/centreon-plugins/network/cisco/standard/snmp/plugin.pm index f2795c5b3..558abceaa 100644 --- a/centreon-plugins/network/cisco/standard/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/standard/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/cisco/vg/snmp/plugin.pm b/centreon-plugins/network/cisco/vg/snmp/plugin.pm new file mode 100644 index 000000000..847817d10 --- /dev/null +++ b/centreon-plugins/network/cisco/vg/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::cisco::vg::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}} = ( + 'interfaces' => 'snmp_standard::mode::interfaces', + 'isdn-usage' => 'snmp_standard::mode::isdnusage', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Cisco Voice Gateway in SNMP. + +=cut diff --git a/centreon-plugins/network/cisco/wlc/snmp/plugin.pm b/centreon-plugins/network/cisco/wlc/snmp/plugin.pm index c76e60fc5..aead226c1 100644 --- a/centreon-plugins/network/cisco/wlc/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/wlc/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/certificatesexpire.pm b/centreon-plugins/network/citrix/netscaler/common/mode/certificatesexpire.pm index aa0772f98..ffb1b1cdb 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/certificatesexpire.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/certificatesexpire.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_sslCertKeyName = '.1.3.6.1.4.1.5951.4.1.1.56.1.1.1'; diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/connections.pm b/centreon-plugins/network/citrix/netscaler/common/mode/connections.pm index 91e250130..acad80cc4 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/connections.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm b/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm index 97e0c6eb4..f6673a0a7 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nsCPUEntry = '.1.3.6.1.4.1.5951.4.1.1.41.6'; diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm b/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm index 17093d3d9..0b657397c 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -84,12 +84,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -99,7 +99,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{result} = $self->{snmp}->get_leef(oids => [$oid_haPeerState, $oid_haCurState], nothing_quit => 1); @@ -162,4 +161,4 @@ Example: --threshold-overload='hastate,CRITICAL,^(?!(up)$)' =back =cut - \ No newline at end of file + diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/health.pm b/centreon-plugins/network/citrix/netscaler/common/mode/health.pm index ea22f4531..6d51e54ee 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/health.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/health.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -78,12 +78,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ('psu', $1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -93,7 +93,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{result} = $self->{snmp}->get_table(oid => $oid_nsSysHealthEntry); @@ -356,4 +355,4 @@ Example: --threshold-overload='CRITICAL,^(?!(normal)$)' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm b/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm index 17a178648..c4564542e 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -94,7 +94,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -119,7 +118,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm b/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm index 2d3ab6416..687acb285 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_resMemUsage = '.1.3.6.1.4.1.5951.4.1.1.41.2.0'; diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm b/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm index ad7e7b132..fd43d4a2a 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nsSysHealthDiskEntry = '.1.3.6.1.4.1.5951.4.1.1.41.8.1'; diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/vserverstatus.pm b/centreon-plugins/network/citrix/netscaler/common/mode/vserverstatus.pm index 8ee0b7fe1..aabc2f759 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/vserverstatus.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/vserverstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -167,12 +167,12 @@ sub check_options { } foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ('vs', $1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $overload_th->{$section} = [] if (!defined($overload_th->{$section})); @@ -182,7 +182,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/citrix/netscaler/mpx8000/plugin.pm b/centreon-plugins/network/citrix/netscaler/mpx8000/plugin.pm index 4cb21ae51..fd2402bc5 100644 --- a/centreon-plugins/network/citrix/netscaler/mpx8000/plugin.pm +++ b/centreon-plugins/network/citrix/netscaler/mpx8000/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.5'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/dell/6200/plugin.pm b/centreon-plugins/network/dell/6200/plugin.pm index 3e76e88a5..24c68880f 100644 --- a/centreon-plugins/network/dell/6200/plugin.pm +++ b/centreon-plugins/network/dell/6200/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/dell/n4000/plugin.pm b/centreon-plugins/network/dell/n4000/plugin.pm index de13e704c..a79ba5326 100644 --- a/centreon-plugins/network/dell/n4000/plugin.pm +++ b/centreon-plugins/network/dell/n4000/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/dell/sseries/snmp/plugin.pm b/centreon-plugins/network/dell/sseries/snmp/plugin.pm index a2deb5533..7cd9b8104 100644 --- a/centreon-plugins/network/dell/sseries/snmp/plugin.pm +++ b/centreon-plugins/network/dell/sseries/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/digi/anywhereusb/snmp/mode/cpu.pm b/centreon-plugins/network/digi/anywhereusb/snmp/mode/cpu.pm new file mode 100644 index 000000000..79602f314 --- /dev/null +++ b/centreon-plugins/network/digi/anywhereusb/snmp/mode/cpu.pm @@ -0,0 +1,99 @@ +# +# Copyright 2016 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::anywhereusb::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}; + + my $oid_diCpuUtilization = '.1.3.6.1.4.1.332.11.6.1.6.0'; + my $result = $self->{snmp}->get_leef(oids => [$oid_diCpuUtilization], nothing_quit => 1); + + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_diCpuUtilization}, + 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_diCpuUtilization})); + $self->{output}->perfdata_add(label => "cpu", + value => $result->{$oid_diCpuUtilization}, + 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/centreon-plugins/network/digi/anywhereusb/snmp/mode/memory.pm b/centreon-plugins/network/digi/anywhereusb/snmp/mode/memory.pm new file mode 100644 index 000000000..e6a4270f0 --- /dev/null +++ b/centreon-plugins/network/digi/anywhereusb/snmp/mode/memory.pm @@ -0,0 +1,132 @@ +# +# Copyright 2016 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::anywhereusb::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +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 set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0 } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', set => { + key_values => [ { name => 'free' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +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 => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_diTotalMemory = '.1.3.6.1.4.1.332.11.6.1.8.0'; + my $oid_diFreeMemory = '.1.3.6.1.4.1.332.11.6.1.9.0'; + my $result = $options{snmp}->get_leef(oids => [$oid_diTotalMemory, $oid_diFreeMemory], + nothing_quit => 1); + $self->{memory} = { free => $result->{$oid_diFreeMemory}, total => $result->{$oid_diTotalMemory} }; +} + +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/centreon-plugins/network/digi/anywhereusb/snmp/plugin.pm b/centreon-plugins/network/digi/anywhereusb/snmp/plugin.pm new file mode 100644 index 000000000..a965548c1 --- /dev/null +++ b/centreon-plugins/network/digi/anywhereusb/snmp/plugin.pm @@ -0,0 +1,51 @@ +# +# Copyright 2016 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::anywhereusb::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::digi::anywhereusb::snmp::mode::cpu', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::digi::anywhereusb::snmp::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Digi AnywhereUSB equipments in SNMP. + +=cut diff --git a/centreon-plugins/network/digi/portserverts/snmp/mode/cpu.pm b/centreon-plugins/network/digi/portserverts/snmp/mode/cpu.pm index 00929cd18..346a95044 100644 --- a/centreon-plugins/network/digi/portserverts/snmp/mode/cpu.pm +++ b/centreon-plugins/network/digi/portserverts/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/digi/portserverts/snmp/mode/memory.pm b/centreon-plugins/network/digi/portserverts/snmp/mode/memory.pm index d5933ff4a..5df388c59 100644 --- a/centreon-plugins/network/digi/portserverts/snmp/mode/memory.pm +++ b/centreon-plugins/network/digi/portserverts/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/digi/portserverts/snmp/plugin.pm b/centreon-plugins/network/digi/portserverts/snmp/plugin.pm index bb2442365..bcf838eed 100644 --- a/centreon-plugins/network/digi/portserverts/snmp/plugin.pm +++ b/centreon-plugins/network/digi/portserverts/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/apps/lync/mode/imsessions.pm b/centreon-plugins/network/digi/standard/snmp/mode/cpu.pm similarity index 56% rename from centreon-plugins/apps/lync/mode/imsessions.pm rename to centreon-plugins/network/digi/standard/snmp/mode/cpu.pm index 269b07e5c..e7dca8d64 100644 --- a/centreon-plugins/apps/lync/mode/imsessions.pm +++ b/centreon-plugins/network/digi/standard/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -18,7 +18,7 @@ # limitations under the License. # -package apps::lync::mode::imsessions; +package network::digi::standard::snmp::mode::cpu; use base qw(centreon::plugins::mode); @@ -29,12 +29,12 @@ 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', }, + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); return $self; @@ -49,34 +49,31 @@ sub check_options { $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}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; + $self->{snmp} = $options{snmp}; - $self->{sql}->connect(); - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=1 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - my $im_sessions = $self->{sql}->fetchrow_array(); + my $oid_cpuUtil = '.1.3.6.1.4.1.16378.10000.3.1.0'; - my $exit_code = $self->{perfdata}->threshold_check(value => $im_sessions, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{results} = $self->{snmp}->get_leef(oids => [ $oid_cpuUtil ], + nothing_quit => 1); - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("%i instant messaging sessions running", $im_sessions)); - $self->{output}->perfdata_add(label => 'im_sessions', unit => 'sessions', - value => $im_sessions, + my $cpu = $self->{results}->{$oid_cpuUtil}; + + my $exit = $self->{perfdata}->threshold_check(value => $cpu, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU Usage is %.2f%%", $cpu)); + $self->{output}->perfdata_add(label => "cpu", unit => '%', + value => $cpu, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); + min => 0, max => 100); $self->{output}->display(); $self->{output}->exit(); @@ -88,17 +85,17 @@ __END__ =head1 MODE -Check Lync number of active instant messaging session during last five minutes +Check cpu usage (sarian-monitor.mib). =over 8 =item B<--warning> -Threshold warning on number of active messaging sessions +Threshold warning in percent. =item B<--critical> -Threshold critical on number of active messaging sessions +Threshold critical in percent. =back diff --git a/centreon-plugins/network/digi/standard/snmp/mode/gprs.pm b/centreon-plugins/network/digi/standard/snmp/mode/gprs.pm new file mode 100644 index 000000000..7add1e7da --- /dev/null +++ b/centreon-plugins/network/digi/standard/snmp/mode/gprs.pm @@ -0,0 +1,272 @@ +# +# Copyright 2016 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::standard::snmp::mode::gprs; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg; + + $msg = 'Attachement : ' . $self->{result_values}->{attachement}; + $msg .= ', Registration : ' . $self->{result_values}->{registered}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{registered} = $options{new_datas}->{$self->{instance} . '_registered'}; + $self->{result_values}->{attachement} = $options{new_datas}->{$self->{instance} . '_attachement'}; + return 0; +} + +sub custom_tech_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_technology}) && $instance_mode->{option_results}->{critical_technology} ne '' && + eval "$instance_mode->{option_results}->{critical_technology}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_technology}) && $instance_mode->{option_results}->{warning_technology} ne '' && + eval "$instance_mode->{option_results}->{warning_technology}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_tech_output { + my ($self, %options) = @_; + my $msg; + + $msg = 'Technology : ' . $self->{result_values}->{technology}; + return $msg; +} + +sub custom_tech_calc { + my ($self, %options) = @_; + + $self->{result_values}->{technology} = $options{new_datas}->{$self->{instance} . '_technology'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'gprs', type => 0 }, + ]; + $self->{maps_counters}->{gprs} = [ + { label => 'signal', set => { + key_values => [ { name => 'signal' } ], + output_template => 'Signal : %d dBm', + perfdatas => [ + { label => 'signal_strenght', value => 'signal_absolute', template => '%s', + unit => 'dBm' }, + ], + } + }, + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'registered' }, { name => 'attachement' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold_output'), + } + }, + { label => 'technology', threshold => 0, set => { + key_values => [ { name => 'technology' } ], + closure_custom_calc => $self->can('custom_tech_calc'), + closure_custom_output => $self->can('custom_tech_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_tech_threshold_output'), + } + }, + ]; +} + +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-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{attachement} eq "notAttached" or %{registered} !~ /registeredHostNetwork|registeredRoaming/' }, + "warning-technology:s" => { name => 'warning_technology', default => '' }, + "critical-technology:s" => { name => 'critical_technology', default => '%{technology} !~ /2G|3G|4G/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'warning_technology', 'critical_technology' )) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_gprs_registration = ( + 0 => 'notRegisteredNotSearching', + 1 => 'registeredHostNetwork', + 2 => 'notRegisteredSearching', + 3 => 'registrationDenied', + 4 => 'unknown', + 5 => 'registeredRoaming', + 6 => 'unrecognised', +); + +my %map_gprs_attachement = ( + 0 => 'notAtached', + 1 => 'attached', +); + +my %map_gprs_technology = ( + 1 => 'unknown', + 2 => 'GPRS(2G)', + 3 => 'EDGE(2G)', + 4 => 'UMTS(3G)', + 5 => 'HSDPA(3G)', + 6 => 'HSUPA(3G)', + 7 => 'DC-HSPA+(3G)', + 8 => 'LTE(4G)', +); + +my $oid_gprsSignalStrength = '.1.3.6.1.4.1.16378.10000.2.1.0'; +my $oid_gprsRegistered = '.1.3.6.1.4.1.16378.10000.2.2.0'; +my $oid_gprsAttached = '.1.3.6.1.4.1.16378.10000.2.3.0'; +my $oid_gprsNetworkTechnology = '.1.3.6.1.4.1.16378.10000.2.7.0'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{gprs} = {}; + $self->{results} = $options{snmp}->get_leef(oids => [ $oid_gprsSignalStrength, $oid_gprsRegistered, + $oid_gprsAttached, $oid_gprsNetworkTechnology ], + nothing_quit => 1); + + $self->{gprs} = { signal => $self->{results}->{$oid_gprsSignalStrength}, + registered => $map_gprs_registration{$self->{results}->{$oid_gprsRegistered}}, + attachement => $map_gprs_attachement{$self->{results}->{$oid_gprsAttached}}, + technology => $map_gprs_technology{$self->{results}->{$oid_gprsNetworkTechnology}}, + }; + +} + +1; + +__END__ + +=head1 MODE + +Check AP status. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='signal|technology' + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{registered}, %{attachement} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{attachement} eq "attached" and %{registered} !~ /registeredHostNetwork|registeredRoaming/' +Can used special variables like: %{registered}, %{attachement} + +=item B<--warning-technology> + +Set warning threshold for technology. +Use special variables %{technology}. + +=item B<--critical-technology> + +Set critical threshold for technology (Default: '%{technology} !~ /2G|3G|4G/' +Use special variables %{technology}. + +=item B<--warning-signal> + +Threshold warning for signal strength. + +=item B<--critical-signal> + +Threshold critical for signal strength. + +=back + +=cut diff --git a/centreon-plugins/apps/lync/mode/remoteassistance.pm b/centreon-plugins/network/digi/standard/snmp/mode/memory.pm similarity index 54% rename from centreon-plugins/apps/lync/mode/remoteassistance.pm rename to centreon-plugins/network/digi/standard/snmp/mode/memory.pm index e0a5defe2..4c316a735 100644 --- a/centreon-plugins/apps/lync/mode/remoteassistance.pm +++ b/centreon-plugins/network/digi/standard/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -18,7 +18,7 @@ # limitations under the License. # -package apps::lync::mode::remoteassistance; +package network::digi::standard::snmp::mode::memory; use base qw(centreon::plugins::mode); @@ -29,14 +29,13 @@ 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', }, + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); - return $self; } @@ -56,27 +55,33 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; + $self->{snmp} = $options{snmp}; - $self->{sql}->connect(); - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=4 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - my $remote_assistance_sessions = $self->{sql}->fetchrow_array(); + my $oid_totalMemory = '.1.3.6.1.4.1.16378.10000.3.17.0'; # in Kbytes + my $oid_freeMemory = '.1.3.6.1.4.1.16378.10000.3.18.0'; # in Kbytes - my $exit_code = $self->{perfdata}->threshold_check(value => $remote_assistance_sessions, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $result = $self->{snmp}->get_leef(oids => [$oid_totalMemory, $oid_freeMemory], + nothing_quit => 1); + my $free = $result->{$oid_freeMemory} * 1024; + my $total_size = $result->{$oid_totalMemory} * 1024; + my $used = $total_size - $free; - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("%i remote assistance sessions running", $remote_assistance_sessions)); - $self->{output}->perfdata_add(label => 'assistance_sessions', unit => 'sessions', - value => $remote_assistance_sessions, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); + my $prct_used = $used * 100 / $total_size; + my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); + my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Ram used %s (%.2f%%), Total: %s", + $used_value . " " . $used_unit, $prct_used, + $total_value . " " . $total_unit)); + + $self->{output}->perfdata_add(label => "used", unit => 'B', + value => $used, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), + min => 0, max => $total_size); $self->{output}->display(); $self->{output}->exit(); @@ -88,17 +93,17 @@ __END__ =head1 MODE -Check Lync number of active remote assistance sessions during last five minutes -- use with dyn-mode mssql plugin +Check memory usage (sarian-monitor.mib). =over 8 =item B<--warning> -Threshold warning +Threshold warning in percent. =item B<--critical> -Threshold critical +Threshold critical in percent. =back diff --git a/centreon-plugins/network/digi/standard/snmp/mode/temperature.pm b/centreon-plugins/network/digi/standard/snmp/mode/temperature.pm new file mode 100644 index 000000000..b31c8e293 --- /dev/null +++ b/centreon-plugins/network/digi/standard/snmp/mode/temperature.pm @@ -0,0 +1,124 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and temperatureplication 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.temperatureache.org/licenses/LICENSE-2.0 +# +# Unless required by temperatureplicable 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::standard::snmp::mode::temperature; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'temperature', type => 0, skipped_code => { -10 => 1 } }, + ]; + $self->{maps_counters}->{temperature} = [ + { label => 'device', set => { + key_values => [ { name => 'device' } ], + output_template => 'Temp Device : %d °C', + perfdatas => [ + { label => 'tempDevice', value => 'device_absolute', template => '%d', + unit => 'C' }, + ], + } + }, + { label => 'processor', set => { + key_values => [ { name => 'processor' } ], + output_template => 'Temp Processor : %d °C', + perfdatas => [ + { label => 'tempProcessor', value => 'processor_absolute', template => '%d', + unit => 'C' }, + ], + } + }, + { label => 'modem', set => { + key_values => [ { name => 'modem' } ], + output_template => 'Temp Modem : %d °C', + perfdatas => [ + { label => 'tempModem', value => 'modem_absolute', template => '%d', + unit => 'C' }, + ], + } + }, + ]; +} + +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 => + { + }); + + return $self; +} + +my $oid_temperature = '.1.3.6.1.4.1.16378.10000.3.11.0'; +my $oid_processorTemperature = '.1.3.6.1.4.1.16378.10000.3.12.0'; +my $oid_modemTemperature = '.1.3.6.1.4.1.16378.10000.3.13.0'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + + $self->{temperature} = {}; + $self->{results} = $self->{snmp}->get_leef(oids => [ $oid_temperature, $oid_processorTemperature, $oid_modemTemperature ], + nothing_quit => 1); + + $self->{temperature} = { device => $self->{results}->{$oid_temperature} > -20 ? $self->{results}->{$oid_temperature} : undef, + processor => $self->{results}->{$oid_processorTemperature}, + modem => $self->{results}->{$oid_modemTemperature} }; + +} + +1; + +__END__ + +=head1 MODE + +Check Digi equipment temperature (sarian-monitor.mib) + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='processor|modem' + +=item B<--warning-*> + +Threshold warning. +Can be: 'device', 'modem', 'processor' (C). + +=item B<--critical-*> + +Threshold critical. +Can be: 'device', 'modem', 'processor' (C). + +=back + +=cut diff --git a/centreon-plugins/network/digi/standard/snmp/plugin.pm b/centreon-plugins/network/digi/standard/snmp/plugin.pm new file mode 100644 index 000000000..732425486 --- /dev/null +++ b/centreon-plugins/network/digi/standard/snmp/plugin.pm @@ -0,0 +1,53 @@ +# +# Copyright 2016 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::standard::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}} = ( + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'cpu' => 'network::digi::standard::snmp::mode::cpu', + 'memory' => 'network::digi::standard::snmp::mode::memory', + 'temperature' => 'network::digi::standard::snmp::mode::temperature', + 'gprs' => 'network::digi::standard::snmp::mode::gprs', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check DIGI equipement supporting standard sarian-monitor.mib + +=cut diff --git a/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/fan.pm b/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/fan.pm index 915d4087a..0fc39e625 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -40,9 +40,9 @@ my $mapping = { my $oid_rlEnvMonFanStatusEntry = '.1.3.6.1.4.1.171.10.94.89.89.83.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; + push @{$self->{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; } sub check { @@ -50,14 +50,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonFanStatusEntry}})) { next if ($oid !~ /^$mapping->{rlEnvMonFanStatusDescr}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonFanStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $result->{rlEnvMonFanStatusDescr})); + next if ($self->check_filter(section => 'fan', instance => $result->{rlEnvMonFanStatusDescr})); next if ($result->{rlEnvMonFanState} eq 'notPresent' && $self->absent_problem(section => 'fan', instance => $result->{rlEnvMonFanStatusDescr})); $self->{components}->{fan}->{total}++; diff --git a/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/psu.pm b/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/psu.pm index e80dd4436..a46cc7aa4 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -40,9 +40,9 @@ my $mapping = { my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.171.10.94.89.89.83.1.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; + push @{$self->{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; } sub check { @@ -50,14 +50,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) { next if ($oid !~ /^$mapping->{rlEnvMonSupplyStatusDescr}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $result->{rlEnvMonSupplyStatusDescr})); + next if ($self->check_filter(section => 'psu', instance => $result->{rlEnvMonSupplyStatusDescr})); next if ($result->{rlEnvMonSupplyState} eq 'notPresent' && $self->absent_problem(section => 'psu', instance => $result->{rlEnvMonSupplyStatusDescr})); $self->{components}->{psu}->{total}++; diff --git a/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm b/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm index cc964bf0c..1bd126621 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rlCpuUtilEnable = '.1.3.6.1.4.1.171.10.94.89.89.1.6.0'; diff --git a/centreon-plugins/network/dlink/dgs3100/snmp/mode/hardware.pm b/centreon-plugins/network/dlink/dgs3100/snmp/mode/hardware.pm index d56eb2ecc..5b0db57b7 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/mode/hardware.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,189 +20,61 @@ package network::dlink::dgs3100::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - psu => [ - ['shutdown', 'WARNING'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['notFunctioning', 'CRITICAL'], - ['notPresent', 'OK'], - ['normal', 'OK'], - ], - fan => [ - ['shutdown', 'WARNING'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['notFunctioning', 'CRITICAL'], - ['notPresent', 'OK'], - ['normal', 'OK'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['shutdown', 'WARNING'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['notFunctioning', 'CRITICAL'], + ['notPresent', 'OK'], + ['normal', 'OK'], + ], + fan => [ + ['shutdown', 'WARNING'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['notFunctioning', 'CRITICAL'], + ['notPresent', 'OK'], + ['normal', 'OK'], + ], + }; + + $self->{components_path} = 'network::dlink::dgs3100::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "absent-problem:s" => { name => 'absent' }, - "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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-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}; - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::dlink::dgs3100::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::dlink::dgs3100::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -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__ @@ -218,10 +90,10 @@ Check hardware (Fans, Power Supplies). Which component to check (Default: '.*'). Can be: 'psu', 'fan'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='fan#fan1_unit2#' +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=fan,fan1_unit2 =item B<--absent-problem> @@ -235,7 +107,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)' diff --git a/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm b/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm index cc4836f62..c4cfc74f1 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/dlink/standard/snmp/mode/components/fan.pm b/centreon-plugins/network/dlink/standard/snmp/mode/components/fan.pm index 4d0d9e5c2..393dd6949 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -41,9 +41,9 @@ my $mapping = { my $oid_swFanEntry = '.1.3.6.1.4.1.171.12.11.1.7.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_swFanEntry }; + push @{$self->{request}}, { oid => $oid_swFanEntry }; } sub check { @@ -51,14 +51,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swFanEntry}})) { next if ($oid !~ /^$mapping->{swFanStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swFanEntry}, instance => $instance); - next if ($self->check_exclude(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 [speed = %s].", diff --git a/centreon-plugins/network/dlink/standard/snmp/mode/components/psu.pm b/centreon-plugins/network/dlink/standard/snmp/mode/components/psu.pm index 3f82dd5ba..7ad60cc90 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -40,9 +40,9 @@ my $mapping = { my $oid_swPowerEntry = '.1.3.6.1.4.1.171.12.11.1.6.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_swPowerEntry }; + push @{$self->{request}}, { oid => $oid_swPowerEntry }; } sub check { @@ -50,14 +50,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swPowerEntry}})) { next if ($oid !~ /^$mapping->{swPowerStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swPowerEntry}, instance => $instance); - next if ($self->check_exclude(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.", diff --git a/centreon-plugins/network/dlink/standard/snmp/mode/components/temperature.pm b/centreon-plugins/network/dlink/standard/snmp/mode/components/temperature.pm index 0fc334b51..c20515337 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,9 +30,9 @@ my $mapping = { my $oid_swTemperatureEntry = '.1.3.6.1.4.1.171.12.11.1.8.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_swTemperatureEntry }; + push @{$self->{request}}, { oid => $oid_swTemperatureEntry }; } sub check { @@ -40,14 +40,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swTemperatureEntry}})) { next if ($oid !~ /^$mapping->{swTemperatureCurrent}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swTemperatureEntry}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %dC.", diff --git a/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm b/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm index a94a2d833..be8b762a8 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_agentCPUutilizationIn5sec = '.1.3.6.1.4.1.171.12.1.1.6.1.0'; diff --git a/centreon-plugins/network/dlink/standard/snmp/mode/hardware.pm b/centreon-plugins/network/dlink/standard/snmp/mode/hardware.pm index 4e982c94d..9a70c79cc 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/hardware.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,222 +20,64 @@ package network::dlink::standard::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - psu => [ - ['connect', 'OK'], - ['working', 'OK'], - ['other', 'UNKNOWN'], - ['lowVoltage', 'WARNING'], - ['overCurrent', 'CRITICAL'], - ['fail', 'CRITICAL'], - ['disconnect', 'WARNING'], - ], - fan => [ - ['working', 'OK'], - ['fail', 'CRITICAL'], - ['other', 'UNKNOWN'], - ['speed-0', 'WARNING'], - ['speed-low', 'WARNING'], - ['speed-middle', 'OK'], - ['speed-high', 'WARNING'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(fan|temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['connect', 'OK'], + ['working', 'OK'], + ['other', 'UNKNOWN'], + ['lowVoltage', 'WARNING'], + ['overCurrent', 'CRITICAL'], + ['fail', 'CRITICAL'], + ['disconnect', 'WARNING'], + ], + fan => [ + ['working', 'OK'], + ['fail', 'CRITICAL'], + ['other', 'UNKNOWN'], + ['speed-0', 'WARNING'], + ['speed-low', 'WARNING'], + ['speed-middle', 'OK'], + ['speed-high', 'WARNING'], + ], + }; + + $self->{components_path} = 'network::dlink::standard::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-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}; - } - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(fan|temperature)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature or fan)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'temperature'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::dlink::standard::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::dlink::standard::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - 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) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - 1; __END__ @@ -251,10 +93,10 @@ Check hardware (Fans, Power Supplies, Temperatures). Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'temperature'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='fan#1.1#' +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=fan,1.1 =item B<--no-component> @@ -269,12 +111,12 @@ Example: --threshold-overload='fan,CRITICAL,^(?!(working)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,threshold) +Set warning threshold for temperatures (syntax: section,[instance,]status,regexp) Example: --warning='temperature,.*,30' --warning='fan,.*,1000' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,threshold) +Set critical threshold for temperatures (syntax: section,[instance,]status,regexp) Example: --critical='temperature,.*,40' =back diff --git a/centreon-plugins/network/dlink/standard/snmp/plugin.pm b/centreon-plugins/network/dlink/standard/snmp/plugin.pm index ade75917d..b7007441f 100644 --- a/centreon-plugins/network/dlink/standard/snmp/plugin.pm +++ b/centreon-plugins/network/dlink/standard/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/extreme/snmp/mode/components/fan.pm b/centreon-plugins/network/extreme/snmp/mode/components/fan.pm index ba18742a3..295e21c11 100644 --- a/centreon-plugins/network/extreme/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/extreme/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/extreme/snmp/mode/components/poe.pm b/centreon-plugins/network/extreme/snmp/mode/components/poe.pm new file mode 100644 index 000000000..e5e616290 --- /dev/null +++ b/centreon-plugins/network/extreme/snmp/mode/components/poe.pm @@ -0,0 +1,98 @@ +# +# Copyright 2016 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::extreme::snmp::mode::components::poe; + +use strict; +use warnings; + +my %map_poe_status = ( + 1 => 'initializing', + 2 => 'operational', + 3 => 'downloadFail', + 4 => 'calibrationRequired', + 5 => 'invalidFirmware', + 6 => 'mismatchVersion', + 7 => 'updating', + 8 => 'invalidDevice', + 9 => 'notOperational', + 10 => 'other', +); + +my $mapping = { + extremePethSlotPoeStatus => { oid => '.1.3.6.1.4.1.1916.1.27.1.2.1.8', map => \%map_poe_status }, +}; +my $mapping2 = { + extremePethSlotMeasuredPower => { oid => '.1.3.6.1.4.1.1916.1.27.1.2.1.14' }, +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{extremePethSlotPoeStatus}->{oid} }, + { oid => $mapping2->{extremePethSlotMeasuredPower}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking poes"); + $self->{components}->{poe} = {name => 'poes', total => 0, skip => 0}; + return if ($self->check_filter(section => 'poe')); + + my ($exit, $warn, $crit, $checked); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{extremePethSlotPoeStatus}->{oid}}})) { + $oid =~ /^$mapping->{extremePethSlotPoeStatus}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{extremePethSlotPoeStatus}->{oid}}, instance => $instance); + my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{extremePethSlotMeasuredPower}->{oid}}, instance => $instance); + + next if ($self->check_filter(section => 'poe', instance => $instance)); + + $result2->{extremePethSlotMeasuredPower} = defined($result2->{extremePethSlotMeasuredPower}) && $result2->{extremePethSlotMeasuredPower} =~ /\d+/ ? + sprintf("%.3f", $result2->{extremePethSlotMeasuredPower} / 1000) : 'unknown'; + + $self->{components}->{poe}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Poe '%s' status is '%s' [instance = %s, power = %s]", + $instance, $result->{extremePethSlotPoeStatus}, + $instance, $result2->{extremePethSlotMeasuredPower})); + $exit = $self->get_severity(section => 'poe', value => $result->{extremePethSlotPoeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Poe '%s' status is '%s'", $instance, $result->{extremePethSlotPoeStatus})); + next; + } + + next if ($result2->{extremePethSlotMeasuredPower} !~ /\d+/); + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'poe', instance => $instance, value => $result2->{extremePethSlotMeasuredPower}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Poe '%s' is '%s' W", $instance, $result2->{extremePethSlotMeasuredPower})); + } + $self->{output}->perfdata_add(label => 'poe_power_' . $instance, unit => 'W', + value => $result2->{extremePethSlotMeasuredPower}, + warning => $warn, + critical => $crit, min => 0 + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/extreme/snmp/mode/components/psu.pm b/centreon-plugins/network/extreme/snmp/mode/components/psu.pm index 6ec457893..cdd40ae1f 100644 --- a/centreon-plugins/network/extreme/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/extreme/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/extreme/snmp/mode/components/slot.pm b/centreon-plugins/network/extreme/snmp/mode/components/slot.pm index 138d7a879..77fcd4a3d 100644 --- a/centreon-plugins/network/extreme/snmp/mode/components/slot.pm +++ b/centreon-plugins/network/extreme/snmp/mode/components/slot.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/extreme/snmp/mode/components/temperature.pm b/centreon-plugins/network/extreme/snmp/mode/components/temperature.pm index 4afff714a..9641a9402 100644 --- a/centreon-plugins/network/extreme/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/extreme/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/extreme/snmp/mode/cpu.pm b/centreon-plugins/network/extreme/snmp/mode/cpu.pm index cd045a7c3..eff61fe4e 100644 --- a/centreon-plugins/network/extreme/snmp/mode/cpu.pm +++ b/centreon-plugins/network/extreme/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/extreme/snmp/mode/hardware.pm b/centreon-plugins/network/extreme/snmp/mode/hardware.pm index 7d556d231..1068f59fc 100644 --- a/centreon-plugins/network/extreme/snmp/mode/hardware.pm +++ b/centreon-plugins/network/extreme/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,12 +28,11 @@ use warnings; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|slot)$'; - $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|psu\.power|psu\.fan)$'; + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|slot|poe)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|poe|psu\.power|psu\.fan)$'; $self->{cb_hook2} = 'snmp_execute'; - #Example for threshold: $self->{thresholds} = { psu => [ ['notPresent', 'OK'], @@ -62,10 +61,22 @@ sub set_system { ['initializing', 'OK'], ['invalid', 'CRITICAL'], ], + poe => [ + ['initializing', 'OK'], + ['operational', 'OK'], + ['downloadFail', 'CRITICAL'], + ['calibrationRequired', 'CRITICAL'], + ['invalidFirmware', 'CRITICAL'], + ['mismatchVersion', 'CRITICAL'], + ['updating', 'OK'], + ['invalidDevice', 'CRITICAL'], + ['notOperational', 'CRITICAL'], + ['other', 'CRITICAL'], + ], }; $self->{components_path} = 'network::extreme::snmp::mode::components'; - $self->{components_module} = ['fan', 'psu', 'slot', 'temperature']; + $self->{components_module} = ['fan', 'psu', 'slot', 'temperature', 'poe']; } sub snmp_execute { @@ -94,14 +105,14 @@ __END__ =head1 MODE -Check Hardware (Fans, Power Supplies, Slot, Temperature). +Check Hardware (Fans, Power Supplies, Slot, Temperature, POEs). =over 8 =item B<--component> Which component to check (Default: '.*'). -Can be: 'fan', 'psu', 'slot', 'temperature'. +Can be: 'fan', 'psu', 'slot', 'temperature', 'poe'. =item B<--filter> diff --git a/centreon-plugins/network/extreme/snmp/mode/memory.pm b/centreon-plugins/network/extreme/snmp/mode/memory.pm index 5444bb1ef..66cbd6749 100644 --- a/centreon-plugins/network/extreme/snmp/mode/memory.pm +++ b/centreon-plugins/network/extreme/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/extreme/snmp/mode/stack.pm b/centreon-plugins/network/extreme/snmp/mode/stack.pm index 706342e7d..7600a0b50 100644 --- a/centreon-plugins/network/extreme/snmp/mode/stack.pm +++ b/centreon-plugins/network/extreme/snmp/mode/stack.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -98,7 +98,6 @@ my $mapping4 = { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $results = $self->{snmp}->get_multiple_table(oids => [ diff --git a/centreon-plugins/network/extreme/snmp/plugin.pm b/centreon-plugins/network/extreme/snmp/plugin.pm index 4c2441ef5..098124dc6 100644 --- a/centreon-plugins/network/extreme/snmp/plugin.pm +++ b/centreon-plugins/network/extreme/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/f5/bigip/mode/components/fan.pm b/centreon-plugins/network/f5/bigip/mode/components/fan.pm index 912d701e8..f9f702686 100644 --- a/centreon-plugins/network/f5/bigip/mode/components/fan.pm +++ b/centreon-plugins/network/f5/bigip/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/f5/bigip/mode/components/psu.pm b/centreon-plugins/network/f5/bigip/mode/components/psu.pm index 705fa73bf..bc369e223 100644 --- a/centreon-plugins/network/f5/bigip/mode/components/psu.pm +++ b/centreon-plugins/network/f5/bigip/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/f5/bigip/mode/components/temperature.pm b/centreon-plugins/network/f5/bigip/mode/components/temperature.pm index c2b5fe378..baef300c9 100644 --- a/centreon-plugins/network/f5/bigip/mode/components/temperature.pm +++ b/centreon-plugins/network/f5/bigip/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/f5/bigip/mode/connections.pm b/centreon-plugins/network/f5/bigip/mode/connections.pm index 863e30138..69ff84b4d 100644 --- a/centreon-plugins/network/f5/bigip/mode/connections.pm +++ b/centreon-plugins/network/f5/bigip/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/f5/bigip/mode/failover.pm b/centreon-plugins/network/f5/bigip/mode/failover.pm index 355407b7e..73d79533e 100644 --- a/centreon-plugins/network/f5/bigip/mode/failover.pm +++ b/centreon-plugins/network/f5/bigip/mode/failover.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/f5/bigip/mode/hardware.pm b/centreon-plugins/network/f5/bigip/mode/hardware.pm index 574e507ef..d8b4b3aa5 100644 --- a/centreon-plugins/network/f5/bigip/mode/hardware.pm +++ b/centreon-plugins/network/f5/bigip/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -33,7 +33,6 @@ sub set_system { $self->{cb_hook2} = 'snmp_execute'; - #Example for threshold: $self->{thresholds} = { fan => [ ['bad', 'CRITICAL'], diff --git a/centreon-plugins/network/f5/bigip/mode/listnodes.pm b/centreon-plugins/network/f5/bigip/mode/listnodes.pm index a0a2f93de..df4dbb99b 100644 --- a/centreon-plugins/network/f5/bigip/mode/listnodes.pm +++ b/centreon-plugins/network/f5/bigip/mode/listnodes.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -80,7 +80,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -106,7 +105,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1); diff --git a/centreon-plugins/network/f5/bigip/mode/listpools.pm b/centreon-plugins/network/f5/bigip/mode/listpools.pm index b7e7ce9c5..17916b0f6 100644 --- a/centreon-plugins/network/f5/bigip/mode/listpools.pm +++ b/centreon-plugins/network/f5/bigip/mode/listpools.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -78,7 +78,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -102,7 +101,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1); diff --git a/centreon-plugins/network/f5/bigip/mode/listvirtualservers.pm b/centreon-plugins/network/f5/bigip/mode/listvirtualservers.pm index 7f7ee7cbc..9a28037de 100644 --- a/centreon-plugins/network/f5/bigip/mode/listvirtualservers.pm +++ b/centreon-plugins/network/f5/bigip/mode/listvirtualservers.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -78,7 +78,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -102,7 +101,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1); diff --git a/centreon-plugins/network/f5/bigip/mode/nodestatus.pm b/centreon-plugins/network/f5/bigip/mode/nodestatus.pm index 05cd16fb9..7d38da636 100644 --- a/centreon-plugins/network/f5/bigip/mode/nodestatus.pm +++ b/centreon-plugins/network/f5/bigip/mode/nodestatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -92,7 +92,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; diff --git a/centreon-plugins/network/f5/bigip/mode/poolstatus.pm b/centreon-plugins/network/f5/bigip/mode/poolstatus.pm index f184244d2..0ee40101d 100644 --- a/centreon-plugins/network/f5/bigip/mode/poolstatus.pm +++ b/centreon-plugins/network/f5/bigip/mode/poolstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -92,7 +92,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; diff --git a/centreon-plugins/network/f5/bigip/mode/virtualserverstatus.pm b/centreon-plugins/network/f5/bigip/mode/virtualserverstatus.pm index 3075a70bc..b425a2b5f 100644 --- a/centreon-plugins/network/f5/bigip/mode/virtualserverstatus.pm +++ b/centreon-plugins/network/f5/bigip/mode/virtualserverstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -92,7 +92,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; diff --git a/centreon-plugins/network/f5/bigip/plugin.pm b/centreon-plugins/network/f5/bigip/plugin.pm index 05d5e0437..4d322b8e1 100644 --- a/centreon-plugins/network/f5/bigip/plugin.pm +++ b/centreon-plugins/network/f5/bigip/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/fortinet/fortigate/plugin.pm b/centreon-plugins/network/fortinet/fortigate/plugin.pm index ec7970c82..1c41a6d17 100644 --- a/centreon-plugins/network/fortinet/fortigate/plugin.pm +++ b/centreon-plugins/network/fortinet/fortigate/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( @@ -42,6 +41,7 @@ sub new { 'memory' => 'centreon::common::fortinet::fortigate::mode::memory', 'sessions' => 'centreon::common::fortinet::fortigate::mode::sessions', 'virus' => 'centreon::common::fortinet::fortigate::mode::virus', + 'vpn' => 'centreon::common::fortinet::fortigate::mode::vpn', ); return $self; diff --git a/centreon-plugins/network/fritzbox/mode/libgetdata.pm b/centreon-plugins/network/fritzbox/mode/libgetdata.pm index cf0c4700c..07e460967 100644 --- a/centreon-plugins/network/fritzbox/mode/libgetdata.pm +++ b/centreon-plugins/network/fritzbox/mode/libgetdata.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/fritzbox/mode/traffic.pm b/centreon-plugins/network/fritzbox/mode/traffic.pm index 6a50214d6..3bd755c7e 100644 --- a/centreon-plugins/network/fritzbox/mode/traffic.pm +++ b/centreon-plugins/network/fritzbox/mode/traffic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/fritzbox/mode/upstatus.pm b/centreon-plugins/network/fritzbox/mode/upstatus.pm index b0ab72a7b..883d7bfd7 100644 --- a/centreon-plugins/network/fritzbox/mode/upstatus.pm +++ b/centreon-plugins/network/fritzbox/mode/upstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/fritzbox/plugin.pm b/centreon-plugins/network/fritzbox/plugin.pm index 6ae1a252f..4418b7c3a 100644 --- a/centreon-plugins/network/fritzbox/plugin.pm +++ b/centreon-plugins/network/fritzbox/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -69,7 +69,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/h3c/snmp/mode/components/default.pm b/centreon-plugins/network/h3c/snmp/mode/components/default.pm index 6be93e67d..b35da93a1 100644 --- a/centreon-plugins/network/h3c/snmp/mode/components/default.pm +++ b/centreon-plugins/network/h3c/snmp/mode/components/default.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -48,7 +48,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking " . $options{component}); $self->{components}->{$options{component}} = {name => $options{component}, total => 0, skip => 0}; - return if ($self->check_exclude(section => $options{component})); + return if ($self->check_filter(section => $options{component})); my $mapping = { EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_default_status }, @@ -58,7 +58,7 @@ sub check { 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)); + next if ($self->check_filter(section => $options{component}, instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => $options{component}, instance => $instance); next; diff --git a/centreon-plugins/network/h3c/snmp/mode/components/fan.pm b/centreon-plugins/network/h3c/snmp/mode/components/fan.pm index a4e2b1cfb..fceaeae16 100644 --- a/centreon-plugins/network/h3c/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/h3c/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -36,7 +36,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); my $mapping = { EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_fan_status }, @@ -46,7 +46,7 @@ sub check { 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)); + next if ($self->check_filter(section => 'fan', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'fan', instance => $instance); next; diff --git a/centreon-plugins/network/h3c/snmp/mode/components/psu.pm b/centreon-plugins/network/h3c/snmp/mode/components/psu.pm index aa963bf58..a3f5be68b 100644 --- a/centreon-plugins/network/h3c/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/h3c/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -36,7 +36,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); my $mapping = { EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_psu_status }, @@ -46,7 +46,7 @@ sub check { 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)); + next if ($self->check_filter(section => 'psu', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'psu', instance => $instance); next; diff --git a/centreon-plugins/network/h3c/snmp/mode/components/sensor.pm b/centreon-plugins/network/h3c/snmp/mode/components/sensor.pm index f6f5735c5..515c149cb 100644 --- a/centreon-plugins/network/h3c/snmp/mode/components/sensor.pm +++ b/centreon-plugins/network/h3c/snmp/mode/components/sensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -36,7 +36,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking sensors"); $self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'sensor')); + return if ($self->check_filter(section => 'sensor')); my $mapping = { EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_sensor_status }, @@ -59,50 +59,47 @@ sub check { 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)); + next if ($self->check_filter(section => 'sensor', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'sensor', instance => $instance); next; } - next if (!(defined($result2->{EntityExtTemperatureThreshold}) && - $result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535)); - my $name = $self->get_long_name(instance => $instance); $self->{components}->{sensor}->{total}++; - if (defined($result2->{EntityExtTemperatureThreshold}) && - $result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535) { - $self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance = %s]", - $name, $result->{EntityExtErrorStatus}, $instance)); - $exit = $self->get_severity(section => 'sensor', value => $result->{EntityExtErrorStatus}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Sensor '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})); - } - - ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result2->{EntityExtTemperature}); - if ($checked == 0) { - my $crit_th = '~:' . $result2->{EntityExtTemperatureThreshold}; - $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => undef); - $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); - - $exit = $self->{perfdata}->threshold_check(value => $result2->{EntityExtTemperature}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, - { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); - $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); - $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); - } - - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature sensor '%s' is %s degree centigrade", $name, $result2->{EntityExtTemperature})); - } - $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', - value => $result2->{EntityExtTemperature}, - warning => $warn, - critical => $crit, - ); + $self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance = %s]", + $name, $result->{EntityExtErrorStatus}, $instance)); + $exit = $self->get_severity(section => 'sensor', value => $result->{EntityExtErrorStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Sensor '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})); } + + next if (defined($result2->{EntityExtTemperature}) && $result2->{EntityExtTemperature} <= 0); + + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result2->{EntityExtTemperature}); + if ($checked == 0 && defined($result2->{EntityExtTemperatureThreshold}) && + $result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535) { + my $crit_th = '~:' . $result2->{EntityExtTemperatureThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => undef); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result2->{EntityExtTemperature}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature sensor '%s' is %s degree centigrade", $name, $result2->{EntityExtTemperature})); + } + $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + value => $result2->{EntityExtTemperature}, + warning => $warn, + critical => $crit, + ); } } diff --git a/centreon-plugins/network/h3c/snmp/mode/cpu.pm b/centreon-plugins/network/h3c/snmp/mode/cpu.pm index 8cb795723..5a5038f08 100644 --- a/centreon-plugins/network/h3c/snmp/mode/cpu.pm +++ b/centreon-plugins/network/h3c/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -94,7 +94,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/h3c/snmp/mode/hardware.pm b/centreon-plugins/network/h3c/snmp/mode/hardware.pm index ac5b9217a..55000458d 100644 --- a/centreon-plugins/network/h3c/snmp/mode/hardware.pm +++ b/centreon-plugins/network/h3c/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,89 +20,138 @@ package network::h3c::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use centreon::plugins::statefile; -my $thresholds = { - psu => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['psuError', 'CRITICAL'], - ['hardwareFaulty', 'CRITICAL'], - ], - fan => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['fanError', 'CRITICAL'], - ['hardwareFaulty', 'CRITICAL'], - ], - sensor => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['sensorError', 'CRITICAL'], - ['hardwareFaulty', 'CRITICAL'], - ], - other => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - unknown => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - chassis => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - backplane => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - container => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - module => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - port => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - stack => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], - cpu => [ - ['notSupported', 'WARNING'], - ['normal', 'OK'], - ['entityAbsent', 'OK'], - ['hardwareFaulty', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook1} = 'init_cache'; + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['psuError', 'CRITICAL'], + ['hardwareFaulty', 'CRITICAL'], + ], + fan => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['fanError', 'CRITICAL'], + ['hardwareFaulty', 'CRITICAL'], + ], + sensor => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['sensorError', 'CRITICAL'], + ['hardwareFaulty', 'CRITICAL'], + ], + other => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + unknown => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + chassis => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + backplane => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + container => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + module => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + port => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + stack => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + cpu => [ + ['notSupported', 'WARNING'], + ['normal', 'OK'], + ['entityAbsent', 'OK'], + ['hardwareFaulty', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'network::h3c::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'slot', 'temperature']; + + $self->{mapping_name} = { + 1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu', + 7 => 'fan', 8 => 'sensor', 9 => 'module', 10 => 'port', 11 => 'stack', 12 => 'cpu' + }; + $self->{mapping_component} = { + 1 => 'default', 2 => 'default', 3 => 'default', 4 => 'default', 5 => 'default', 6 => 'psu', + 7 => 'fan', 8 => 'sensor', 9 => 'default', 10 => 'default', 11 => 'default', 12 => 'default' + }; +} + +my $oid_hh3cEntityExtStateEntry = '.1.3.6.1.4.1.25506.2.6.1.1.1.1'; +my $oid_h3cEntityExtStateEntry = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1'; +my $oid_h3cEntityExtErrorStatus = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1.19'; +my $oid_hh3cEntityExtErrorStatus = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.19'; + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); + $self->write_cache(); + + $self->{branch} = $oid_hh3cEntityExtStateEntry; + if (defined($self->{results}->{$oid_h3cEntityExtErrorStatus}) && scalar(keys %{$self->{results}->{$oid_h3cEntityExtErrorStatus}}) > 0) { + $self->{branch} = $oid_h3cEntityExtStateEntry; + } +} + +sub init_cache { + my ($self, %options) = @_; + + $self->{request} = [ + { oid => $oid_h3cEntityExtErrorStatus }, + { oid => $oid_hh3cEntityExtErrorStatus }, + ]; + $self->check_cache(%options); +} sub new { my ($class, %options) = @_; @@ -111,75 +160,17 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { "reload-cache-time:s" => { name => 'reload_cache_time', default => 180 }, }); - $self->{components} = {}; - $self->{no_components} = undef; - $self->{statefile_cache} = centreon::plugins::statefile->new(%options); - + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); 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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /^(temperature)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } + $self->SUPER::check_options(%options); $self->{statefile_cache}->check_options(%options); } @@ -193,8 +184,8 @@ my $oid_entPhysicalName = '.1.3.6.1.2.1.47.1.1.1.1.7'; sub check_cache { my ($self, %options) = @_; - $self->{hostname} = $self->{snmp}->get_hostname(); - $self->{snmp_port} = $self->{snmp}->get_port(); + $self->{hostname} = $options{snmp}->get_hostname(); + $self->{snmp_port} = $options{snmp}->get_port(); # init cache file $self->{write_cache} = 0; @@ -202,7 +193,7 @@ sub check_cache { my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp'); if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) { - push @{$self->{snmp_request}}, { oid => $oid_entPhysicalEntry, start => $oid_entPhysicalDescr, end => $oid_entPhysicalName }; + push @{$self->{request}}, { oid => $oid_entPhysicalEntry, start => $oid_entPhysicalDescr, end => $oid_entPhysicalName }; $self->{write_cache} = 1; } } @@ -250,159 +241,29 @@ sub get_instance_class { return @instances; } -sub run { +sub load_components { my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $oid_hh3cEntityExtStateEntry = '.1.3.6.1.4.1.25506.2.6.1.1.1.1'; - my $oid_h3cEntityExtStateEntry = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1'; - my $oid_h3cEntityExtErrorStatus = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1.19'; - my $oid_hh3cEntityExtErrorStatus = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.19'; - $self->{snmp_request} = [ - { oid => $oid_h3cEntityExtErrorStatus }, - { oid => $oid_hh3cEntityExtErrorStatus }, - ]; - $self->check_cache(); - - my %mapping_name = ( - 1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu', - 7 => 'fan', 8 => 'sensor', 9 => 'module', 10 => 'port', 11 => 'stack', 12 => 'cpu' - ); - my %mapping_component = ( - 1 => 'default', 2 => 'default', 3 => 'default', 4 => 'default', 5 => 'default', 6 => 'psu', - 7 => 'fan', 8 => 'sensor', 9 => 'default', 10 => 'default', 11 => 'default', 12 => 'default' - ); - my $component = 0; - foreach (keys %mapping_name) { - if ($mapping_name{$_} =~ /$self->{option_results}->{component}/) { - my $mod_name = "network::h3c::snmp::mode::components::" . $mapping_component{$_}; + foreach (keys %{$self->{mapping_name}}) { + if ($self->{mapping_name}->{$_} =~ /$self->{option_results}->{component}/) { + my $mod_name = $self->{components_path} . "::" . $self->{mapping_component}->{$_}; centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, error_msg => "Cannot load module '$mod_name'."); - $component = 1; + $self->{loaded} = 1; } } - if ($component == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } +} + +sub exec_components { + my ($self, %options) = @_; - $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{snmp_request}); - $self->write_cache(); - - $self->{branch} = $oid_hh3cEntityExtStateEntry; - if (defined($self->{results}->{$oid_h3cEntityExtErrorStatus}) && scalar(keys %{$self->{results}->{$oid_h3cEntityExtErrorStatus}}) > 0) { - $self->{branch} = $oid_h3cEntityExtStateEntry; - } - - foreach (keys %mapping_name) { - if ($mapping_name{$_} =~ /$self->{option_results}->{component}/) { - my $mod_name = "network::h3c::snmp::mode::components::" . $mapping_component{$_}; + foreach (keys %{$self->{mapping_name}}) { + if ($self->{mapping_name}->{$_} =~ /$self->{option_results}->{component}/) { + my $mod_name = $self->{components_path} . "::" . $self->{mapping_component}->{$_}; my $func = $mod_name->can('check'); - $func->($self, component => $mapping_name{$_}, component_class => $_); + $func->($self, component => $self->{mapping_name}->{$_}, component_class => $_); } } - - 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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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; @@ -421,10 +282,10 @@ Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'other', 'unknown', 'sensor', 'chassis', 'backplane', 'container', 'module', 'port', 'stack', 'cpu'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan) -Can also exclude specific instance: --exclude=fan#101# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,101 =item B<--absent-problem> @@ -438,7 +299,7 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)' diff --git a/centreon-plugins/network/h3c/snmp/mode/memory.pm b/centreon-plugins/network/h3c/snmp/mode/memory.pm index 36be86cc2..2003f3269 100644 --- a/centreon-plugins/network/h3c/snmp/mode/memory.pm +++ b/centreon-plugins/network/h3c/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -151,7 +151,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/h3c/snmp/plugin.pm b/centreon-plugins/network/h3c/snmp/plugin.pm index 9c9fcd65b..87b22ae32 100644 --- a/centreon-plugins/network/h3c/snmp/plugin.pm +++ b/centreon-plugins/network/h3c/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/fan.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/fan.pm index d4695f9da..896a56c6b 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{hmFanState}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{hmFanState}->{oid} }; } sub check { @@ -44,14 +44,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{hmFanState}->{oid}}})) { next if ($oid !~ /^$mapping->{hmFanState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{hmFanState}->{oid}}, instance => $instance); - next if ($self->check_exclude(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].", diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/led.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/led.pm index cce547c46..9508e90e1 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/led.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/led.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my %map_led_status = ( my $oid_hmLEDGroup = '.1.3.6.1.4.1.248.14.1.1.35'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_hmLEDGroup }; + push @{$self->{request}}, { oid => $oid_hmLEDGroup }; } sub check_led { @@ -49,7 +49,7 @@ sub check_led { $options{mapping}->{$name}->{oid} =~ /\.(\d+)$/; my $instance = $1; - next if ($self->check_exclude(section => 'led', instance => $instance)); + next if ($self->check_filter(section => 'led', instance => $instance)); $self->{components}->{led}->{total}++; $self->{output}->output_add(long_msg => sprintf("Led '%s' status is %s [instance: %s].", @@ -70,7 +70,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking leds"); $self->{components}->{led} = {name => 'leds', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'led')); + return if ($self->check_filter(section => 'led')); my $mapping; if (defined($self->{results}->{$oid_hmLEDGroup}->{$oid_hmLEDGroup . '.1.1.0'})) { diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/psu.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/psu.pm index 9af81b65a..2502fa7e5 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -36,9 +36,9 @@ my $mapping = { }; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $mapping->{hmPSState}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{hmPSState}->{oid} }; } sub check { @@ -46,14 +46,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{hmPSState}->{oid}}})) { next if ($oid !~ /^$mapping->{hmPSState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{hmPSState}->{oid}}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); next if ($result->{hmPSState} =~ /notInstalled/i && $self->absent_problem(section => 'psu', instance => $instance)); $self->{components}->{psu}->{total}++; diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/temperature.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/temperature.pm index 3f571bfb2..5587ec105 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -32,9 +32,9 @@ my $mapping = { my $oid_hmTempTable = '.1.3.6.1.4.1.248.14.2.5'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_hmTempTable }; + push @{$self->{request}}, { oid => $oid_hmTempTable }; } sub check { @@ -42,13 +42,13 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); return if (!defined($self->{results}->{$oid_hmTempTable}->{$mapping->{hmTemperature}->{oid} . '.0'})); my $instance = 0; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hmTempTable}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("temperature is %dC [instance: %s].", diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm index 495f01699..40433e169 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hmCpuUtilization = '.1.3.6.1.4.1.248.14.2.15.2.1.0'; # in % diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/hardware.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/hardware.pm index 5371baf6c..25d148fdd 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/hardware.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,29 +20,48 @@ package network::hirschmann::standard::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['ok', 'OK'], - ['failed', 'CRITICAL'], - ], - psu => [ - ['ok', 'OK'], - ['failed', 'CRITICAL'], - ['notInstalled', 'OK'], - ['unknown', 'UNKNOWN'], - ], - led => [ - ['off', 'UNKNOWN'], - ['green', 'OK'], - ['yellow', 'WARNING'], - ['red', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|led)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ], + psu => [ + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ['notInstalled', 'OK'], + ['unknown', 'UNKNOWN'], + ], + led => [ + ['off', 'UNKNOWN'], + ['green', 'OK'], + ['yellow', 'WARNING'], + ['red', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'network::hirschmann::standard::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature', 'led']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -51,208 +70,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(temperature)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'temperature', 'led'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::hirschmann::standard::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::hirschmann::standard::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ @@ -268,15 +91,15 @@ Check Hardware (Power Supplies, Fans, Temperatures, LEDs). Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'temperature', 'led'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan) -Can also exclude specific instance: --exclude=fan#1.1#,psu#3.2# +Exclude some parts (comma seperated list) (Example: --filter=fan) +Can also exclude specific instance: --filter=fan,1.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=psu#1.1# +Can be specific or global: --absent-problem=psu,1.1 =item B<--no-component> @@ -285,20 +108,20 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,treshold) +Set warning threshold for temperatures (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,treshold) +Set critical threshold for temperatures (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm index 43cd65945..6a15e5f27 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hmMemoryFree = '.1.3.6.1.4.1.248.14.2.15.3.2.0'; # in KBytes diff --git a/centreon-plugins/network/hirschmann/standard/snmp/mode/processcount.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/processcount.pm index 580285cc1..87f996fff 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/processcount.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/processcount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hmCpuRunningProcesses = '.1.3.6.1.4.1.248.14.2.15.2.3.0'; diff --git a/centreon-plugins/network/hirschmann/standard/snmp/plugin.pm b/centreon-plugins/network/hirschmann/standard/snmp/plugin.pm index 6a35b8220..83fe5e7d0 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/plugin.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/hp/procurve/mode/components/sensor.pm b/centreon-plugins/network/hp/procurve/mode/components/sensor.pm index de152d1a0..018782694 100644 --- a/centreon-plugins/network/hp/procurve/mode/components/sensor.pm +++ b/centreon-plugins/network/hp/procurve/mode/components/sensor.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,9 +45,9 @@ my $mapping = { my $oid_hpicfSensorEntry = '.1.3.6.1.4.1.11.2.14.11.1.2.6.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_hpicfSensorEntry }; + push @{$self->{request}}, { oid => $oid_hpicfSensorEntry }; } sub check { @@ -56,7 +56,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking sensors"); $self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'sensor')); + return if ($self->check_filter(section => 'sensor')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hpicfSensorEntry}})) { next if ($oid !~ /^$mapping->{hpicfSensorStatus}->{oid}\.(.*)$/); @@ -64,7 +64,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hpicfSensorEntry}, instance => $instance_mapping); my $instance = $result->{hpicfSensorObjectId} . '.' . $instance_mapping; - next if ($self->check_exclude(section => 'sensor', instance => $instance)); + next if ($self->check_filter(section => 'sensor', instance => $instance)); next if ($result->{hpicfSensorStatus} =~ /not present/i && $self->absent_problem(section => 'sensor', instance => $instance)); $self->{components}->{sensor}->{total}++; diff --git a/centreon-plugins/network/hp/procurve/mode/cpu.pm b/centreon-plugins/network/hp/procurve/mode/cpu.pm index b6abb066e..2336a830f 100644 --- a/centreon-plugins/network/hp/procurve/mode/cpu.pm +++ b/centreon-plugins/network/hp/procurve/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hpSwitchCpuStat = '.1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0'; diff --git a/centreon-plugins/network/hp/procurve/mode/environment.pm b/centreon-plugins/network/hp/procurve/mode/environment.pm index 64d39f504..dc2b0d9a9 100644 --- a/centreon-plugins/network/hp/procurve/mode/environment.pm +++ b/centreon-plugins/network/hp/procurve/mode/environment.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,179 +20,52 @@ package network::hp::procurve::mode::environment; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - sensor => [ - ['unknown', 'UNKNOWN'], - ['bad', 'CRITICAL'], - ['warning', 'WARNING'], - ['good', 'OK'], - ['not present', 'WARNING'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(sensor)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + sensor => [ + ['unknown', 'UNKNOWN'], + ['bad', 'CRITICAL'], + ['warning', 'WARNING'], + ['good', 'OK'], + ['not present', 'WARNING'], + ], + }; + + $self->{components_path} = 'network::hp::procurve::mode::components'; + $self->{components_module} = ['sensor']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, }); 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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ('sensor', $1, $2); - 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}; - } -} - -sub check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -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 run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('sensor'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::hp::procurve::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::hp::procurve::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(); -} - 1; __END__ @@ -208,15 +81,15 @@ Check sensors (hpicfChassis.mib). Which component to check (Default: '.*'). Can be: 'sensor'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) -Can also exclude specific instance: --exclude=sensor#fan.1# +Exclude some parts (comma seperated list) (Example: --filter=sensor) +Can also exclude specific instance: --filter=sensor,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=sensor#temperature.2# +Can be specific or global: --absent-problem=sensor,temperature.2 =item B<--no-component> @@ -225,9 +98,9 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). -Example: --threshold-overload='CRITICAL,^(?!(good)$)' +Example: --threshold-overload='sensor,CRITICAL,^(?!(good)$)' =back diff --git a/centreon-plugins/network/hp/procurve/mode/memory.pm b/centreon-plugins/network/hp/procurve/mode/memory.pm index 1f6abb32a..a78d23fe3 100644 --- a/centreon-plugins/network/hp/procurve/mode/memory.pm +++ b/centreon-plugins/network/hp/procurve/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hpGlobalMemEntry = '.1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1'; diff --git a/centreon-plugins/network/hp/procurve/plugin.pm b/centreon-plugins/network/hp/procurve/plugin.pm index c8f4132eb..d79ca65d3 100644 --- a/centreon-plugins/network/hp/procurve/plugin.pm +++ b/centreon-plugins/network/hp/procurve/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/domain.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/domain.pm new file mode 100644 index 000000000..61be91892 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/domain.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::domain; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcDomainName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.1.1' }, + vcDomainManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.1.2', map => $map_managed_status }, + vcDomainReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.1.10', map => $map_reason_code }, +}; +my $oid_vcDomain = '.1.3.6.1.4.1.11.5.7.5.2.1.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcDomain }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking domains"); + $self->{components}->{domain} = { name => 'domains', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'domain')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcDomain}})) { + next if ($oid !~ /^$mapping->{vcDomainManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcDomain}, instance => $instance); + + next if ($self->check_filter(section => 'domain', instance => $instance)); + $self->{components}->{domain}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("domain '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcDomainName}, $result->{vcDomainManagedStatus}, + $instance, $result->{vcDomainReasonCode} + )); + my $exit = $self->get_severity(section => 'domain', label => 'default', value => $result->{vcDomainManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Domain '%s' status is '%s'", + $result->{vcDomainName}, $result->{vcDomainManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/enclosure.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/enclosure.pm new file mode 100644 index 000000000..326d63518 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/enclosure.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::enclosure; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcEnclosureName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1.2' }, + vcEnclosureManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1.3', map => $map_managed_status }, + vcEnclosureReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1.9', map => $map_reason_code }, +}; +my $oid_vcEnclosureEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcEnclosureEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosures"); + $self->{components}->{enclosure} = { name => 'enclosures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'enclosure')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcEnclosureEntry}})) { + next if ($oid !~ /^$mapping->{vcEnclosureManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcEnclosureEntry}, instance => $instance); + + next if ($self->check_filter(section => 'enclosure', instance => $instance)); + $self->{components}->{enclosure}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcEnclosureName}, $result->{vcEnclosureManagedStatus}, + $instance, $result->{vcEnclosureReasonCode} + )); + my $exit = $self->get_severity(section => 'enclosure', label => 'default', value => $result->{vcEnclosureManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure '%s' status is '%s'", + $result->{vcEnclosureName}, $result->{vcEnclosureManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/enet.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/enet.pm new file mode 100644 index 000000000..2514ee9a2 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/enet.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::enet; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcEnetNetworkName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1.2' }, + vcEnetNetworkManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1.3', map => $map_managed_status }, + vcEnetNetworkReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1.7', map => $map_reason_code }, +}; +my $oid_vcEnetNetworkEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcEnetNetworkEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking ethernet network"); + $self->{components}->{enet} = { name => 'enet', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'enet')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcEnetNetworkEntry}})) { + next if ($oid !~ /^$mapping->{vcEnetNetworkManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcEnetNetworkEntry}, instance => $instance); + + next if ($self->check_filter(section => 'enet', instance => $instance)); + $self->{components}->{enet}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("ethernet network '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcEnetNetworkName}, $result->{vcEnetNetworkManagedStatus}, + $instance, $result->{vcEnetNetworkReasonCode} + )); + my $exit = $self->get_severity(section => 'enet', label => 'default', value => $result->{vcEnetNetworkManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Ethernet network '%s' status is '%s'", + $result->{vcEnetNetworkName}, $result->{vcEnetNetworkManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/fc.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/fc.pm new file mode 100644 index 000000000..38c2881dd --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/fc.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::fc; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcFcFabricName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1.2' }, + vcFcFabricManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1.3', map => $map_managed_status }, + vcFcFabricReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1.6', map => $map_reason_code }, +}; +my $oid_vcFcFabricEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcFcFabricEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fc"); + $self->{components}->{fc} = { name => 'fc', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fc')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcFcFabricEntry}})) { + next if ($oid !~ /^$mapping->{vcFcFabricManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcFcFabricEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fc', instance => $instance)); + $self->{components}->{fc}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fc '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcFcFabricName}, $result->{vcFcFabricManagedStatus}, + $instance, $result->{vcFcFabricReasonCode} + )); + my $exit = $self->get_severity(section => 'fc', label => 'default', value => $result->{vcFcFabricManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fc '%s' status is '%s'", + $result->{vcFcFabricName}, $result->{vcFcFabricManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/module.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/module.pm new file mode 100644 index 000000000..d6117dcdd --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/module.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::module; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcModuleProductName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1.6' }, + vcModuleManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1.3', map => $map_managed_status }, + vcModuleReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1.15', map => $map_reason_code }, +}; +my $oid_vcModuleEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcModuleEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking modules"); + $self->{components}->{module} = { name => 'modules', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'module')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcModuleEntry}})) { + next if ($oid !~ /^$mapping->{vcModuleManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcModuleEntry}, instance => $instance); + + next if ($self->check_filter(section => 'module', instance => $instance)); + $self->{components}->{module}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("module '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcModuleProductName}, $result->{vcModuleManagedStatus}, + $instance, $result->{vcModuleReasonCode} + )); + my $exit = $self->get_severity(section => 'module', label => 'default', value => $result->{vcModuleManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Module '%s' status is '%s'", + $result->{vcModuleProductName}, $result->{vcModuleManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/moduleport.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/moduleport.pm new file mode 100644 index 000000000..2c10b824a --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/moduleport.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::moduleport; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_moduleport_loop_status $map_moduleport_protection_status); + +my $mapping = { + vcModulePortBpduLoopStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.3.1.1.6.1.3', map => $map_moduleport_loop_status }, + vcModulePortProtectionStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.3.1.1.6.1.4', map => $map_moduleport_protection_status }, +}; +my $oid_vcModulePortEntry = '.1.3.6.1.4.1.11.5.7.5.2.3.1.1.6.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcModulePortEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking module ports"); + $self->{components}->{moduleport} = { name => 'module ports', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'moduleport')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcModulePortEntry}})) { + next if ($oid !~ /^$mapping->{vcModulePortBpduLoopStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcModulePortEntry}, instance => $instance); + + next if ($self->check_filter(section => 'moduleport', instance => $instance)); + $self->{components}->{moduleport}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("module port '%s' loop status is '%s' [instance: %s, protection status: %s].", + $instance, $result->{vcModulePortBpduLoopStatus}, + $instance, $result->{vcModulePortProtectionStatus} + )); + my $exit = $self->get_severity(section => 'moduleport.loop', value => $result->{vcModulePortBpduLoopStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Module port '%s' loop status is '%s'", + $instance, $result->{vcModulePortBpduLoopStatus})); + } + + $exit = $self->get_severity(section => 'moduleport.protection', value => $result->{vcModulePortProtectionStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Module port '%s' protection status is '%s'", + $instance, $result->{vcModulePortProtectionStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/physicalserver.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/physicalserver.pm new file mode 100644 index 000000000..931c78cfc --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/physicalserver.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::physicalserver; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcPhysicalServerManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.5.1.1.3', map => $map_managed_status }, + vcPhysicalServerReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.5.1.1.10', map => $map_reason_code }, +}; +my $oid_vcPhysicalServerEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.5.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcPhysicalServerEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking physical servers"); + $self->{components}->{physicalserver} = { name => 'physical servers', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'physicalserver')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcPhysicalServerEntry}})) { + next if ($oid !~ /^$mapping->{vcPhysicalServerManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcPhysicalServerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'physicalserver', instance => $instance)); + $self->{components}->{physicalserver}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("physical server '%s' status is '%s' [instance: %s, reason: %s].", + $instance, $result->{vcPhysicalServerManagedStatus}, + $instance, $result->{vcPhysicalServerReasonCode} + )); + my $exit = $self->get_severity(section => 'physicalserver', label => 'default', value => $result->{vcPhysicalServerManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Physical server '%s' status is '%s'", + $result->{vcModuleProductName}, $result->{vcPhysicalServerManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/port.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/port.pm new file mode 100644 index 000000000..601107ea7 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/port.pm @@ -0,0 +1,65 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::port; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcPortManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.4.1.1.3', map => $map_managed_status }, +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{vcPortManagedStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking ports"); + $self->{components}->{port} = { name => 'ports', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'port')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{vcPortManagedStatus}->{oid}}})) { + $oid =~ /^$mapping->{vcPortManagedStatus}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{vcPortManagedStatus}->{oid}}, instance => $instance); + + next if ($self->check_filter(section => 'port', instance => $instance)); + $self->{components}->{port}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("port '%s' status is '%s' [instance: %s].", + $instance, $result->{vcPortManagedStatus}, + $instance + )); + my $exit = $self->get_severity(section => 'port', label => 'default', value => $result->{vcPortManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Port '%s' status is '%s'", + $instance, $result->{vcPortManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/profile.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/profile.pm new file mode 100644 index 000000000..9c02b1889 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/profile.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::profile; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcProfileName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1.2' }, + vcProfileManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1.3', map => $map_managed_status }, + vcProfileReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1.8', map => $map_reason_code }, +}; +my $oid_vcProfileEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcProfileEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking profiles"); + $self->{components}->{profile} = { name => 'profiles', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'profile')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcProfileEntry}})) { + next if ($oid !~ /^$mapping->{vcProfileManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcProfileEntry}, instance => $instance); + + next if ($self->check_filter(section => 'profile', instance => $instance)); + $self->{components}->{profile}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("profile '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcProfileName}, $result->{vcProfileManagedStatus}, + $instance, $result->{vcProfileReasonCode} + )); + my $exit = $self->get_severity(section => 'profile', label => 'default', value => $result->{vcProfileManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Profile '%s' status is '%s'", + $result->{vcProfileName}, $result->{vcProfileManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/components/resources.pm b/centreon-plugins/network/hp/vc/snmp/mode/components/resources.pm new file mode 100644 index 000000000..abc987d62 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/components/resources.pm @@ -0,0 +1,119 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_managed_status; +our $map_reason_code; +our $map_moduleport_loop_status; +our $map_moduleport_protection_status; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_managed_status $map_reason_code $map_moduleport_loop_status $map_moduleport_protection_status); + +$map_managed_status = { + 1 => 'unknown', + 2 => 'normal', + 3 => 'warning', + 4 => 'minor', + 5 => 'major', + 6 => 'critical', + 7 => 'disabled', + 8 => 'info', +}; + +$map_reason_code = { + 100 => 'vcNetworkOk', + 101 => 'vcNetworkUnknown', + 102 => 'vcNetworkDisabled', + 104 => 'vcNetworkAbnormal', + 105 => 'vcNetworkFailed', + 106 => 'vcNetworkDegraded', + 109 => 'vcNetworkNoPortsAssignedToPrivateNetwork', + 200 => 'vcFabricOk', + 202 => 'vcFabricNoPortsConfigured', + 203 => 'vcFabricSomePortsAbnormal', + 204 => 'vcFabricAllPortsAbnormal', + 205 => 'vcFabricWwnMismatch', + 206 => 'vcFabricUnknown', + 300 => 'vcProfileOk', + 301 => 'vcProfileServerAbnormal', + 304 => 'vcProfileAllConnectionsFailed', + 309 => 'vcProfileSomeConnectionsUnmapped', + 310 => 'vcProfileAllConnectionsAbnormal', + 311 => 'vcProfileSomeConnectionsAbnormal', + 312 => 'vcProfileUEFIBootmodeIncompatibleWithServer', + 313 => 'vcProfileUnknown', + 400 => 'vcEnetmoduleOk', + 401 => 'vcEnetmoduleEnclosureDown', + 402 => 'vcEnetmoduleModuleMissing', + 404 => 'vcEnetmodulePortprotect', + 405 => 'vcEnetmoduleIncompatible', + 406 => 'vcEnetmoduleHwDegraded', + 407 => 'vcEnetmoduleUnknown', + 408 => 'vcFcmoduleOk', + 409 => 'vcFcmoduleEnclosureDown', + 410 => 'vcFcmoduleModuleMissing', + 412 => 'vcFcmoduleHwDegraded', + 413 => 'vcFcmoduleIncompatible', + 414 => 'vcFcmoduleUnknown', + 500 => 'vcPhysicalServerOk', + 501 => 'vcPhysicalServerEnclosureDown', + 502 => 'vcPhysicalServerFailed', + 503 => 'vcPhysicalServerDegraded', + 504 => 'vcPhysicalServerUnknown', + 600 => 'vcEnclosureOk', + 601 => 'vcEnclosureAllEnetModulesFailed', + 602 => 'vcEnclosureSomeEnetModulesAbnormal', + 603 => 'vcEnclosureSomeModulesOrServersIncompatible', + 604 => 'vcEnclosureSomeFcModulesAbnormal', + 605 => 'vcEnclosureSomeServersAbnormal', + 606 => 'vcEnclosureUnknown', + 700 => 'vcDomainOk', + 701 => 'vcDomainAbnormalEnclosuresAndProfiles', + 702 => 'vcDomainSomeEnclosuresAbnormal', + 703 => 'vcDomainUnmappedProfileConnections', + 706 => 'vcDomainStackingFailed', + 707 => 'vcDomainStackingNotRedundant', + 709 => 'vcDomainSomeProfilesAbnormal', + 712 => 'vcDomainUnknown', + 713 => 'vcDomainOverProvisioned', + 801 => 'vcDomainSflowIndirectlyDisabled', + 802 => 'vcDomainSflowFailed', + 803 => 'vcDomainSflowDegraded', + 901 => 'vcDomainPortMonitorIndirectlyDisabled', +}; + +$map_moduleport_protection_status = { + 1 => 'ok', + 2 => 'pause-flood-detected', + 3 => 'in-pause-condition', +}; + +$map_moduleport_loop_status = { + 1 => 'ok', + 2 => 'loop-dectected', +}; + +1; \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/mode/hardware.pm b/centreon-plugins/network/hp/vc/snmp/mode/hardware.pm new file mode 100644 index 000000000..800c45409 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/mode/hardware.pm @@ -0,0 +1,114 @@ +# +# Copyright 2016 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::hp::vc::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(domain|enclosure|module|port|moduleport|physicalserver|enet|fc|profile)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['minor', 'WARNING'], + ['major', 'CRITICAL'], + ['critical', 'CRITICAL'], + ['disabled', 'OK'], + ['info', 'OK'], + ], + 'moduleport.loop' => [ + ['ok', 'OK'], + ['loop-detected', 'CRITICAL'], + ], + 'moduleport.protection' => [ + ['ok', 'OK'], + ['pause-flood-detected', 'CRITICAL'], + ['in-pause-condition', 'WARNING'], + ], + }; + + $self->{components_path} = 'network::hp::vc::snmp::mode::components'; + $self->{components_module} = ['domain', 'enclosure', 'module', 'moduleport', 'port', 'physicalserver', 'enet', 'fc', 'profile']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'domain', 'enclosure', 'module', 'moduleport', 'port', 'physicalserver', 'enet', 'fc', 'profile'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=enet --filter=fc) +Can also exclude specific instance: --filter=fc,1 + +=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='module,CRITICAL,^(?!(normal)$)' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/network/hp/vc/snmp/plugin.pm b/centreon-plugins/network/hp/vc/snmp/plugin.pm new file mode 100644 index 000000000..30492d560 --- /dev/null +++ b/centreon-plugins/network/hp/vc/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::hp::vc::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}} = ( + 'hardware' => 'network::hp::vc::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check HP Virtual Connect in SNMP. + +=cut diff --git a/centreon-plugins/network/juniper/common/ive/mode/cpu.pm b/centreon-plugins/network/juniper/common/ive/mode/cpu.pm index fa7f476b0..54a178d03 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/cpu.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_iveCpuUtil = '.1.3.6.1.4.1.12532.10.0'; diff --git a/centreon-plugins/network/juniper/common/ive/mode/disk.pm b/centreon-plugins/network/juniper/common/ive/mode/disk.pm index 9a09f4b07..3f95bcfee 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/disk.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_diskFullPercent = '.1.3.6.1.4.1.12532.25.0'; diff --git a/centreon-plugins/network/juniper/common/ive/mode/logfile.pm b/centreon-plugins/network/juniper/common/ive/mode/logfile.pm index 88f3d825b..d8fdfcb4f 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/logfile.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/logfile.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_logFullPercent = '.1.3.6.1.4.1.12532.1.0'; diff --git a/centreon-plugins/network/juniper/common/ive/mode/users.pm b/centreon-plugins/network/juniper/common/ive/mode/users.pm index 04619612e..f6ca96244 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/users.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/users.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,11 +20,53 @@ package network::juniper::common::ive::mode::users; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'web', set => { + key_values => [ { name => 'web' } ], + output_template => 'Current concurrent signed-in web users connections: %s', output_error_template => 'Current concurrent signed-in web users connections: %s', + perfdatas => [ + { label => 'web', value => 'web_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'meeting', set => { + key_values => [ { name => 'meeting' } ], + output_template => 'Current concurrent meeting users connections: %s', output_error_template => 'Current concurrent meeting users connections: %s', + perfdatas => [ + { label => 'meeting', value => 'meeting_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'node', set => { + key_values => [ { name => 'node' } ], + output_template => 'Current concurrent node logged users connections: %s', output_error_template => 'Current concurrent node logged users connections: %s', + perfdatas => [ + { label => 'node', value => 'node_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'cluster', set => { + key_values => [ { name => 'cluster' } ], + output_template => 'Current concurrent cluster logged users connections: %s', output_error_template => 'Current concurrent cluster logged users connections: %s', + perfdatas => [ + { label => 'cluster', value => 'cluster_absolute', template => '%s', min => 0 }, + ], + } + }, + ]; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -33,114 +75,24 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning-web:s" => { name => 'warning_web' }, - "critical-web:s" => { name => 'critical_web' }, - "warning-meeting:s" => { name => 'warning_meeting' }, - "critical-meeting:s" => { name => 'critical_meeting' }, - "warning-node:s" => { name => 'warning_node' }, - "critical-node:s" => { name => 'critical_node' }, - "warning-cluster:s" => { name => 'warning_cluster' }, - "critical-cluster:s" => { name => 'critical_cluster' }, }); return $self; } -sub check_options { +sub manage_selection { my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning_web', value => $self->{option_results}->{warning_web})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning web threshold '" . $self->{option_results}->{warning_web} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_web', value => $self->{option_results}->{critical_web})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical web threshold '" . $self->{option_results}->{critical_web} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning_meeting', value => $self->{option_results}->{warning_meeting})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning meeting threshold '" . $self->{option_results}->{warning_meeting} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_meeting', value => $self->{option_results}->{critical_meeting})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical meeting threshold '" . $self->{option_results}->{critical_meeting} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning_node', value => $self->{option_results}->{warning_node})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning node threshold '" . $self->{option_results}->{warning_node} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_node', value => $self->{option_results}->{critical_node})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical node threshold '" . $self->{option_results}->{critical_node} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning_cluster', value => $self->{option_results}->{warning_cluster})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning cluster threshold '" . $self->{option_results}->{warning_cluster} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical_cluster', value => $self->{option_results}->{critical_cluster})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical cluster threshold '" . $self->{option_results}->{critical_cluster} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; my $oid_signedInWebUsers = '.1.3.6.1.4.1.12532.2.0'; my $oid_meetingUserCount = '.1.3.6.1.4.1.12532.9.0'; my $oid_iveConcurrentUsers = '.1.3.6.1.4.1.12532.12.0'; my $oid_clusterConcurrentUsers = '.1.3.6.1.4.1.12532.13.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_signedInWebUsers, $oid_meetingUserCount, - $oid_iveConcurrentUsers, $oid_clusterConcurrentUsers], nothing_quit => 1); - - my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_signedInWebUsers}, - threshold => [ { label => 'critical_web', 'exit_litteral' => 'critical' }, { label => 'warning_web', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_meetingUserCount}, - threshold => [ { label => 'critical_meeting', 'exit_litteral' => 'critical' }, { label => 'warning_meeting', exit_litteral => 'warning' } ]); - my $exit3 = $self->{perfdata}->threshold_check(value => $result->{$oid_iveConcurrentUsers}, - threshold => [ { label => 'critical_node', 'exit_litteral' => 'critical' }, { label => 'warning_node', exit_litteral => 'warning' } ]); - my $exit4 = $self->{perfdata}->threshold_check(value => $result->{$oid_clusterConcurrentUsers}, - threshold => [ { label => 'critical_cluster', 'exit_litteral' => 'critical' }, { label => 'warning_cluster', exit_litteral => 'warning' } ]); - - $self->{output}->output_add(severity => $exit1, - short_msg => sprintf("Current concurrent signed-in web users connections: %d", - $result->{$oid_signedInWebUsers})); - $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("Current concurrent meeting users connections: %s", - defined($result->{$oid_meetingUserCount}) ? $result->{$oid_meetingUserCount} : 'unknown')); - $self->{output}->output_add(severity => $exit3, - short_msg => sprintf("Current concurrent node logged users connections: %d", - $result->{$oid_iveConcurrentUsers})); - $self->{output}->output_add(severity => $exit4, - short_msg => sprintf("Current concurrent cluster logged users connections: %d", - $result->{$oid_clusterConcurrentUsers})); - - $self->{output}->perfdata_add(label => "web", - value => $result->{$oid_signedInWebUsers}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_web'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_web'), - min => 0); - $self->{output}->perfdata_add(label => "meeting", - value => $result->{$oid_meetingUserCount}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_meeting'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_meeting'), - min => 0); - $self->{output}->perfdata_add(label => "node", - value => $result->{$oid_iveConcurrentUsers}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_node'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_node'), - min => 0); - $self->{output}->perfdata_add(label => "cluster", - value => $result->{$oid_clusterConcurrentUsers}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_cluster'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_cluster'), - min => 0); - - $self->{output}->display(); - $self->{output}->exit(); + my $result = $options{snmp}->get_leef(oids => [$oid_signedInWebUsers, $oid_meetingUserCount, + $oid_iveConcurrentUsers, $oid_clusterConcurrentUsers], nothing_quit => 1); + $self->{global} = { web => $result->{$oid_signedInWebUsers}, + meeting => $result->{$oid_meetingUserCount}, + node => $result->{$oid_iveConcurrentUsers}, + cluster => $result->{$oid_clusterConcurrentUsers} }; } 1; @@ -153,37 +105,20 @@ Check users connections (web users, cluster users, node users, meeting users) (J =over 8 -=item B<--warning-web> +=item B<--filter-counters> -Threshold warning for users connected and uses the web feature. +Only display some counters (regexp can be used). +Example: --filter-counters='^web|meeting$' -=item B<--critical-web> +=item B<--warning-*> -Threshold critical for users connected and uses the web feature. +Threshold warning. +Can be: 'web', 'meeting', 'node', 'cluster'. -=item B<--warning-meeting> +=item B<--critical-*> -Threshold warning for secure meeting users connected. - -=item B<--critical-meeting> - -Threshold critical for secure meeting users connected. - -=item B<--warning-node> - -Threshold warning for users in this node that are logged in. - -=item B<--critical-node> - -Threshold critical for users in this node that are logged in. - -=item B<--warning-cluster> - -Threshold warning for users in this cluster that are logged in. - -=item B<--critical-cluster> - -Threshold critical for users in this cluster that are logged in. +Threshold critical. +Can be: 'web', 'meeting', 'node', 'cluster'. =back diff --git a/centreon-plugins/network/juniper/common/junos/mode/components/fru.pm b/centreon-plugins/network/juniper/common/junos/mode/components/fru.pm index b9458b2e9..306c94f0c 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/components/fru.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/components/fru.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -76,9 +76,9 @@ my $mapping = { my $oid_jnxFruEntry = '.1.3.6.1.4.1.2636.3.1.15.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_jnxFruEntry, start => $mapping->{jnxFruName}->{oid}, end => $mapping->{jnxFruOfflineReason}->{oid} }; + push @{$self->{request}}, { oid => $oid_jnxFruEntry, start => $mapping->{jnxFruName}->{oid}, end => $mapping->{jnxFruOfflineReason}->{oid} }; } sub check { @@ -86,14 +86,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking frus"); $self->{components}->{fru} = {name => 'frus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fru')); + return if ($self->check_filter(section => 'fru')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_jnxFruEntry}})) { next if ($oid !~ /^$mapping->{jnxFruName}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_jnxFruEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fru', instance => $instance)); + next if ($self->check_filter(section => 'fru', instance => $instance)); next if ($result->{jnxFruState} =~ /empty/i && $self->absent_problem(section => 'fru', instance => $instance)); $self->{components}->{fru}->{total}++; diff --git a/centreon-plugins/network/juniper/common/junos/mode/components/operating.pm b/centreon-plugins/network/juniper/common/junos/mode/components/operating.pm index 3b3ad5bea..1e388ea34 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/components/operating.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/components/operating.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -41,9 +41,9 @@ my $mapping = { my $oid_jnxOperatingEntry = '.1.3.6.1.4.1.2636.3.1.13.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_jnxOperatingEntry, start => $mapping->{jnxOperatingDescr}->{oid}, end => $mapping->{jnxOperatingState}->{oid} }; + push @{$self->{request}}, { oid => $oid_jnxOperatingEntry, start => $mapping->{jnxOperatingDescr}->{oid}, end => $mapping->{jnxOperatingState}->{oid} }; } sub check { @@ -51,14 +51,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking operatings"); $self->{components}->{operating} = {name => 'operatings', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'operating')); + return if ($self->check_filter(section => 'operating')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_jnxOperatingEntry}})) { next if ($oid !~ /^$mapping->{jnxOperatingDescr}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_jnxOperatingEntry}, instance => $instance); - next if ($self->check_exclude(section => 'operating', instance => $instance)); + next if ($self->check_filter(section => 'operating', instance => $instance)); $self->{components}->{operating}->{total}++; $self->{output}->output_add(long_msg => sprintf("Operating '%s' state is %s [instance: %s]", diff --git a/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm b/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm index 942e719f8..7b4817ad2 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_jnxJsSPUMonitoringSPUIndex = '.1.3.6.1.4.1.2636.3.39.1.12.1.1.1.3'; diff --git a/centreon-plugins/network/juniper/common/junos/mode/cpuforwarding.pm b/centreon-plugins/network/juniper/common/junos/mode/cpuforwarding.pm index 934fe4ab2..eec24a5ec 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/cpuforwarding.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/cpuforwarding.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_jnxJsSPUMonitoringSPUIndex = '.1.3.6.1.4.1.2636.3.39.1.12.1.1.1.3'; diff --git a/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm b/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm index db1a51755..478fb4639 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_jnxOperatingDescr = '.1.3.6.1.4.1.2636.3.1.13.1.5'; diff --git a/centreon-plugins/network/juniper/common/junos/mode/flowsessions.pm b/centreon-plugins/network/juniper/common/junos/mode/flowsessions.pm index 923d44bc0..4b8c0a53a 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/flowsessions.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/flowsessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_jnxJsSPUMonitoringSPUIndex = '.1.3.6.1.4.1.2636.3.39.1.12.1.1.1.3'; diff --git a/centreon-plugins/network/juniper/common/junos/mode/hardware.pm b/centreon-plugins/network/juniper/common/junos/mode/hardware.pm index 8f31b2469..1dec0789b 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/hardware.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,34 +20,54 @@ package network::juniper::common::junos::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fru => [ - ['unknown', 'UNKNOWN'], - ['present', 'OK'], - ['ready', 'OK'], - ['announce online', 'OK'], - ['online', 'OK'], - ['announce offline', 'WARNING'], - ['offline', 'CRITICAL'], - ['diagnostic', 'WARNING'], - ['standby', 'WARNING'], - ['empty', 'OK'], - ], - operating => [ - ['unknown', 'UNKNOWN'], - ['running', 'OK'], - ['ready', 'OK'], - ['reset', 'WARNING'], - ['runningAtFullSpeed', 'WARNING'], - ['down', 'CRITICAL'], - ['standby', 'OK'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fru|operating)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(fru-temperature)$'; + + $self->{cb_hook1} = 'get_type'; + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fru => [ + ['unknown', 'UNKNOWN'], + ['present', 'OK'], + ['ready', 'OK'], + ['announce online', 'OK'], + ['online', 'OK'], + ['announce offline', 'WARNING'], + ['offline', 'CRITICAL'], + ['diagnostic', 'WARNING'], + ['standby', 'WARNING'], + ['empty', 'OK'], + ], + operating => [ + ['unknown', 'UNKNOWN'], + ['running', 'OK'], + ['ready', 'OK'], + ['reset', 'WARNING'], + ['runningAtFullSpeed', 'WARNING'], + ['down', 'CRITICAL'], + ['standby', 'OK'], + ], + }; + + $self->{components_path} = 'network::juniper::common::junos::mode::components'; + $self->{components_module} = ['fru', 'operating']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -56,220 +76,23 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(fru-temperature)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: fru-temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - $self->get_type(); - - my $snmp_request = []; - my @components = ('fru', 'operating'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::juniper::common::junos::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::juniper::common::junos::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 get_type { - my ($self) = @_; + my ($self, %options) = @_; my $oid_jnxBoxDescr = ".1.3.6.1.4.1.2636.3.1.2.0"; - my $result = $self->{snmp}->get_leef(oids => [$oid_jnxBoxDescr]); + my $result = $options{snmp}->get_leef(oids => [$oid_jnxBoxDescr]); $self->{env_type} = defined($result->{$oid_jnxBoxDescr}) ? $result->{$oid_jnxBoxDescr} : 'unknown'; $self->{output}->output_add(long_msg => sprintf("Environment type: %s", $self->{env_type})); } - -sub check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ @@ -285,15 +108,15 @@ Check Hardware (mib-jnx-chassis) (frus, operating). Which component to check (Default: '.*'). Can be: 'fru', 'operating'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fru) -Can also exclude specific instance: --exclude=fru#7.3.0.0# +Exclude some parts (comma seperated list) (Example: --filter=fru) +Can also exclude specific instance: --filter=fru,7.3.0.0 =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=fru#7.1.0.0# +Can be specific or global: --absent-problem=fru,7.1.0.0 =item B<--no-component> @@ -302,18 +125,18 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='operating,CRITICAL,^(?!(running)$)' =item B<--warning> -Set warning threshold for fru temperatures (syntax: type,regexp,treshold) +Set warning threshold for fru temperatures (syntax: type,regexp,threshold) Example: --warning='fru-temperature,.*,30' =item B<--critical> -Set critical threshold for fru temperatures (syntax: type,regexp,treshold) +Set critical threshold for fru temperatures (syntax: type,regexp,threshold) Example: --critical='fru-temperature,.*,40' =back diff --git a/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm b/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm index 50746d617..ca4eefdab 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_jnxJsSPUMonitoringSPUIndex = '.1.3.6.1.4.1.2636.3.39.1.12.1.1.1.3'; diff --git a/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm b/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm index f4ccf8bb9..ab3108295 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_jnxOperatingDescr = '.1.3.6.1.4.1.2636.3.1.13.1.5'; diff --git a/centreon-plugins/network/juniper/common/screenos/mode/components/fan.pm b/centreon-plugins/network/juniper/common/screenos/mode/components/fan.pm index 0007759ec..c755bb528 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/components/fan.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping = { my $oid_nsFanEntry = '.1.3.6.1.4.1.3224.21.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_nsFanEntry }; + push @{$self->{request}}, { oid => $oid_nsFanEntry }; } sub check { diff --git a/centreon-plugins/network/juniper/common/screenos/mode/components/module.pm b/centreon-plugins/network/juniper/common/screenos/mode/components/module.pm index 568bc5011..8ebd656d8 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/components/module.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/components/module.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -35,9 +35,9 @@ my $mapping = { my $oid_nsSlotEntry = '.1.3.6.1.4.1.3224.21.5.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_nsSlotEntry }; + push @{$self->{request}}, { oid => $oid_nsSlotEntry }; } sub check { diff --git a/centreon-plugins/network/juniper/common/screenos/mode/components/psu.pm b/centreon-plugins/network/juniper/common/screenos/mode/components/psu.pm index be8f99471..434cfd9a6 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/components/psu.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -34,9 +34,9 @@ my $mapping = { my $oid_nsPowerEntry = '.1.3.6.1.4.1.3224.21.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_nsPowerEntry }; + push @{$self->{request}}, { oid => $oid_nsPowerEntry }; } sub check { diff --git a/centreon-plugins/network/juniper/common/screenos/mode/components/temperature.pm b/centreon-plugins/network/juniper/common/screenos/mode/components/temperature.pm index 05ec02119..632345478 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/components/temperature.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,9 +30,9 @@ my $mapping = { my $oid_nsTemperatureEntry = '.1.3.6.1.4.1.3224.21.4.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_nsTemperatureEntry }; + push @{$self->{request}}, { oid => $oid_nsTemperatureEntry }; } sub check { diff --git a/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm b/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm index 66b9cf974..25739df6e 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nsResCpuLast1Min = '.1.3.6.1.4.1.3224.16.1.2.0'; diff --git a/centreon-plugins/network/juniper/common/screenos/mode/hardware.pm b/centreon-plugins/network/juniper/common/screenos/mode/hardware.pm index 705f2c3b2..abb37945b 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/hardware.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,240 +20,58 @@ package network::juniper::common::screenos::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['active', 'OK'], - ['.*', 'CRITICAL'], - ], - module => [ - ['active', 'OK'], - ['.*', 'CRITICAL'], - ], - psu => [ - ['active', 'OK'], - ['.*', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(psu|module|fan)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['active', 'OK'], + ['.*', 'CRITICAL'], + ], + module => [ + ['active', 'OK'], + ['.*', 'CRITICAL'], + ], + psu => [ + ['active', 'OK'], + ['.*', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'network::juniper::common::screenos::mode::components'; + $self->{components_module} = ['psu', 'fan', 'temperature', 'module']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "filter:s@" => { name => 'filter' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $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->{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 !~ /^temperature|psu|module|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 }; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - next if (!defined($val) || $val eq ''); - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $instance, $value) = ($1, $2, $3); - if ($section !~ /^sensor$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance }; - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('psu', 'fan', 'temperature', 'module'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::juniper::common::screenos::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::juniper::common::screenos::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 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_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{instance}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ diff --git a/centreon-plugins/network/juniper/common/screenos/mode/memory.pm b/centreon-plugins/network/juniper/common/screenos/mode/memory.pm index 17c2decb0..63bdd7dab 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/memory.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nsResMemAllocate= '.1.3.6.1.4.1.3224.16.2.1.0'; diff --git a/centreon-plugins/network/juniper/common/screenos/mode/sessions.pm b/centreon-plugins/network/juniper/common/screenos/mode/sessions.pm index b529e1922..e9c98152c 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/sessions.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,99 +20,80 @@ package network::juniper::common::screenos::mode::sessions; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'usage', set => { + key_values => [ { name => 'prct_used' }, { name => 'total' }, { name => 'used' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { label => 'sessions', value => 'used_absolute', template => '%s', + min => 0, max => 'total_absolute', threshold_total => 'total_absolute', cast_int => 1 }, + ], + } + }, + { label => 'failed', set => { + key_values => [ { name => 'failed', diff => 1 } ], + per_second => 1, + output_template => 'Failed sessions : %.2f/s', output_error_template => "Failed sessions : %s", + perfdatas => [ + { label => 'sessions_failed', value => 'failed_per_second', template => '%.2f', unit => '/s', + min => 0 }, + ], + } + }, + ]; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my $msg = sprintf("%.2f%% of the sessions limit reached (%d of max. %d)", + $self->{result_values}->{prct_used_absolute}, + $self->{result_values}->{used_absolute}, + $self->{result_values}->{total_absolute}); + return $msg; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $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; } -sub check_options { +sub manage_selection { 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 (($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 { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - 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, $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_nsResSessFailed}; - my $prct_used = $cp_used * 100 / $cp_total; - my $prct_failed = $cp_failed * 100 / $cp_total; - $spu_done = 1; - - 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' } ]); - - $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, - 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)."); - $self->{output}->option_exit(); - } - - $self->{output}->display(); - $self->{output}->exit(); + my $result = $options{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium, $oid_nsResSessFailed], nothing_quit => 1); + $self->{global} = { total => $result->{$oid_nsResSessMaxium}, + used => $result->{$oid_nsResSessAllocate}, + failed => $result->{$oid_nsResSessFailed}, + prct_used => $result->{$oid_nsResSessAllocate} * 100 / $result->{$oid_nsResSessMaxium}, + }; + + $self->{cache_name} = "juniper_" . $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')); } 1; @@ -123,21 +104,20 @@ Check Juniper sessions usage and failed sessions (NETSCREEN-RESOURCE-MIB). =over 8 -=item B<--warning> +=item B<--filter-counters> -Threshold warning (percentage). +Only display some counters (regexp can be used). +Example: --filter-counters='^usage$' -=item B<--critical> +=item B<--warning-*> -Threshold critical (percentage). +Threshold warning. +Can be: 'usage' (%), 'failed'. -=item B<--warning-failed> +=item B<--critical-*> -Threshold warning on failed sessions (percentage). - -=item B<--critical-failed> - -Threshold critical in failed sessions (percentage). +Threshold critical. +Can be: 'usage' (%), 'failed'. =back diff --git a/centreon-plugins/network/juniper/ex/plugin.pm b/centreon-plugins/network/juniper/ex/plugin.pm index 83887f372..a030f80ce 100644 --- a/centreon-plugins/network/juniper/ex/plugin.pm +++ b/centreon-plugins/network/juniper/ex/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/ggsn/mode/apnstats.pm b/centreon-plugins/network/juniper/ggsn/mode/apnstats.pm index 13122b9ec..1b0b828a7 100644 --- a/centreon-plugins/network/juniper/ggsn/mode/apnstats.pm +++ b/centreon-plugins/network/juniper/ggsn/mode/apnstats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -254,7 +254,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/juniper/ggsn/mode/globalstats.pm b/centreon-plugins/network/juniper/ggsn/mode/globalstats.pm index a70478c51..02ed2e78b 100644 --- a/centreon-plugins/network/juniper/ggsn/mode/globalstats.pm +++ b/centreon-plugins/network/juniper/ggsn/mode/globalstats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -250,7 +250,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/juniper/ggsn/plugin.pm b/centreon-plugins/network/juniper/ggsn/plugin.pm index cd62dd8b9..4ba145741 100644 --- a/centreon-plugins/network/juniper/ggsn/plugin.pm +++ b/centreon-plugins/network/juniper/ggsn/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/isg/plugin.pm b/centreon-plugins/network/juniper/isg/plugin.pm new file mode 100644 index 000000000..c3bbc8d20 --- /dev/null +++ b/centreon-plugins/network/juniper/isg/plugin.pm @@ -0,0 +1,53 @@ +# +# Copyright 2016 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::juniper::isg::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::juniper::common::screenos::mode::cpu', + 'memory' => 'network::juniper::common::screenos::mode::memory', + 'sessions' => 'network::juniper::common::screenos::mode::sessions', + 'hardware' => 'network::juniper::common::screenos::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Juniper ISG series in SNMP. + +=cut diff --git a/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm b/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm index d54442ed2..cc4c7486d 100644 --- a/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm +++ b/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_iveTemperature = '.1.3.6.1.4.1.12532.42.0'; diff --git a/centreon-plugins/network/juniper/mag/plugin.pm b/centreon-plugins/network/juniper/mag/plugin.pm index afefe878e..551a8470c 100644 --- a/centreon-plugins/network/juniper/mag/plugin.pm +++ b/centreon-plugins/network/juniper/mag/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/mseries/plugin.pm b/centreon-plugins/network/juniper/mseries/plugin.pm index a45395f36..5ea2f60d1 100644 --- a/centreon-plugins/network/juniper/mseries/plugin.pm +++ b/centreon-plugins/network/juniper/mseries/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/sa/plugin.pm b/centreon-plugins/network/juniper/sa/plugin.pm index 5cbd1cb6b..61cd57493 100644 --- a/centreon-plugins/network/juniper/sa/plugin.pm +++ b/centreon-plugins/network/juniper/sa/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/srx/plugin.pm b/centreon-plugins/network/juniper/srx/plugin.pm index 4b6eb3b09..fb1e6e866 100644 --- a/centreon-plugins/network/juniper/srx/plugin.pm +++ b/centreon-plugins/network/juniper/srx/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/ssg/plugin.pm b/centreon-plugins/network/juniper/ssg/plugin.pm index bd4f9f759..78bfe3d54 100644 --- a/centreon-plugins/network/juniper/ssg/plugin.pm +++ b/centreon-plugins/network/juniper/ssg/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/juniper/trapeze/snmp/mode/apstatus.pm b/centreon-plugins/network/juniper/trapeze/snmp/mode/apstatus.pm new file mode 100644 index 000000000..c2684dadd --- /dev/null +++ b/centreon-plugins/network/juniper/trapeze/snmp/mode/apstatus.pm @@ -0,0 +1,235 @@ +# +# 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::juniper::trapeze::snmp::mode::apstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg; + + if ($self->{result_values}->{opstatus} eq 'disabled') { + $msg = ' is disabled'; + } else { + $msg = 'Status : ' . $self->{result_values}->{opstatus}; + } + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{opstatus} = $options{new_datas}->{$self->{instance} . '_opstatus'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_init => 'skip_global', }, + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All AP status are ok' } + ]; + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total ap : %s', + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + min => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{ap} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'opstatus' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{opstatus} !~ /init|redundant|operationnal/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub skip_global { + my ($self, %options) = @_; + + scalar(keys %{$self->{ap}}) > 1 ? return(0) : return(1); +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "AP '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_ap_status = ( + 1 => 'cleared', + 2 => 'init', + 3 => 'bootStarted', + 4 => 'imageDownloaded', + 5 => 'connectFailed', + 6 => 'configuring', + 7 => 'operationnal', + 10 => 'redundant', + 20 => 'connOutage', +); + +my $mapping_name_oid = { + trpzApStatApStatusApName => { oid => '.1.3.6.1.4.1.14525.4.5.1.1.2.1.8' }, +}; +my $mapping_state_oid = { + trpzApStatApStatusApState => { oid => '.1.3.6.1.4.1.14525.4.5.1.1.2.1.5', map => \%map_ap_status }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{ap} = {}; + $self->{global} = { total => 0}; + $self->{results} = $options{snmp}->get_multiple_table(oids => [{ oid => $mapping_name_oid->{trpzApStatApStatusApName}->{oid} }, + { oid => $mapping_state_oid->{trpzApStatApStatusApState}->{oid} }, + ], + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}->{ $mapping_name_oid->{trpzApStatApStatusApName}->{oid} }}) { + $oid =~ /^$mapping_name_oid->{trpzApStatApStatusApName}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping_name_oid, results => $self->{results}->{ $mapping_name_oid->{trpzApStatApStatusApName}->{oid} }, instance => $instance); + my $result2 = $options{snmp}->map_instance(mapping => $mapping_state_oid, results => $self->{results}->{ $mapping_state_oid->{trpzApStatApStatusApState}->{oid} }, instance => $instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{trpzApStatApStatusApName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $result->{trpzApStatApStatusApName} . "': no matching filter.", debug => 1); + next; + } + + $self->{global}->{total}++; + $self->{ap}->{$instance} = { display => $result->{trpzApStatApStatusApName}, + opstatus => $result2->{trpzApStatApStatusApState}}; + } + + if (scalar(keys %{$self->{ap}}) <= 0) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'No AP associated, check your filter ? '); + } +} + +1; + +__END__ + +=head1 MODE + +Check AP status. + +=over 8 + +=item B<--filter-name> + +Filter AP name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{opstatus}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{opstatus} !~ /init|redundant|operationnal/'). +Can used special variables like: %{opstatus}, %{display} + +=item B<--warning-total> + +Set warning threshold for number of AP linked to the WLC + +=item B<--critical-total> + +Set critical threshold for number of AP linked to the WLC + +=back + +=cut diff --git a/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm b/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm new file mode 100644 index 000000000..d2c1b124d --- /dev/null +++ b/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm @@ -0,0 +1,189 @@ +# +# 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::juniper::trapeze::snmp::mode::apusers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' }, + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by AP are ok' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total Users : %s', + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + unit => 'users', min => 0 }, + ], + } + }, + ]; + + $self->{maps_counters}->{ssid} = [ + { label => 'ssid', set => { + key_values => [ { name => 'total' }, { name => 'display' } ], + output_template => 'users : %s', + perfdatas => [ + { label => 'ssid', value => 'total_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; + + $self->{maps_counters}->{ap} = [ + { label => 'ap', set => { + key_values => [ { name => 'total' }, { name => 'display' } ], + output_template => 'users : %s', + perfdatas => [ + { label => 'ap', value => 'total_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; + +} + +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-ssid:s" => { name => 'filter_ssid' }, + "filter-ap:s" => { name => 'filter_ap' }, + }); + + return $self; +} + +sub prefix_ssid_output { + my ($self, %options) = @_; + + return "SSID '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "AP '" . $options{instance_value}->{display} . "' "; +} + +my $mapping = { + trpzClSessClientSessApSerialNum => { oid => '.1.3.6.1.4.1.14525.4.4.1.1.1.1.7' }, +}; + +my $mapping1 = { + trpzClSessClientSessSsid => { oid => '.1.3.6.1.4.1.14525.4.4.1.1.1.1.15' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_trpzApStatApStatusApName = '.1.3.6.1.4.1.14525.4.5.1.1.2.1.8'; + $self->{global} = { total => 0}; + $self->{ssid} = {}; + $self->{ap} = {}; + + $self->{results} = $options{snmp}->get_multiple_table(oids => [{ oid => $oid_trpzApStatApStatusApName }, { oid => $mapping->{trpzClSessClientSessApSerialNum}->{oid} }, + { oid => $mapping1->{trpzClSessClientSessSsid}->{oid} }], + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}->{ $mapping->{trpzClSessClientSessApSerialNum}->{oid} }}) { + $oid =~ /^$mapping->{trpzClSessClientSessApSerialNum}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{trpzClSessClientSessApSerialNum}->{oid} }, instance => $instance); + my $result1 = $options{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{ $mapping1->{trpzClSessClientSessSsid}->{oid} }, instance => $instance); + my @chars = split(//,$result->{trpzClSessClientSessApSerialNum}); + my $ap_oid = '12'; + foreach my $char (@chars) { + $ap_oid .= '.'.ord($char); + } + my $ap_name = $self->{results}->{$oid_trpzApStatApStatusApName}->{$oid_trpzApStatApStatusApName . '.' . $ap_oid}; + if (defined($self->{option_results}->{filter_ap}) && $self->{option_results}->{filter_ap} ne '' && + $ap_name !~ /$self->{option_results}->{filter_ap}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $ap_name . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' && + $result1->{trpzClSessClientSessSsid} !~ /$self->{option_results}->{filter_ssid}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $result1->{trpzClSessClientSessSsid} . "': no matching filter.", debug => 1); + next; + } + + $self->{global}->{total}++; + $self->{ap}->{$ap_name} = { total => 0, display => $ap_name } if (!defined($self->{ap}->{$ap_name})); + $self->{ap}->{$ap_name}->{total}++; + $self->{ssid}->{$result1->{trpzClSessClientSessSsid}} = { total => 0, display => $result1->{trpzClSessClientSessSsid} } if (!defined($self->{ssid}->{$result1->{trpzClSessClientSessSsid}})); + $self->{ssid}->{$result1->{trpzClSessClientSessSsid}}->{total}++; + } + + if (scalar(keys %{$self->{ap}}) <= 0 && scalar(keys %{$self->{ssid}}) <= 0) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'No AP nor SSID finded, check your filter or maybe we are on a slave controller ? '); + } +} + +1; + +__END__ + +=head1 MODE + +Check AP users. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--filter-ap> + +Filter AP name (can be a regexp). + +=item B<--filter-ssid> + +Filter SSID name (can be a regexp). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'total', 'ssid', 'ap' . + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'total', 'ssid', 'ap' . + +=back + +=cut diff --git a/centreon-plugins/network/juniper/trapeze/snmp/mode/cpu.pm b/centreon-plugins/network/juniper/trapeze/snmp/mode/cpu.pm new file mode 100644 index 000000000..c28e6f3e9 --- /dev/null +++ b/centreon-plugins/network/juniper/trapeze/snmp/mode/cpu.pm @@ -0,0 +1,141 @@ +# +# 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::juniper::trapeze::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 0, cb_prefix_output => 'prefix_cpu_output' } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'average', set => { + key_values => [ { name => 'trpzSysCpuAverageLoad' } ], + output_template => 'average : %.2f %%', + perfdatas => [ + { label => 'cpu_average', value => 'trpzSysCpuAverageLoad_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => '1m', set => { + key_values => [ { name => 'trpzSysCpuLastMinuteLoad' } ], + output_template => '1 minute : %.2f %%', + perfdatas => [ + { label => 'cpu_1m', value => 'trpzSysCpuLastMinuteLoad_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => '5m', set => { + key_values => [ { name => 'trpzSysCpuLast5MinutesLoad' } ], + output_template => '5 minutes : %.2f %%', + perfdatas => [ + { label => 'cpu_5m', value => 'trpzSysCpuLast5MinutesLoad_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => '1h', set => { + key_values => [ { name => ' trpzSysCpuLastHourLoad' } ], + output_template => '1 hour : %.2f %%', + perfdatas => [ + { label => 'cpu_1h', value => ' trpzSysCpuLastHourLoad_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + ]; +} + +sub prefix_cpu_output { + my ($self, %options) = @_; + + return "CPU Usage "; +} + +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 => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # TRAPEZE-NETWORKS-SYSTEM-MIB + my $oid_trpzSysCpuAverageLoad = '.1.3.6.1.4.1.14525.4.8.1.1.5.0'; + my $oid_trpzSysCpuLastMinuteLoad = '.1.3.6.1.4.1.14525.4.8.1.1.11.2.0'; + my $oid_trpzSysCpuLast5MinutesLoad = '.1.3.6.1.4.1.14525.4.8.1.1.11.3.0'; + my $oid_trpzSysCpuLastHourLoad = '.1.3.6.1.4.1.14525.4.8.1.1.11.4.0'; + + my $results = $options{snmp}->get_leef(oids => [$oid_trpzSysCpuAverageLoad, $oid_trpzSysCpuLastMinuteLoad, + $oid_trpzSysCpuLast5MinutesLoad, $oid_trpzSysCpuLastHourLoad ], + nothing_quit => 1); + + $self->{cpu} = { trpzSysCpuAverageLoad => $results->{$oid_trpzSysCpuAverageLoad}, + trpzSysCpuLastMinuteLoad => $results->{$oid_trpzSysCpuLastMinuteLoad}, + trpzSysCpuLast5MinutesLoad => $results->{$oid_trpzSysCpuLast5MinutesLoad}, + trpzSysCpuLastHourLoad => $results->{$oid_trpzSysCpuLastHourLoad}, + }; +} + +1; + +__END__ + +=head1 MODE + +Check CPU usage + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(1m|5m)$' + +=item B<--warning-*> + +Threshold warning. +Can be: '1m', '5m', '1h, 'average' + +=item B<--critical-*> + +Threshold critical. +Can be: '1m', '5m', '1h', 'average' + +=back + +=cut diff --git a/centreon-plugins/network/juniper/trapeze/snmp/mode/memory.pm b/centreon-plugins/network/juniper/trapeze/snmp/mode/memory.pm new file mode 100644 index 000000000..2fd4b6e99 --- /dev/null +++ b/centreon-plugins/network/juniper/trapeze/snmp/mode/memory.pm @@ -0,0 +1,172 @@ +# +# 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::juniper::trapeze::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + + 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_absolute}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}); + return $msg; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0, cb_prefix_output => 'prefix_memory_output' }, + { name => 'flash', type => 0, cb_prefix_output => 'prefix_flash_output' } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'memory', set => { + key_values => [ { name => 'prct_used'}, { name => 'used' }, { name => 'free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + threshold_use => 'prct_used_absolute', + perfdatas => [ + { label => 'memory', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, + min => 0, max => 'total_absolute', unit => 'B' }, + ], + } + }, + ]; + $self->{maps_counters}->{flash} = [ + { label => 'flash', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + threshold_use => 'prct_used_absolute', + perfdatas => [ + { label => 'flash', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, + min => 0, max => 'total_absolute', unit => 'B' }, + ], + } + }, + ]; +} + +sub prefix_memory_output { + my ($self, %options) = @_; + + return "Memory "; +} + +sub prefix_flash_output { + my ($self, %options) = @_; + + return "Flash "; +} + +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 => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($total_bytes, $used_bytes, $free_bytes); + + # TRAPEZE-NETWORKS-SYSTEM-MIB + my $oid_trpzSysFlashMemoryUsedBytes = '.1.3.6.1.4.1.14525.4.8.1.1.3.0'; + my $oid_trpzSysFlashMemoryTotalBytes = '.1.3.6.1.4.1.14525.4.8.1.1.4.0'; + my $oid_trpzSysCpuMemoryInstantUsage = '.1.3.6.1.4.1.14525.4.8.1.1.12.1.0'; + my $oid_trpzSysCpuMemoryUsedBytes = '.1.3.6.1.4.1.14525.4.8.1.1.1.0'; + my $oid_trpzSysCpuMemoryTotalBytes = '.1.3.6.1.4.1.14525.4.8.1.1.2.0'; + my $oid_trpzSysCpuMemorySize = '.1.3.6.1.4.1.14525.4.8.1.1.6.0'; + + my $results = $options{snmp}->get_leef(oids => [$oid_trpzSysFlashMemoryUsedBytes, $oid_trpzSysFlashMemoryTotalBytes, $oid_trpzSysCpuMemoryUsedBytes, + $oid_trpzSysCpuMemoryInstantUsage, $oid_trpzSysCpuMemorySize, $oid_trpzSysCpuMemoryTotalBytes ], + nothing_quit => 1); + + if (defined($results->{$oid_trpzSysCpuMemorySize}) || $results->{$oid_trpzSysCpuMemorySize} != 0) { + $total_bytes = $results->{$oid_trpzSysCpuMemorySize} * 1024; + $used_bytes = $results->{$oid_trpzSysCpuMemoryInstantUsage} * 1024; + $free_bytes = $total_bytes - $used_bytes; + } else { + $total_bytes = $results->{$oid_trpzSysCpuMemoryTotalBytes}; + $used_bytes = $results->{$oid_trpzSysCpuMemoryUsedBytes}; + $free_bytes = $total_bytes - $used_bytes; + } + + my $free_bytes_flash = $results->{$oid_trpzSysFlashMemoryTotalBytes} - $results->{$oid_trpzSysFlashMemoryUsedBytes}; + + $self->{memory} = {display => 'memory', + prct_used => $used_bytes * 100 / $total_bytes, + used => $used_bytes, + free => $free_bytes, + total => $total_bytes, + }; + + $self->{flash} = {display => 'flash', + prct_used => $results->{$oid_trpzSysFlashMemoryUsedBytes} * 100 / $results->{$oid_trpzSysFlashMemoryTotalBytes}, + used => $results->{$oid_trpzSysFlashMemoryUsedBytes}, + free => $free_bytes_flash, + total => $results->{$oid_trpzSysFlashMemoryTotalBytes}, + }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(memory)$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'memory', 'flash' + +=item B<--critical-*> + +Threshold critical. +Can be: 'memory', 'flash' + +=back + +=cut diff --git a/centreon-plugins/hardware/pdu/apc/plugin.pm b/centreon-plugins/network/juniper/trapeze/snmp/plugin.pm similarity index 67% rename from centreon-plugins/hardware/pdu/apc/plugin.pm rename to centreon-plugins/network/juniper/trapeze/snmp/plugin.pm index abf5c80ad..9461c65b2 100644 --- a/centreon-plugins/hardware/pdu/apc/plugin.pm +++ b/centreon-plugins/network/juniper/trapeze/snmp/plugin.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package hardware::pdu::apc::plugin; +package network::juniper::trapeze::snmp::plugin; use strict; use warnings; @@ -28,15 +28,13 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object - + $self->{version} = '0.1'; %{$self->{modes}} = ( - 'load' => 'hardware::pdu::apc::mode::load', - 'psu' => 'hardware::pdu::apc::mode::psu', - 'outlet' => 'hardware::pdu::apc::mode::outlet', - 'temperature' => 'hardware::pdu::apc::mode::temperature', - 'humidity' => 'hardware::pdu::apc::mode::humidity', + 'cpu' => 'network::juniper::trapeze::snmp::mode::cpu', + 'memory' => 'network::juniper::trapeze::snmp::mode::memory', + 'ap-status' => 'network::juniper::trapeze::snmp::mode::apstatus', + 'ap-users' => 'network::juniper::trapeze::snmp::mode::apusers', ); return $self; @@ -48,6 +46,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check APC PDU in SNMP (PowerNet-MIB). +Check Trapeze Network (Juniper) Wifi LAN Controller through SNMP =cut diff --git a/centreon-plugins/network/kemp/snmp/mode/hastatus.pm b/centreon-plugins/network/kemp/snmp/mode/hastatus.pm new file mode 100644 index 000000000..15ef72920 --- /dev/null +++ b/centreon-plugins/network/kemp/snmp/mode/hastatus.pm @@ -0,0 +1,210 @@ +# +# Copyright 2016 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::kemp::snmp::mode::hastatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label}} ne '' && + eval "$instance_mode->{option_results}->{\"critical_\" . $self->{result_values}->{label}}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label}} ne '' && + eval "$instance_mode->{option_results}->{\"warning_\" . $self->{result_values}->{label}}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_hastatus_output { + my ($self, %options) = @_; + + my $msg = 'HA status : ' . $self->{result_values}->{status}; + return $msg; +} + +sub custom_syncstatus_output { + my ($self, %options) = @_; + + my $msg = 'Synchronization l4 status : ' . $self->{result_values}->{status}; + return $msg; +} + +sub custom_hastatus_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_hAstate'}; + $self->{result_values}->{label} = 'ha_status'; + return 0; +} + +sub custom_syncstatus_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_daemonState'}; + $self->{result_values}->{label} = 'sync_status'; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'ha-status', threshold => 0, set => { + key_values => [ { name => 'hAstate' } ], + closure_custom_calc => $self->can('custom_hastatus_calc'), + closure_custom_output => $self->can('custom_hastatus_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'sync-status', threshold => 0, set => { + key_values => [ { name => 'daemonState' } ], + closure_custom_calc => $self->can('custom_syncstatus_calc'), + closure_custom_output => $self->can('custom_syncstatus_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + ]; +} + +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-ha-status:s" => { name => 'warning_ha_status', default => '' }, + "critical-ha-status:s" => { name => 'critical_ha_status', default => '' }, + "warning-sync-status:s" => { name => 'warning_sync_status', default => '' }, + "critical-sync-status:s" => { name => 'critical_sync_status', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_ha_status', 'critical_ha_status', 'warning_sync_status', 'critical_sync_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_daemon_state = ( + 0 => 'none', + 1 => 'master', + 2 => 'backup', +); +my %map_ha_state = ( + 0 => 'none', + 1 => 'master', + 2 => 'standby', + 3 => 'passive', +); +my $mapping = { + daemonState => { oid => '.1.3.6.1.4.1.12196.13.0.7', map => \%map_daemon_state }, + hAstate => { oid => '.1.3.6.1.4.1.12196.13.0.9', map => \%map_ha_state }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{vs} = {}; + my $snmp_result = $options{snmp}->get_leef(oids => [ $mapping->{daemonState}->{oid} . '.0', $mapping->{hAstate}->{oid} . '.0' ], + nothing_quit => 1); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0'); + + $self->{global} = { %$result }; +} + +1; + +__END__ + +=head1 MODE + +Check ha status. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^ha-status$' + +=item B<--warning-ha-status> + +Set warning threshold for status (Default: none). +Can used special variables like: %{status}, %{display} + +=item B<--critical-ha-status> + +Set critical threshold for status (Default: none). +Can used special variables like: %{status}, %{display} + +=item B<--warning-sync-status> + +Set warning threshold for status (Default: none). +Can used special variables like: %{status}, %{display} + +=item B<--critical-sync-status> + +Set critical threshold for status (Default: none). +Can used special variables like: %{status}, %{display} + +=back + +=cut diff --git a/centreon-plugins/network/kemp/snmp/mode/listvs.pm b/centreon-plugins/network/kemp/snmp/mode/listvs.pm new file mode 100644 index 000000000..f8629fa30 --- /dev/null +++ b/centreon-plugins/network/kemp/snmp/mode/listvs.pm @@ -0,0 +1,133 @@ +# +# Copyright 2016 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::kemp::snmp::mode::listvs; + +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 => + { + "filter-name:s" => { name => 'filter_name' }, + }); + $self->{vs_id_selected} = []; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my %map_state = ( + 1 => 'inService', + 2 => 'outOfService', + 4 => 'disabled', + 5 => 'sorry', + 6 => 'redirect', + 7 => 'errormsg', +); +my $mapping = { + vSname => { oid => '.1.3.6.1.4.1.12196.13.1.1.13' }, + vSstate => { oid => '.1.3.6.1.4.1.12196.13.1.1.14', map => \%map_state }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{vSname}->{oid} }, { oid => $mapping->{vSstate}->{oid} } ], + nothing_quit => 1, return_type => 1); + foreach my $oid (keys %{$self->{results}}) { + next if ($oid !~ /^$mapping->{vSname}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{vSname} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{vSname} . "': no matching filter.", debug => 1); + next; + } + + push @{$self->{vs_id_selected}}, $instance; + } +} + +sub run { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->manage_selection(); + foreach my $instance (sort @{$self->{vs_id_selected}}) { + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + $self->{output}->output_add(long_msg => "'" . $result->{vSname} . "' [state = " . $result->{vSstate} . "]"); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List Virtual Servers:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'state']); +} + +sub disco_show { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + $self->manage_selection(disco => 1); + foreach my $instance (sort @{$self->{vs_id_selected}}) { + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + $self->{output}->add_disco_entry(name => $result->{vSname}, state => $result->{vSstate}); + } +} + +1; + +__END__ + +=head1 MODE + +List virtual servers. + +=over 8 + +=item B<--filter-name> + +Set the virtual server name. + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/network/kemp/snmp/mode/rsstatus.pm b/centreon-plugins/network/kemp/snmp/mode/rsstatus.pm new file mode 100644 index 000000000..f221a1001 --- /dev/null +++ b/centreon-plugins/network/kemp/snmp/mode/rsstatus.pm @@ -0,0 +1,254 @@ +# +# Copyright 2016 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::kemp::snmp::mode::rsstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{status}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'rs', type => 1, cb_prefix_output => 'prefix_rs_output', message_multiple => 'All real servers are ok' } + ]; + + $self->{maps_counters}->{rs} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'active', set => { + key_values => [ { name => 'rSActiveConns' }, { name => 'display' } ], + output_template => 'Active connections : %s', + perfdatas => [ + { label => 'active', value => 'rSActiveConns_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'in-traffic', set => { + key_values => [ { name => 'rSInBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic In : %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_in', value => 'rSInBytes_per_second', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'out-traffic', set => { + key_values => [ { name => 'rSOutBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic Out : %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_out', value => 'rSOutBytes_per_second', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /inService|disabled/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_rs_output { + my ($self, %options) = @_; + + return "Real server '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + 1 => 'inService', + 2 => 'outOfService', + 4 => 'disabled', +); +my $mapping = { + rSvsidx => { oid => '.1.3.6.1.4.1.12196.13.2.1.1' }, + rSip => { oid => '.1.3.6.1.4.1.12196.13.2.1.2' }, + rSport => { oid => '.1.3.6.1.4.1.12196.13.2.1.3' }, + rSstate => { oid => '.1.3.6.1.4.1.12196.13.2.1.8', map => \%map_state }, + rSInBytes => { oid => '.1.3.6.1.4.1.12196.13.2.1.15' }, + rSOutBytes => { oid => '.1.3.6.1.4.1.12196.13.2.1.16' }, + rSActiveConns => { oid => '.1.3.6.1.4.1.12196.13.2.1.17' }, +}; + +my $oid_rsEntry = '.1.3.6.1.4.1.12196.13.2.1'; +my $oid_vSname = '.1.3.6.1.4.1.12196.13.1.1.13'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{rs} = {}; + my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_rsEntry }, { oid => $oid_vSname } ], + nothing_quit => 1); + + + foreach my $oid (keys %{$snmp_result->{$oid_rsEntry}}) { + next if ($oid !~ /^$mapping->{rSstate}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_rsEntry}, instance => $instance); + my $vs_name = $snmp_result->{$oid_vSname}->{$oid_vSname . '.' . $result->{rSvsidx}}; + + my $display_name = $vs_name . '/' . $result->{rSip} . ':' . $result->{rSport}; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $display_name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $display_name . "': no matching filter.", debug => 1); + next; + } + + $self->{rs}->{$instance} = { display => $display_name, + status => $result->{rSstate}, + rSInBytes => defined($result->{rSInBytes}) ? $result->{rSInBytes} * 8 : undef, + rSOutBytes => defined($result->{rSOutBytes}) ? $result->{rSOutBytes} * 8 : undef, + rSActiveConns => $result->{rSActiveConns} }; + } + + if (scalar(keys %{$self->{rs}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No real server found."); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "kemp_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check real server status. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter real server name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} !~ /inService|disabled/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'active', 'in-traffic' (b/s), 'out-traffic' (b/s). + +=item B<--critical-*> + +Threshold critical. +Can be: 'active', 'in-traffic' (b/s), 'out-traffic' (b/s). + +=back + +=cut diff --git a/centreon-plugins/network/kemp/snmp/mode/vsstatus.pm b/centreon-plugins/network/kemp/snmp/mode/vsstatus.pm new file mode 100644 index 000000000..95b406aab --- /dev/null +++ b/centreon-plugins/network/kemp/snmp/mode/vsstatus.pm @@ -0,0 +1,252 @@ +# +# Copyright 2016 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::kemp::snmp::mode::vsstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{status}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'vs', type => 1, cb_prefix_output => 'prefix_vs_output', message_multiple => 'All virtual servers are ok' } + ]; + + $self->{maps_counters}->{vs} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'active', set => { + key_values => [ { name => 'vSActivConns' }, { name => 'display' } ], + output_template => 'Active connections : %s', + perfdatas => [ + { label => 'active', value => 'vSActivConns_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'in-traffic', set => { + key_values => [ { name => 'vSInBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic In : %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_in', value => 'vSInBytes_per_second', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'out-traffic', set => { + key_values => [ { name => 'vSOutBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic Out : %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_out', value => 'vSOutBytes_per_second', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /inService|disabled|redirect/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_vs_output { + my ($self, %options) = @_; + + return "Virtual server '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_state = ( + 1 => 'inService', + 2 => 'outOfService', + 4 => 'disabled', + 5 => 'sorry', + 6 => 'redirect', + 7 => 'errormsg', +); +my $mapping = { + vSname => { oid => '.1.3.6.1.4.1.12196.13.1.1.13' }, + vSstate => { oid => '.1.3.6.1.4.1.12196.13.1.1.14', map => \%map_state }, + vSInBytes => { oid => '.1.3.6.1.4.1.12196.13.1.1.19' }, + vSOutBytes => { oid => '.1.3.6.1.4.1.12196.13.1.1.20' }, + vSActivConns => { oid => '.1.3.6.1.4.1.12196.13.1.1.21' }, +}; + +my $oid_vsEntry = '.1.3.6.1.4.1.12196.13.1.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{vs} = {}; + my $snmp_result = $options{snmp}->get_table(oid => $oid_vsEntry, + nothing_quit => 1); + + + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{vSstate}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{vSname} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{vSname} . "': no matching filter.", debug => 1); + next; + } + + $self->{vs}->{$instance} = { display => $result->{vSname}, + status => $result->{vSstate}, + vSInBytes => defined($result->{vSInBytes}) ? $result->{vSInBytes} * 8 : undef, + vSOutBytes => defined($result->{vSOutBytes}) ? $result->{vSOutBytes} * 8 : undef, + vSActivConns => $result->{vSActivConns} }; + } + + if (scalar(keys %{$self->{vs}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No virtual server found."); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "kemp_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check virtual server status. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter virtual server name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} !~ /inService|disabled|redirect/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'active', 'in-traffic' (b/s), 'out-traffic' (b/s). + +=item B<--critical-*> + +Threshold critical. +Can be: 'active', 'in-traffic' (b/s), 'out-traffic' (b/s). + +=back + +=cut diff --git a/centreon-plugins/network/kemp/snmp/plugin.pm b/centreon-plugins/network/kemp/snmp/plugin.pm new file mode 100644 index 000000000..3e6367ce3 --- /dev/null +++ b/centreon-plugins/network/kemp/snmp/plugin.pm @@ -0,0 +1,56 @@ +# +# Copyright 2016 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::kemp::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} = '0.1'; + %{$self->{modes}} = ( + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'load' => 'snmp_standard::mode::loadaverage', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-vs' => 'network::kemp::snmp::mode::listvs', + 'ha-status' => 'network::kemp::snmp::mode::hastatus', + 'memory' => 'snmp_standard::mode::memory', + 'rs-status' => 'network::kemp::snmp::mode::rsstatus', + 'vs-status' => 'network::kemp::snmp::mode::vsstatus', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Kemp equipments in SNMP. + +=cut diff --git a/centreon-plugins/network/netasq/snmp/mode/connections.pm b/centreon-plugins/network/netasq/snmp/mode/connections.pm new file mode 100644 index 000000000..1215cbc5c --- /dev/null +++ b/centreon-plugins/network/netasq/snmp/mode/connections.pm @@ -0,0 +1,108 @@ +# +# Copyright 2016 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::netasq::snmp::mode::connections; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'udp', set => { + key_values => [ { name => 'udp', diff => 1 } ], + per_second => 1, + output_template => 'UDP : %d connections/s', + perfdatas => [ + { label => 'udp', value => 'udp_per_second', template => '%d', + min => 0, unit => 'con' }, + ], + } + }, + { label => 'tcp', set => { + key_values => [ { name => 'tcp', diff => 1 } ], + per_second => 1, + output_template => 'TCP : %d connections/s', + perfdatas => [ + { label => 'tcp', value => 'tcp_per_second', template => '%d', + min => 0, unit => 'con' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + $self->{cache_name} = "fw_netasq_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . md5_hex('all'); + + my $oid_ntqASQStatsStatefulUdpConn = '.1.3.6.1.4.1.11256.1.12.1.33.0'; + my $oid_ntqASQStatsStatefulTcpConn = '.1.3.6.1.4.1.11256.1.12.1.23.0'; + + my $result = $options{snmp}->get_leef(oids => [ $oid_ntqASQStatsStatefulUdpConn, $oid_ntqASQStatsStatefulTcpConn ], + nothing_quit => 1); + $self->{global} = { + udp => $result->{$oid_ntqASQStatsStatefulUdpConn}, + tcp => $result->{$oid_ntqASQStatsStatefulTcpConn}, + }; +} + +1; + +__END__ + +=head1 MODE + +Check connections setup rate on Netasq Firewall equipments. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'tcp', 'udp' + +=item B<--critical-*> + +Threshold critical. +Can be: 'tcp', 'udp' + +=back + +=cut diff --git a/centreon-plugins/network/netasq/snmp/mode/hanodes.pm b/centreon-plugins/network/netasq/snmp/mode/hanodes.pm new file mode 100644 index 000000000..4936330d2 --- /dev/null +++ b/centreon-plugins/network/netasq/snmp/mode/hanodes.pm @@ -0,0 +1,270 @@ +# +# Copyright 2016 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::netasq::snmp::mode::hanodes; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_node_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = defined($instance_mode->{option_results}->{percent}) ? $self->{result_values}->{prct_dead} : $self->{result_values}->{dead_nodes} ; + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_node_output { + my ($self, %options) = @_; + + my $msg = sprintf("Dead nodes: absolute: %d/%d - percentage: %.2f%% ", + $self->{result_values}->{dead_nodes}, $self->{result_values}->{total_nodes}, $self->{result_values}->{prct_dead}); + return $msg; +} + +sub custom_node_calc { + my ($self, %options) = @_; + + $self->{result_values}->{dead_nodes} = $options{new_datas}->{$self->{instance} . '_dead_nodes'}; + $self->{result_values}->{total_nodes} = $options{new_datas}->{$self->{instance} . '_total_nodes'}; + $self->{result_values}->{prct_dead} = $options{new_datas}->{$self->{instance} . '_prct_dead'}; + + return 0; +} + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_state}) && $instance_mode->{option_results}->{critical_state} ne '' && + eval "$instance_mode->{option_results}->{critical_state}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_state}) && $instance_mode->{option_results}->{warning_state} ne '' && + eval "$instance_mode->{option_results}->{warning_state}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_state_output { + my ($self, %options) = @_; + + my $msg = sprintf("state is '%s'", $self->{result_values}->{state}); + return $msg; +} + +sub custom_state_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'nodes', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All HA nodes are OK' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'dead-nodes', set => { + key_values => [ { name => 'dead_nodes' }, { name => 'prct_dead' }, { name => 'total_nodes' } ], + closure_custom_calc => \&custom_node_calc, + closure_custom_output => \&custom_node_output, + closure_custom_threshold_check => \&custom_node_threshold, + perfdatas => [ + { label => 'dead_nodes', value => 'dead_nodes', template => '%d', + min => 0, unit => 'nodes' }, + ], + } + } + ]; + $self->{maps_counters}->{nodes} = [ + { label => 'state', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => \&custom_state_calc, + closure_custom_output => \&custom_state_output, + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&custom_threshold_output, + } + }, + { label => 'health', set => { + key_values => [ { name => 'health' }, { name => 'display' } ], + output_template => 'node health: %s%%', + perfdatas => [ + { label => 'health', value => 'health_absolute', template => '%d', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + } + ]; +} + +sub prefix_node_output { + my ($self, %options) = @_; + + return "Node '" . $options{instance_value}->{display} . "' "; +} + +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-node:s" => { name => 'filter_node' }, + "percent" => { name => 'percent' }, + "warning-state:s" => { name => 'warning_state', default => '' }, + "critical-state:s" => { name => 'critical_state', default => '%{state} eq "offline"' }, + }); + return $self; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_state', 'critical_state')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(); + $instance_mode = $self; +} + +my %map_status = ( + 1 => 'online', + 2 => 'offline', +); + +my $mapping = { + ntqFwSerial => { oid => '.1.3.6.1.4.1.11256.1.11.7.1.2' }, + ntqHAQuality => { oid => '.1.3.6.1.4.1.11256.1.11.7.1.7' }, + ntqOnline => { oid => '.1.3.6.1.4.1.11256.1.11.7.1.3', map => \%map_status }, +}; + +my $oid_ntqNodeTable = '.1.3.6.1.4.1.11256.1.11.7'; +my $oid_ntqNbNode = '.1.3.6.1.4.1.11256.1.11.1'; +my $oid_ntqNbDeadNode = '.1.3.6.1.4.1.11256.1.11.2'; + +sub manage_selection { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_ntqNodeTable }, + { oid => $oid_ntqNbNode }, + { oid => $oid_ntqNbDeadNode } ], + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}->{$oid_ntqNodeTable}}) { + $oid =~ /^$mapping->{ntqOnline}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ntqNodeTable}, instance => $instance); + + if (defined($self->{option_results}->{filter_node}) && $self->{option_results}->{filter_node} ne '' && + $result->{ntqFwSerial} !~ /$self->{option_results}->{filter_node}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $result->{ntqFwSerial} . "': no matching filter.", debug => 1); + next; + } + $self->{nodes}->{$result->{ntqFwSerial}} = { state => $result->{ntqOnline}, + health => $result->{ntqHAQuality}, + display => $result->{ntqFwSerial} }; + } + + my $prct_dead = $self->{results}->{$oid_ntqNbDeadNode}->{$oid_ntqNbDeadNode . '.' . '0'}/$self->{results}->{$oid_ntqNbNode}->{$oid_ntqNbNode . '.' . '0'}*100; + + $self->{global} = { dead_nodes => $self->{results}->{$oid_ntqNbDeadNode}->{$oid_ntqNbDeadNode . '.' . '0'}, + toatl_nodes => $self->{results}->{$oid_ntqNbDeadNode}->{$oid_ntqNbNode . '.' . '0'}, + prct_dead => $prct_dead }; +} + +1; + +__END__ + +=head1 MODE + +Check Netasq dead nodes and state and health of nodes + +=over 8 + +=item B<--filter-node> + +Filter name with regexp (based on serial) + +=item B<--warning-health> + +Warning on health level. (e.g --warning 90:) + +=item B<--critical-health> + +Critical on health level. (e.g --critical 80:) + +=item B<--warning-dead-nodes> + +Warning on deadnode (absolute unless --percent is used) + +=item B<--critical-dead-nodes> + +Critical on deadnode (absolute unless --percent is used) + +=item B<--warning-state> + +Set warning threshold for status. Use "%{state}" as a special variable. +Value can be 'online' or 'offline'. + +=item B<--critical-state> + +Set critical threshold for status. Use "%{state}" as a special variable. +Value can be 'online' or 'offline'. + +=item B<--percent> + +Set this option if you want to warn on percent + +=back + +=cut diff --git a/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm b/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm index 244b034df..11b982699 100644 --- a/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm +++ b/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -142,7 +142,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/netasq/snmp/plugin.pm b/centreon-plugins/network/netasq/snmp/plugin.pm index e79cbd440..fc0f06178 100644 --- a/centreon-plugins/network/netasq/snmp/plugin.pm +++ b/centreon-plugins/network/netasq/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,17 +28,17 @@ 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' => 'snmp_standard::mode::cpu', 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'connections' => 'network::netasq::snmp::mode::connections', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'load' => 'snmp_standard::mode::loadaverage', - 'ha-status' => 'network::netasq::snmp::mode::hastatus', - 'memory' => 'snmp_standard::mode::memory', + 'ha-nodes' => 'network::netasq::snmp::mode::hanodes', + 'memory' => 'os::freebsd::snmp::mode::memory', 'storage' => 'snmp_standard::mode::storage', 'swap' => 'snmp_standard::mode::swap', 'vpn-status' => 'network::netasq::snmp::mode::vpnstatus', diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/components/card.pm b/centreon-plugins/network/nortel/standard/snmp/mode/components/card.pm new file mode 100644 index 000000000..bb1169a40 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/components/card.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::components::card; + +use strict; +use warnings; +use network::nortel::standard::snmp::mode::components::resources qw($map_card_status); + +my $mapping = { + rcCardSerialNumber => { oid => '.1.3.6.1.4.1.2272.1.4.9.1.1.3' }, + rcCardOperStatus => { oid => '.1.3.6.1.4.1.2272.1.4.9.1.1.6', map => $map_card_status }, +}; +my $oid_rcCardEntry = '.1.3.6.1.4.1.2272.1.4.9.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_rcCardEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cards"); + $self->{components}->{card} = {name => 'cards', total => 0, skip => 0}; + return if ($self->check_filter(section => 'card')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rcCardEntry}})) { + next if ($oid !~ /^$mapping->{rcCardOperStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rcCardEntry}, instance => $instance); + + next if ($self->check_filter(section => 'card', instance => $instance)); + $self->{components}->{card}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("card '%s' status is '%s' [instance: %s].", + $result->{rcCardSerialNumber}, $result->{rcCardOperStatus}, + $instance + )); + my $exit = $self->get_severity(section => 'card', instance => $instance, value => $result->{rcCardOperStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Card '%s' status is '%s'", + $result->{rcCardSerialNumber}, $result->{rcCardOperStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/components/entity.pm b/centreon-plugins/network/nortel/standard/snmp/mode/components/entity.pm new file mode 100644 index 000000000..69096e850 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/components/entity.pm @@ -0,0 +1,69 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::components::entity; + +use strict; +use warnings; +use network::nortel::standard::snmp::mode::components::resources qw($map_comp_status); + +my $mapping = { + s5ChasComDescr => { oid => '.1.3.6.1.4.1.45.1.6.3.3.1.1.5' }, + s5ChasComOperState => { oid => '.1.3.6.1.4.1.45.1.6.3.3.1.1.10', map => $map_comp_status }, +}; +my $oid_s5ChasComEntry = '.1.3.6.1.4.1.45.1.6.3.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_s5ChasComEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking entities"); + $self->{components}->{entity} = {name => 'entities', total => 0, skip => 0}; + return if ($self->check_filter(section => 'entity')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_s5ChasComEntry}})) { + next if ($oid !~ /^$mapping->{s5ChasComOperState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_s5ChasComEntry}, instance => $instance); + + next if ($self->check_filter(section => 'entity', instance => $instance)); + $self->{components}->{entity}->{total}++; + + my $name = defined($result->{s5ChasComDescr}) && $result->{s5ChasComDescr} ne '' ? + $result->{s5ChasComDescr} : $instance; + $self->{output}->output_add(long_msg => sprintf("entity '%s' status is '%s' [instance: %s].", + $name, $result->{s5ChasComOperState}, + $instance + )); + my $exit = $self->get_severity(section => 'entity', instance => $instance, value => $result->{s5ChasComOperState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Entity '%s' status is '%s'", + $name, $result->{s5ChasComOperState})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/components/fan.pm b/centreon-plugins/network/nortel/standard/snmp/mode/components/fan.pm new file mode 100644 index 000000000..645bf4101 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/components/fan.pm @@ -0,0 +1,78 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::components::fan; + +use strict; +use warnings; +use network::nortel::standard::snmp::mode::components::resources qw($map_fan_status); + +my $mapping = { + rcChasFanOperStatus => { oid => '.1.3.6.1.4.1.2272.1.4.7.1.1.2', map => $map_fan_status }, + rcChasFanAmbientTemperature => { oid => '.1.3.6.1.4.1.2272.1.4.7.1.1.3' }, +}; +my $oid_rcChasFanEntry = '.1.3.6.1.4.1.2272.1.4.7.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_rcChasFanEntry }; +} + +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_rcChasFanEntry}})) { + next if ($oid !~ /^$mapping->{rcChasFanOperStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rcChasFanEntry}, 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, value: %s].", + $instance, $result->{rcChasFanOperStatus}, + $instance, $result->{rcChasFanAmbientTemperature} + )); + my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{rcChasFanOperStatus}); + 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->{rcChasFanOperStatus})); + } + + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.temperature', instance => $instance, value => $result->{rcChasFanAmbientTemperature}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Fan temperature '%s' is %s degree centigrade", $instance, $result->{rcChasFanAmbientTemperature})); + } + $self->{output}->perfdata_add(label => 'fan_temp_' . $instance, unit => 'C', + value => $result->{rcChasFanAmbientTemperature}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/components/psu.pm b/centreon-plugins/network/nortel/standard/snmp/mode/components/psu.pm new file mode 100644 index 000000000..e7b8ce7ce --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/components/psu.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::components::psu; + +use strict; +use warnings; +use network::nortel::standard::snmp::mode::components::resources qw($map_psu_status); + +my $mapping = { + rcChasPowerSupplyOperStatus => { oid => '.1.3.6.1.4.1.2272.1.4.8.1.1.2', map => $map_psu_status }, +}; +my $oid_rcChasPowerSupplyEntry = '.1.3.6.1.4.1.2272.1.4.8.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_rcChasPowerSupplyEntry }; +} + +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_rcChasPowerSupplyEntry}})) { + next if ($oid !~ /^$mapping->{rcChasPowerSupplyOperStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rcChasPowerSupplyEntry}, 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->{rcChasPowerSupplyOperStatus}, + $instance + )); + my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{rcChasPowerSupplyOperStatus}); + 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->{rcChasPowerSupplyOperStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/components/resources.pm b/centreon-plugins/network/nortel/standard/snmp/mode/components/resources.pm new file mode 100644 index 000000000..7b22e15e7 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/components/resources.pm @@ -0,0 +1,68 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our ($map_comp_status, $map_fan_status, $map_psu_status, $map_card_status); + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_comp_status $map_fan_status $map_psu_status $map_card_status); + +$map_fan_status = { + 1 => 'unknown', + 2 => 'up', + 3 => 'down', +}; + +$map_psu_status = { + 1 => 'unknown', + 2 => 'empty', + 3 => 'up', + 4 => 'down', +}; + +$map_card_status = { + 1 => 'up', + 2 => 'down', + 3 => 'testing', + 4 => 'unknown', + 5 => 'dormant', +}; + +$map_comp_status = { + 1 => 'other', + 2 => 'notAvail', + 3 => 'removed', + 4 => 'disabled', + 5 => 'normal', + 6 => 'resetInProg', + 7 => 'testing', + 8 => 'warning', + 9 => 'nonFatalErr', + 10 => 'fatalErr', + 11 => 'notConfig', + 12 => 'obsoleted', +}; + +1; \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/components/temperature.pm b/centreon-plugins/network/nortel/standard/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..9f9543183 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/components/temperature.pm @@ -0,0 +1,70 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + s5ChasTmpSnrTmpValue => { oid => '.1.3.6.1.4.1.45.1.6.3.7.1.1.5' }, +}; +my $oid_s5ChasTmpSnrEntry = '.1.3.6.1.4.1.45.1.6.3.7.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_s5ChasTmpSnrEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_s5ChasTmpSnrEntry}})) { + next if ($oid !~ /^$mapping->{s5ChasTmpSnrTmpValue}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_s5ChasTmpSnrEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $result->{s5ChasTmpSnrTmpValue} = sprintf("%.2f", $result->{s5ChasTmpSnrTmpValue} / 2); + $self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s degree centigrade [instance = %s]", + $instance, $result->{s5ChasTmpSnrTmpValue}, $instance, + )); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{s5ChasTmpSnrTmpValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{slHdwTempSensorName}, $result->{s5ChasTmpSnrTmpValue})); + } + $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + value => $result->{s5ChasTmpSnrTmpValue}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/cpu.pm b/centreon-plugins/network/nortel/standard/snmp/mode/cpu.pm new file mode 100644 index 000000000..b82b8d28b --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/cpu.pm @@ -0,0 +1,155 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPU usages are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'total', set => { + key_values => [ { name => 'total' }, { name => 'num' } ], + output_template => 'Total CPU Usage : %.2f %%', + perfdatas => [ + { label => 'cpu_total', value => 'total_absolute', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + { label => '1m', set => { + key_values => [ { name => '1m' }, { name => 'num' } ], + output_template => '1 minute : %.2f %%', + perfdatas => [ + { label => 'cpu_1min', value => '1m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + { label => '10m', set => { + key_values => [ { name => '10m' }, { name => 'num' } ], + output_template => '10 minutes : %.2f %%', + perfdatas => [ + { label => 'cpu_10min', value => '10m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + { label => '1h', set => { + key_values => [ { name => '1h' }, { name => 'num' } ], + output_template => '1 hour : %.2f %%', + perfdatas => [ + { label => 'cpu_1h', value => '1h_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + ], + } + }, + ]; +} + +sub prefix_cpu_output { + my ($self, %options) = @_; + + return "CPU '" . $options{instance_value}->{num} . "' "; +} + +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 => + { + }); + + return $self; +} + +my $mapping = { + s5ChasUtilTotalCPUUsage => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.4' }, + s5ChasUtilCPUUsageLast1Minute => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.5' }, + s5ChasUtilCPUUsageLast10Minutes => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.6' }, + s5ChasUtilCPUUsageLast1Hour => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.7' }, +}; + +my $oid_rcSysCpuUtil = '.1.3.6.1.4.1.2272.1.1.20'; # without .0 +my $oid_s5ChasUtilEntry = '.1.3.6.1.4.1.45.1.6.3.8.1.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{results} = $options{snmp}->get_multiple_table(oids => [ + { oid => $oid_rcSysCpuUtil }, + { oid => $oid_s5ChasUtilEntry }, + ], nothing_quit => 1); + + $self->{cpu} = {}; + foreach my $oid (keys %{$self->{results}->{$oid_s5ChasUtilEntry}}) { + next if ($oid !~ /^$mapping->{s5ChasUtilTotalCPUUsage}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_s5ChasUtilEntry}, instance => $instance); + + $self->{cpu}->{$instance} = { num => $instance, total => $result->{s5ChasUtilTotalCPUUsage}, + '1m' => $result->{s5ChasUtilCPUUsageLast1Minute}, '10m' => $result->{s5ChasUtilCPUUsageLast10Minutes}, + '1h' => $result->{s5ChasUtilCPUUsageLast1Hour} }; + } + + if (scalar(keys %{$self->{results}->{$oid_rcSysCpuUtil}}) > 0) { + $self->{cpu}->{0} = { num => 0, total => $self->{results}->{$oid_rcSysCpuUtil}->{$oid_rcSysCpuUtil . '.0'} }; + } +} + +1; + +__END__ + +=head1 MODE + +Check CPU usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(1m|10m)$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'total', '1m', '5m', '10m', '1h'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'total', '1m', '5m', '10m', '1h'. + +=back + +=cut diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/hardware.pm b/centreon-plugins/network/nortel/standard/snmp/mode/hardware.pm new file mode 100644 index 000000000..f74465860 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/hardware.pm @@ -0,0 +1,138 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|card|entity)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan.temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['up', 'OK'], + ['down', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ], + psu => [ + ['up', 'OK'], + ['down', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ['empty', 'OK'], + ], + card => [ + ['up', 'OK'], + ['down', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ['testing', 'OK'], + ['dormant', 'OK'], + ], + entity => [ + ['other', 'UNKNOWN'], + ['notAvail', 'OK'], + ['removed', 'OK'], + ['disabled', 'OK'], + ['normal', 'OK'], + ['resetInProg', 'OK'], + ['testing', 'OK'], + ['warning', 'WARNING'], + ['nonFatalErr', 'WARNING'], + ['fatalErr', 'CRITICAL'], + ['notConfig', 'OK'], + ['obsoleted', 'WARNING'], + ], + }; + + $self->{components_path} = 'network::nortel::standard::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'card', 'entity']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'fan', 'psu', 'card', 'entity'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=psu,1 + +=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='entity,WARNING,disabled' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' --warning=fan.temperature,.*,10 + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/network/nortel/standard/snmp/mode/memory.pm b/centreon-plugins/network/nortel/standard/snmp/mode/memory.pm new file mode 100644 index 000000000..eb0160521 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/mode/memory.pm @@ -0,0 +1,107 @@ +# +# Copyright 2016 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::nortel::standard::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memory usages are ok' } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', set => { + key_values => [ { name => 'used' }, { name => 'display' } ], + output_template => 'Used : %.2f %%', + perfdatas => [ + { label => 'used', value => 'used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_memory_output { + my ($self, %options) = @_; + + return "Memory '" . $options{instance_value}->{display} . "' "; +} + +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 => + { + }); + + return $self; +} + +my $mapping = { + s5ChasUtilMemoryAvailable => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.9' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{memory} = {}; + $self->{results} = $options{snmp}->get_table(oid => $mapping->{s5ChasUtilMemoryAvailable}->{oid}, + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}}) { + next if ($oid !~ /^$mapping->{s5ChasUtilMemoryAvailable}->{oid}\.(.*)/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + $self->{memory}->{$instance} = { display => $instance, + used => 100 - $result->{s5ChasUtilMemoryAvailable}}; + } +} + +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/centreon-plugins/network/nortel/standard/snmp/plugin.pm b/centreon-plugins/network/nortel/standard/snmp/plugin.pm new file mode 100644 index 000000000..5d64bc2e9 --- /dev/null +++ b/centreon-plugins/network/nortel/standard/snmp/plugin.pm @@ -0,0 +1,53 @@ +# +# Copyright 2016 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::nortel::standard::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::nortel::standard::snmp::mode::cpu', + 'hardware' => 'network::nortel::standard::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::nortel::standard::snmp::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Nortel switch/routers in SNMP. +Can be used for avaya equipments also. + +=cut diff --git a/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm b/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm index 5826b3133..4b7b2aaa5 100644 --- a/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm +++ b/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_oacSysCpuUsed = '.1.3.6.1.4.1.13191.10.3.3.1.2.1.0'; diff --git a/centreon-plugins/network/oneaccess/snmp/mode/memory.pm b/centreon-plugins/network/oneaccess/snmp/mode/memory.pm index bd090a02d..905b2a511 100644 --- a/centreon-plugins/network/oneaccess/snmp/mode/memory.pm +++ b/centreon-plugins/network/oneaccess/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_oacSysMemoryTotal = '.1.3.6.1.4.1.13191.10.3.3.1.1.3.0'; diff --git a/centreon-plugins/network/oneaccess/snmp/plugin.pm b/centreon-plugins/network/oneaccess/snmp/plugin.pm index 23d0a2ee5..ff696c28e 100644 --- a/centreon-plugins/network/oneaccess/snmp/plugin.pm +++ b/centreon-plugins/network/oneaccess/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.5'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/paloalto/snmp/mode/clusterstatus.pm b/centreon-plugins/network/paloalto/snmp/mode/clusterstatus.pm index be8dfaa89..9a98ca90f 100644 --- a/centreon-plugins/network/paloalto/snmp/mode/clusterstatus.pm +++ b/centreon-plugins/network/paloalto/snmp/mode/clusterstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -50,7 +50,7 @@ sub new { return $self; } -sub check_treshold_overload { +sub check_threshold_overload { my ($self, %options) = @_; $self->{overload_th} = {}; @@ -72,7 +72,7 @@ sub check_treshold_overload { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - $self->check_treshold_overload(); + $self->check_threshold_overload(); } sub get_severity { @@ -99,7 +99,6 @@ sub get_severity { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{result} = $self->{snmp}->get_leef(oids => [ $oid_panSysHAState, $oid_panSysHAPeerState, $oid_panSysHAMode ], @@ -168,4 +167,4 @@ Example: --threshold-overload='peer,critical,active' --threshold-overload='curre =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/network/paloalto/snmp/mode/panorama.pm b/centreon-plugins/network/paloalto/snmp/mode/panorama.pm index 5a5976b67..25d9d879d 100644 --- a/centreon-plugins/network/paloalto/snmp/mode/panorama.pm +++ b/centreon-plugins/network/paloalto/snmp/mode/panorama.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -47,7 +47,7 @@ sub new { return $self; } -sub check_treshold_overload { +sub check_threshold_overload { my ($self, %options) = @_; $self->{overload_th} = {}; @@ -69,7 +69,7 @@ sub check_treshold_overload { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - $self->check_treshold_overload(); + $self->check_threshold_overload(); } sub check_exclude { @@ -106,7 +106,6 @@ sub get_severity { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_panMgmtPanoramaConnected = '.1.3.6.1.4.1.25461.2.1.2.4.1.0'; @@ -163,4 +162,4 @@ Can also exclude specific instance: --exclude=panorama#2# =back =cut - \ No newline at end of file + diff --git a/centreon-plugins/network/paloalto/snmp/mode/sessions.pm b/centreon-plugins/network/paloalto/snmp/mode/sessions.pm index 7d88179db..8895209f3 100644 --- a/centreon-plugins/network/paloalto/snmp/mode/sessions.pm +++ b/centreon-plugins/network/paloalto/snmp/mode/sessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -137,7 +137,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/paloalto/snmp/plugin.pm b/centreon-plugins/network/paloalto/snmp/plugin.pm index 9b0365d2d..0958ea926 100644 --- a/centreon-plugins/network/paloalto/snmp/plugin.pm +++ b/centreon-plugins/network/paloalto/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.5'; %{$self->{modes}} = ( diff --git a/centreon-plugins/network/radware/alteon/5224/plugin.pm b/centreon-plugins/network/radware/alteon/5224/plugin.pm index 0b7efe22b..fca2dcb49 100644 --- a/centreon-plugins/network/radware/alteon/5224/plugin.pm +++ b/centreon-plugins/network/radware/alteon/5224/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/radware/alteon/common/mode/cpu.pm b/centreon-plugins/network/radware/alteon/common/mode/cpu.pm index ca10e8ab4..03ea40c6a 100644 --- a/centreon-plugins/network/radware/alteon/common/mode/cpu.pm +++ b/centreon-plugins/network/radware/alteon/common/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_mpCpuStatsUtil1Second = '.1.3.6.1.4.1.1872.2.5.1.2.2.1.0'; diff --git a/centreon-plugins/network/radware/alteon/common/mode/hardware.pm b/centreon-plugins/network/radware/alteon/common/mode/hardware.pm index 924264464..90af5a195 100644 --- a/centreon-plugins/network/radware/alteon/common/mode/hardware.pm +++ b/centreon-plugins/network/radware/alteon/common/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -71,7 +71,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{components_fans} = 0; diff --git a/centreon-plugins/network/radware/alteon/common/mode/memory.pm b/centreon-plugins/network/radware/alteon/common/mode/memory.pm index df6da5ac4..b72539938 100644 --- a/centreon-plugins/network/radware/alteon/common/mode/memory.pm +++ b/centreon-plugins/network/radware/alteon/common/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_mpMemStatsTotal = '.1.3.6.1.4.1.1872.2.5.1.2.8.1.0'; diff --git a/centreon-plugins/network/redback/snmp/mode/components/disk.pm b/centreon-plugins/network/redback/snmp/mode/components/disk.pm index afee478a8..6ae0e208f 100644 --- a/centreon-plugins/network/redback/snmp/mode/components/disk.pm +++ b/centreon-plugins/network/redback/snmp/mode/components/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -37,9 +37,9 @@ my $mapping = { my $oid_rbnSRStorageEntry = '.1.3.6.1.4.1.2352.2.24.1.2.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rbnSRStorageEntry }; + push @{$self->{request}}, { oid => $oid_rbnSRStorageEntry }; } sub check { @@ -47,14 +47,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking disks"); $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'disk')); + return if ($self->check_filter(section => 'disk')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rbnSRStorageEntry}})) { next if ($oid !~ /^$mapping->{rbnSRStorageStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rbnSRStorageEntry}, instance => $instance); - next if ($self->check_exclude(section => 'disk', instance => $instance)); + next if ($self->check_filter(section => 'disk', instance => $instance)); $self->{components}->{disk}->{total}++; $self->{output}->output_add(long_msg => sprintf("Disk '%s' status is %s [instance: %s].", diff --git a/centreon-plugins/network/redback/snmp/mode/components/fan.pm b/centreon-plugins/network/redback/snmp/mode/components/fan.pm index de66c2a0b..602a328ce 100644 --- a/centreon-plugins/network/redback/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/redback/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -38,9 +38,9 @@ my $mapping = { my $oid_rbnFanStatusEntry = '.1.3.6.1.4.1.2352.2.4.1.1.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rbnFanStatusEntry }; + push @{$self->{request}}, { oid => $oid_rbnFanStatusEntry }; } sub check { @@ -48,14 +48,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rbnFanStatusEntry}})) { next if ($oid !~ /^$mapping->{rbnFanStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rbnFanStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($result->{rbnFanStatus} =~ /absent/i && $self->absent_problem(section => 'fan', instance => $instance)); $self->{components}->{fan}->{total}++; diff --git a/centreon-plugins/network/redback/snmp/mode/components/psu.pm b/centreon-plugins/network/redback/snmp/mode/components/psu.pm index 0fcb8395d..da38d42fa 100644 --- a/centreon-plugins/network/redback/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/redback/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -38,9 +38,9 @@ my $mapping = { my $oid_rbnPowerStatusEntry = '.1.3.6.1.4.1.2352.2.4.1.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rbnPowerStatusEntry }; + push @{$self->{request}}, { oid => $oid_rbnPowerStatusEntry }; } sub check { @@ -48,14 +48,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rbnPowerStatusEntry}})) { next if ($oid !~ /^$mapping->{rbnPowerStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rbnPowerStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); next if ($result->{rbnPowerStatus} =~ /absent/i && $self->absent_problem(section => 'psu', instance => $instance)); $self->{components}->{psu}->{total}++; diff --git a/centreon-plugins/network/redback/snmp/mode/components/temperature.pm b/centreon-plugins/network/redback/snmp/mode/components/temperature.pm index 8aa26b996..9b5481ef2 100644 --- a/centreon-plugins/network/redback/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/redback/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -31,9 +31,9 @@ my $mapping = { my $oid_rbnEntityTempSensorEntry = '.1.3.6.1.4.1.2352.2.4.1.6.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rbnEntityTempSensorEntry }; + push @{$self->{request}}, { oid => $oid_rbnEntityTempSensorEntry }; } sub check { @@ -41,14 +41,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rbnEntityTempSensorEntry}})) { next if ($oid !~ /^$mapping->{rbnEntityTempCurrent}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rbnEntityTempSensorEntry}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("'%s' temperature is %dC [instance: %s].", diff --git a/centreon-plugins/network/redback/snmp/mode/components/voltage.pm b/centreon-plugins/network/redback/snmp/mode/components/voltage.pm index afdf75800..5befd5879 100644 --- a/centreon-plugins/network/redback/snmp/mode/components/voltage.pm +++ b/centreon-plugins/network/redback/snmp/mode/components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -31,9 +31,9 @@ my $mapping = { my $oid_rbnVoltageSensorEntry = '.1.3.6.1.4.1.2352.2.4.1.3.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_rbnVoltageSensorEntry }; + push @{$self->{request}}, { oid => $oid_rbnVoltageSensorEntry }; } sub check { @@ -41,14 +41,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking voltages"); $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'voltage')); + return if ($self->check_filter(section => 'voltage')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rbnVoltageSensorEntry}})) { next if ($oid !~ /^$mapping->{rbnVoltageCurrent}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rbnVoltageSensorEntry}, instance => $instance); - next if ($self->check_exclude(section => 'voltage', instance => $instance)); + next if ($self->check_filter(section => 'voltage', instance => $instance)); $self->{components}->{voltage}->{total}++; $self->{output}->output_add(long_msg => sprintf("'%s' voltage is %d mV [instance: %s].", diff --git a/centreon-plugins/network/redback/snmp/mode/cpu.pm b/centreon-plugins/network/redback/snmp/mode/cpu.pm index bd4c834b6..44d54398a 100644 --- a/centreon-plugins/network/redback/snmp/mode/cpu.pm +++ b/centreon-plugins/network/redback/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -89,7 +89,6 @@ sub check_table_cpu { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rbnCpuMeterFiveSecondAvg = '.1.3.6.1.4.1.2352.2.6.1.1.0'; diff --git a/centreon-plugins/network/redback/snmp/mode/disk.pm b/centreon-plugins/network/redback/snmp/mode/disk.pm index f1432ad4e..62a4eda7c 100644 --- a/centreon-plugins/network/redback/snmp/mode/disk.pm +++ b/centreon-plugins/network/redback/snmp/mode/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/redback/snmp/mode/hardware.pm b/centreon-plugins/network/redback/snmp/mode/hardware.pm index 0d0c8044c..e8bfca4a4 100644 --- a/centreon-plugins/network/redback/snmp/mode/hardware.pm +++ b/centreon-plugins/network/redback/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,30 +20,49 @@ package network::redback::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - fan => [ - ['unknown', 'UNKNOWN'], - ['normal', 'OK'], - ['failed', 'CRITICAL'], - ['absent', 'OK'], - ], - psu => [ - ['unknown', 'UNKNOWN'], - ['normal', 'OK'], - ['failed', 'CRITICAL'], - ['absent', 'OK'], - ], - disk => [ - ['operational', 'OK'], - ['failed', 'CRITICAL'], - ['degrading', 'WARNING'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|disk)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['failed', 'CRITICAL'], + ['absent', 'OK'], + ], + psu => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['failed', 'CRITICAL'], + ['absent', 'OK'], + ], + disk => [ + ['operational', 'OK'], + ['failed', 'CRITICAL'], + ['degrading', 'WARNING'], + ], + }; + + $self->{components_path} = 'network::redback::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature', 'voltage', 'disk']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -52,208 +71,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(temperature|voltage)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature or voltage)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('fan', 'psu', 'temperature', 'voltage', 'disk'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "network::redback::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::redback::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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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__ @@ -269,15 +92,15 @@ Check Hardware (Power Supplies, Fans, Temperatures, Voltages, Disks). Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'temperature', 'voltage', 'disk'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=fan) -Can also exclude specific instance: --exclude=fan#1#,psu#3# +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +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#1# +Can be specific or global: --absent-problem=fan,1 =item B<--no-component> @@ -286,20 +109,20 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,treshold) +Set warning threshold for temperatures (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,treshold) +Set critical threshold for temperatures (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/network/redback/snmp/mode/memory.pm b/centreon-plugins/network/redback/snmp/mode/memory.pm index ed9dd24b3..23aa61d3c 100644 --- a/centreon-plugins/network/redback/snmp/mode/memory.pm +++ b/centreon-plugins/network/redback/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/network/redback/snmp/plugin.pm b/centreon-plugins/network/redback/snmp/plugin.pm index bde6e4636..992cf3cd8 100644 --- a/centreon-plugins/network/redback/snmp/plugin.pm +++ b/centreon-plugins/network/redback/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwoptimization.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwoptimization.pm index 531d0775e..6cf0446c9 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwoptimization.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwoptimization.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -46,7 +46,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwpassthrough.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwpassthrough.pm index 88bdc933c..ae377d703 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwpassthrough.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwpassthrough.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -71,7 +71,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/connections.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/connections.pm index 2c4783202..58c4cbac4 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/connections.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_optimizedConnections = '.1.3.6.1.4.1.17163.1.1.5.2.1.0'; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/diskutilization.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/diskutilization.pm index e4373a28e..85cfb0aa3 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/diskutilization.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/diskutilization.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_dsAveDiskUtilization = '.1.3.6.1.4.1.17163.1.1.5.4.4.0'; # in % diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/health.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/health.pm index df79fd1aa..362029168 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/health.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/health.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -49,7 +49,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_systemHealth = '.1.3.6.1.4.1.17163.1.1.2.7.0'; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/loadaverage.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/loadaverage.pm index 495191382..ecaeadc3c 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/loadaverage.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/loadaverage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -75,7 +75,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cpuLoad1 = '.1.3.6.1.4.1.17163.1.1.5.1.1.0'; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/servicestatus.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/servicestatus.pm index 134b5dc71..06b5a318d 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/servicestatus.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/servicestatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -54,7 +54,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_optServiceStatus = '.1.3.6.1.4.1.17163.1.1.2.8.0'; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/serviceuptime.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/serviceuptime.pm index eba96d801..d73a24fa7 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/serviceuptime.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/serviceuptime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -58,7 +58,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_serviceUptime = '.1.3.6.1.4.1.17163.1.1.2.4.0'; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/mode/temperature.pm b/centreon-plugins/network/riverbed/steelhead/snmp/mode/temperature.pm index 344bbc012..e85c9f8dc 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/temperature.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_systemTemperature = '.1.3.6.1.4.1.17163.1.1.2.9.0'; # in Celsius diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm index fb78bb894..a97a9e48c 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object # Plugin version $self->{version} = '0.1'; diff --git a/centreon-plugins/network/ruggedcom/mode/errors.pm b/centreon-plugins/network/ruggedcom/mode/errors.pm index 1e06364f2..8bb31d480 100644 --- a/centreon-plugins/network/ruggedcom/mode/errors.pm +++ b/centreon-plugins/network/ruggedcom/mode/errors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -85,7 +85,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{results} = $self->{snmp}->get_table(oid => $oid_rcDeviceError, start => $oid_rcDeviceErrWatchdogReset); diff --git a/centreon-plugins/network/ruggedcom/mode/hardware.pm b/centreon-plugins/network/ruggedcom/mode/hardware.pm index 12059aa47..39bc82518 100644 --- a/centreon-plugins/network/ruggedcom/mode/hardware.pm +++ b/centreon-plugins/network/ruggedcom/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -100,12 +100,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -115,7 +115,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # There is a bug with get_leef and snmpv1. diff --git a/centreon-plugins/network/ruggedcom/mode/memory.pm b/centreon-plugins/network/ruggedcom/mode/memory.pm index e413b8355..981549525 100644 --- a/centreon-plugins/network/ruggedcom/mode/memory.pm +++ b/centreon-plugins/network/ruggedcom/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rcDeviceStsAvailableRam = '.1.3.6.1.4.1.15004.4.2.2.2.0'; # in bytes diff --git a/centreon-plugins/network/ruggedcom/mode/temperature.pm b/centreon-plugins/network/ruggedcom/mode/temperature.pm index 912cd6d9d..b87f822ec 100644 --- a/centreon-plugins/network/ruggedcom/mode/temperature.pm +++ b/centreon-plugins/network/ruggedcom/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rcDeviceStsTemperature = '.1.3.6.1.4.1.15004.4.2.2.3.0'; # in Celsius diff --git a/centreon-plugins/network/ruggedcom/plugin.pm b/centreon-plugins/network/ruggedcom/plugin.pm index d387ef2d4..86d953df6 100644 --- a/centreon-plugins/network/ruggedcom/plugin.pm +++ b/centreon-plugins/network/ruggedcom/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/securactive/mode/bca.pm b/centreon-plugins/network/securactive/mode/bca.pm index 4070a46d9..b9e75eaae 100644 --- a/centreon-plugins/network/securactive/mode/bca.pm +++ b/centreon-plugins/network/securactive/mode/bca.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -108,7 +108,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/securactive/mode/bcn.pm b/centreon-plugins/network/securactive/mode/bcn.pm index 185748847..2ae1179a4 100644 --- a/centreon-plugins/network/securactive/mode/bcn.pm +++ b/centreon-plugins/network/securactive/mode/bcn.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -100,7 +100,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/securactive/mode/listbca.pm b/centreon-plugins/network/securactive/mode/listbca.pm index bb52cce90..ac9c1c724 100644 --- a/centreon-plugins/network/securactive/mode/listbca.pm +++ b/centreon-plugins/network/securactive/mode/listbca.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -78,7 +78,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -102,7 +101,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/securactive/mode/listbcn.pm b/centreon-plugins/network/securactive/mode/listbcn.pm index 940d31ee4..ab9bc50d6 100644 --- a/centreon-plugins/network/securactive/mode/listbcn.pm +++ b/centreon-plugins/network/securactive/mode/listbcn.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -85,7 +85,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -121,7 +120,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/securactive/plugin.pm b/centreon-plugins/network/securactive/plugin.pm index 93ed999c5..5fc5ff8f5 100644 --- a/centreon-plugins/network/securactive/plugin.pm +++ b/centreon-plugins/network/securactive/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/sonus/sbc/plugin.pm b/centreon-plugins/network/sonus/sbc/plugin.pm new file mode 100644 index 000000000..1eff70cc3 --- /dev/null +++ b/centreon-plugins/network/sonus/sbc/plugin.pm @@ -0,0 +1,58 @@ +# +# Copyright 2016 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::sonus::sbc::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}} = ( + 'call-statistics' => 'network::sonus::sbc::snmp::mode::callstats', + 'channels' => 'network::sonus::sbc::snmp::mode::channels', + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'dsp-stats' => 'network::sonus::sbc::snmp::mode::dspstats', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'load' => 'snmp_standard::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', + 'storage' => 'snmp_standard::mode::storage', + 'swap' => 'snmp_standard::mode::swap', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Sonus Session Border Controllers equipment in SNMP. + +=cut diff --git a/centreon-plugins/network/sonus/sbc/snmp/callstats.pm b/centreon-plugins/network/sonus/sbc/snmp/callstats.pm new file mode 100644 index 000000000..92c55d54c --- /dev/null +++ b/centreon-plugins/network/sonus/sbc/snmp/callstats.pm @@ -0,0 +1,173 @@ +# +# Copyright 2016 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::sonus::sbc::snmp::mode::callstats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All calls stats on ports are OK' }, + ]; + + $self->{maps_counters}->{port} = [ + { label => 'current-calls', set => { + key_values => [ { name => 'current' }, { name => 'display' } ], + output_template => 'Current calls : %s', + perfdatas => [ + { label => 'current', value => 'current_absolute', template => '%d', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'total-per-sec', set => { + key_values => [ { name => 'total', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'total calls: %.2f/s', + perfdatas => [ + { label => 'total', value => 'total_per_second', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'connected-per-sec', set => { + key_values => [ { name => 'connected', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'connected calls: %.2f/s', + perfdatas => [ + { label => 'connected', value => 'connected_per_second', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'refused-per-sec', set => { + key_values => [ { name => 'refused', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'refused calls: %.2f/s', + perfdatas => [ + { label => 'refused', value => 'refused_per_second', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'errored-per-sec', set => { + key_values => [ { name => 'errored', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'errored calls: %.2f/s', + perfdatas => [ + { label => 'errored', value => 'errored_per_second', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'blocked-per-sec', set => { + key_values => [ { name => 'blocked', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'blocked calls: %.2f/s', + perfdatas => [ + { label => 'blocked', value => 'blocked_per_second', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_dsp_output { + my ($self, %options) = @_; + + return "Port => '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + return $self; +} + +my $mapping = { + uxPTCurrentCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.5' }, + uxPTTotalCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.6' }, + uxPTConnectedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.7' }, + uxPTRefusedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.8' }, + uxPTErroredCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.9' }, + uxPTBlockedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.18' }, +}; + +my $oid_uxPortTable = '.1.3.6.1.4.1.177.15.1.5.1.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{cache_name} = "sonus_" . $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->{results} = $options{snmp}->get_table(oid => $oid_uxPortTable, + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}}) { + next if $oid !~ /^$mapping->{uxPTCurrentCalls}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + $self->{port}->{$instance} = { current => $result->{uxPTCurrentCalls}, + total => $result->{uxPTTotalCalls}, + connected => $result->{uxPTConnectedCalls}, + refused => $result->{uxPTRefusedCalls}, + errored => $result->{uxPTErroredCalls}, + blocked => $result->{uxPTBlockedCalls}, + display => $instance }; + } +} + +1; + +__END__ + +=head1 MODE + +Check Call statistics + +=over 8 + +=item B<--warning-*> + +Warning on counters. Can be ('current-calls', 'total-per-sec', 'connected-per-sec', 'refused-per-sec', 'errored-per-sec', 'blocked-per-sec') + +=item B<--critical-*> + +Critical on counters. Can be ('current-calls', 'total-per-sec', 'connected-per-sec', 'refused-per-sec', 'errored-per-sec', 'blocked-per-sec') + +=back + +=cut diff --git a/centreon-plugins/network/sonus/sbc/snmp/channels.pm b/centreon-plugins/network/sonus/sbc/snmp/channels.pm new file mode 100644 index 000000000..5c98a74ab --- /dev/null +++ b/centreon-plugins/network/sonus/sbc/snmp/channels.pm @@ -0,0 +1,406 @@ +# +# Copyright 2016 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::sonus::sbc::snmp::mode::channels; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg; + + if ($self->{result_values}->{admstatus} eq 'disabled') { + $msg = ' is disabled (admin)'; + } else { + $msg = 'Oper Status : ' . $self->{result_values}->{opstatus}; + } + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{opstatus} = $options{new_datas}->{$self->{instance} . '_opstatus'}; + $self->{result_values}->{admstatus} = $options{new_datas}->{$self->{instance} . '_admstatus'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'channels', type => 1, cb_prefix_output => 'prefix_channels_output', message_multiple => 'All channels are ok' } + ]; + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total channels : %s', + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-outofservice', set => { + key_values => [ { name => 'outofservice' } ], + output_template => 'OutOfService : %s', + perfdatas => [ + { label => 'total_outofservice', value => 'outofservice_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-idle', set => { + key_values => [ { name => 'idle' } ], + output_template => 'Idle : %s', + perfdatas => [ + { label => 'total_idle', value => 'idle_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-pending', set => { + key_values => [ { name => 'pending' } ], + output_template => 'Pending : %s', + perfdatas => [ + { label => 'total_pending', value => 'pending_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-waitingforroute', set => { + key_values => [ { name => 'waitingforroute' } ], + output_template => 'WaitingForRoute : %s', + perfdatas => [ + { label => 'total_waitingforroute', value => 'waitingforroute_absolute_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-actionlist', set => { + key_values => [ { name => 'actionlist' } ], + output_template => 'ActionList : %s', + perfdatas => [ + { label => 'total_actionlist', value => 'actionlist_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-waitingfordigits', set => { + key_values => [ { name => 'waitingfordigits' } ], + output_template => 'WaitingForDigits : %s', + perfdatas => [ + { label => 'total_waitingfordigits', value => 'waitingfordigits_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-remotesetup', set => { + key_values => [ { name => 'remotesetup' } ], + output_template => 'RemoteSetup : %s', + perfdatas => [ + { label => 'total_remotesetup', value => 'remotesetup_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-peersetup', set => { + key_values => [ { name => 'peersetup' } ], + output_template => 'PeerSetup : %s', + perfdatas => [ + { label => 'total_peersetup', value => 'peersetup_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-alerting', set => { + key_values => [ { name => 'alerting' } ], + output_template => 'Alerting : %s', + perfdatas => [ + { label => 'total_alerting', value => 'alerting_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-inbandinfo', set => { + key_values => [ { name => 'inbandinfo' } ], + output_template => 'InBandInfo : %s', + perfdatas => [ + { label => 'total_inbandinfo', value => 'inbandinfo_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-connected', set => { + key_values => [ { name => 'connected' } ], + output_template => 'Connected : %s', + perfdatas => [ + { label => 'total_connected', value => 'connected_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-tonegeneration', set => { + key_values => [ { name => 'tonegeneration' } ], + output_template => 'ToneGeneration : %s', + perfdatas => [ + { label => 'total_tonegeneration', value => 'tonegeneration_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-releasing', set => { + key_values => [ { name => 'releasing' } ], + output_template => 'Releasing : %s', + perfdatas => [ + { label => 'total_releasing', value => 'releasing_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-aborting', set => { + key_values => [ { name => 'aborting' } ], + output_template => 'Aborting : %s', + perfdatas => [ + { label => 'total_aborting', value => 'aborting_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-resetting', set => { + key_values => [ { name => 'resetting' } ], + output_template => 'Resetting : %s', + perfdatas => [ + { label => 'total_resetting', value => 'resetting_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-up', set => { + key_values => [ { name => 'up' } ], + output_template => 'Up : %s', + perfdatas => [ + { label => 'total_up', value => 'up_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'total-down', set => { + key_values => [ { name => 'down' } ], + output_template => 'Down : %s', + perfdatas => [ + { label => 'total_down', value => 'down_absolute', template => '%s', + min => 0 }, + ], + } + }, + ]; + + $self->{maps_counters}->{channels} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'opstatus' }, { name => 'admstatus' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + { label => 'seconds', set => { + key_values => [ { name => 'seconds' }, { name => 'display' } ], + output_template => 'lifetime : %s seconds', + perfdatas => [ + { label => 'seconds', value => 'seconds_absolute', template => '%s', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{admstatus} eq "enable" and %{opstatus} !~ /up|idle|connected/' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_channels_output { + my ($self, %options) = @_; + + return "Channels '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %map_admin_status = ( + 0 => 'down', + 1 => 'up', +); +my %map_operation_status = ( + 0 => 'outOfService', + 1 => 'idle', + 2 => 'pending', + 3 => 'waitingForRoute', + 4 => 'actionList', + 5 => 'waitingForDigits', + 6 => 'remoteSetUp', + 7 => 'peerSetUp', + 8 => 'alerting', + 9 => 'inBandInfo', + 10 => 'connected', + 11 => 'toneGeneration', + 12 => 'releasing', + 13 => 'aborting', + 14 => 'resetting', + 15 => 'up', + 16 => 'down', +); + +my $mapping = { + uxChAdminState => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.5', map => \%map_admin_status }, + uxChOperState => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.6', map => \%map_operation_status }, + uxChInUseSeconds => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.7' }, +}; + +my $oid_uxChannelStatusEntry = '.1.3.6.1.4.1.177.15.1.5.6.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{channels} = {}; + $self->{global} = { total => 0, outofservice => 0, idle => 0, + pending => 0, waitingforroute => 0, actionlist => 0, + waitingfordigits => 0, remotesetup => 0, peersetup => 0, + alerting => 0, inbandinfo => 0, connected => 0, tonegeneration => 0, + releasing => 0, aborting => 0, resetting => 0, up => 0, down => 0 }; + + $self->{results} = $options{snmp}->get_table(oid => $oid_uxChannelStatusEntry, + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}}) { + next if($oid !~ /^$mapping->{uxChOperState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + $self->{global}->{total}++; + my $oper_state = lc($result->{uxChOperState}); + + $self->{global}->{$oper_state}++; + $self->{channels}->{$instance} = {display => $instance, + opstatus => $result->{uxChOperState}, + admstatus => $result->{uxChAdminState}, + seconds => $result->{uxChInUseSeconds}}; + } + +} + +1; + +__END__ + +=head1 MODE + +Check Channels on Sonus + +=over 8 + +=item B<--filter-counters> + +Only display some counters (Can be 'channels' or 'global'). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{admstatus}, %{opstatus}, %{display} + +=item B<--critical-status> + +Set critical threshold for status. +Can used special variables like: %{admstatus}, %{opstatus}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'total', 'total-outofservice', 'total-disassociating', 'total-idle', 'total-pending', 'total-waitingforroute', 'total-actionlist', 'total-waitingfordigits', 'total-remotesetup', 'total-peersetup', 'total-alerting', 'total-inbandinfo', 'total-connected', 'total-tonegeneration', 'total-releasing', 'total-aborting', 'total-resetting', 'total-up', 'total-down', 'seconds' + +=item B<--critical-*> + +Threshold critical. +Can be: 'total', 'total', 'total-outofservice', 'total-disassociating', 'total-idle', 'total-pending', 'total-waitingforroute', 'total-actionlist', 'total-waitingfordigits', 'total-remotesetup', 'total-peersetup', 'total-alerting', 'total-inbandinfo', 'total-connected', 'total-tonegeneration', 'total-releasing', 'total-aborting', 'total-resetting', 'total-up', 'total-down', 'seconds' + +=back + +=cut diff --git a/centreon-plugins/network/sonus/sbc/snmp/dspstats.pm b/centreon-plugins/network/sonus/sbc/snmp/dspstats.pm new file mode 100644 index 000000000..e59f37440 --- /dev/null +++ b/centreon-plugins/network/sonus/sbc/snmp/dspstats.pm @@ -0,0 +1,209 @@ +# +# Copyright 2016 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::sonus::sbc::snmp::mode::dspstats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_state_output { + my ($self, %options) = @_; + + my $msg = sprintf("state is '%s'", $self->{result_values}->{state}); + return $msg; +} + +sub custom_state_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'dsp', type => 1, cb_prefix_output => 'prefix_dsp_output', message_multiple => 'All DSP stats and states are OK' }, + ]; + $self->{maps_counters}->{dsp} = [ + { label => 'state', threshold => 0, set => { + key_values => [ { name => 'state' }, { name => 'display' } ], + closure_custom_calc => \&custom_state_calc, + closure_custom_output => \&custom_state_output, + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&custom_threshold_output, + } + }, + { label => 'cpu', set => { + key_values => [ { name => 'cpu' }, { name => 'display' } ], + output_template => 'CPU Usage: %s', + perfdatas => [ + { label => 'cpu', value => 'cpu_absolute', template => '%d', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'channels', set => { + key_values => [ { name => 'channels' }, { name => 'display' } ], + output_template => 'Active Channels: %s', + perfdatas => [ + { label => 'channels', value => 'channels_absolute', template => '%d', + min => 0, unit => 'channels', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_dsp_output { + my ($self, %options) = @_; + + return "DSP '" . $options{instance_value}->{display} . "' "; +} + +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-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} eq "down"' }, + }); + return $self; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(); + $instance_mode = $self; +} + +my %map_status = ( + 0 => 'down', + 1 => 'up', +); + +my $mapping = { + uxDSPIsPresent => { oid => '.1.3.6.1.4.1.177.15.1.6.1.3' }, + uxDSPCPUUsage => { oid => '.1.3.6.1.4.1.177.15.1.6.1.4' }, + uxDSPChannelsInUse => { oid => '.1.3.6.1.4.1.177.15.1.6.1.5' }, + uxDSPServiceStatus => { oid => '.1.3.6.1.4.1.177.15.1.6.1.6', map => \%map_status }, +}; + +my $oid_uxDSPResourceTable = '.1.3.6.1.4.1.177.15.1.6.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + + $self->{results} = $options{snmp}->get_table(oid => $oid_uxDSPResourceTable, + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}}) { + next if($oid !~ /^$mapping->{uxDSPServiceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + next if ($result->{uxDSPIsPresent} eq '0'); + + $self->{dsp}->{$instance} = { state => $result->{uxDSPServiceStatus}, + cpu => $result->{uxDSPCPUUsage}, + channels => $result->{uxDSPChannelsInUse}, + display => $instance }; + } +} + +1; + +__END__ + +=head1 MODE + +Check Digital Signal Processing statistics + +=over 8 + +=item B<--warning-*> + +Warning on counters. Can be ('cpu', 'channels') + +=item B<--critical-*> + +Warning on counters. Can be ('cpu', 'channels') + +=item B<--warning-status> + +Set warning threshold for status. Use "%{state}" as a special variable. +Useful to be notified when tunnel is up "%{state} eq 'up'" + +=item B<--critical-status> + +Set critical threshold for status. Use "%{state}" as a special variable. +Useful to be notified when tunnel is up "%{state} eq 'up'" + +=back + +=cut diff --git a/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm b/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm index cf72d05d5..ece6d59e8 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nodeCPULoad = '.1.3.6.1.4.1.1369.6.1.1.4.0'; diff --git a/centreon-plugins/network/stonesoft/snmp/mode/clusterstate.pm b/centreon-plugins/network/stonesoft/snmp/mode/clusterstate.pm index 848d14966..2a3e1c737 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/clusterstate.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/clusterstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nodeMemberId = '.1.3.6.1.4.1.1369.6.1.1.2.0'; diff --git a/centreon-plugins/network/stonesoft/snmp/mode/connections.pm b/centreon-plugins/network/stonesoft/snmp/mode/connections.pm index 938fc7bc4..a9ddad144 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/connections.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -97,7 +97,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/stonesoft/snmp/mode/cpu.pm b/centreon-plugins/network/stonesoft/snmp/mode/cpu.pm index 801007c8c..f54223e41 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/cpu.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cputable = '.1.3.6.1.4.1.1369.5.2.1.11.1.1.3'; diff --git a/centreon-plugins/network/stonesoft/snmp/mode/droppedpackets.pm b/centreon-plugins/network/stonesoft/snmp/mode/droppedpackets.pm index 7d5672bd3..2097cc432 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/droppedpackets.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/droppedpackets.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -61,7 +61,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/stonesoft/snmp/mode/memory.pm b/centreon-plugins/network/stonesoft/snmp/mode/memory.pm index 03556e12d..383868e45 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/memory.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -78,7 +78,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_fwMemBytesTotal = '.1.3.6.1.4.1.1369.5.2.1.11.2.4.0'; diff --git a/centreon-plugins/network/stonesoft/snmp/mode/rejectedpackets.pm b/centreon-plugins/network/stonesoft/snmp/mode/rejectedpackets.pm index 5373f63ef..b3e40a24c 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/rejectedpackets.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/rejectedpackets.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -61,7 +61,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/network/stonesoft/snmp/mode/storage.pm b/centreon-plugins/network/stonesoft/snmp/mode/storage.pm index be5d120b0..7c69f6ecb 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/storage.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -67,7 +67,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/stonesoft/snmp/plugin.pm b/centreon-plugins/network/stonesoft/snmp/plugin.pm index 7a1458a7f..f59ecd0e7 100644 --- a/centreon-plugins/network/stonesoft/snmp/plugin.pm +++ b/centreon-plugins/network/stonesoft/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/network/ucopia/wlc/snmp/mode/temperature.pm b/centreon-plugins/network/ucopia/wlc/snmp/mode/temperature.pm new file mode 100644 index 000000000..56c704437 --- /dev/null +++ b/centreon-plugins/network/ucopia/wlc/snmp/mode/temperature.pm @@ -0,0 +1,111 @@ +# +# Copyright 2016 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::ucopia::wlc::snmp::mode::temperature; + +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) = @_; + + my $oid_cpuTemperature = '.1.3.6.1.4.1.31218.3.3.0'; + my $oid_diskTemperature = '.1.3.6.1.4.1.31218.3.4.0'; + + my $result = $options{snmp}->get_leef(oids => [$oid_cpuTemperature, $oid_diskTemperature], nothing_quit => 1); + + if ($result->{$oid_cpuTemperature} != 0) { + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_cpuTemperature}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU Temp: %dC", $result->{$oid_cpuTemperature})); + $self->{output}->perfdata_add(value => $result->{$oid_cpuTemperature}, + label => 'cpu_temp', unit => 'C', + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0); + } + + if ($result->{$oid_diskTemperature} != 0) { + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_diskTemperature}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("DISK Temp: %dC", $result->{$oid_diskTemperature})); + $self->{output}->perfdata_add(value => $result->{$oid_diskTemperature}, + label => 'disk_temp', unit => 'C', + 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 temperatures. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut + diff --git a/centreon-plugins/network/ucopia/wlc/snmp/mode/users.pm b/centreon-plugins/network/ucopia/wlc/snmp/mode/users.pm new file mode 100644 index 000000000..51c0b0d50 --- /dev/null +++ b/centreon-plugins/network/ucopia/wlc/snmp/mode/users.pm @@ -0,0 +1,100 @@ +# +# Copyright 2016 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::ucopia::wlc::snmp::mode::users; + +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) = @_; + + my $oid_totalConnectedUsers = '.1.3.6.1.4.1.31218.3.1.0'; + my $oid_licenceUsers = '.1.3.6.1.4.1.31218.3.5.0'; + + my $result = $options{snmp}->get_leef(oids => [$oid_totalConnectedUsers, $oid_licenceUsers], nothing_quit => 1); + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_totalConnectedUsers}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + $result->{$oid_licenceUsers} = undef if ($result->{$oid_licenceUsers} == 0); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("'%d' connected users (Available licence: %s)", + $result->{$oid_totalConnectedUsers}, + defined($result->{$oid_licenceUsers}) ? $result->{$oid_licenceUsers} : '-')); + $self->{output}->perfdata_add(value => $result->{$oid_totalConnectedUsers}, label => 'users', + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => $result->{$oid_licenceUsers}); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check connected users. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut + diff --git a/centreon-plugins/network/ucopia/wlc/snmp/plugin.pm b/centreon-plugins/network/ucopia/wlc/snmp/plugin.pm new file mode 100644 index 000000000..ad4cb5a38 --- /dev/null +++ b/centreon-plugins/network/ucopia/wlc/snmp/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2016 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::ucopia::wlc::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}} = ( + 'temperature' => 'network::ucopia::wlc::snmp::mode::temperature', + 'users' => 'network::ucopia::wlc::snmp::mode::users', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Ucopia Wlc in SNMP. + +=cut diff --git a/centreon-plugins/notification/slack/mode/alert.pm b/centreon-plugins/notification/slack/mode/alert.pm new file mode 100644 index 000000000..6b5a2fe14 --- /dev/null +++ b/centreon-plugins/notification/slack/mode/alert.pm @@ -0,0 +1,343 @@ +# +# Copyright 2016 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 notification::slack::mode::alert; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::http; +use JSON; + +my %slack_color_host = ( + up => 'good', + down => 'danger', + unreachable => 'danger', +); +my %slack_color_service = ( + ok => 'good', + warning => 'warning', + critical => 'danger', + unknown => '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 => + { + "slack-url:s" => { name => 'slack_url' }, + "slack-channel:s" => { name => 'slack_channel' }, + "slack-username:s" => { name => 'slack_username' }, + "host-name:s" => { name => 'host_name' }, + "host-state:s" => { name => 'host_state' }, + "host-output:s" => { name => 'host_output' }, + "service-description:s" => { name => 'service_description' }, + "service-state:s" => { name => 'service_state' }, + "service-output:s" => { name => 'service_output' }, + "slack-color:s" => { name => 'slack_color' }, + "slack-emoji:s" => { name => 'slack_emoji', }, + "graph-url:s" => { name => 'graph_url' }, + "priority:s" => { name => 'priority' }, + "zone:s" => { name => 'zone' }, + "link-url:s" => { name => 'link_url' }, + "centreon-url:s" => { name => 'centreon_url' }, + "centreon-token:s" => { name => 'centreon_token' }, + + "credentials" => { name => 'credentials' }, + "ntlm" => { name => 'ntlm' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "proxyurl:s" => { name => 'proxyurl' }, + "proxypac:s" => { name => 'proxypac' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{payload_attachment} = { fields => [] }; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (!defined($self->{option_results}->{slack_url}) || $self->{option_results}->{slack_url} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --slack-url option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{slack_channel}) || $self->{option_results}->{slack_channel} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --slack-channel option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{host_name}) || $self->{option_results}->{host_name} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --host-name option."); + $self->{output}->option_exit(); + } + + foreach (('graph_url', 'link_url')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{option_results}->{$1}/g; + eval "\$self->{option_results}->{\$_} = \"$self->{option_results}->{$_}\""; + } + } + + $self->{http}->set_options(%{$self->{option_results}}, hostname => 'dummy'); +} + +sub format_payload { + my ($self, %options) = @_; + + my $json = JSON->new; + my $payload = { channel => $self->{option_results}->{slack_channel}, + attachments => [ $self->{payload_attachment} ] }; + if (defined($self->{option_results}->{slack_emoji}) && $self->{option_results}->{slack_emoji} ne '') { + $payload->{icon_emoji} = $self->{option_results}->{slack_emoji}; + } + if (defined($self->{option_results}->{slack_username}) && $self->{option_results}->{slack_username} ne '') { + $payload->{username} = $self->{option_results}->{slack_username}; + } + eval { + $self->{payload_str} = $json->encode($payload); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->option_exit(); + } +} + +sub host_message { + my ($self, %options) = @_; + + my $url_host = $self->{option_results}->{host_name}; + if (defined($self->{option_results}->{link_url}) && $self->{option_results}->{link_url} ne '') { + $url_host = '<' . $self->{option_results}->{link_url} . '|' . $self->{option_results}->{host_name} . '>'; + $self->{payload_attachment}->{fallback} = "Host " . $self->{option_results}->{host_name}; + } + $self->{payload_attachment}->{text} = "Host " . $url_host; + + if (defined($self->{option_results}->{host_state}) && $self->{option_results}->{host_state} ne '') { + $self->{payload_attachment}->{text} .= ' is ' . $self->{option_results}->{host_state}; + $self->{payload_attachment}->{fallback} .= ' is ' . $self->{option_results}->{host_state}; + if (defined($slack_color_host{lc($self->{option_results}->{host_state})})) { + $self->{payload_attachment}->{color} = $slack_color_host{lc($self->{option_results}->{host_state})}; + } + } else { + $self->{payload_attachment}->{text} .= ' alert'; + $self->{payload_attachment}->{fallback} .= ' alert'; + } + + if (defined($self->{option_results}->{link_url}) && $self->{option_results}->{link_url} ne '') { + $self->{payload_attachment}->{fallback} .= ' : ' . $self->{option_results}->{link_url}; + } + + if (defined($self->{option_results}->{host_output}) && $self->{option_results}->{host_output} ne '') { + push @{$self->{payload_attachment}->{fields}}, { title => 'output', value => $self->{option_results}->{host_output} }; + } +} + +sub service_message { + my ($self, %options) = @_; + + my $url_service = $self->{option_results}->{service_description}; + if (defined($self->{option_results}->{link_url}) && $self->{option_results}->{link_url} ne '') { + $url_service = '<' . $self->{option_results}->{link_url} . '|' . $self->{option_results}->{host_name} . '/' . $self->{option_results}->{service_description} . '>'; + $self->{payload_attachment}->{fallback} = "Service " . $self->{option_results}->{host_name} . '/' . $self->{option_results}->{service_description}; + } + $self->{payload_attachment}->{text} = "Service " . $url_service; + + if (defined($self->{option_results}->{service_state}) && $self->{option_results}->{service_state} ne '') { + $self->{payload_attachment}->{text} .= ' is ' . $self->{option_results}->{service_state}; + $self->{payload_attachment}->{fallback} .= ' is ' . $self->{option_results}->{service_state}; + if (defined($slack_color_service{lc($self->{option_results}->{service_state})})) { + $self->{payload_attachment}->{color} = $slack_color_service{lc($self->{option_results}->{service_state})}; + } + } else { + $self->{payload_attachment}->{text} .= ' alert'; + $self->{payload_attachment}->{fallback} .= ' alert'; + } + + if (defined($self->{option_results}->{link_url}) && $self->{option_results}->{link_url} ne '') { + $self->{payload_attachment}->{fallback} .= ' : ' . $self->{option_results}->{link_url}; + } + + if (defined($self->{option_results}->{service_output}) && $self->{option_results}->{service_output} ne '') { + push @{$self->{payload_attachment}->{fields}}, { title => 'output', value => $self->{option_results}->{service_output} }; + } + + if (defined($self->{option_results}->{graph_url}) && $self->{option_results}->{graph_url} ne '') { + $self->{payload_attachment}->{image_url} = $self->{option_results}->{graph_url}; + } +} + +sub set_payload { + my ($self, %options) = @_; + + if (!defined($self->{option_results}->{service_description}) && $self->{option_results}->{service_description} ne '') { + $self->host_message(); + } else { + $self->service_message(); + } + + if (defined($self->{option_results}->{slack_color}) && $self->{option_results}->{slack_color} ne '') { + $self->{payload_attachment}->{color} = $self->{option_results}->{slack_color}; + } + + if (defined($self->{option_results}->{priority}) && $self->{option_results}->{priority} ne '') { + push @{$self->{payload_attachment}->{fields}}, { title => 'Priority', value => $self->{option_results}->{priority}, short => 'true' }; + } + if (defined($self->{option_results}->{zone}) && $self->{option_results}->{zone} ne '') { + push @{$self->{payload_attachment}->{fields}}, { title => 'Zone', value => $self->{option_results}->{zone}, short => 'true' }; + } +} + +sub run { + my ($self, %options) = @_; + + $self->set_payload(); + $self->format_payload(); + my $response = $self->{http}->request(full_url => $self->{option_results}->{slack_url}, + method => 'POST', + post_param => ['payload=' . $self->{payload_str}]); + + $self->{output}->output_add(short_msg => 'slack response: ' . $response); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Send slack alerts. + +Example for a host: +centreon_plugins.pl --plugin=notification::slack::plugin --mode=alert --slack-url='https://hooks.slack.com/services/T0A754E2V/B0E0CEL4B/81V8kCJusL7kafDSdsd' --slack-channel='#testchannel' --slack-username='bot' --slack-emoji=':ghost:' --host-name='srvi-clus-win' --host-state='DOWN' --host-output='test output' --priority='High' --zone='Production' --centreon-url='https://centreon.test.com/centreon/' --link-url='%{centreon_url}/main.php?p=20202&o=svc&host_search=%{host_name}' + +Example for a service: +centreon_plugins.pl --plugin=notification::slack::plugin --mode=alert --slack-url='https://hooks.slack.com/services/T0A754E2V/B0E0CEL4B/81V8kCJusL7kafDSdsd' --slack-channel='#tmptestqga' --slack-username='bot' --slack-emoji=':ghost:' --host-name='srvi-clus-win' --service-description='Ping' --service-state='WARNING' --service-output='CRITICAL - 10.50.1.78: rta nan, lost 100%' --priority='High' --zone='Production' --centreon-url='https://ces.merethis.net/centreon/' --link-url='%{centreon_url}/main.php?p=20201&o=svc&host_search=%{host_name}&svc_search=%{service_description}' --centreon-token='LxTQxFbLU6' --graph-url='%{centreon_url}/include/views/graphs/generateGraphs/generateImage.php?username=myuser&token=%{centreon_token}&hostname=%{host_name}&service=%{service_description}' + +=over 8 + +=item B<--slack-url> + +Specify slack url (Required). + +=item B<--slack-channel> + +Specify slack channel (Required). + +=item B<--slack-username> + +Specify slack username. + +=item B<--host-name> + +Specify host server name for the alert (Required). + +=item B<--host-state> + +Specify host server state for the alert. + +=item B<--host-output> + +Specify host server output message for the alert. + +=item B<--service-description> + +Specify service description name for the alert. + +=item B<--service-state> + +Specify service state for the alert. + +=item B<--service-output> + +Specify service output message for the alert. + +=item B<--slack-color> + +Specify slack color (According state option, color will be choosed). + +=item B<--slack-emoji> + +Specify slack emoji. + +=item B<--priority> + +Specify the priority message. + +=item B<--zone> + +Specify the zone message. + +=item B<--centreon-url> + +Specify the centreon url macro (could be used in link-url and graph-url option). + +=item B<--centreon-token> + +Specify the centreon token for autologin macro (could be used in link-url and graph-url option). + +=item B<--graph-url> + +Specify the graph url (Example: %{centreon_url}/include/views/graphs/generateGraphs/generateImage.php?username=myuser&token=%{centreon_token}&hostname=%{host_name}&service=%{service_description}). + +=item B<--link-url> + +Specify the link url (Example: %{centreon_url}/main.php?p=20201&o=svc&host_search=%{host_name}&svc_search=%{service_description}) + +=item B<--proxyurl> + +Proxy URL + +=item B<--proxypac> + +Proxy pac file (can be an url or local file) + +=item B<--credentials> + +Specify this option if you access webpage over basic authentification + +=item B<--ntlm> + +Specify this option if you access webpage over ntlm authentification (Use with --credentials option) + +=item B<--username> + +Specify username for basic authentification (Mandatory if --credentials is specidied) + +=item B<--password> + +Specify password for basic authentification (Mandatory if --credentials is specidied) + +=item B<--timeout> + +Threshold for HTTP timeout (Default: 5) + +=back + +=cut diff --git a/centreon-plugins/notification/slack/plugin.pm b/centreon-plugins/notification/slack/plugin.pm new file mode 100644 index 000000000..b221d5af5 --- /dev/null +++ b/centreon-plugins/notification/slack/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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 notification::slack::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'alert' => 'notification::slack::mode::alert', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Send Slack notifications. + +=cut diff --git a/centreon-plugins/os/aix/local/mode/errpt.pm b/centreon-plugins/os/aix/local/mode/errpt.pm index 12b4e7be6..90bec32e8 100644 --- a/centreon-plugins/os/aix/local/mode/errpt.pm +++ b/centreon-plugins/os/aix/local/mode/errpt.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/aix/local/mode/liststorages.pm b/centreon-plugins/os/aix/local/mode/liststorages.pm index b277753c1..111e2ccde 100644 --- a/centreon-plugins/os/aix/local/mode/liststorages.pm +++ b/centreon-plugins/os/aix/local/mode/liststorages.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/aix/local/mode/lvsync.pm b/centreon-plugins/os/aix/local/mode/lvsync.pm index 38e258e7a..73e10b9d4 100644 --- a/centreon-plugins/os/aix/local/mode/lvsync.pm +++ b/centreon-plugins/os/aix/local/mode/lvsync.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/aix/local/mode/storage.pm b/centreon-plugins/os/aix/local/mode/storage.pm index d0ead0e34..5b28ee127 100644 --- a/centreon-plugins/os/aix/local/mode/storage.pm +++ b/centreon-plugins/os/aix/local/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/aix/local/plugin.pm b/centreon-plugins/os/aix/local/plugin.pm index be2b54963..696b7963f 100644 --- a/centreon-plugins/os/aix/local/plugin.pm +++ b/centreon-plugins/os/aix/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/aix/snmp/mode/swap.pm b/centreon-plugins/os/aix/snmp/mode/swap.pm index 6282e41ea..df11c1eaf 100644 --- a/centreon-plugins/os/aix/snmp/mode/swap.pm +++ b/centreon-plugins/os/aix/snmp/mode/swap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -57,7 +57,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # sysDescr values: diff --git a/centreon-plugins/os/aix/snmp/plugin.pm b/centreon-plugins/os/aix/snmp/plugin.pm index a1895b17d..fd4095883 100644 --- a/centreon-plugins/os/aix/snmp/plugin.pm +++ b/centreon-plugins/os/aix/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/freebsd/snmp/mode/memory.pm b/centreon-plugins/os/freebsd/snmp/mode/memory.pm new file mode 100644 index 000000000..06c503ad0 --- /dev/null +++ b/centreon-plugins/os/freebsd/snmp/mode/memory.pm @@ -0,0 +1,202 @@ +# +# Copyright 2016 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 os::freebsd::snmp::mode::memory; + +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' }, + "swap" => { name => 'check_swap' }, + "warning-swap:s" => { name => 'warning_swap' }, + "critical-swap:s" => { name => 'critical_swap' }, + "no-swap:s" => { name => 'no_swap' }, + }); + $self->{no_swap} = '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(); + } + if (defined($self->{option_results}->{check_swap})) { + if (($self->{perfdata}->threshold_validate(label => 'warning-swap', value => $self->{option_results}->{warning_swap})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning-swap threshold '" . $self->{option_results}->{warning_swap} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-swap', value => $self->{option_results}->{critical_swap})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical-swap threshold '" . $self->{option_results}->{critical_swap} . "'."); + $self->{output}->option_exit(); + } + if (defined($self->{option_results}->{no_swap}) && $self->{option_results}->{no_swap} ne '') { + if ($self->{output}->is_litteral_status(status => $self->{option_results}->{no_swap}) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong --no-swap status '" . $self->{option_results}->{no_swap} . "'."); + $self->{output}->option_exit(); + } + $self->{no_swap} = $self->{option_results}->{no_swap}; + } + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + # with bsnmpd-ucd 0.4.1 + my $oid_memTotalReal = '.1.3.6.1.4.1.2021.4.5.0'; # hw.physmem + my $oid_memAvailReal = '.1.3.6.1.4.1.2021.4.6.0'; # vm.stats.vm.v_free_count + my $oid_memShared = '.1.3.6.1.4.1.2021.4.13.0'; # not needed + my $oid_memBuffer = '.1.3.6.1.4.1.2021.4.14.0'; # vfs.bufspace (not needed) + my $oid_memCached = '.1.3.6.1.4.1.2021.4.15.0'; # vm.stats.vm.v_cache_count + vm.stats.vm.v_inactive_count + my $oid_memTotalSwap = '.1.3.6.1.4.1.2021.4.3.0'; # KB + my $oid_memAvailSwap = '.1.3.6.1.4.1.2021.4.4.0'; # KB + + my $oids = [$oid_memTotalReal, $oid_memAvailReal, + $oid_memShared, $oid_memBuffer, $oid_memCached]; + if (defined($self->{option_results}->{check_swap})) { + push @$oids, ($oid_memTotalSwap, $oid_memAvailSwap); + } + + my $result = $self->{snmp}->get_leef(oids => $oids, + nothing_quit => 1); + + my $cached_used = $result->{$oid_memCached} * 1024; + my $physical_used = ($result->{$oid_memTotalReal} * 1024) - ($result->{$oid_memAvailReal} * 1024); + # mem_available = total - mem_inactive - mem_cache - mem_free + # Maybe it's will be better to have have total with: total = 'active' + 'wired' + 'cache' + 'inactive' + 'free' + # But i can't have that with values from bsnmpd-ucd + my $nobuf_used = $physical_used - $cached_used; + + my $total_size = $result->{$oid_memTotalReal} * 1024; + + my $prct_used = $nobuf_used * 100 / $total_size; + my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); + my ($nobuf_value, $nobuf_unit) = $self->{perfdata}->change_bytes(value => $nobuf_used); + my ($cached_value, $cached_unit) = $self->{perfdata}->change_bytes(value => $cached_used); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Ram Total: %s, Used (-cache): %s (%.2f%%), Cached: %s", + $total_value . " " . $total_unit, + $nobuf_value . " " . $nobuf_unit, $prct_used, + $cached_value . " " . $cached_unit)); + + $self->{output}->perfdata_add(label => "cached", unit => 'B', + value => $cached_used, + min => 0); + $self->{output}->perfdata_add(label => "used", unit => 'B', + value => $nobuf_used, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), + min => 0, max => $total_size); + + if (defined($self->{option_results}->{check_swap})) { + if ($result->{$oid_memTotalSwap} == 0) { + $self->{output}->output_add(severity => $self->{no_swap}, + short_msg => 'No active swap.'); + $self->{output}->display(); + $self->{output}->exit(); + } + + $total_size = $result->{$oid_memTotalSwap} * 1024; + my $swap_used = ($result->{$oid_memTotalSwap} - $result->{$oid_memAvailSwap}) * 1024; + + $prct_used = $swap_used * 100 / $total_size; + $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical-swap', 'exit_litteral' => 'critical' }, { label => 'warning-swap', exit_litteral => 'warning' } ]); + + my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); + my ($swap_used_value, $swap_used_unit) = $self->{perfdata}->change_bytes(value => $swap_used); + my ($swap_free_value, $swap_free_unit) = $self->{perfdata}->change_bytes(value => ($total_size - $swap_used)); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Swap Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_value . " " . $total_unit, + $swap_used_value . " " . $swap_used_unit, $prct_used, + $swap_free_value . " " . $swap_free_unit, (100 - $prct_used))); + + $self->{output}->perfdata_add(label => "swap", unit => 'B', + value => $swap_used, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-swap', total => $total_size, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-swap', total => $total_size, cast_int => 1), + min => 0, max => $total_size); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check physical memory (UCD-SNMP-MIB). + +=over 8 + +=item B<--warning> + +Threshold warning in percent. + +=item B<--critical> + +Threshold critical in percent. + +=item B<--swap> + +Check swap also. + +=item B<--warning-swap> + +Threshold warning in percent. + +=item B<--critical-swap> + +Threshold critical in percent. + +=item B<--no-swap> + +Threshold if no active swap (default: 'critical'). + +=back + +=cut diff --git a/centreon-plugins/os/freebsd/snmp/plugin.pm b/centreon-plugins/os/freebsd/snmp/plugin.pm index 1ec8e033d..bc5fe1e80 100644 --- a/centreon-plugins/os/freebsd/snmp/plugin.pm +++ b/centreon-plugins/os/freebsd/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( @@ -42,7 +41,7 @@ sub new { 'list-diskspath' => 'snmp_standard::mode::listdiskspath', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'list-storages' => 'snmp_standard::mode::liststorages', - 'memory' => 'snmp_standard::mode::memory', + 'memory' => 'os::freebsd::snmp::mode::memory', 'processcount' => 'snmp_standard::mode::processcount', 'storage' => 'snmp_standard::mode::storage', 'swap' => 'snmp_standard::mode::swap', diff --git a/centreon-plugins/os/hpux/snmp/mode/cpu.pm b/centreon-plugins/os/hpux/snmp/mode/cpu.pm new file mode 100644 index 000000000..baba0bc0b --- /dev/null +++ b/centreon-plugins/os/hpux/snmp/mode/cpu.pm @@ -0,0 +1,159 @@ +# +# Copyright 2016 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 os::hpux::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_output' }, + ]; + $self->{maps_counters}->{global} = [ + { label => 'user', set => { + key_values => [ { name => 'total', diff => 1 }, { name => 'user', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'user' }, + output_template => 'User %.2f %%', output_use => 'user_prct', threshold_use => 'user_prct', + perfdatas => [ + { label => 'user', value => 'user_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'sys', set => { + key_values => [ { name => 'total', diff => 1 }, { name => 'sys', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'sys' }, + output_template => 'System %.2f %%', output_use => 'sys_prct', threshold_use => 'sys_prct', + perfdatas => [ + { label => 'sys', value => 'sys_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'nice', set => { + key_values => [ { name => 'total', diff => 1 }, { name => 'nice', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'nice' }, + output_template => 'Nice %.2f %%', output_use => 'nice_prct', threshold_use => 'nice_prct', + perfdatas => [ + { label => 'nice', value => 'nice_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => 'idle', set => { + key_values => [ { name => 'total', diff => 1 }, { name => 'idle', diff => 1 } ], + closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'idle' }, + output_template => 'Idle %.2f %%', output_use => 'idle_prct', threshold_use => 'idle_prct', + perfdatas => [ + { label => 'idle', value => 'idle_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + } + }, + ]; +} + +sub custom_data_calc { + my ($self, %options) = @_; + + my $label = $options{extra_options}->{label_ref}; + my $delta_value = $options{new_datas}->{$self->{instance} . '_' . $label} - $options{old_datas}->{$self->{instance} . '_' . $label}; + my $delta_total = $options{new_datas}->{$self->{instance} . '_total'} - $options{old_datas}->{$self->{instance} . '_total'}; + + $self->{result_values}->{$label . '_prct'} = 0; + if ($delta_total > 0) { + $self->{result_values}->{$label . '_prct'} = $delta_value * 100 / $delta_total; + } + return 0; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "CPU Usage : "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-counters:s" => { name => 'filter_counters' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "hpux_" . $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')); + + my $oid_computerSystemUserCPU = '.1.3.6.1.4.1.11.2.3.1.1.13.0'; + my $oid_computerSystemSysCPU = '.1.3.6.1.4.1.11.2.3.1.1.14.0'; + my $oid_computerSystemIdleCPU = '.1.3.6.1.4.1.11.2.3.1.1.15.0'; + my $oid_computerSystemNiceCPU = '.1.3.6.1.4.1.11.2.3.1.1.16.0'; + + my $result = $options{snmp}->get_leef(oids => [$oid_computerSystemUserCPU, $oid_computerSystemSysCPU, + $oid_computerSystemIdleCPU, $oid_computerSystemNiceCPU], + nothing_quit => 1); + $self->{global} = { + total => $result->{$oid_computerSystemUserCPU} + $result->{$oid_computerSystemSysCPU} + $result->{$oid_computerSystemIdleCPU} + $result->{$oid_computerSystemNiceCPU}, + sys => $result->{$oid_computerSystemSysCPU}, + user => $result->{$oid_computerSystemUserCPU}, + idle => $result->{$oid_computerSystemIdleCPU}, + nice => $result->{$oid_computerSystemNiceCPU}, + }; +} + +1; + +__END__ + +=head1 MODE + +Check system CPUs. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example : --filter-counters='^idle$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'user', 'sys', 'idle', 'nice'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'user', 'sys', 'idle', 'nice'. + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/os/hpux/snmp/mode/load.pm b/centreon-plugins/os/hpux/snmp/mode/load.pm new file mode 100644 index 000000000..d5c6bde31 --- /dev/null +++ b/centreon-plugins/os/hpux/snmp/mode/load.pm @@ -0,0 +1,139 @@ +# +# Copyright 2016 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 os::hpux::snmp::mode::load; + +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', default => '' }, + "critical:s" => { name => 'critical', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + ($self->{warn1}, $self->{warn5}, $self->{warn15}) = split /,/, $self->{option_results}->{warning}; + ($self->{crit1}, $self->{crit5}, $self->{crit15}) = split /,/, $self->{option_results}->{critical}; + + if (($self->{perfdata}->threshold_validate(label => 'warn1', value => $self->{warn1})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warn5', value => $self->{warn5})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warn15', value => $self->{warn15})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (15min) threshold '" . $self->{warn15} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit1', value => $self->{crit1})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit5', value => $self->{crit5})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit15', value => $self->{crit15})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (15min) threshold '" . $self->{crit15} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + + my $oid_computerSystemAvgJobs1 = '.1.3.6.1.4.1.11.2.3.1.1.3.0'; + my $oid_computerSystemAvgJobs5 = '.1.3.6.1.4.1.11.2.3.1.1.4.0'; + my $oid_computerSystemAvgJobs15 = '.1.3.6.1.4.1.11.2.3.1.1.5.0'; + + my $result = $options{snmp}->get_leef(oids => [$oid_computerSystemAvgJobs1, $oid_computerSystemAvgJobs5, $oid_computerSystemAvgJobs15], nothing_quit => 1); + + my $cpu_load1 = $result->{$oid_computerSystemAvgJobs1} / 100; + my $cpu_load5 = $result->{$oid_computerSystemAvgJobs5} / 100; + my $cpu_load15 = $result->{$oid_computerSystemAvgJobs15} / 100; + + $self->{output}->perfdata_add(label => 'load1', + value => $cpu_load1, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1'), + min => 0); + $self->{output}->perfdata_add(label => 'load5', + value => $cpu_load5, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5'), + min => 0); + $self->{output}->perfdata_add(label => 'load15', + value => $cpu_load15, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn15'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit15'), + min => 0); + + my $exit1 = $self->{perfdata}->threshold_check(value => $cpu_load1, + threshold => [ { label => 'crit1', exit_litteral => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]); + my $exit2 = $self->{perfdata}->threshold_check(value => $cpu_load5, + threshold => [ { label => 'crit5', exit_litteral => 'critical' }, { label => 'warn5', exit_litteral => 'warning' } ]); + my $exit3 = $self->{perfdata}->threshold_check(value => $cpu_load15, + threshold => [ { label => 'crit15', exit_litteral => 'critical' }, { label => 'warn15', exit_litteral => 'warning' } ]); + my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Load average: %s, %s, %s", $cpu_load1, $cpu_load5, $cpu_load15)); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check system load-average. + +=over 8 + +=item B<--warning> + +Threshold warning (1min,5min,15min). + +=item B<--critical> + +Threshold critical (1min,5min,15min). + +=back + +=cut diff --git a/centreon-plugins/os/hpux/snmp/mode/memory.pm b/centreon-plugins/os/hpux/snmp/mode/memory.pm new file mode 100644 index 000000000..528204a29 --- /dev/null +++ b/centreon-plugins/os/hpux/snmp/mode/memory.pm @@ -0,0 +1,175 @@ +# +# Copyright 2016 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 os::hpux::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add(label => $self->{result_values}->{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->{result_values}->{label} . '-usage', exit_litteral => 'critical' }, { label => 'warning-' . $self->{result_values}->{label} . '-usage', 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}->{label} = $options{extra_options}->{label_ref}; + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_used'} + $options{new_datas}->{$self->{instance} . '_free'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $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 set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0, cb_prefix_output => 'prefix_memory_output' }, + { name => 'swap', type => 0, cb_prefix_output => 'prefix_swap_output' } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'physical-usage', set => { + key_values => [ { name => 'free' }, { name => 'used' } ], + closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'physical' }, + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + $self->{maps_counters}->{swap} = [ + { label => 'swap-usage', set => { + key_values => [ { name => 'free' }, { name => 'used' } ], + closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'swap' }, + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +sub prefix_memory_output { + my ($self, %options) = @_; + + return "Physical memory "; +} + +sub prefix_swap_output { + my ($self, %options) = @_; + + return "Swap memory "; +} + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_computerSystemFreeMemory = '.1.3.6.1.4.1.11.2.3.1.1.7.0'; # in KB + my $oid_computerSystemPhysMemory = '.1.3.6.1.4.1.11.2.3.1.1.8.0'; # in KB + my $oid_computerSystemSwapConfig = '.1.3.6.1.4.1.11.2.3.1.1.10.0'; # in KB + my $oid_computerSystemFreeSwap = '.1.3.6.1.4.1.11.2.3.1.1.12.0'; # in KB + + my $result = $options{snmp}->get_leef(oids => [$oid_computerSystemFreeMemory, $oid_computerSystemPhysMemory, + $oid_computerSystemSwapConfig, $oid_computerSystemFreeSwap], + nothing_quit => 1); + $self->{memory} = { + free => $result->{$oid_computerSystemFreeMemory} * 1024, + used => $result->{$oid_computerSystemPhysMemory} * 1024 - $result->{$oid_computerSystemFreeMemory} * 1024, + }; + $self->{swap} = { + free => $result->{$oid_computerSystemFreeSwap} * 1024, + used => $result->{$oid_computerSystemSwapConfig} * 1024 - $result->{$oid_computerSystemFreeSwap} * 1024, + }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example : --filter-counters='^physical-usage$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'physical-usage' (%), 'swap-usage' (%). + +=item B<--critical-*> + +Threshold critical. +Can be: 'physical-usage' (%), 'swap-usage' (%). + +=back + +=cut diff --git a/centreon-plugins/os/hpux/snmp/mode/process.pm b/centreon-plugins/os/hpux/snmp/mode/process.pm new file mode 100644 index 000000000..5d0ed09f1 --- /dev/null +++ b/centreon-plugins/os/hpux/snmp/mode/process.pm @@ -0,0 +1,199 @@ +# +# Copyright 2016 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 os::hpux::snmp::mode::process; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my %map_process_status = ( + 1 => 'sleep', + 2 => 'run', + 3 => 'stop', + 4 => 'zombie', + 5 => 'other', + 6 => 'idle', +); + +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', }, + "process-cmd:s" => { name => 'process_cmd', }, + "regexp-cmd" => { name => 'regexp_cmd', }, + "process-status:s" => { name => 'process_status', default => 'run' }, + }); + + 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(); + } +} + +my $oids = { + status => '.1.3.6.1.4.1.11.2.3.1.4.2.1.19', # processStatus + cmd => '.1.3.6.1.4.1.11.2.3.1.4.2.1.22', # processCmd +}; + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + my $oid2check_filter = 'status'; + # To have a better order + foreach (('cmd', 'status')) { + if (defined($self->{option_results}->{'process_' . $_}) && $self->{option_results}->{'process_' . $_} ne '') { + $oid2check_filter = $_; + last; + } + } + # Build other + my $mores_filters = {}; + my $more_oids = []; + foreach (keys %$oids) { + if ($_ ne $oid2check_filter && defined($self->{option_results}->{'process_' . $_}) && $self->{option_results}->{'process_' . $_} ne '') { + push @{$more_oids}, $oids->{$_}; + $mores_filters->{$_} = 1; + } + } + + my $oids_multiple_table = [ { oid => $oids->{$oid2check_filter} } ]; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => $oids_multiple_table); + my $result = $self->{results}->{$oids->{$oid2check_filter}}; + my $instances_keep = {}; + foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$result})) { + my $option_val = $self->{option_results}->{'process_' . $oid2check_filter}; + + if ($oid2check_filter eq 'status') { + if ($map_process_status{$result->{$key}} =~ /$option_val/) { + $key =~ /\.([0-9]+)$/; + $instances_keep->{$1} = 1; + } + } elsif ((defined($self->{option_results}->{'regexp_' . $oid2check_filter}) && $result->{$key} =~ /$option_val/) + || (!defined($self->{option_results}->{'regexp_' . $oid2check_filter}) && $result->{$key} eq $option_val)) { + $key =~ /\.([0-9]+)$/; + $instances_keep->{$1} = 1; + } + } + + my $result2; + if (scalar(keys %$instances_keep) > 0) { + if (scalar(@$more_oids) > 0) { + $self->{snmp}->load(oids => $more_oids, instances => [ keys %$instances_keep ]); + $result2 = $self->{snmp}->get_leef(); + } + + foreach my $key (keys %$instances_keep) { + my $value = ($oid2check_filter eq 'status') ? $map_process_status{$result->{$oids->{$oid2check_filter} . '.' . $key}} : $result->{$oids->{$oid2check_filter} . '.' . $key}; + my $long_value = '[ ' . $oid2check_filter . ' => ' . $value . ' ]'; + my $deleted = 0; + foreach (keys %$mores_filters) { + my $opt_val = $self->{option_results}->{'process_' . $_}; + $value = ($_ eq 'status') ? $map_process_status{$result2->{$oids->{$_} . '.' . $key}} : $result2->{$oids->{$_} . '.' . $key}; + + if ($_ eq 'status') { + if ($value !~ /$opt_val/) { + delete $instances_keep->{$key}; + $deleted = 1; + last; + } + } elsif ((defined($self->{option_results}->{'regexp_' . $_}) && $value !~ /$opt_val/) + || (!defined($self->{option_results}->{'regexp_' . $_}) && $value ne $opt_val)) { + delete $instances_keep->{$key}; + $deleted = 1; + last; + } + + $long_value .= ' [ ' . $_ . ' => ' . $value . ' ]'; + } + + if ($deleted == 0) { + $self->{output}->output_add(long_msg => 'Process: ' . $long_value); + } + } + } + + my $num_processes_match = scalar(keys(%$instances_keep)); + my $exit = $self->{perfdata}->threshold_check(value => $num_processes_match, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => "Number of current processes running: $num_processes_match"); + $self->{output}->perfdata_add(label => 'nbproc', + value => $num_processes_match, + 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 system number of processes. + +=over 8 + +=item B<--warning> + +Threshold warning (process count). + +=item B<--critical> + +Threshold critical (process count). + +=item B<--process-cmd> + +Check process command. + +=item B<--regexp-cmd> + +Allows to use regexp to filter process command (with option --process-cmd). + +=item B<--process-status> + +Check process status (Default: 'run'). Can be a regexp. + +=back + +=cut diff --git a/centreon-plugins/os/hpux/snmp/mode/storage.pm b/centreon-plugins/os/hpux/snmp/mode/storage.pm new file mode 100644 index 000000000..fa5978771 --- /dev/null +++ b/centreon-plugins/os/hpux/snmp/mode/storage.pm @@ -0,0 +1,214 @@ +# +# Copyright 2016 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 os::hpux::snmp::mode::storage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = 'used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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("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}->{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_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'storage', type => 1, cb_prefix_output => 'prefix_storage_output', message_multiple => 'All storages are ok' } + ]; + + $self->{maps_counters}->{storage} = [ + { label => 'usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +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' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; +} + +sub prefix_storage_output { + my ($self, %options) = @_; + + return "Storage '" . $options{instance_value}->{display} . "' "; +} + +my $mapping = { + fileSystemName => { oid => '.1.3.6.1.4.1.11.2.3.1.2.2.1.3' }, + fileSystemBlock => { oid => '.1.3.6.1.4.1.11.2.3.1.2.2.1.4' }, + fileSystemBfree => { oid => '.1.3.6.1.4.1.11.2.3.1.2.2.1.5' }, + fileSystemBavail => { oid => '.1.3.6.1.4.1.11.2.3.1.2.2.1.6' }, + fileSystemBsize => { oid => '.1.3.6.1.4.1.11.2.3.1.2.2.1.7' }, + fileSystemDir => { oid => '.1.3.6.1.4.1.11.2.3.1.2.2.1.10' }, +}; +my $oid_fileSystemEntry = '.1.3.6.1.4.1.11.2.3.1.2.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{storage} = {}; + $self->{results} = $options{snmp}->get_table(oid => $oid_fileSystemEntry, + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}}) { + next if ($oid !~ /^$mapping->{fileSystemDir}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{fileSystemDir} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{fileSystemDir} . "': no matching filter.", debug => 1); + next; + } + + $self->{storage}->{$instance} = { display => $result->{fileSystemDir}, + total => $result->{fileSystemBlock} * $result->{fileSystemBsize}, + used => $result->{fileSystemBlock} * $result->{fileSystemBsize} - $result->{fileSystemBavail} * $result->{fileSystemBsize} }; + } + + + if (scalar(keys %{$self->{storage}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No storage found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check storages. + +=over 8 + +=item B<--filter-name> + +Filter path name (can be a regexp). + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage'. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=back + +=cut diff --git a/centreon-plugins/os/hpux/snmp/plugin.pm b/centreon-plugins/os/hpux/snmp/plugin.pm new file mode 100644 index 000000000..3bf1ae533 --- /dev/null +++ b/centreon-plugins/os/hpux/snmp/plugin.pm @@ -0,0 +1,54 @@ +# +# Copyright 2016 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 os::hpux::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} = '0.1'; + %{$self->{modes}} = ( + 'cpu' => 'os::hpux::snmp::mode::cpu', + 'load' => 'os::hpux::snmp::mode::load', + 'memory' => 'os::hpux::snmp::mode::memory', + 'process' => 'os::hpux::snmp::mode::process', + 'storage' => 'os::hpux::snmp::mode::storage', + 'tcpcon' => 'snmp_standard::mode::tcpcon', + 'uptime' => 'snmp_standard::mode::uptime', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check HP-UX operating systems in SNMP. + +=cut diff --git a/centreon-plugins/os/linux/local/mode/cmdreturn.pm b/centreon-plugins/os/linux/local/mode/cmdreturn.pm index bff8517c7..b565ef10e 100644 --- a/centreon-plugins/os/linux/local/mode/cmdreturn.pm +++ b/centreon-plugins/os/linux/local/mode/cmdreturn.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/connections.pm b/centreon-plugins/os/linux/local/mode/connections.pm index afd891816..0722fe9f1 100644 --- a/centreon-plugins/os/linux/local/mode/connections.pm +++ b/centreon-plugins/os/linux/local/mode/connections.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -312,7 +312,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->build_connections(); diff --git a/centreon-plugins/os/linux/local/mode/cpu.pm b/centreon-plugins/os/linux/local/mode/cpu.pm index ff42d926e..ccfe7d615 100644 --- a/centreon-plugins/os/linux/local/mode/cpu.pm +++ b/centreon-plugins/os/linux/local/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/cpudetailed.pm b/centreon-plugins/os/linux/local/mode/cpudetailed.pm index d3c1f54c1..77c13320e 100644 --- a/centreon-plugins/os/linux/local/mode/cpudetailed.pm +++ b/centreon-plugins/os/linux/local/mode/cpudetailed.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/diskio.pm b/centreon-plugins/os/linux/local/mode/diskio.pm index ddaa61114..acdf11ce4 100644 --- a/centreon-plugins/os/linux/local/mode/diskio.pm +++ b/centreon-plugins/os/linux/local/mode/diskio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/filesdate.pm b/centreon-plugins/os/linux/local/mode/filesdate.pm index 9c8209e95..58a8a8a6b 100644 --- a/centreon-plugins/os/linux/local/mode/filesdate.pm +++ b/centreon-plugins/os/linux/local/mode/filesdate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/filessize.pm b/centreon-plugins/os/linux/local/mode/filessize.pm index 9c48d3df5..0b094874c 100644 --- a/centreon-plugins/os/linux/local/mode/filessize.pm +++ b/centreon-plugins/os/linux/local/mode/filessize.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/inodes.pm b/centreon-plugins/os/linux/local/mode/inodes.pm index ad78e8b5f..c7bfef017 100644 --- a/centreon-plugins/os/linux/local/mode/inodes.pm +++ b/centreon-plugins/os/linux/local/mode/inodes.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/listinterfaces.pm b/centreon-plugins/os/linux/local/mode/listinterfaces.pm index aec606f90..170b6a181 100644 --- a/centreon-plugins/os/linux/local/mode/listinterfaces.pm +++ b/centreon-plugins/os/linux/local/mode/listinterfaces.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/listpartitions.pm b/centreon-plugins/os/linux/local/mode/listpartitions.pm index 33948997e..147a15218 100644 --- a/centreon-plugins/os/linux/local/mode/listpartitions.pm +++ b/centreon-plugins/os/linux/local/mode/listpartitions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/liststorages.pm b/centreon-plugins/os/linux/local/mode/liststorages.pm index c9ae2fe95..b129aee1e 100644 --- a/centreon-plugins/os/linux/local/mode/liststorages.pm +++ b/centreon-plugins/os/linux/local/mode/liststorages.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/loadaverage.pm b/centreon-plugins/os/linux/local/mode/loadaverage.pm index 6646f7b76..cd7fc4ac2 100644 --- a/centreon-plugins/os/linux/local/mode/loadaverage.pm +++ b/centreon-plugins/os/linux/local/mode/loadaverage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/memory.pm b/centreon-plugins/os/linux/local/mode/memory.pm index 86c8d57c0..85a4b1dc3 100644 --- a/centreon-plugins/os/linux/local/mode/memory.pm +++ b/centreon-plugins/os/linux/local/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/packeterrors.pm b/centreon-plugins/os/linux/local/mode/packeterrors.pm index ebdba48d5..b60d4826d 100644 --- a/centreon-plugins/os/linux/local/mode/packeterrors.pm +++ b/centreon-plugins/os/linux/local/mode/packeterrors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/paging.pm b/centreon-plugins/os/linux/local/mode/paging.pm index 3e44c5c5b..e98b382e4 100644 --- a/centreon-plugins/os/linux/local/mode/paging.pm +++ b/centreon-plugins/os/linux/local/mode/paging.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/process.pm b/centreon-plugins/os/linux/local/mode/process.pm index 5c734308b..20aca4680 100644 --- a/centreon-plugins/os/linux/local/mode/process.pm +++ b/centreon-plugins/os/linux/local/mode/process.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/storage.pm b/centreon-plugins/os/linux/local/mode/storage.pm index 06a73601c..8fac41838 100644 --- a/centreon-plugins/os/linux/local/mode/storage.pm +++ b/centreon-plugins/os/linux/local/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/swap.pm b/centreon-plugins/os/linux/local/mode/swap.pm index 8f1a904b0..01540f629 100644 --- a/centreon-plugins/os/linux/local/mode/swap.pm +++ b/centreon-plugins/os/linux/local/mode/swap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/mode/traffic.pm b/centreon-plugins/os/linux/local/mode/traffic.pm index 9a3d47bfd..753fd9d32 100644 --- a/centreon-plugins/os/linux/local/mode/traffic.pm +++ b/centreon-plugins/os/linux/local/mode/traffic.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -113,6 +113,7 @@ sub manage_selection { command_options => $self->{option_results}->{command_options}); while ($stdout =~ /^(\S+)(.*?)(\n\n|\n$)/msg) { my ($interface_name, $values) = ($1, $2); + $interface_name =~ s/:$//; my $states = ''; $states .= 'R' if ($values =~ /RUNNING/ms); $states .= 'U' if ($values =~ /UP/ms); @@ -128,8 +129,9 @@ sub manage_selection { next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $interface_name ne $self->{option_results}->{name}); - $values =~ /RX bytes:(\S+).*?TX bytes:(\S+)/msi; - $self->{result}->{$interface_name} = {state => $states, in => $1, out => $2}; + if ($values =~ /RX bytes:(\S+).*?TX bytes:(\S+)/msi || $values =~ /RX packets\s+\d+\s+bytes\s+(\S+).*?TX packets\s+\d+\s+bytes\s+(\S+)/msi) { + $self->{result}->{$interface_name} = {state => $states, in => $1, out => $2}; + } } if (scalar(keys %{$self->{result}}) <= 0) { @@ -373,4 +375,4 @@ Don't display loopback interfaces. =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/os/linux/local/mode/uptime.pm b/centreon-plugins/os/linux/local/mode/uptime.pm index 13103d8ee..efd7fdd15 100644 --- a/centreon-plugins/os/linux/local/mode/uptime.pm +++ b/centreon-plugins/os/linux/local/mode/uptime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/linux/local/plugin.pm b/centreon-plugins/os/linux/local/plugin.pm index 96ae37925..879ea0e84 100644 --- a/centreon-plugins/os/linux/local/plugin.pm +++ b/centreon-plugins/os/linux/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/linux/snmp/plugin.pm b/centreon-plugins/os/linux/snmp/plugin.pm index 14d619403..701775fdb 100644 --- a/centreon-plugins/os/linux/snmp/plugin.pm +++ b/centreon-plugins/os/linux/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/solaris/local/mode/analyzedisks.pm b/centreon-plugins/os/solaris/local/mode/analyzedisks.pm index ff8b77c22..1e05a8b30 100644 --- a/centreon-plugins/os/solaris/local/mode/analyzedisks.pm +++ b/centreon-plugins/os/solaris/local/mode/analyzedisks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/cpu.pm b/centreon-plugins/os/solaris/local/mode/cpu.pm index 02b9faf99..2bd7d6dfe 100644 --- a/centreon-plugins/os/solaris/local/mode/cpu.pm +++ b/centreon-plugins/os/solaris/local/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/fcconnected.pm b/centreon-plugins/os/solaris/local/mode/fcconnected.pm index 8f75b0867..fc79a092f 100644 --- a/centreon-plugins/os/solaris/local/mode/fcconnected.pm +++ b/centreon-plugins/os/solaris/local/mode/fcconnected.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/fmadm.pm b/centreon-plugins/os/solaris/local/mode/fmadm.pm index 970247834..643a6a503 100644 --- a/centreon-plugins/os/solaris/local/mode/fmadm.pm +++ b/centreon-plugins/os/solaris/local/mode/fmadm.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -41,9 +41,9 @@ sub new { "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'luxadm' }, + "command:s" => { name => 'command', default => 'fmadm' }, "command-path:s" => { name => 'command_path', default => '/usr/sbin' }, - "command-options:s" => { name => 'command_options', default => '-e port 2>&1' }, + "command-options:s" => { name => 'command_options', default => 'faulty -r 2>&1' }, "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, }); diff --git a/centreon-plugins/os/solaris/local/mode/hwraidctl.pm b/centreon-plugins/os/solaris/local/mode/hwraidctl.pm index 3f693ae36..5e0c3d561 100644 --- a/centreon-plugins/os/solaris/local/mode/hwraidctl.pm +++ b/centreon-plugins/os/solaris/local/mode/hwraidctl.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/hwsas2ircu.pm b/centreon-plugins/os/solaris/local/mode/hwsas2ircu.pm index c89c78495..b128c04fc 100644 --- a/centreon-plugins/os/solaris/local/mode/hwsas2ircu.pm +++ b/centreon-plugins/os/solaris/local/mode/hwsas2ircu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/lomv120.pm b/centreon-plugins/os/solaris/local/mode/lomv120.pm index 1b66ce4b3..82648e04b 100644 --- a/centreon-plugins/os/solaris/local/mode/lomv120.pm +++ b/centreon-plugins/os/solaris/local/mode/lomv120.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/lomv120components/fan.pm b/centreon-plugins/os/solaris/local/mode/lomv120components/fan.pm index 9478eba4b..564acd04d 100644 --- a/centreon-plugins/os/solaris/local/mode/lomv120components/fan.pm +++ b/centreon-plugins/os/solaris/local/mode/lomv120components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/lomv120components/psu.pm b/centreon-plugins/os/solaris/local/mode/lomv120components/psu.pm index 04bfad4fb..5ee592009 100644 --- a/centreon-plugins/os/solaris/local/mode/lomv120components/psu.pm +++ b/centreon-plugins/os/solaris/local/mode/lomv120components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/lomv120components/sf.pm b/centreon-plugins/os/solaris/local/mode/lomv120components/sf.pm index 9c05a5a8e..6682690a6 100644 --- a/centreon-plugins/os/solaris/local/mode/lomv120components/sf.pm +++ b/centreon-plugins/os/solaris/local/mode/lomv120components/sf.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/lomv120components/voltage.pm b/centreon-plugins/os/solaris/local/mode/lomv120components/voltage.pm index ae1c8b5be..7888e340d 100644 --- a/centreon-plugins/os/solaris/local/mode/lomv120components/voltage.pm +++ b/centreon-plugins/os/solaris/local/mode/lomv120components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/lomv1280.pm b/centreon-plugins/os/solaris/local/mode/lomv1280.pm index c9dc5a96c..1528fc036 100644 --- a/centreon-plugins/os/solaris/local/mode/lomv1280.pm +++ b/centreon-plugins/os/solaris/local/mode/lomv1280.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/prtdiag.pm b/centreon-plugins/os/solaris/local/mode/prtdiag.pm index 6a77ea0fb..aadf9517a 100644 --- a/centreon-plugins/os/solaris/local/mode/prtdiag.pm +++ b/centreon-plugins/os/solaris/local/mode/prtdiag.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/svmdisks.pm b/centreon-plugins/os/solaris/local/mode/svmdisks.pm index 73845df10..b453110aa 100644 --- a/centreon-plugins/os/solaris/local/mode/svmdisks.pm +++ b/centreon-plugins/os/solaris/local/mode/svmdisks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/mode/vxdisks.pm b/centreon-plugins/os/solaris/local/mode/vxdisks.pm index f3af2be7b..4e8ad4de0 100644 --- a/centreon-plugins/os/solaris/local/mode/vxdisks.pm +++ b/centreon-plugins/os/solaris/local/mode/vxdisks.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/solaris/local/plugin.pm b/centreon-plugins/os/solaris/local/plugin.pm index 9908c97cc..f0c12238d 100644 --- a/centreon-plugins/os/solaris/local/plugin.pm +++ b/centreon-plugins/os/solaris/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/solaris/snmp/plugin.pm b/centreon-plugins/os/solaris/snmp/plugin.pm index b01ba6b1c..1be0f2586 100644 --- a/centreon-plugins/os/solaris/snmp/plugin.pm +++ b/centreon-plugins/os/solaris/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/windows/local/mode/ntp.pm b/centreon-plugins/os/windows/local/mode/ntp.pm index 2931426f9..a8e327db3 100644 --- a/centreon-plugins/os/windows/local/mode/ntp.pm +++ b/centreon-plugins/os/windows/local/mode/ntp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -99,7 +99,7 @@ sub run { } my %ntp; - + # Need to set following patch: https://rt.cpan.org/Public/Bug/Display.html?id=59607 eval { %ntp = Net::NTP::get_ntp_response($ntp_hostname, $self->{option_results}->{ntp_port}); }; diff --git a/centreon-plugins/os/windows/local/mode/rdpsessions.pm b/centreon-plugins/os/windows/local/mode/rdpsessions.pm index c532eb836..a8a084f48 100644 --- a/centreon-plugins/os/windows/local/mode/rdpsessions.pm +++ b/centreon-plugins/os/windows/local/mode/rdpsessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/windows/local/plugin.pm b/centreon-plugins/os/windows/local/plugin.pm index 5744558c4..58736a3e7 100644 --- a/centreon-plugins/os/windows/local/plugin.pm +++ b/centreon-plugins/os/windows/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/windows/snmp/mode/memory.pm b/centreon-plugins/os/windows/snmp/mode/memory.pm index 9a080eebf..5f6fad4a5 100644 --- a/centreon-plugins/os/windows/snmp/mode/memory.pm +++ b/centreon-plugins/os/windows/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -58,7 +58,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hrStorageDescr = '.1.3.6.1.2.1.25.2.3.1.3'; diff --git a/centreon-plugins/os/windows/snmp/mode/service.pm b/centreon-plugins/os/windows/snmp/mode/service.pm index cef3116b0..fbe477231 100644 --- a/centreon-plugins/os/windows/snmp/mode/service.pm +++ b/centreon-plugins/os/windows/snmp/mode/service.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -77,7 +77,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_svSvcEntry = '.1.3.6.1.4.1.77.1.2.3.1'; diff --git a/centreon-plugins/os/windows/snmp/mode/swap.pm b/centreon-plugins/os/windows/snmp/mode/swap.pm index 263ba8379..7b2ddb74f 100644 --- a/centreon-plugins/os/windows/snmp/mode/swap.pm +++ b/centreon-plugins/os/windows/snmp/mode/swap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -58,7 +58,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_hrStorageDescr = '.1.3.6.1.2.1.25.2.3.1.3'; diff --git a/centreon-plugins/os/windows/snmp/plugin.pm b/centreon-plugins/os/windows/snmp/plugin.pm index 820182370..dbed7c263 100644 --- a/centreon-plugins/os/windows/snmp/plugin.pm +++ b/centreon-plugins/os/windows/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/os/windows/wsman/mode/listservices.pm b/centreon-plugins/os/windows/wsman/mode/listservices.pm index 4b5a710b0..d00a298a9 100644 --- a/centreon-plugins/os/windows/wsman/mode/listservices.pm +++ b/centreon-plugins/os/windows/wsman/mode/listservices.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/windows/wsman/mode/service.pm b/centreon-plugins/os/windows/wsman/mode/service.pm index e8e40c407..ab7fb667e 100644 --- a/centreon-plugins/os/windows/wsman/mode/service.pm +++ b/centreon-plugins/os/windows/wsman/mode/service.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/os/windows/wsman/plugin.pm b/centreon-plugins/os/windows/wsman/plugin.pm index 5a2634a29..d7cd1827d 100644 --- a/centreon-plugins/os/windows/wsman/plugin.pm +++ b/centreon-plugins/os/windows/wsman/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/snmp_standard/mode/cpu.pm b/centreon-plugins/snmp_standard/mode/cpu.pm index 668e64db8..3ac2e0d04 100644 --- a/centreon-plugins/snmp_standard/mode/cpu.pm +++ b/centreon-plugins/snmp_standard/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cputable = '.1.3.6.1.2.1.25.3.3.1.2'; diff --git a/centreon-plugins/snmp_standard/mode/cpudetailed.pm b/centreon-plugins/snmp_standard/mode/cpudetailed.pm index 17e203126..39c3cdcb0 100644 --- a/centreon-plugins/snmp_standard/mode/cpudetailed.pm +++ b/centreon-plugins/snmp_standard/mode/cpudetailed.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -78,7 +78,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/snmp_standard/mode/diskio.pm b/centreon-plugins/snmp_standard/mode/diskio.pm index ed26dea82..b1f86a38c 100644 --- a/centreon-plugins/snmp_standard/mode/diskio.pm +++ b/centreon-plugins/snmp_standard/mode/diskio.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/snmp_standard/mode/diskusage.pm b/centreon-plugins/snmp_standard/mode/diskusage.pm index 46179ce59..c4aec55c8 100644 --- a/centreon-plugins/snmp_standard/mode/diskusage.pm +++ b/centreon-plugins/snmp_standard/mode/diskusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -82,7 +82,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{snmp_port} = $self->{snmp}->get_port(); $self->{hostname} = $self->{snmp}->get_hostname(); diff --git a/centreon-plugins/snmp_standard/mode/dynamiccommand.pm b/centreon-plugins/snmp_standard/mode/dynamiccommand.pm index b3b3ad550..cb5ffd34b 100644 --- a/centreon-plugins/snmp_standard/mode/dynamiccommand.pm +++ b/centreon-plugins/snmp_standard/mode/dynamiccommand.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -124,7 +124,6 @@ sub update_command { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); diff --git a/centreon-plugins/snmp_standard/mode/hardwaredevice.pm b/centreon-plugins/snmp_standard/mode/hardwaredevice.pm index 48253fc34..9ff8d4fa9 100644 --- a/centreon-plugins/snmp_standard/mode/hardwaredevice.pm +++ b/centreon-plugins/snmp_standard/mode/hardwaredevice.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -54,7 +54,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{output}->output_add(severity => 'OK', diff --git a/centreon-plugins/snmp_standard/mode/hardwarefibrealliance.pm b/centreon-plugins/snmp_standard/mode/hardwarefibrealliance.pm index 139464ffb..305cada4d 100644 --- a/centreon-plugins/snmp_standard/mode/hardwarefibrealliance.pm +++ b/centreon-plugins/snmp_standard/mode/hardwarefibrealliance.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -119,12 +119,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -172,7 +172,6 @@ sub component { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{results} = $self->{snmp}->get_multiple_table(oids => [ @@ -322,4 +321,4 @@ Example: --threshold-overload='sensors,CRITICAL,^(?!(ok)$)' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/snmp_standard/mode/inodes.pm b/centreon-plugins/snmp_standard/mode/inodes.pm index 6f61e8058..40430f3fe 100644 --- a/centreon-plugins/snmp_standard/mode/inodes.pm +++ b/centreon-plugins/snmp_standard/mode/inodes.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/snmp_standard/mode/interfaces.pm b/centreon-plugins/snmp_standard/mode/interfaces.pm index fd06e2512..3e15f731e 100644 --- a/centreon-plugins/snmp_standard/mode/interfaces.pm +++ b/centreon-plugins/snmp_standard/mode/interfaces.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -668,6 +668,7 @@ sub new { "show-cache" => { name => 'show_cache' }, "reload-cache-time:s" => { name => 'reload_cache_time', default => 180 }, "nagvis-perfdata" => { name => 'nagvis_perfdata' }, + "force-counters32" => { name => 'force_counters32' }, }); if ($self->{no_traffic} == 0) { $options{options}->add_options(arguments => { "add-traffic" => { name => 'add_traffic' } }); @@ -1053,7 +1054,7 @@ sub load_traffic { if ($self->{get_speed} == 1) { $self->{snmp}->load(oids => [$self->{oid_speed32}], instances => $self->{array_interface_selected}); } - if (!$self->{snmp}->is_snmpv1()) { + if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) { $self->{snmp}->load(oids => [$self->{oid_in64}, $self->{oid_out64}], instances => $self->{array_interface_selected}); if ($self->{get_speed} == 1) { $self->{snmp}->load(oids => [$self->{oid_speed64}], instances => $self->{array_interface_selected}); @@ -1076,7 +1077,7 @@ sub load_cast { $self->{snmp}->load(oids => [$self->{oid_ifInUcastPkts}, $self->{oid_ifInBroadcastPkts}, $self->{oid_ifInMulticastPkts}, $self->{oid_ifOutUcastPkts}, $self->{oid_ifOutMulticastPkts}, $self->{oid_ifOutBroadcastPkts}], instances => $self->{array_interface_selected}); - if (!$self->{snmp}->is_snmpv1()) { + if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) { $self->{snmp}->load(oids => [$self->{oid_ifHCInUcastPkts}, $self->{oid_ifHCInMulticastPkts}, $self->{oid_ifHCInBroadcastPkts}, $self->{oid_ifHCOutUcastPkts}, $self->{oid_ifHCOutMulticastPkts}, $self->{oid_ifHCOutBroadcastPkts}], instances => $self->{array_interface_selected}); @@ -1155,7 +1156,7 @@ sub add_result_traffic { $self->{interface_selected}->{$options{instance}}->{mode_traffic} = 32; $self->{interface_selected}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in32} . '.' . $options{instance}}; $self->{interface_selected}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out32} . '.' . $options{instance}}; - if (!$self->{snmp}->is_snmpv1()) { + if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) { if (defined($self->{results}->{$self->{oid_in64} . '.' . $options{instance}}) && $self->{results}->{$self->{oid_in64} . '.' . $options{instance}} ne '' && $self->{results}->{$self->{oid_in64} . '.' . $options{instance}} != 0) { $self->{interface_selected}->{$options{instance}}->{mode_traffic} = 64; @@ -1204,7 +1205,7 @@ sub add_result_cast { $self->{interface_selected}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifOutUcastPkts} . '.' . $options{instance}}; $self->{interface_selected}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifOutMulticastPkts} . '.' . $options{instance}} : 0; $self->{interface_selected}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifOutBroadcastPkts} . '.' . $options{instance}} : 0; - if (!$self->{snmp}->is_snmpv1()) { + if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) { my $iucast = $self->{results}->{$self->{oid_ifHCInUcastPkts} . '.' . $options{instance}}; if (defined($iucast) && $iucast =~ /[1-9]/) { $self->{interface_selected}->{$options{instance}}->{iucast} = $iucast; @@ -1315,6 +1316,10 @@ Set interface speed for outgoing traffic (in Mb). Don't skip counters when no change. +=item B<--force-counters32> + +Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy. + =item B<--reload-cache-time> Time in minutes before reloading cache file (default: 180). diff --git a/centreon-plugins/snmp_standard/mode/isdnusage.pm b/centreon-plugins/snmp_standard/mode/isdnusage.pm new file mode 100644 index 000000000..c99b5d3fa --- /dev/null +++ b/centreon-plugins/snmp_standard/mode/isdnusage.pm @@ -0,0 +1,182 @@ +# +# Copyright 2016 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 snmp_standard::mode::isdnusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bearer', type => 0 }, + { name => 'isdn', type => 1, cb_prefix_output => 'prefix_isdn_output', message_multiple => 'All isdn channels are ok' } + ]; + + $self->{maps_counters}->{isdn} = [ + { label => 'in-calls', set => { + key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], + output_template => 'Incoming calls : %s', + perfdatas => [ + { label => 'in_calls', value => 'in_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'out-calls', set => { + key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], + output_template => 'Outgoing calls : %s', + perfdatas => [ + { label => 'out_calls', value => 'out_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; + $self->{maps_counters}->{bearer} = [ + { label => 'current-calls', set => { + key_values => [ { name => 'active' }, { name => 'total' } ], + output_template => 'Current calls : %s', + perfdatas => [ + { label => 'current_calls', value => 'active_absolute', template => '%s', + min => 0, max => 'total_absolute' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub prefix_isdn_output { + my ($self, %options) = @_; + + return "ISDN channel '" . $options{instance_value}->{display} . "' "; +} + +my %map_bearer_state = ( + 1 => 'idle', + 2 => 'connecting', + 3 => 'connected', + 4 => 'active', +); +my $mapping = { + isdnSigStatsInCalls => { oid => '.1.3.6.1.2.1.10.20.1.3.3.1.1' }, + isdnSigStatsOutCalls => { oid => '.1.3.6.1.2.1.10.20.1.3.3.1.3' }, +}; + +my $oid_isdnBearerOperStatus = '.1.3.6.1.2.1.10.20.1.2.1.1.2'; +my $oid_isdnSignalingIfIndex = '.1.3.6.1.2.1.10.20.1.3.2.1.2'; +my $oid_isdnSignalingStatsEntry = '.1.3.6.1.2.1.10.20.1.3.3.1'; +my $oid_ifDescr = '.1.3.6.1.2.1.2.2.1.2'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{isdn} = {}; + $self->{bearer} = { active => 0, total => 0 }; + my $snmp_result = $options{snmp}->get_multiple_table(oids => [ + { oid => $oid_isdnBearerOperStatus }, + { oid => $oid_isdnSignalingIfIndex }, + { oid => $oid_isdnSignalingStatsEntry }, + ], + nothing_quit => 1); + + # Get interface name + foreach my $oid (keys %{$snmp_result->{$oid_isdnSignalingIfIndex}}) { + $options{snmp}->load(oids => [$oid_ifDescr], instances => [$snmp_result->{$oid_isdnSignalingIfIndex}->{$oid}]); + } + my $result_ifdesc = $options{snmp}->get_leef(nothing_quit => 1); + + foreach my $oid (keys %{$snmp_result->{$oid_isdnSignalingIfIndex}}) { + $oid =~ /^$oid_isdnSignalingIfIndex\.(.*)/; + my $instance = $1; + my $display = $result_ifdesc->{$oid_ifDescr . '.' . $snmp_result->{$oid_isdnSignalingIfIndex}->{$oid_isdnSignalingIfIndex . '.' . $instance}}; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $display !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter name.", debug => 1); + next; + } + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_isdnSignalingStatsEntry}, instance => $instance); + $self->{isdn}->{$instance} = { in => $result->{isdnSigStatsInCalls}, out => $result->{isdnSigStatsOutCalls}, + display => $display }; + } + + foreach my $oid (keys %{$snmp_result->{$oid_isdnBearerOperStatus}}) { + my $status = defined($map_bearer_state{$snmp_result->{$oid_isdnBearerOperStatus}->{$oid}}) ? + $map_bearer_state{$snmp_result->{$oid_isdnBearerOperStatus}->{$oid}} : 'unknown'; + $self->{bearer}->{total}++; + $self->{bearer}->{active}++ if ($status =~ /active/); + } + + $self->{cache_name} = "isdn_usage_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check ISDN usages (ISDN-MIB). + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^current-calls$' + +=item B<--filter-name> + +Filter by name (regexp can be used). + +=item B<--warning-*> + +Threshold warning. +Can be: 'in-calls', 'out-calls', 'current-calls'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'in-calls', 'out-calls', 'current-calls'. + +=back + +=cut diff --git a/centreon-plugins/snmp_standard/mode/listdiskspath.pm b/centreon-plugins/snmp_standard/mode/listdiskspath.pm index 567768134..464b2a708 100644 --- a/centreon-plugins/snmp_standard/mode/listdiskspath.pm +++ b/centreon-plugins/snmp_standard/mode/listdiskspath.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -58,7 +58,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -170,7 +169,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1); diff --git a/centreon-plugins/snmp_standard/mode/listinterfaces.pm b/centreon-plugins/snmp_standard/mode/listinterfaces.pm index 5c0c9e52d..f067adba8 100644 --- a/centreon-plugins/snmp_standard/mode/listinterfaces.pm +++ b/centreon-plugins/snmp_standard/mode/listinterfaces.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -125,12 +125,13 @@ sub check_options { $self->{extra_oids} = {}; foreach (@{$self->{option_results}->{add_extra_oid}}) { next if ($_ eq ''); - my ($name, $oid) = split /,/; + my ($name, $oid, $matching) = split /,/; + $matching = '%{instance}$' if (!defined($matching)); if (!defined($oid) || $oid !~ /^(\.\d+){1,}$/ || $name eq '') { $self->{output}->add_option_msg(short_msg => "Wrong syntax for add-extra-oid '" . $_ . "' option."); $self->{output}->option_exit(); } - $self->{extra_oids}->{$name} = $oid; + $self->{extra_oids}->{$name} = { oid => $oid, matching => $matching }; } } @@ -146,8 +147,10 @@ sub run { my $interface_speed = 0; if ($self->{no_speed} == 0) { - $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0 ? - ($result->{$oid_speed64 . "." . $_}) : (sprintf("%g", $result->{$oid_speed32 . "." . $_} / 1000 / 1000))); + $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0) ? + ($result->{$oid_speed64 . "." . $_}) : + (defined($result->{$oid_speed32 . "." . $_}) && $result->{$oid_speed32 . "." . $_} ne '' && $result->{$oid_speed32 . "." . $_} != 0 ? + (sprintf("%g", $result->{$oid_speed32 . "." . $_} / 1000 / 1000)) : ''); } if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { $interface_speed = $self->{option_results}->{speed}; @@ -166,14 +169,16 @@ sub run { $self->{output}->output_add(long_msg => "Skipping interface '" . $display_value . "': adminstatus is not 'up' and option --use-adminstatus is set"); next; } + + my $extra_values = $self->get_extra_values_by_instance(instance => $_); my $extra_display = ''; - my $extra_display_append = ' '; - foreach my $name (keys %{$self->{extra_oids}}) { - $extra_display .= $extra_display_append . $name . ' = ' . (defined($result->{$self->{extra_oids}->{$name} . "." . $_}) ? $result->{$self->{extra_oids}->{$name} . "." . $_} : ''); - $extra_display_append = ', '; + foreach my $name (keys %{$extra_values}) { + $extra_display .= ', ' . $name . ' = ' . $extra_values->{$name}; } - $self->{output}->output_add(long_msg => "'" . $display_value . "' [speed = $interface_speed, status = " . $self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}} . ', id = ' . $_ . $extra_display . ']'); + $self->{output}->output_add(long_msg => "'" . $display_value . "' [speed = $interface_speed, status = " . + (defined($result->{$self->{oid_opstatus} . "." . $_}) ? $self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}} : '') . + ', id = ' . $_ . $extra_display . ']'); } $self->{output}->output_add(severity => 'OK', @@ -190,9 +195,6 @@ sub get_additional_information { push @$oids, $self->{oid_opstatus} if (defined($self->{oid_opstatus})); push @$oids, $oid_speed32 if ($self->{no_speed} == 0); push @$oids, $oid_speed64 if (!$self->{snmp}->is_snmpv1() && $self->{no_speed} == 0); - if (scalar(keys %{$self->{extra_oids}}) > 0) { - push @$oids, values %{$self->{extra_oids}}; - } $self->{snmp}->load(oids => $oids, instances => $self->{interface_id_selected}); return $self->{snmp}->get_leef(); @@ -212,12 +214,22 @@ sub get_display_value { sub manage_selection { my ($self, %options) = @_; + my $oids = [{ oid => $self->{oids_label}->{$self->{option_results}->{oid_filter}} }]; + if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) { + push @$oids, { oid => $self->{oids_label}->{$self->{option_results}->{oid_display}} }; + } + if (scalar(keys %{$self->{extra_oids}}) > 0) { + foreach (keys %{$self->{extra_oids}}) { + push @$oids, { oid => $self->{extra_oids}->{$_}->{oid} }; + } + } + $self->{datas} = {}; - my $result = $self->{snmp}->get_table(oid => $self->{oids_label}->{$self->{option_results}->{oid_filter}}); + $self->{results} = $self->{snmp}->get_multiple_table(oids => $oids); $self->{datas}->{all_ids} = []; - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oids_label}->{$self->{option_results}->{oid_filter}} }})) { next if ($key !~ /^$self->{oids_label}->{$self->{option_results}->{oid_filter}}\.(.*)$/); - $self->{datas}->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($result->{$key}); + $self->{datas}->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_filter}} }->{$key}); push @{$self->{datas}->{all_ids}}, $1; } @@ -227,11 +239,10 @@ sub manage_selection { } if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) { - $result = $self->{snmp}->get_table(oid => $self->{oids_label}->{$self->{option_results}->{oid_display}}); - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oids_label}->{$self->{option_results}->{oid_display}} }})) { next if ($key !~ /^$self->{oids_label}->{$self->{option_results}->{oid_display}}\.(.*)$/); - $self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($result->{$key}); - } + $self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_display}} }->{$key}); + } } if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{interface})) { @@ -261,6 +272,27 @@ sub manage_selection { } } +sub get_extra_values_by_instance { + my ($self, %options) = @_; + + my $extra_values = {}; + foreach my $name (keys %{$self->{extra_oids}}) { + my $matching = $self->{extra_oids}->{$name}->{matching}; + $matching =~ s/%\{instance\}/$options{instance}/g; + next if (!defined($self->{results}->{ $self->{extra_oids}->{$name}->{oid} })); + + my $append = ''; + foreach (keys %{$self->{results}->{ $self->{extra_oids}->{$name}->{oid} }}) { + if (/^$self->{extra_oids}->{$name}->{oid}\.$matching/) { + $extra_values->{$name} = '' if (!defined($extra_values->{$name})); + $extra_values->{$name} .= $append . $self->{results}->{$self->{extra_oids}->{$name}->{oid}}->{$_}; + $append = ','; + } + } + } + return $extra_values; +} + sub disco_format { my ($self, %options) = @_; @@ -283,8 +315,10 @@ sub disco_show { my $interface_speed = 0; if ($self->{no_speed} == 0) { - $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0 ? - ($result->{$oid_speed64 . "." . $_}) : (sprintf("%g", $result->{$oid_speed32 . "." . $_} / 1000 / 1000))); + $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0) ? + ($result->{$oid_speed64 . "." . $_}) : + (defined($result->{$oid_speed32 . "." . $_}) && $result->{$oid_speed32 . "." . $_} ne '' && $result->{$oid_speed32 . "." . $_} != 0 ? + (sprintf("%g", $result->{$oid_speed32 . "." . $_} / 1000 / 1000)) : ''); } if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { $interface_speed = $self->{option_results}->{speed}; @@ -293,18 +327,13 @@ sub disco_show { next if (defined($self->{option_results}->{filter_status}) && defined($result->{$self->{oid_opstatus} . "." . $_}) && $self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}} !~ /$self->{option_results}->{filter_status}/i); next if ($self->is_admin_status_down(admin_status => $result->{$self->{oid_adminstatus} . "." . $_})); - - my %extra_values = (); - foreach my $name (keys %{$self->{extra_oids}}) { - $extra_values{$name} = defined($result->{$self->{extra_oids}->{$name} . "." . $_}) ? - $result->{$self->{extra_oids}->{$name} . "." . $_} : ''; - } - + + my $extra_values = $self->get_extra_values_by_instance(instance => $_); $self->{output}->add_disco_entry(name => $display_value, total => $interface_speed, - status => $self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}}, + status => defined($result->{$self->{oid_opstatus} . "." . $_}) ? $self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}} : '', interfaceid => $_, - %extra_values); + %$extra_values); } } @@ -358,7 +387,10 @@ Regexp dst to transform display value. (security risk!!!) =item B<--add-extra-oid> -Display an OID. Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18' +Display an OID. +Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18' +or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*' + =back diff --git a/centreon-plugins/snmp_standard/mode/liststorages.pm b/centreon-plugins/snmp_standard/mode/liststorages.pm index 83e4ca775..281ff3a33 100644 --- a/centreon-plugins/snmp_standard/mode/liststorages.pm +++ b/centreon-plugins/snmp_standard/mode/liststorages.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -114,7 +114,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -252,7 +251,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1); diff --git a/centreon-plugins/snmp_standard/mode/loadaverage.pm b/centreon-plugins/snmp_standard/mode/loadaverage.pm index dc26c4bcc..5c04a2d0f 100644 --- a/centreon-plugins/snmp_standard/mode/loadaverage.pm +++ b/centreon-plugins/snmp_standard/mode/loadaverage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -76,7 +76,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_CountCpu = '.1.3.6.1.2.1.25.3.3.1.2'; diff --git a/centreon-plugins/snmp_standard/mode/memory.pm b/centreon-plugins/snmp_standard/mode/memory.pm index cf86277aa..b4638ff17 100644 --- a/centreon-plugins/snmp_standard/mode/memory.pm +++ b/centreon-plugins/snmp_standard/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -77,7 +77,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_memTotalReal = '.1.3.6.1.4.1.2021.4.5.0'; diff --git a/centreon-plugins/snmp_standard/mode/ntp.pm b/centreon-plugins/snmp_standard/mode/ntp.pm index d7708a54c..9a7c606a4 100644 --- a/centreon-plugins/snmp_standard/mode/ntp.pm +++ b/centreon-plugins/snmp_standard/mode/ntp.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,7 +64,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my ($ref_time, $distant_time); diff --git a/centreon-plugins/snmp_standard/mode/numericvalue.pm b/centreon-plugins/snmp_standard/mode/numericvalue.pm index 7b9fbd736..dc9264571 100644 --- a/centreon-plugins/snmp_standard/mode/numericvalue.pm +++ b/centreon-plugins/snmp_standard/mode/numericvalue.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -87,7 +87,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/snmp_standard/mode/printererror.pm b/centreon-plugins/snmp_standard/mode/printererror.pm index d130d5217..6b427f75c 100644 --- a/centreon-plugins/snmp_standard/mode/printererror.pm +++ b/centreon-plugins/snmp_standard/mode/printererror.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,7 +64,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{output}->output_add(severity => 'OK', diff --git a/centreon-plugins/snmp_standard/mode/processcount.pm b/centreon-plugins/snmp_standard/mode/processcount.pm index e4c8c7d42..f531cc265 100644 --- a/centreon-plugins/snmp_standard/mode/processcount.pm +++ b/centreon-plugins/snmp_standard/mode/processcount.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -154,7 +154,6 @@ sub check_top { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid2check_filter = 'status'; diff --git a/centreon-plugins/snmp_standard/mode/spanningtree.pm b/centreon-plugins/snmp_standard/mode/spanningtree.pm index 9e83b5475..1d603577a 100644 --- a/centreon-plugins/snmp_standard/mode/spanningtree.pm +++ b/centreon-plugins/snmp_standard/mode/spanningtree.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_dot1dStpPortEnable = '.1.3.6.1.2.1.17.2.15.1.4'; diff --git a/centreon-plugins/snmp_standard/mode/storage.pm b/centreon-plugins/snmp_standard/mode/storage.pm index 4908fe6ba..3d5a6a0b5 100644 --- a/centreon-plugins/snmp_standard/mode/storage.pm +++ b/centreon-plugins/snmp_standard/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -135,7 +135,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/snmp_standard/mode/stringvalue.pm b/centreon-plugins/snmp_standard/mode/stringvalue.pm index 12c278c21..ad8c5c01f 100644 --- a/centreon-plugins/snmp_standard/mode/stringvalue.pm +++ b/centreon-plugins/snmp_standard/mode/stringvalue.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -35,15 +35,45 @@ sub new { $options{options}->add_options(arguments => { "oid:s" => { name => 'oid' }, + "oid-leef:s" => { name => 'oid_leef' }, + "oid-table:s" => { name => 'oid_table' }, + "oid-instance:s" => { name => 'oid_instance' }, + "filter-table-value:s" => { name => 'filter_table_value' }, + "filter-table-instance:s" => { name => 'filter_table_instance' }, + "warning-regexp:s" => { name => 'warning_regexp' }, "critical-regexp:s" => { name => 'critical_regexp' }, "unknown-regexp:s" => { name => 'unknown_regexp' }, - "format:s" => { name => 'format', default => 'current value is %s' }, - "map-values:s" => { name => 'map_values' }, - "map-values-separator:s" => { name => 'map_values_separator', default => ',' }, - "regexp-map-values" => { name => 'use_regexp_map_values' }, "regexp-isensitive" => { name => 'use_iregexp' }, + + "warning-absent:s@" => { name => 'warning_absent' }, + "critical-absent:s@" => { name => 'critical_absent' }, + "unknown-absent:s@" => { name => 'unknown_absent' }, + "warning-present:s@" => { name => 'warning_present' }, + "critical-present:s@" => { name => 'critical_present' }, + "unknown-present:s@" => { name => 'unknown_present' }, + + "format-ok:s" => { name => 'format_ok', default => '%{filter_rows} value(s)' }, + "format-warning:s" => { name => 'format_warning', default => 'value(s): %{details_warning}' }, + "format-critical:s" => { name => 'format_critical', default => 'value(s): %{details_critical}' }, + "format-unknown:s" => { name => 'format_unknown', default => 'value(s): %{details_unknown}' }, + + "format-details-ok:s" => { name => 'format_details_ok', default => '%{value}' }, + "format-details-warning:s" => { name => 'format_details_warning', default => '%{value}' }, + "format-details-critical:s" => { name => 'format_details_critical', default => '%{value}' }, + "format-details-unknown:s" => { name => 'format_details_unknown', default => '%{value}' }, + + "format-details-separator-ok:s" => { name => 'format_details_separator_ok', default => ', ' }, + "format-details-separator-warning:s" => { name => 'format_details_separator_warning', default => ', ' }, + "format-details-separator-critical:s" => { name => 'format_details_separator_critical', default => ', ' }, + "format-details-separator-unknown:s" => { name => 'format_details_separator_unknown', default => ', ' }, + + "map-values:s" => { name => 'map_values' }, + "map-value-other:s" => { name => 'map_value_other' }, + "map-values-separator:s" => { name => 'map_values_separator', default => ',' }, }); + + $self->{macros} = { ok => {}, warning => {}, critical => {}, unknown => {} }; return $self; } @@ -51,12 +81,16 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - if (!defined($self->{option_results}->{oid}) || $self->{option_results}->{oid} eq '') { - $self->{output}->add_option_msg(short_msg => "Need to specify an OID."); + $self->{option_results}->{oid_leef} = $self->{option_results}->{oid} if (defined($self->{option_results}->{oid}) && $self->{option_results}->{oid} ne ''); + if ((!defined($self->{option_results}->{oid_leef}) || $self->{option_results}->{oid_leef} eq '') && + (!defined($self->{option_results}->{oid_table}) || $self->{option_results}->{oid_table} eq '')) { + $self->{output}->add_option_msg(short_msg => "Need to specify an OID with option --oid-leef or --oid-table."); $self->{output}->option_exit(); } - $self->{option_results}->{oid} = '.' . $self->{option_results}->{oid} if ($self->{option_results}->{oid} !~ /^\./); - + foreach (('oid_leef', 'oid_table', 'oid_instance')) { + $self->{option_results}->{$_} = '.' . $self->{option_results}->{$_} if (defined($self->{option_results}->{$_}) && $self->{option_results}->{$_} ne '' && $self->{option_results}->{$_} !~ /^\./); + } + $self->{map_values} = {}; if (defined($self->{option_results}->{map_values})) { foreach (split /$self->{option_results}->{map_values_separator}/, $self->{option_results}->{map_values}) { @@ -66,47 +100,201 @@ sub check_options { } } -sub check_regexp { +sub get_instance_value { + my ($self, %options) = @_; + + if (!defined($self->{option_results}->{oid_instance}) || $self->{option_results}->{oid_instance} eq '' + || !defined($self->{results}->{$self->{option_results}->{oid_instance} . '.' . $options{instance}})) { + return $options{instance}; + } + + return $self->{results}->{$self->{option_results}->{oid_instance} . '.' . $options{instance}}; +} + +sub get_map_value { + my ($self, %options) = @_; + + my $value = $options{value}; + return '' if (!defined($options{value})); + if (defined($self->{map_values}->{$options{value}})) { + $value = $self->{map_values}->{$options{value}}; + } elsif (defined($self->{option_results}->{map_value_other}) && $self->{option_results}->{map_value_other} ne '') { + $value = $self->{option_results}->{map_value_other}; + } + + return $value; +} + +sub get_snmp_values { + my ($self, %options) = @_; + + $self->{instances} = {}; + if (defined($self->{option_results}->{oid_leef}) && $self->{option_results}->{oid_leef} ne '') { + $self->{results} = $self->{snmp}->get_leef(oids => [$self->{option_results}->{oid_leef}], nothing_quit => 1); + $self->{macros}->{rows} = 1; + $self->{macros}->{filter_rows} = 1; + $self->{instances}->{0} = $self->get_map_value(value => $self->{results}->{$self->{option_results}->{oid_leef}}); + return 0; + } + + my $tables = [ { oid => $self->{option_results}->{oid_table}} ]; + push @$tables, { oid => $self->{option_results}->{oid_instance} } if (defined($self->{option_results}->{oid_instance}) && $self->{option_results}->{oid_instance} ne ''); + $self->{results} = $self->{snmp}->get_multiple_table(oids => $tables, nothing_quit => 1, return_type => 1); + my ($row, $filter_row) = (0, 0); + foreach (keys %{$self->{results}}) { + next if ($_ !~ /^$self->{option_results}->{oid_table}\.(.*)$/); + + $row++; + my $instance = $self->get_instance_value(instance => $1); + my $value = $self->get_map_value(value => $self->{results}->{$_}); + $self->{output}->output_add(long_msg => sprintf("[instance: %s][value: %s]", $_, $value), debug => 1); + if (defined($self->{option_results}->{filter_table_value}) && $self->{option_results}->{filter_table_value} ne '' && + $value !~ /$self->{option_results}->{filter_table_value}/) { + $self->{output}->output_add(long_msg => sprintf("skipping oid '%s' value '%s': not matching the filter", $_, $value), debug => 1); + next; + } + if (defined($self->{option_results}->{filter_table_instance}) && $self->{option_results}->{filter_table_instance} ne '' && + $instance !~ /$self->{option_results}->{filter_table_instance}/) { + $self->{output}->output_add(long_msg => sprintf("skipping oid '%s' instance '%s': not matching the filter", $_, $instance), debug => 1); + next; + } + + $self->{instances}->{$instance} = $value; + $filter_row++; + } + $self->{macros}->{rows} = $row; + $self->{macros}->{filter_rows} = $filter_row; + + return 0; +} + +sub checking_regexp { my ($self, %options) = @_; return 0 if (!defined($self->{option_results}->{$options{severity} . '_regexp'})); my $regexp = $self->{option_results}->{$options{severity} . '_regexp'}; if (defined($self->{option_results}->{use_iregexp}) && $options{value} =~ /$regexp/i) { - $self->{exit_code} = $options{severity}; + $self->{instances}->{$options{severity}}->{$options{instance}} = $options{value}; return 1; } elsif (!defined($self->{option_results}->{use_iregexp}) && $options{value} =~ /$regexp/) { - $self->{exit_code} = $options{severity}; + $self->{instances}->{$options{severity}}->{$options{instance}} = $options{value}; return 1; - } + } return 0; } -sub run { +sub store_ok { my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $result = $self->{snmp}->get_leef(oids => [$self->{option_results}->{oid}], nothing_quit => 1); - my $value_check = $result->{$self->{option_results}->{oid}}; - my $value_display = $value_check; - if (defined($self->{option_results}->{map_values})) { - # If we don't find it. We keep the original value - $value_display = defined($self->{map_values}->{$value_check}) ? $self->{map_values}->{$value_check} : $value_check; - if (defined($self->{option_results}->{use_regexp_map_values})) { - $value_check = $value_display; + foreach my $severity (('critical', 'warning', 'unknown')) { + foreach my $type (('absent', 'present')) { + if (defined($self->{option_results}->{$severity . '_' . $type}) && scalar(@{$self->{option_results}->{$severity . '_' . $type}}) > 0) { + return 0; + } } } - - $self->{exit_code} = 'ok'; - $self->check_regexp(severity => 'critical', value => $value_check) || - $self->check_regexp(severity => 'warning', value => $value_check) || - $self->check_regexp(severity => 'unknown', value => $value_check); - $self->{output}->output_add(severity => $self->{exit_code}, - short_msg => sprintf($self->{option_results}->{format}, $value_display)); + $self->{instances}->{ok}->{$options{instance}} = $options{value}; +} + +sub checking_exist { + my ($self, %options) = @_; + + foreach my $severity (('critical', 'warning', 'unknown')) { + foreach my $absent (@{$self->{option_results}->{$severity . '_absent'}}) { + my $match = 0; + foreach (keys %{$self->{instances}}) { + if ($self->{instances}->{$_} eq $absent) { + $match = 1; + last; + } + } + + if ($match == 0) { + $self->{instances}->{$severity}->{$absent} = $absent; + } + } + + foreach my $present (@{$self->{option_results}->{$severity . '_present'}}) { + my $match = 0; + foreach (keys %{$self->{instances}}) { + if ($self->{instances}->{$_} eq $present) { + $self->{instances}->{$severity}->{$_} = $self->{instances}->{$_}; + } + } + } + } +} + +sub change_macros { + my ($self, %options) = @_; + + my $value = $self->{option_results}->{'format_' . $options{severity}}; + while ($value =~ /%\{(.*?)\}/g) { + $value =~ s/%\{($1)\}/\$self->{macros}->{$1}/g; + } + + return $value; +} + +sub build_format_details { + my ($self, %options) = @_; + + foreach my $severity (('ok', 'critical', 'warning', 'unknown')) { + $self->{macros}->{'details_' . $severity} = ''; + my $append = ''; + foreach my $instance (sort keys %{$self->{instances}->{$severity}}) { + my $details = $self->{option_results}->{'format_details_' . $severity}; + $details =~ s/%{rows}/$self->{macros}->{rows}/g; + $details =~ s/%{filter_rows}/$self->{macros}->{filter_rows}/g; + $details =~ s/%{instance}/$instance/g; + $details =~ s/%{value}/$self->{instances}->{$severity}->{$instance}/g; + + $self->{macros}->{'details_' . $severity} .= $append . $details; + $append = $self->{option_results}->{'format_details_separator_' . $severity}; + } + } +} + +sub display_severity { + my ($self, %options) = @_; + + if (!(defined($options{force}) && $options{force} == 1) && scalar(keys %{$self->{instances}->{$options{severity}}}) == 0) { + return 0; + } + + my $display = $self->change_macros(severity => $options{severity}); + eval "\$display = \"$display\""; + $self->{output}->output_add(severity => $options{severity}, + short_msg => $display); +} + +sub display_result { + my ($self, %options) = @_; + + $self->build_format_details(); + $self->display_severity(severity => 'ok', force => 1); + foreach my $severity (('critical', 'warning', 'unknown')) { + $self->display_severity(severity => $severity); + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + $self->get_snmp_values(); + + foreach (keys %{$self->{instances}}) { + $self->checking_regexp(severity => 'critical', instance => $_, value => $self->{instances}->{$_}) || + $self->checking_regexp(severity => 'warning', instance => $_, value => $self->{instances}->{$_}) || + $self->checking_regexp(severity => 'unknown', instance => $_, value => $self->{instances}->{$_}) || + $self->store_ok(instance => $_, value => $self->{instances}->{$_}); + } + $self->checking_exist(); + $self->display_result(); $self->{output}->display(); $self->{output}->exit(); @@ -118,47 +306,78 @@ __END__ =head1 MODE -Check an SNMP string value (can be a String or an Integer). +Check SNMP string values (can be a String or an Integer). +Check values absent: +centreon_plugins.pl --plugin=snmp_standard::plugin --mode=string-value --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public + --oid-table='.1.3.6.1.2.1.25.4.2.1.2' --format-ok='%{filter_rows} processes' --format-critical='processes are absent: %{details_critical}' --critical-absent='centengine' --critical-absent='crond' --filter-table-value='centengine|crond' + +Check table status: +centreon_plugins.pl --plugin=snmp_standard::plugin --mode=string-value --hostname=127.0.0.1 --snmp-version=2c --snmp-community=akcp + --oid-table='.1.3.6.1.4.1.3854.1.2.2.1.16.1.4' --oid-instance='.1.3.6.1.4.1.3854.1.2.2.1.16.1.1' --map-values='1=>noStatus,2=>normal,3=>highWarning,4=>highCritical,5=>lowWarning,6=>lowCritical,7=>sensorError' --map-value-other='unknown' --format-ok='All %{rows} entries [%{filter_rows}/%{rows} Temperatures] are ok.' --format-critical='%{details_critical}' --format-details-critical='%{instance} status is %{value}' --critical-regexp='highCritical|lowCritical|sensorError' + +Check like the old plugin: +centreon_plugins.pl --plugin=snmp_standard::plugin --mode=string-value --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public + --oid='.1.3.6.1.2.1.1.1.0' --format-ok='current value is: %{details_ok}' --format-details-warning='current value is: %{details_warning}' --format-details-critical='current value is: %{details_critical}' + =over 8 -=item B<--oid> +=item B<--oid> or <--oid-leef> OID value to check (numeric format only). +=item B<--oid-table> + +OID table value to check (numeric format only). + +=item B<--oid-instance> + +OID table value for the instance (numeric format only). +Can be used to have human readable instance name. + +=item B<--filter-table-value> + +Filter value from --oid-table option (can be a regexp). + +=item B<--filter-table-instance> + +Filter instance from --oid-table option (can be a regexp). + =item B<--warning-regexp> -Return Warning if the oid value match the regexp. +Return Warning if an oid value match the regexp. =item B<--critical-regexp> -Return Critical if the oid value match the regexp. +Return Critical if an oid value match the regexp. -=item B<--unknown-regexp> +=item B<--regexp-isensitive> -Return Unknown if the oid value match the regexp. +Allows to use regexp non case-sensitive. -=item B<--format> +=item B<--format-*> -Output format (Default: 'current value is %s'). +Output format according the threshold. +Can be: +'ok' (default: '%{filter_rows} value(s)'), +'warning' (default: 'value(s): %{details_warning}'), +'critical' (default: 'value(s): %{details_critical}'), +'unknown' (default: 'value(s): %{details_unknown}'). +Can used: %{rows}, %{filter_rows}, %{details_warning}, %{details_ok}, %{details_critical}, %{details_unknown} =item B<--map-values> Use to transform an integer value in most common case. Example: --map-values='1=>ok,10=>fan failed,11=>psu recovery' +=item B<--map-value-other> + +Use to transform an integer value not defined in --map-values option. + =item B<--map-values-separator> Separator uses between values (default: coma). -=item B<--regexp-map-values> - -Use the 'map values' to match in regexp (need --map-values option). - -=item B<--regexp-isensitive> - -Allows to use regexp non case-sensitive. - =back =cut diff --git a/centreon-plugins/snmp_standard/mode/swap.pm b/centreon-plugins/snmp_standard/mode/swap.pm index a490677b2..b022541c8 100644 --- a/centreon-plugins/snmp_standard/mode/swap.pm +++ b/centreon-plugins/snmp_standard/mode/swap.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -64,7 +64,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_memTotalSwap = '.1.3.6.1.4.1.2021.4.3.0'; # KB diff --git a/centreon-plugins/snmp_standard/mode/tcpcon.pm b/centreon-plugins/snmp_standard/mode/tcpcon.pm index dfe5b541d..55e8e87a0 100644 --- a/centreon-plugins/snmp_standard/mode/tcpcon.pm +++ b/centreon-plugins/snmp_standard/mode/tcpcon.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -299,7 +299,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->build_connections(); diff --git a/centreon-plugins/snmp_standard/mode/uptime.pm b/centreon-plugins/snmp_standard/mode/uptime.pm index 152486839..0264c7c24 100644 --- a/centreon-plugins/snmp_standard/mode/uptime.pm +++ b/centreon-plugins/snmp_standard/mode/uptime.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -25,6 +25,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use POSIX; +use centreon::plugins::misc; sub new { my ($class, %options) = @_; @@ -36,7 +37,6 @@ sub new { { "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, - "seconds" => { name => 'seconds', }, "force-oid:s" => { name => 'force_oid', }, }); @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # To be used first for OS @@ -89,8 +88,8 @@ sub run { min => 0); $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("System uptime is: %s", - defined($self->{option_results}->{seconds}) ? floor($value / 100) . " seconds" : floor($value / 86400 / 100) . " days" )); + short_msg => sprintf("System uptime is: %s", + centreon::plugins::misc::change_seconds(value => floor($value / 100), start => 'd'))); $self->{output}->display(); $self->{output}->exit(); @@ -114,10 +113,6 @@ Threshold warning in seconds. Threshold critical in seconds. -=item B<--seconds> - -Display uptime in seconds. - =item B<--force-oid> Can choose your oid (numeric format only). diff --git a/centreon-plugins/snmp_standard/plugin.pm b/centreon-plugins/snmp_standard/plugin.pm index ea21277bf..d0bf3ea14 100644 --- a/centreon-plugins/snmp_standard/plugin.pm +++ b/centreon-plugins/snmp_standard/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/dell/MD3000/cli/plugin.pm b/centreon-plugins/storage/dell/MD3000/cli/plugin.pm index f8784f728..8018d43b2 100644 --- a/centreon-plugins/storage/dell/MD3000/cli/plugin.pm +++ b/centreon-plugins/storage/dell/MD3000/cli/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/dell/TL2000/mode/globalstatus.pm b/centreon-plugins/storage/dell/TL2000/mode/globalstatus.pm index c16545263..499da55ca 100644 --- a/centreon-plugins/storage/dell/TL2000/mode/globalstatus.pm +++ b/centreon-plugins/storage/dell/TL2000/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -48,18 +48,18 @@ sub new { return $self; } -sub check_treshold_overload { +sub check_threshold_overload { my ($self, %options) = @_; $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /(.*?)=(.*)/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($filter, $threshold) = ($1, $2); if ($self->{output}->is_litteral_status(status => $threshold) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $self->{overload_th}->{$filter} = $threshold; @@ -69,7 +69,7 @@ sub check_treshold_overload { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - $self->check_treshold_overload(); + $self->check_threshold_overload(); } sub get_severity { @@ -86,7 +86,6 @@ sub get_severity { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_TL2000StatusGlobalStatus = '.1.3.6.1.4.1.674.10893.2.102.2.1.0'; @@ -118,4 +117,4 @@ Example: --threshold-overload='(unknown|non critical)=critical' =back =cut - \ No newline at end of file + diff --git a/centreon-plugins/storage/dell/TL2000/plugin.pm b/centreon-plugins/storage/dell/TL2000/plugin.pm index 226e3ecae..e44d292bb 100644 --- a/centreon-plugins/storage/dell/TL2000/plugin.pm +++ b/centreon-plugins/storage/dell/TL2000/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/dell/compellent/local/mode/hbausage.pm b/centreon-plugins/storage/dell/compellent/local/mode/hbausage.pm new file mode 100644 index 000000000..0b91419d1 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/local/mode/hbausage.pm @@ -0,0 +1,318 @@ +# +# Copyright 2016 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::dell::compellent::local::mode::hbausage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::common::powershell::dell::compellent::hbausage; +use DateTime; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'hba', type => 1, cb_prefix_output => 'prefix_hba_output', message_multiple => 'All HBA are ok' } + ]; + + $self->{maps_counters}->{hba} = [ + { label => 'read-iops', set => { + key_values => [ { name => 'read_iops' }, { name => 'display' } ], + output_template => 'Read IOPs : %s', + perfdatas => [ + { label => 'read_iops', value => 'read_iops_absolute', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'read-usage', set => { + key_values => [ { name => 'read_bps' }, { name => 'display' } ], + output_template => 'Read usage : %s %s/s', + output_change_bytes => 2, + perfdatas => [ + { label => 'read_usage', value => 'read_bps_absolute', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'read-latency', set => { + key_values => [ { name => 'read_latency' }, { name => 'display' } ], + output_template => 'Read latency : %s ms', + perfdatas => [ + { label => 'read_latency', value => 'read_latency_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'write-iops', set => { + key_values => [ { name => 'write_iops' }, { name => 'display' } ], + output_template => 'Write IOPs : %s', + perfdatas => [ + { label => 'write_iops', value => 'write_iops_absolute', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'write-usage', set => { + key_values => [ { name => 'write_bps' }, { name => 'display' } ], + output_template => 'Write Usage : %s %s/s', + output_change_bytes => 2, + perfdatas => [ + { label => 'write_usage', value => 'write_bps_absolute', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'write-latency', set => { + key_values => [ { name => 'write_latency' }, { name => 'display' } ], + output_template => 'Write Latency : %s ms', + perfdatas => [ + { label => 'write_latency', value => 'write_latency_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_hba_output { + my ($self, %options) = @_; + + return "HBA '" . $options{instance_value}->{display} . "' "; +} + +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 => + { + "cem-host:s" => { name => 'cem_host' }, + "cem-user:s" => { name => 'cem_user' }, + "cem-password:s" => { name => 'cem_password' }, + "cem-port:s" => { name => 'cem_port', default => 3033 }, + "sdk-path-dll:s" => { name => 'sdk_path_dll' }, + "timeout:s" => { name => 'timeout', default => 50 }, + "command:s" => { name => 'command', default => 'powershell.exe' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, + "no-ps" => { name => 'no_ps' }, + "ps-exec-only" => { name => 'ps_exec_only' }, + "ps-sc-filter:s" => { name => 'ps_sc_filter' }, + "start-time:s" => { name => 'start_time' }, + "end-time:s" => { name => 'end_time' }, + "timezone:s" => { name => 'timezone' }, + }); + return $self; +} + +sub get_iso8601 { + my ($self, %options) = @_; + my $value = $options{date}->datetime . '.' . sprintf("%03d", $options{date}->millisecond()); + my $offset = $options{date}->offset(); + + $value .= "-" if ($offset < 0); + $value .= "+" if ($offset >= 0); + $offset = abs($offset); + $value .= sprintf("%02d:%02d", $offset / 3600, $offset % 3600); + + return $value; +} + +sub parse_date { + my ($self, %options) = @_; + + if ($options{date} !~ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/) { + $self->{output}->add_option_msg(short_msg => "Wrong time option '" . $options{date} . "'."); + $self->{output}->option_exit(); + } + + my $dt = DateTime->new(year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6, + time_zone => $self->{option_results}->{timezone}); + return $dt; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); + foreach my $label (('cem_host', 'cem_user', 'cem_password', 'cem_port', 'sdk_path_dll')) { + if (!defined($self->{option_results}->{$label}) || $self->{option_results}->{$label} eq '') { + my ($label_opt) = $label; + $label_opt =~ tr/_/-/; + $self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option."); + $self->{output}->option_exit(); + } + } + + my ($dt_start, $dt_end); + if (defined($self->{option_results}->{end_time}) && $self->{option_results}->{end_time} ne '') { + $dt_end = $self->parse_date(date => $self->{option_results}->{end_time}); + } else { + $dt_end = DateTime->now(time_zone => $self->{option_results}->{timezone}); + } + $self->{end_time} = $self->get_iso8601(date => $dt_end); + + if (defined($self->{option_results}->{start_time}) && $self->{option_results}->{start_time} ne '') { + $dt_start = $self->parse_date(date => $self->{option_results}->{start_time}); + } else { + $dt_start = $dt_end->subtract(minutes => 30); + } + $self->{start_time} = $self->get_iso8601(date => $dt_start); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $ps = centreon::common::powershell::dell::compellent::hbausage::get_powershell(cem_host => $self->{option_results}->{cem_host}, + cem_user => $self->{option_results}->{cem_user}, + cem_password => $self->{option_results}->{cem_password}, + cem_port => $self->{option_results}->{cem_port}, + sdk_path_dll => $self->{option_results}->{sdk_path_dll}, + no_ps => $self->{option_results}->{no_ps}, + filter_sc => $self->{option_results}->{ps_sc_filter}, + end_time => $self->{end_time}, start_time => $self->{start_time}); + + $self->{option_results}->{command_options} .= " " . $ps; + my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, + timeout => $self->{option_results}->{timeout}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + if (defined($self->{option_results}->{ps_exec_only})) { + $self->{output}->output_add(severity => 'OK', + short_msg => $stdout); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); + } + + # microseconds for latencies + #[sc=PRD-SAN-01][name=xxxx][ReadIops=39,5][ReadKbPerSecond=1220,75][ReadLatency=3997][WriteIops=95,75][WriteKbPerSecond=1217][WriteLatency=3903,25] + $self->{hba} = {}; + $stdout =~ s/,/\./msg; + while ($stdout =~ /^\[sc=(.*?)\]\[name=(.*?)\]\[ReadIops=(.*?)\]\[ReadKbPerSecond=(.*?)\]\[ReadLatency=(.*?)\]\[WriteIops=(.*?)\]\[WriteKbPerSecond=(.*?)\]\[WriteLatency=(.*?)\]/mig) { + my ($sc, $name, $read_iops, $read_kbps, $read_latency, $write_iops, $write_kbps, $write_latency) = + ($1, $2, $3, $4, $5, $6, $7, $8); + my $display = $sc . '/' . $name; + + $self->{hba}->{$name} = { display => $display, read_iops => $read_iops, read_bps => $read_kbps * 1000, read_latency => $read_latency / 1000, + write_iops => $write_iops, write_bps => $write_kbps * 1000, write_latency => $write_latency / 1000 }; + } +} + +1; + +__END__ + +=head1 MODE + +Check hba usages. + +=over 8 + +=item B<--cem-host> + +Compellent Entreprise Manager hostname (Required). + +=item B<--cem-user> + +Compellent Entreprise Manager username (Required). + +=item B<--cem-password> + +Compellent Entreprise Manager password (Required). + +=item B<--cem-port> + +Compellent Entreprise Manager port (Default: 3033). + +=item B<--sdk-path-dll> + +Path to 'DellStorage.ApiCommandSet.dll' (Required). + +=item B<--timeout> + +Set timeout time for command execution (Default: 50 sec) + +=item B<--no-ps> + +Don't encode powershell. To be used with --command and 'type' command. + +=item B<--command> + +Command to get information (Default: 'powershell.exe'). +Can be changed if you have output in a file. To be used with --no-ps option!!! + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-InputFormat none -NoLogo -EncodedCommand'). + +=item B<--ps-exec-only> + +Print powershell output. + +=item B<--ps-sc-filter> + +Filter Storage Center (only wilcard '*' can be used. In Powershell). + +=item B<--start-time> + +Begin time for counters sampling. If not set, 30 minutes before the end-time option or current time +Format: 2016-05-25T10:30:00 + +=item B<--end-time> + +End time for counters sampling. If not set, the current execution time. +Format: 2016-05-25T15:30:00 + +=item B<--timezone> + +Timezone of time options. Default is 'GMT'. + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^read-iops$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'read-iops', 'read-usage', 'read-latency', +'write-iops', 'write-usage', 'write-latency'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'read-iops', 'read-usage', 'read-latency', +'write-iops', 'write-usage', 'write-latency'. + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm b/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm new file mode 100644 index 000000000..b7062968f --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm @@ -0,0 +1,352 @@ +# +# Copyright 2016 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::dell::compellent::local::mode::volumeusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::common::powershell::dell::compellent::volumeusage; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'sc', type => 1, cb_prefix_output => 'prefix_sc_output', message_multiple => 'All storage centers are ok', cb_init => 'sc_init' }, + { name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All volumes are ok' } + ]; + $self->{maps_counters}->{sc} = [ + { label => 'sc-total', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' }, { name => 'type' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{volume} = [ + { label => 'volume-usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' }, { name => 'type' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + { label => 'volume-overhead', set => { + key_values => [ { name => 'overhead' }, { name => 'display' } ], + output_template => 'Raid Overhead : %s %s', + output_change_bytes => 1, + perfdatas => [ + { label => 'volume_overhead', value => 'overhead_absolute', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'volume-replay', set => { + key_values => [ { name => 'replay' }, { name => 'display' } ], + output_template => 'Replay : %s %s', + output_change_bytes => 1, + perfdatas => [ + { label => 'volume_replay', value => 'replay_absolute', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_sc_output { + my ($self, %options) = @_; + + return "Storage center '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_volume_output { + my ($self, %options) = @_; + + return "Volume '" . $options{instance_value}->{display} . "' "; +} + +sub sc_init { + my ($self, %options) = @_; + + if (defined($self->{option_results}->{ps_sc_volume}) && $self->{option_results}->{ps_sc_volume} ne '') { + return 1; + } + return 0; +} + +my $instance_mode; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = $self->{result_values}->{type} . '_used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = $self->{result_values}->{type} . '_free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; + + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + # snapshot can be over 100% + if ($self->{result_values}->{free} < 0) { + $self->{result_values}->{free} = 0; + $self->{result_values}->{prct_free} = 0; + } + + 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 => + { + "cem-host:s" => { name => 'cem_host' }, + "cem-user:s" => { name => 'cem_user' }, + "cem-password:s" => { name => 'cem_password' }, + "cem-port:s" => { name => 'cem_port', default => 3033 }, + "sdk-path-dll:s" => { name => 'sdk_path_dll' }, + "timeout:s" => { name => 'timeout', default => 50 }, + "command:s" => { name => 'command', default => 'powershell.exe' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, + "no-ps" => { name => 'no_ps' }, + "ps-exec-only" => { name => 'ps_exec_only' }, + "ps-sc-filter:s" => { name => 'ps_sc_filter' }, + "ps-sc-volume:s" => { name => 'ps_sc_volume' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + foreach my $label (('cem_host', 'cem_user', 'cem_password', 'cem_port', 'sdk_path_dll')) { + if (!defined($self->{option_results}->{$label}) || $self->{option_results}->{$label} eq '') { + my ($label_opt) = $label; + $label_opt =~ tr/_/-/; + $self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option."); + $self->{output}->option_exit(); + } + } + + $instance_mode = $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $ps = centreon::common::powershell::dell::compellent::volumeusage::get_powershell(cem_host => $self->{option_results}->{cem_host}, + cem_user => $self->{option_results}->{cem_user}, + cem_password => $self->{option_results}->{cem_password}, + cem_port => $self->{option_results}->{cem_port}, + sdk_path_dll => $self->{option_results}->{sdk_path_dll}, + no_ps => $self->{option_results}->{no_ps}, + filter_sc => $self->{option_results}->{ps_sc_filter}); + + $self->{option_results}->{command_options} .= " " . $ps; + my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, + timeout => $self->{option_results}->{timeout}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + if (defined($self->{option_results}->{ps_exec_only})) { + $self->{output}->output_add(severity => 'OK', + short_msg => $stdout); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); + } + + # [sc=PRD-SAN-01][volume=SC-S06][configuredSpace=xxxxx][freeSpace=xxxxx][activeSpace=xxxxx][raidOverhead=xxx][totalDiskSpace=xxxx][replaySpace=xxxx] + $self->{volume} = {}; + $self->{sc} = {}; + while ($stdout =~ /^\[sc=(.*?)\]\[volume=(.*?)\]\[configuredSpace=(.*?)\]\[freeSpace=(.*?)\]\[activeSpace=(.*?)\]\[raidOverhead=(.*?)\]\[totalDiskSpace=(.*?)\]\[replaySpace=(.*?)\]/mig) { + my ($sc, $volume, $configured_space, $free_space, $active_space, $raid_overhead, $total_disk_space, $replay_space) = + ($1, $2, $3, $4, $5, $6, $7, $8); + my $name = $sc . '/' . $volume; + + $self->{volume}->{$name} = { display => $name, total => $configured_space, type => 'volume', + used => $active_space + $raid_overhead + $replay_space, + overhead => $raid_overhead, replay => $replay_space}; + $self->{sc}->{$sc} = { display => $sc, total => 0, used => 0, type => 'sc' } if (!defined($self->{sc}->{$sc})); + $self->{sc}->{$sc}->{used} += $active_space + $raid_overhead + $replay_space; + } + + # [sc=PRD-SAN-01][disk=01-01][spare=False][allocatedSpace=960195723264] + while ($stdout =~ /^\[sc=(.*?)\]\[disk=(.*?)\]\[spare=(.*?)\]\[allocatedSpace=(.*?)\]/mig) { + my ($sc, $disk, $spare, $allocated_space) = + ($1, $2, $3, $4); + $self->{sc}->{$sc}->{total} += $allocated_space; + } +} + +1; + +__END__ + +=head1 MODE + +Check storage center and volume usages. + +=over 8 + +=item B<--cem-host> + +Compellent Entreprise Manager hostname (Required). + +=item B<--cem-user> + +Compellent Entreprise Manager username (Required). + +=item B<--cem-password> + +Compellent Entreprise Manager password (Required). + +=item B<--cem-port> + +Compellent Entreprise Manager port (Default: 3033). + +=item B<--sdk-path-dll> + +Path to 'DellStorage.ApiCommandSet.dll' (Required). + +=item B<--timeout> + +Set timeout time for command execution (Default: 50 sec) + +=item B<--no-ps> + +Don't encode powershell. To be used with --command and 'type' command. + +=item B<--command> + +Command to get information (Default: 'powershell.exe'). +Can be changed if you have output in a file. To be used with --no-ps option!!! + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '-InputFormat none -NoLogo -EncodedCommand'). + +=item B<--ps-exec-only> + +Print powershell output. + +=item B<--ps-sc-filter> + +Filter Storage Center (only wilcard '*' can be used. In Powershell). + +=item B<--ps-sc-volume> + +Filter Volume Name to display. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^sc-total$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'sc-total', 'volume-usage', 'volume-overhead', 'volume-replay'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'sc-total', 'volume-usage', 'volume-overhead', 'volume-replay'. + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/local/plugin.pm b/centreon-plugins/storage/dell/compellent/local/plugin.pm new file mode 100644 index 000000000..64e94e7aa --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/local/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2016 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::dell::compellent::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'hba-usage' => 'storage::dell::compellent::local::mode::hbausage', + 'volume-usage' => 'storage::dell::compellent::local::mode::volumeusage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Dell Compellent Storage. Need Dell Storage PowerShell SDK. + +=cut diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/cache.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/cache.pm new file mode 100644 index 000000000..54e329b67 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/cache.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::cache; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scCacheStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1.3', map => \%map_sc_status }, + scCacheName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1.4' }, +}; +my $oid_scCacheEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scCacheEntry, begin => $mapping->{scCacheStatus}->{oid}, end => $mapping->{scCacheName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking caches"); + $self->{components}->{cache} = {name => 'caches', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cache')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCacheEntry}})) { + next if ($oid !~ /^$mapping->{scCacheStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCacheEntry}, instance => $instance); + + next if ($self->check_filter(section => 'cache', instance => $instance)); + $self->{components}->{cache}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cache '%s' status is '%s' [instance = %s]", + $result->{scCacheName}, $result->{scCacheStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'cache', value => $result->{scCacheStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cache '%s' status is '%s'", $result->{scCacheName}, $result->{scCacheStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrl.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrl.pm new file mode 100644 index 000000000..534a668bf --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrl.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::ctrl; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scCtlrStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1.3', map => \%map_sc_status }, + scCtlrName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1.4' }, +}; +my $oid_scCtlrEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scCtlrEntry, begin => $mapping->{scCtlrStatus}->{oid}, end => $mapping->{scCtlrName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controllers"); + $self->{components}->{ctrl} = {name => 'controllers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'ctrl')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCtlrEntry}})) { + next if ($oid !~ /^$mapping->{scCtlrStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCtlrEntry}, instance => $instance); + + next if ($self->check_filter(section => 'ctrl', instance => $instance)); + $self->{components}->{ctrl}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("controller '%s' status is '%s' [instance = %s]", + $result->{scCtlrName}, $result->{scCtlrStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'ctrl', value => $result->{scCtlrStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Controller '%s' status is '%s'", $result->{scCtlrName}, $result->{scCtlrStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlfan.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlfan.pm new file mode 100644 index 000000000..f896432bd --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlfan.pm @@ -0,0 +1,102 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::ctrlfan; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scCtlrFanStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.3', map => \%map_sc_status }, + scCtlrFanName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.4' }, + scCtlrFanCurrentRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.5' }, + scCtlrFanWarnLwrRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.8' }, + scCtlrFanWarnUprRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.9' }, + scCtlrFanCritLwrRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.10' }, + scCtlrFanCritUprRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.11' }, +}; +my $oid_scCtlrFanEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scCtlrFanEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controller fans"); + $self->{components}->{ctrlfan} = {name => 'controller fans', total => 0, skip => 0}; + return if ($self->check_filter(section => 'ctrlfan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCtlrFanEntry}})) { + next if ($oid !~ /^$mapping->{scCtlrFanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCtlrFanEntry}, instance => $instance); + + next if ($self->check_filter(section => 'ctrlfan', instance => $instance)); + + $self->{components}->{ctrlfan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("controller fan '%s' status is '%s' [instance = %s] [value = %s]", + $result->{scCtlrFanName}, $result->{scCtlrFanStatus}, $instance, + $result->{scCtlrFanCurrentRpm})); + + my $exit = $self->get_severity(label => 'default', section => 'ctrlfan', value => $result->{scCtlrFanStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Controller fan '%s' status is '%s'", $result->{scCtlrFanName}, $result->{scCtlrFanStatus})); + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'ctrlfan', instance => $instance, value => $result->{scCtlrFanCurrentRpm}); + if ($checked == 0) { + $result->{scCtlrFanWarnLwrRpm} = (defined($result->{scCtlrFanWarnLwrRpm}) && $result->{scCtlrFanWarnLwrRpm} =~ /[0-9]/) ? + $result->{scCtlrFanWarnLwrRpm} : ''; + $result->{scCtlrFanCritLwrRpm} = (defined($result->{scCtlrFanCritLwrRpm}) && $result->{scCtlrFanCritLwrRpm} =~ /[0-9]/) ? + $result->{scCtlrFanCritLwrRpm} : ''; + $result->{scCtlrFanWarnUprRpm} = (defined($result->{scCtlrFanWarnUprRpm}) && $result->{scCtlrFanWarnUprRpm} =~ /[0-9]/) ? + $result->{scCtlrFanWarnUprRpm} : ''; + $result->{scCtlrFanCritUprRpm} = (defined($result->{scCtlrFanCritUprRpm}) && $result->{scCtlrFanCritUprRpm} =~ /[0-9]/) ? + $result->{scCtlrFanCritUprRpm} : ''; + my $warn_th = $result->{scCtlrFanWarnLwrRpm} . ':' . $result->{scCtlrFanWarnUprRpm}; + my $crit_th = $result->{scCtlrFanCritLwrRpm} . ':' . $result->{scCtlrFanCritUprRpm}; + $self->{perfdata}->threshold_validate(label => 'warning-ctrlfan-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-ctrlfan-instance-' . $instance, value => $crit_th); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-ctrlfan-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-ctrlfan-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Controller fan '%s' is %s rpm", $result->{scCtlrFanName}, $result->{scCtlrFanCurrentRpm})); + } + $self->{output}->perfdata_add(label => 'ctrlfan_' . $instance, unit => 'rpm', + value => $result->{scCtlrFanCurrentRpm}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlpower.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlpower.pm new file mode 100644 index 000000000..cad63091e --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlpower.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::ctrlpower; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scCtlrPowerStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.17.1.3', map => \%map_sc_status }, + scCtlrPowerName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.17.1.4' }, +}; +my $oid_scCtlrPowerEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.17.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scCtlrPowerEntry, begin => $mapping->{scCtlrPowerStatus}->{oid}, end => $mapping->{scCtlrPowerName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controller power supplies"); + $self->{components}->{ctrlpower} = {name => 'controller psus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'ctrlpower')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCtlrPowerEntry}})) { + next if ($oid !~ /^$mapping->{scCtlrPowerStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCtlrPowerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'ctrlpower', instance => $instance)); + $self->{components}->{ctrlpower}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("controller power supply '%s' status is '%s' [instance = %s]", + $result->{scCtlrPowerName}, $result->{scCtlrPowerStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'ctrlpower', value => $result->{scCtlrPowerStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Controller power supply '%s' status is '%s'", $result->{scCtlrPowerName}, $result->{scCtlrPowerStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrltemp.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrltemp.pm new file mode 100644 index 000000000..ef0d76f94 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrltemp.pm @@ -0,0 +1,101 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::ctrltemp; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scCtlrTempStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.3', map => \%map_sc_status }, + scCtlrTempName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.4' }, + scCtlrTempCurrentC => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.5' }, + scCtlrTempWarnLwrC => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.8' }, + scCtlrTempWarnUprC => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.9' }, + scCtlrTempCritLwrC => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.10' }, + scCtlrTempCritUprC => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1.11' }, +}; +my $oid_scCtlrTempEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.19.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scCtlrTempEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controller temperatures"); + $self->{components}->{ctrltemp} = {name => 'controller temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'ctrltemp')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCtlrTempEntry}})) { + next if ($oid !~ /^$mapping->{scCtlrTempStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCtlrTempEntry}, instance => $instance); + + next if ($self->check_filter(section => 'ctrltemp', instance => $instance)); + + $self->{components}->{ctrltemp}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("controller temperature '%s' status is '%s' [instance = %s] [value = %s]", + $result->{scCtlrTempName}, $result->{scCtlrTempStatus}, $instance, + $result->{scCtlrTempCurrentC})); + + my $exit = $self->get_severity(label => 'default', section => 'ctrltemp', value => $result->{scCtlrTempStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Controller temperature '%s' status is '%s'", $result->{scCtlrTempName}, $result->{scCtlrTempStatus})); + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'ctrltemp', instance => $instance, value => $result->{scCtlrTempCurrentC}); + if ($checked == 0) { + $result->{scCtlrTempWarnLwrC} = (defined($result->{scCtlrTempWarnLwrC}) && $result->{scCtlrTempWarnLwrC} =~ /[0-9]/) ? + $result->{scCtlrTempWarnLwrC} : ''; + $result->{scCtlrTempCritLwrC} = (defined($result->{scCtlrTempCritLwrC}) && $result->{scCtlrTempCritLwrC} =~ /[0-9]/) ? + $result->{scCtlrTempCritLwrC} : ''; + $result->{scCtlrTempWarnUprC} = (defined($result->{scCtlrTempWarnUprC}) && $result->{scCtlrTempWarnUprC} =~ /[0-9]/) ? + $result->{scCtlrTempWarnUprC} : ''; + $result->{scCtlrTempCritUprC} = (defined($result->{scCtlrTempCritUprC}) && $result->{scCtlrTempCritUprC} =~ /[0-9]/) ? + $result->{scCtlrTempCritUprC} : ''; + my $warn_th = $result->{scCtlrTempWarnLwrC} . ':' . $result->{scCtlrTempWarnUprC}; + my $crit_th = $result->{scCtlrTempCritLwrC} . ':' . $result->{scCtlrTempCritUprC}; + $self->{perfdata}->threshold_validate(label => 'warning-ctrltemp-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-ctrltemp-instance-' . $instance, value => $crit_th); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-ctrltemp-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-ctrltemp-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Controller temperature '%s' is %s C", $result->{scCtlrTempName}, $result->{scCtlrTempCurrentC})); + } + $self->{output}->perfdata_add(label => 'ctrltemp_' . $instance, unit => 'C', + value => $result->{scCtlrTempCurrentC}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlvoltage.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlvoltage.pm new file mode 100644 index 000000000..275e85220 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/ctrlvoltage.pm @@ -0,0 +1,101 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::ctrlvoltage; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scCtlrVoltageStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.3', map => \%map_sc_status }, + scCtlrVoltageName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.4' }, + scCtlrVoltageCurrentV => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.5' }, + scCtlrVoltageWarnLwrV => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.8' }, + scCtlrVoltageWarnUprV => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.9' }, + scCtlrVoltageCritLwrV => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.10' }, + scCtlrVoltageCritUprV => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1.11' }, +}; +my $oid_scCtlrVoltageEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.18.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scCtlrVoltageEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controller voltages"); + $self->{components}->{ctrlvoltage} = {name => 'controller voltages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'ctrlvoltage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCtlrVoltageEntry}})) { + next if ($oid !~ /^$mapping->{scCtlrVoltageStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCtlrVoltageEntry}, instance => $instance); + + next if ($self->check_filter(section => 'ctrlvoltage', instance => $instance)); + + $self->{components}->{ctrlvoltage}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("controller voltage '%s' status is '%s' [instance = %s] [value = %s]", + $result->{scCtlrVoltageName}, $result->{scCtlrVoltageStatus}, $instance, + $result->{scCtlrVoltageCurrentV})); + + my $exit = $self->get_severity(label => 'default', section => 'ctrlvoltage', value => $result->{scCtlrVoltageStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Controller voltage '%s' status is '%s'", $result->{scCtlrVoltageName}, $result->{scCtlrVoltageStatus})); + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'ctrlvoltage', instance => $instance, value => $result->{scCtlrVoltageCurrentV}); + if ($checked == 0) { + $result->{scCtlrVoltageWarnLwrV} = (defined($result->{scCtlrVoltageWarnLwrV}) && $result->{scCtlrVoltageWarnLwrV} =~ /[0-9]/) ? + $result->{scCtlrVoltageWarnLwrV} : ''; + $result->{scCtlrVoltageCritLwrV} = (defined($result->{scCtlrVoltageCritLwrV}) && $result->{scCtlrVoltageCritLwrV} =~ /[0-9]/) ? + $result->{scCtlrVoltageCritLwrV} : ''; + $result->{scCtlrVoltageWarnUprV} = (defined($result->{scCtlrVoltageWarnUprV}) && $result->{scCtlrVoltageWarnUprV} =~ /[0-9]/) ? + $result->{scCtlrVoltageWarnUprV} : ''; + $result->{scCtlrVoltageCritUprV} = (defined($result->{scCtlrVoltageCritUprV}) && $result->{scCtlrVoltageCritUprV} =~ /[0-9]/) ? + $result->{scCtlrVoltageCritUprV} : ''; + my $warn_th = $result->{scCtlrVoltageWarnLwrV} . ':' . $result->{scCtlrVoltageWarnUprV}; + my $crit_th = $result->{scCtlrVoltageCritLwrV} . ':' . $result->{scCtlrVoltageCritUprV}; + $self->{perfdata}->threshold_validate(label => 'warning-ctrlvoltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-ctrlvoltage-instance-' . $instance, value => $crit_th); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-ctrlvoltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-ctrlvoltage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Controller voltage '%s' is %s V", $result->{scCtlrVoltageName}, $result->{scCtlrVoltageCurrentV})); + } + $self->{output}->perfdata_add(label => 'ctrlvoltage_' . $instance, unit => 'V', + value => $result->{scCtlrVoltageCurrentV}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/disk.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/disk.pm new file mode 100644 index 000000000..e8ac28059 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/disk.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::disk; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scDiskStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.14.1.3', map => \%map_sc_status }, + scDiskNamePosition => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.14.1.4' }, +}; +my $oid_scDiskEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.14.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scDiskEntry, begin => $mapping->{scDiskStatus}->{oid}, end => $mapping->{scDiskNamePosition}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking disks"); + $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'disk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scDiskEntry}})) { + next if ($oid !~ /^$mapping->{scDiskStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scDiskEntry}, instance => $instance); + + next if ($self->check_filter(section => 'disk', instance => $instance)); + $self->{components}->{disk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("disk '%s' status is '%s' [instance = %s]", + $result->{scDiskNamePosition}, $result->{scDiskStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'disk', value => $result->{scDiskStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Disk '%s' status is '%s'", $result->{scDiskNamePosition}, $result->{scDiskStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/encl.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/encl.pm new file mode 100644 index 000000000..19e85cb00 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/encl.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::encl; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scEnclStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.15.1.3', map => \%map_sc_status }, + scEnclName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.15.1.4' }, +}; +my $oid_scEnclEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.15.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scEnclEntry, begin => $mapping->{scEnclStatus}->{oid}, end => $mapping->{scEnclName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosures"); + $self->{components}->{encl} = {name => 'enclosures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'encl')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scEnclEntry}})) { + next if ($oid !~ /^$mapping->{scEnclStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scEnclEntry}, instance => $instance); + + next if ($self->check_filter(section => 'encl', instance => $instance)); + $self->{components}->{encl}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure '%s' status is '%s' [instance = %s]", + $result->{scEnclName}, $result->{scEnclStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'encl', value => $result->{scEnclStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure '%s' status is '%s'", $result->{scEnclName}, $result->{scEnclStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/enclfan.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/enclfan.pm new file mode 100644 index 000000000..9794bc204 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/enclfan.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::enclfan; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scEnclFanStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.20.1.3', map => \%map_sc_status }, + scEnclFanLocation => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.20.1.4' }, +}; +my $oid_scEnclFanEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.20.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scEnclFanEntry, begin => $mapping->{scEnclFanStatus}->{oid}, end => $mapping->{scEnclFanLocation}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure fans"); + $self->{components}->{enclfan} = {name => 'enclosure fans', total => 0, skip => 0}; + return if ($self->check_filter(section => 'enclfan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scEnclFanEntry}})) { + next if ($oid !~ /^$mapping->{scEnclFanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scEnclFanEntry}, instance => $instance); + + next if ($self->check_filter(section => 'enclfan', instance => $instance)); + $self->{components}->{enclfan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure fan '%s' status is '%s' [instance = %s]", + $result->{scEnclFanLocation}, $result->{scEnclFanStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'enclfan', value => $result->{scEnclFanStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure fan '%s' status is '%s'", $result->{scEnclFanLocation}, $result->{scEnclFanStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/encliomod.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/encliomod.pm new file mode 100644 index 000000000..5bbcbd137 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/encliomod.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::encliomod; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scEnclIoModStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.22.1.3', map => \%map_sc_status }, + scEnclIoModPosition => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.22.1.4' }, +}; +my $oid_scEnclIoModEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.22.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scEnclIoModEntry, begin => $mapping->{scEnclIoModStatus}->{oid}, end => $mapping->{scEnclIoModPosition}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure I/O modules"); + $self->{components}->{encliomod} = {name => 'enclosure I/O modules', total => 0, skip => 0}; + return if ($self->check_filter(section => 'encliomod')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scEnclIoModEntry}})) { + next if ($oid !~ /^$mapping->{scEnclIoModStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scEnclIoModEntry}, instance => $instance); + + next if ($self->check_filter(section => 'encliomod', instance => $instance)); + $self->{components}->{encliomod}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure I/O module '%s' status is '%s' [instance = %s]", + $result->{scEnclIoModPosition}, $result->{scEnclIoModStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'encliomod', value => $result->{scEnclIoModStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure I/O module '%s' status is '%s'", $result->{scEnclIoModPosition}, $result->{scEnclIoModStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/enclpower.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/enclpower.pm new file mode 100644 index 000000000..36105d2ba --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/enclpower.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::enclpower; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scEnclPowerStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.21.1.3', map => \%map_sc_status }, + scEnclPowerPosition => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.21.1.4' }, +}; +my $oid_scEnclPowerEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.21.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scEnclPowerEntry, begin => $mapping->{scEnclPowerStatus}->{oid}, end => $mapping->{scEnclPowerPosition}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure power supplies"); + $self->{components}->{enclpower} = {name => 'enclosure psus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'enclpower')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scEnclPowerEntry}})) { + next if ($oid !~ /^$mapping->{scEnclPowerStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scEnclPowerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'enclpower', instance => $instance)); + $self->{components}->{enclpower}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure power supply '%s' status is '%s' [instance = %s]", + $result->{scEnclPowerPosition}, $result->{scEnclPowerStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'enclpower', value => $result->{scEnclPowerStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure power supply '%s' status is '%s'", $result->{scEnclPowerPosition}, $result->{scEnclPowerStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/encltemp.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/encltemp.pm new file mode 100644 index 000000000..0c60642c1 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/encltemp.pm @@ -0,0 +1,80 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::encltemp; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scEnclTempStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.23.1.3', map => \%map_sc_status }, + scEnclTempLocation => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.23.1.4' }, + scEnclTempCurrentC => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.23.1.5' }, +}; +my $oid_scEnclTempEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.23.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scEnclTempEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure temperatures"); + $self->{components}->{encltemp} = {name => 'enclosure temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'encltemp')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scEnclTempEntry}})) { + next if ($oid !~ /^$mapping->{scEnclTempStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scEnclTempEntry}, instance => $instance); + + next if ($self->check_filter(section => 'encltemp', instance => $instance)); + + $self->{components}->{encltemp}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure temperature '%s' status is '%s' [instance = %s] [value = %s]", + $result->{scEnclTempLocation}, $result->{scEnclTempStatus}, $instance, + $result->{scEnclTempCurrentC})); + + my $exit = $self->get_severity(label => 'default', section => 'encltemp', value => $result->{scEnclTempStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure temperature '%s' status is '%s'", $result->{scEnclTempLocation}, $result->{scEnclTempStatus})); + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'encltemp', instance => $instance, value => $result->{scEnclTempCurrentC}); + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Enclosure temperature '%s' is %s C", $result->{scEnclTempLocation}, $result->{scEnclTempCurrentC})); + } + $self->{output}->perfdata_add(label => 'encltemp_' . $instance, unit => 'C', + value => $result->{scEnclTempCurrentC}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/resources.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/resources.pm new file mode 100644 index 000000000..206e7dbf4 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/resources.pm @@ -0,0 +1,38 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %map_sc_status; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(%map_sc_status); + +%map_sc_status = ( + 1 => 'up', + 2 => 'down', + 3 => 'degraded', +); + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/sc.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/sc.pm new file mode 100644 index 000000000..fcb4ec115 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/sc.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::sc; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scScStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.29.1.3', map => \%map_sc_status }, + scScName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.29.1.4' }, +}; +my $oid_scScEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.29.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scScEntry, begin => $mapping->{scScStatus}->{oid}, end => $mapping->{scScName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking storage centers"); + $self->{components}->{sc} = {name => 'storage centers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'sc')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scScEntry}})) { + next if ($oid !~ /^$mapping->{scScStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scScEntry}, instance => $instance); + + next if ($self->check_filter(section => 'sc', instance => $instance)); + $self->{components}->{sc}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("storage center '%s' status is '%s' [instance = %s]", + $result->{scScName}, $result->{scScStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'sc', value => $result->{scScStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Storage center '%s' status is '%s'", $result->{scScName}, $result->{scScStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/server.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/server.pm new file mode 100644 index 000000000..802ca7c8e --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/server.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::server; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scServerStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.27.1.3', map => \%map_sc_status }, + scServerName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.27.1.4' }, +}; +my $oid_scServerEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.27.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scServerEntry, begin => $mapping->{scServerStatus}->{oid}, end => $mapping->{scServerName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking servers"); + $self->{components}->{server} = {name => 'servers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'server')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scServerEntry}})) { + next if ($oid !~ /^$mapping->{scServerStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scServerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'server', instance => $instance)); + $self->{components}->{server}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("server '%s' status is '%s' [instance = %s]", + $result->{scServerName}, $result->{scServerStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'server', value => $result->{scServerStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Server '%s' status is '%s'", $result->{scServerName}, $result->{scServerStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/components/volume.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/components/volume.pm new file mode 100644 index 000000000..6e31d56b4 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/components/volume.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::components::volume; + +use strict; +use warnings; +use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); + +my $mapping = { + scVolumeStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.26.1.3', map => \%map_sc_status }, + scVolumeName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.26.1.4' }, +}; +my $oid_scVolumeEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.26.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_scVolumeEntry, begin => $mapping->{scVolumeStatus}->{oid}, end => $mapping->{scVolumeName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking volumes"); + $self->{components}->{volume} = {name => 'volumes', total => 0, skip => 0}; + return if ($self->check_filter(section => 'volume')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scVolumeEntry}})) { + next if ($oid !~ /^$mapping->{scVolumeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scVolumeEntry}, instance => $instance); + + next if ($self->check_filter(section => 'volume', instance => $instance)); + $self->{components}->{volume}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("volume '%s' status is '%s' [instance = %s]", + $result->{scVolumeName}, $result->{scVolumeStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'volume', value => $result->{scVolumeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Volume '%s' status is '%s'", $result->{scVolumeName}, $result->{scVolumeStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/mode/hardware.pm b/centreon-plugins/storage/dell/compellent/snmp/mode/hardware.pm new file mode 100644 index 000000000..e09232baa --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/mode/hardware.pm @@ -0,0 +1,114 @@ +# +# Copyright 2016 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::dell::compellent::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(ctrl|disk|encl|ctrlfan|ctrlpower|ctrlvoltage|ctrltemp|enclfan|enclpower|encliomod|encltemp|volume|cache|server|sc)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(ctrltemp|ctrlvoltage|ctrlfan|encltemp)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['up', 'OK'], + ['down', 'CRITICAL'], + ['degraded', 'WARNING'], + ], + }; + + $self->{components_path} = 'storage::dell::compellent::snmp::mode::components'; + $self->{components_module} = ['ctrl', 'disk', 'ctrlfan', 'ctrlpower', 'ctrlvoltage', 'ctrltemp', + 'encl', 'enclfan', 'enclpower', 'encliomod', 'encltemp', 'volume', 'cache', 'server', 'sc']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check sensors. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'ctrl', 'disk', 'encl', 'ctrlfan', 'ctrlpower', 'ctrlvoltage', +'ctrltemp', 'enclfan', 'enclpower', 'encliomod', 'encltemp', 'volume', 'cache', 'server', 'sc'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=ctrlfan --filter=enclpower) +Can also exclude specific instance: --filter=ctrlfan,1 + +=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='ctrl,CRITICAL,^(?!(up)$)' + +=item B<--warning> + +Set warning threshold for 'ctrltemp', 'ctrlfan', 'ctrlvoltage', 'encltemp' (syntax: type,regexp,threshold) +Example: --warning='ctrltemp,1,30' + +=item B<--critical> + +Set critical threshold for 'ctrltemp', 'ctrlfan', 'ctrlvoltage', 'encltemp' (syntax: type,regexp,threshold) +Example: --critical='ctrltemp,1,50' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/dell/compellent/snmp/plugin.pm b/centreon-plugins/storage/dell/compellent/snmp/plugin.pm new file mode 100644 index 000000000..050341b61 --- /dev/null +++ b/centreon-plugins/storage/dell/compellent/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::dell::compellent::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}} = ( + 'hardware' => 'storage::dell::compellent::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Dell Compellent in SNMP. + +=cut diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm index 6c30b783a..e331abb00 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -198,7 +198,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/disk.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/disk.pm index 02c458c34..d4b7e0581 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/disk.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/fan.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/fan.pm index 58f6aae4e..7145f95fb 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/fan.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/health.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/health.pm index b1c3638b7..8eb5f372b 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/health.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/health.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/psu.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/psu.pm index 20ecc167e..538130c3a 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/psu.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/raid.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/raid.pm index c9e539052..2c7be1655 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/raid.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/raid.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/temperature.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/temperature.pm index 0712fb070..9478523c0 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/components/temperature.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm index c84f4b4d0..36e4e33c8 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -142,7 +142,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/hardware.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/hardware.pm index f4b2bd01d..30cc22e06 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/hardware.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -165,7 +165,6 @@ sub get_member_name { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $snmp_request = [ { oid => $oid_eqlMemberName } ]; @@ -313,14 +312,14 @@ Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,regexp,treshold) +Set warning threshold for temperatures (syntax: type,regexp,threshold) Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: type,regexp,treshold) +Set critical threshold for temperatures (syntax: type,regexp,threshold) Example: --critical='temperature,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm index 5a0e44154..aa870964c 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -122,7 +122,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/dell/equallogic/snmp/plugin.pm b/centreon-plugins/storage/dell/equallogic/snmp/plugin.pm index ee4b3ee21..7ea205d59 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/plugin.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/dell/ml6000/snmp/plugin.pm b/centreon-plugins/storage/dell/ml6000/snmp/plugin.pm new file mode 100644 index 000000000..6dd742036 --- /dev/null +++ b/centreon-plugins/storage/dell/ml6000/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::dell::ml6000::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}} = ( + 'hardware' => 'centreon::common::adic::tape::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Dell ML6000 in SNMP. + +=cut diff --git a/centreon-plugins/storage/emc/DataDomain/lib/functions.pm b/centreon-plugins/storage/emc/DataDomain/lib/functions.pm index 136dc8a42..d42cb9c72 100644 --- a/centreon-plugins/storage/emc/DataDomain/lib/functions.pm +++ b/centreon-plugins/storage/emc/DataDomain/lib/functions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm index cb56fdedb..a8e07b8e1 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,12 +28,18 @@ my %map_battery_status = (); my ($oid_nvramBatteryStatus, $oid_nvramBatteryCharge); my $oid_nvramBatteryEntry = '.1.3.6.1.4.1.19746.1.2.3.1.1'; +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_nvramBatteryEntry }; +} + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking nvram batteries"); $self->{components}->{battery} = {name => 'nvram batteries', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'battery')); + return if ($self->check_filter(section => 'battery')); if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { $oid_nvramBatteryStatus = '.1.3.6.1.4.1.19746.1.2.3.1.1.3'; @@ -53,7 +59,7 @@ sub check { $map_battery_status{$self->{results}->{$oid_nvramBatteryEntry}->{$oid}} : 'unknown'; my $batt_value = $self->{results}->{$oid_nvramBatteryEntry}->{$oid_nvramBatteryCharge . '.' . $instance}; - next if ($self->check_exclude(section => 'battery', instance => $instance)); + next if ($self->check_filter(section => 'battery', instance => $instance)); next if ($batt_status =~ /disabled/i && $self->absent_problem(section => 'battery', instance => $instance)); diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm index 668c8b179..71247a6f7 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -35,19 +35,23 @@ my %map_disk_status = ( 6 => 'available', # since OS 5.4 ); -sub check { +sub load { my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking disks"); - $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'disk')); - my $oid_diskPropState; if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.8'; } else { $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.7'; } + push @{$self->{request}}, { oid => $oid_diskPropState }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking disks"); + $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'disk')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_diskPropState}})) { $oid =~ /^$oid_diskPropState\.(.*)$/; @@ -55,7 +59,7 @@ sub check { my $disk_status = defined($map_disk_status{$self->{results}->{$oid_diskPropState}->{$oid}}) ? $map_disk_status{$self->{results}->{$oid_diskPropState}->{$oid}} : 'unknown'; - next if ($self->check_exclude(section => 'disk', instance => $instance)); + next if ($self->check_filter(section => 'disk', instance => $instance)); next if ($disk_status =~ /absent/i && $self->absent_problem(section => 'disk', instance => $instance)); diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm index 63f4b207e..d6a711407 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -39,12 +39,18 @@ my %level_map = ( my ($oid_fanDescription, $oid_fanLevel, $oid_fanStatus); my $oid_fanPropertiesEntry = '.1.3.6.1.4.1.19746.1.1.3.1.1.1'; +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fanPropertiesEntry }; +} + 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_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { $oid_fanDescription = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.4'; @@ -64,7 +70,7 @@ sub check { $map_fan_status{$self->{results}->{$oid_fanPropertiesEntry}->{$oid}} : 'unknown'; my $fan_level = $self->{results}->{$oid_fanPropertiesEntry}->{$oid_fanLevel . '.' . $instance}; - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($fan_status =~ /notfound/i && $self->absent_problem(section => 'fan', instance => $instance)); diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm index e93b5eb0b..5b0225983 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -27,12 +27,18 @@ my %map_psu_status = (); my ($oid_powerModuleDescription, $oid_powerModuleStatus); my $oid_powerModuleEntry = '.1.3.6.1.4.1.19746.1.1.1.1.1.1'; +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerModuleEntry }; +} + 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_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { $oid_powerModuleDescription = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.3'; @@ -53,7 +59,7 @@ sub check { my $psu_status = defined($map_psu_status{$self->{results}->{$oid_powerModuleEntry}->{$oid}}) ? $map_psu_status{$self->{results}->{$oid_powerModuleEntry}->{$oid}} : 'unknown'; - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); next if ($psu_status =~ /absent/i && $self->absent_problem(section => 'psu', instance => $instance)); diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm index 98d7e8c70..b1c556246 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,12 +28,18 @@ my %map_temp_status = (); my ($oid_tempSensorDescription, $oid_tempSensorCurrentValue, $oid_tempSensorStatus); my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.19746.1.1.2.1.1.1'; +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_temperatureSensorEntry }; +} + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { $oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; @@ -57,7 +63,7 @@ sub check { $map_temp_status{$self->{results}->{$oid_temperatureSensorEntry}->{$oid}} : 'unknown'; my $temp_value = $self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorCurrentValue . '.' . $instance}; - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); next if ($temp_status =~ /absent|notfound/i && $self->absent_problem(section => 'temperature', instance => $instance)); diff --git a/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm b/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm index a52f80d39..10f207e40 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,35 +20,40 @@ package storage::emc::DataDomain::mode::filesystem; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; use storage::emc::DataDomain::lib::functions; -use centreon::plugins::values; -my $oid_fileSystemSpaceEntry = '.1.3.6.1.4.1.19746.1.3.2.1.1'; -my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' -my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceAvail); +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' }, + ]; + + $self->{maps_counters}->{fs} = [ + { label => 'usage', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_used_calc'), + closure_custom_output => $self->can('custom_used_output'), + threshold_use => 'used_prct', output_error_template => '%s', + perfdatas => [ + { value => 'used', label => 'used', cast_int => 1, + unit => 'B', min => 0, max => 'total', threshold_total => 'total', + label_extra_instance => 1, instance_use => 'display' }, + ], + } + }, + ]; +} -my $maps_counters = { - usage => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ - { name => 'free' }, { name => 'used' }, { name => 'display' }, - ], - closure_custom_calc => \&custom_used_calc, - closure_custom_output => \&custom_used_output, - threshold_use => 'used_prct', - output_error_template => '%s', - perfdatas => [ - { value => 'used', label => 'used', cast_int => 1, - unit => 'B', min => 0, max => 'total', threshold_total => 'total', - label_extra_instance => 1, instance_use => 'display' }, - ], - } - }, -}; +sub prefix_fs_output { + my ($self, %options) = @_; + + return "Filesystem '" . $options{instance_value}->{display} . "' "; +} sub custom_used_calc { my ($self, %options) = @_; @@ -87,113 +92,32 @@ sub new { "filesystem:s" => { name => 'filesystem' }, "regexp" => { name => 'use_regexp' }, "regexp-isensitive" => { name => 'use_regexpi' }, - }); - - $self->{filesystem_id_selected} = {}; - - foreach (keys %{$maps_counters}) { - $options{options}->add_options(arguments => { - 'warning-' . $_ . ':s' => { name => 'warning-' . $_ }, - 'critical-' . $_ . ':s' => { name => 'critical-' . $_ }, - }); - my $class = $maps_counters->{$_}->{class}; - $maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value}, - output => $self->{output}, perfdata => $self->{perfdata}, - label => $_); - $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); - } + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - foreach (keys %{$maps_counters}) { - $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - $self->manage_selection(); - - my $multiple = 1; - if (scalar(keys %{$self->{filesystem_id_selected}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All filesystems are ok.'); - } - - foreach my $id (sort keys %{$self->{filesystem_id_selected}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters}) { - $maps_counters->{$_}->{obj}->set(instance => $id); - - my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{filesystem_id_selected}->{$id}); - - if ($value_check != 0) { - $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); - $long_msg_append = ', '; - next; - } - my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); - push @exits, $exit2; - - my $output = $maps_counters->{$_}->{obj}->output(); - $long_msg .= $long_msg_append . $output; - $long_msg_append = ', '; - - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= $short_msg_append . $output; - $short_msg_append = ', '; - } - - $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); - } - - $self->{output}->output_add(long_msg => "Filesystem '" . $self->{filesystem_id_selected}->{$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 => "Filesystem '" . $self->{filesystem_id_selected}->{$id}->{display} . "' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "Filesystem '" . $self->{filesystem_id_selected}->{$id}->{display} . "' $long_msg"); - } - } - - $self->{output}->display(); - $self->{output}->exit(); -} +my $oid_fileSystemSpaceEntry = '.1.3.6.1.4.1.19746.1.3.2.1.1'; +my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' +my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceAvail); sub add_result { my ($self, %options) = @_; - $self->{filesystem_id_selected}->{$options{instance}} = {}; - $self->{filesystem_id_selected}->{$options{instance}}->{display} = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $options{instance}}; - $self->{filesystem_id_selected}->{$options{instance}}->{free} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceAvail . '.' . $options{instance}} * 1024 * 1024 * 1024); - $self->{filesystem_id_selected}->{$options{instance}}->{used} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceUsed . '.' . $options{instance}} * 1024 * 1024 * 1024); + $self->{fs}->{$options{instance}} = {}; + $self->{fs}->{$options{instance}}->{display} = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $options{instance}}; + $self->{fs}->{$options{instance}}->{free} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceAvail . '.' . $options{instance}} * 1024 * 1024 * 1024); + $self->{fs}->{$options{instance}}->{used} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceUsed . '.' . $options{instance}} * 1024 * 1024 * 1024); } sub manage_selection { my ($self, %options) = @_; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_sysDescr }, { oid => $oid_fileSystemSpaceEntry }, - ], - , nothing_quit => 1); + ], + nothing_quit => 1); if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => 'Cannot get DataDomain OS version.'); @@ -237,7 +161,7 @@ sub manage_selection { } } - if (scalar(keys %{$self->{filesystem_id_selected}}) <= 0 && !defined($options{disco})) { + if (scalar(keys %{$self->{fs}}) <= 0 && !defined($options{disco})) { if (defined($self->{option_results}->{device})) { $self->{output}->add_option_msg(short_msg => "No filesystem found '" . $self->{option_results}->{filesystem} . "'."); } else { @@ -256,16 +180,14 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1); - foreach (sort keys %{$self->{filesystem_id_selected}}) { - $self->{output}->add_disco_entry(name => $self->{filesystem_id_selected}->{$_}->{display}, + foreach (sort keys %{$self->{fs}}) { + $self->{output}->add_disco_entry(name => $self->{fs}->{$_}->{display}, deviceid => $_); } } - 1; __END__ diff --git a/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm b/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm index f7f7114e6..1c1ab4152 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,61 +20,70 @@ package storage::emc::DataDomain::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use storage::emc::DataDomain::lib::functions; -use storage::emc::DataDomain::mode::components::temperature; -use storage::emc::DataDomain::mode::components::psu; -use storage::emc::DataDomain::mode::components::fan; -use storage::emc::DataDomain::mode::components::disk; -use storage::emc::DataDomain::mode::components::battery; -my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' -my $oid_powerModuleEntry = '.1.3.6.1.4.1.19746.1.1.1.1.1.1'; -my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.19746.1.1.2.1.1.1'; -my $oid_fanPropertiesEntry = '.1.3.6.1.4.1.19746.1.1.3.1.1.1'; -my $oid_nvramBatteryEntry = '.1.3.6.1.4.1.19746.1.2.3.1.1'; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(fan|temperature|psu|disk|battery)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(battery|temperature)$'; + + $self->{cb_hook1} = 'get_version'; # before the loads + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['notfound', 'OK'], + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ], + temperature => [ + ['failed', 'CRITICAL'], + ['ok', 'OK'], + ['notfound', 'OK'], + ['absent', 'OK'], + ['overheatWarning', 'WARNING'], + ['overheatCritical', 'CRITICAL'], + ], + psu => [ + ['absent', 'OK'], + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ['faulty', 'WARNING'], + ['acnone', 'WARNING'], + ['unknown', 'UNKNOWN'], + ], + disk => [ + ['ok', 'OK'], + ['spare', 'OK'], + ['available', 'OK'], + ['unknown', 'UNKNOWN'], + ['absent', 'OK'], + ['failed', 'CRITICAL'], + ], + battery => [ + ['ok', 'OK'], + ['disabled', 'OK'], + ['discharged', 'WARNING'], + ['softdisabled', 'OK'], + ['UNKNOWN', 'UNKNOWN'], + ], + }; + + $self->{components_path} = 'storage::emc::DataDomain::mode::components'; + $self->{components_module} = ['fan', 'temperature', 'psu', 'disk', 'battery']; +} -my $thresholds = { - fan => [ - ['notfound', 'OK'], - ['ok', 'OK'], - ['failed', 'CRITICAL'], - ], - temperature => [ - ['failed', 'CRITICAL'], - ['ok', 'OK'], - ['notfound', 'OK'], - ['absent', 'OK'], - ['overheatWarning', 'WARNING'], - ['overheatCritical', 'CRITICAL'], - ], - psu => [ - ['absent', 'OK'], - ['ok', 'OK'], - ['failed', 'CRITICAL'], - ['faulty', 'WARNING'], - ['acnone', 'WARNING'], - ['unknown', 'UNKNOWN'], - ], - disk => [ - ['ok', 'OK'], - ['spare', 'OK'], - ['available', 'OK'], - ['unknown', 'UNKNOWN'], - ['absent', 'OK'], - ['failed', 'CRITICAL'], - ], - battery => [ - ['ok', 'OK'], - ['disabled', 'OK'], - ['discharged', 'WARNING'], - ['softdisabled', 'OK'], - ['UNKNOWN', 'UNKNOWN'], - ], -}; +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} sub new { my ($class, %options) = @_; @@ -83,223 +92,25 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => 'all' }, - "absent-problem:s" => { name => 'absent' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - $self->{components} = {}; - $self->{no_components} = undef; return $self; } -sub check_options { +sub get_version { 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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(battery|temperature)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: battery or temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - $self->{results_leef} = $self->{snmp}->get_leef(oids => [ $oid_sysDescr . '.0' ]); - if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results_leef}->{$oid_sysDescr . '.0'}))) { + my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752' + my $result = $options{snmp}->get_leef(oids => [ $oid_sysDescr ]); + if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $result->{$oid_sysDescr}))) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => 'Cannot get DataDomain OS version.'); $self->{output}->display(); $self->{output}->exit(); } - my $oid_diskPropState; - if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { - $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.8'; - } else { - $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.7'; - } - - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ - { oid => $oid_powerModuleEntry }, - { oid => $oid_temperatureSensorEntry }, - { oid => $oid_fanPropertiesEntry }, - { oid => $oid_diskPropState }, - { oid => $oid_nvramBatteryEntry }, - ]); - - $self->{output}->output_add(long_msg => 'DataDomain OS version: ' . $self->{os_version} . '.'); - if ($self->{option_results}->{component} eq 'all') { - storage::emc::DataDomain::mode::components::psu::check($self); - storage::emc::DataDomain::mode::components::fan::check($self); - storage::emc::DataDomain::mode::components::disk::check($self); - storage::emc::DataDomain::mode::components::temperature::check($self); - storage::emc::DataDomain::mode::components::battery::check($self); - } elsif ($self->{option_results}->{component} eq 'fan') { - storage::emc::DataDomain::mode::components::fan::check($self); - } elsif ($self->{option_results}->{component} eq 'psu') { - storage::emc::DataDomain::mode::components::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'disk') { - storage::emc::DataDomain::mode::components::disk::check($self); - } elsif ($self->{option_results}->{component} eq 'temperature') { - storage::emc::DataDomain::mode::components::temperature::check($self); - } elsif ($self->{option_results}->{component} eq 'battery') { - storage::emc::DataDomain::mode::components::battery::check($self); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - 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 check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}); -} - -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; @@ -314,18 +125,18 @@ Check components (Fans, Power Supplies, Temperatures, Disks, Nvram Batteries). =item B<--component> -Which component to check (Default: 'all'). +Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'disk', 'temperature', 'battery'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#3.3#' +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=psu,3.3 =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#1.1# +Return an error if an entity is not 'present' (default is skipping) +Can be specific or global: --absent-problem=psu,1 =item B<--no-component> @@ -334,18 +145,18 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,CRITICAL,^(?!(ok)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: regexp,treshold) -Example: --warning='.*,20' +Set warning threshold for temperatures (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,20' =item B<--critical> -Set critical threshold for temperatures and battery charge (syntax: type,regexp,treshold) +Set critical threshold for temperatures and battery charge (syntax: type,regexp,threshold) Example: --critical='temperature,1.1,25' --critical='battery,.*,20:' =back diff --git a/centreon-plugins/storage/emc/DataDomain/mode/replication.pm b/centreon-plugins/storage/emc/DataDomain/mode/replication.pm new file mode 100644 index 000000000..974c8021b --- /dev/null +++ b/centreon-plugins/storage/emc/DataDomain/mode/replication.pm @@ -0,0 +1,237 @@ +# +# Copyright 2016 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::DataDomain::mode::replication; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use storage::emc::DataDomain::lib::functions; + +my $instance_mode; + +sub custom_threshold_output { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' && + eval "$instance_mode->{option_results}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'repl', type => 1, cb_prefix_output => 'prefix_repl_output', message_multiple => 'All replications are ok' }, + ]; + + $self->{maps_counters}->{repl} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' } ], + output_template => "status is '%s'", + output_use => 'state', + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_threshold_output'), + } + }, + { label => 'offset', set => { + key_values => [ { name => 'offset' }, { name => 'display' } ], + output_template => 'last time peer sync : %s seconds ago', + perfdatas => [ + { label => 'offset', value => 'offset_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_repl_output { + my ($self, %options) = @_; + + if ($self->{multiple} == 1) { + return "Replication '" . $options{instance_value}->{display} . "' "; + } + return "Replication "; +} + +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 => + { + "unknown-status:s" => { name => 'unknown_status', default => '' }, + "warning-status:s" => { name => 'warning_status', default => '%{state} =~ /initializing|recovering/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{state} =~ /disabledNeedsResync|uninitialized/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'unknown_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' +my $oid_replicationInfoEntry = '.1.3.6.1.4.1.19746.1.8.1.1.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = {}; + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_sysDescr }, + { oid => $oid_replicationInfoEntry }, + ], + nothing_quit => 1); + if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => 'Cannot get DataDomain OS version.'); + $self->{output}->display(); + $self->{output}->exit(); + } + + my ($oid_replSource, $oid_replDestination, $oid_replState); + my %map_state = ( + 1 => 'enabled', 2 => 'disabled', 3 => 'disabledNeedsResync', + ); + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.4')) { + %map_state = ( + 1 => 'initializing', 2 => 'normal', 3 => 'recovering', 4 => 'uninitialized', + ); + $oid_replSource = '.1.3.6.1.4.1.19746.1.8.1.1.1.7'; + $oid_replDestination = '.1.3.6.1.4.1.19746.1.8.1.1.1.8'; + $oid_replState = '.1.3.6.1.4.1.19746.1.8.1.1.1.3'; + } elsif (centreon::plugins::misc::minimal_version($self->{os_version}, '5.0')) { + $oid_replSource = '.1.3.6.1.4.1.19746.1.8.1.1.1.7'; + $oid_replDestination = '.1.3.6.1.4.1.19746.1.8.1.1.1.8'; + $oid_replState = '.1.3.6.1.4.1.19746.1.8.1.1.1.3'; + } else { + $oid_replSource = '.1.3.6.1.4.1.19746.1.8.1.1.1.6'; + $oid_replDestination = '.1.3.6.1.4.1.19746.1.8.1.1.1.7'; + $oid_replState = '.1.3.6.1.4.1.19746.1.8.1.1.1.2'; + } + + my $mapping = { + replState => { oid => $oid_replState, map => \%map_state }, + replSource => { oid => $oid_replSource }, + replDestination => { oid => $oid_replDestination }, + replSyncedAsOfTime => { oid => '.1.3.6.1.4.1.19746.1.8.1.1.1.14' }, + }; + + foreach my $oid (keys %{$self->{results}->{$oid_replicationInfoEntry}}) { + next if ($oid !~ /^$mapping->{replState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_replicationInfoEntry}, instance => $instance); + $self->{repl}->{$instance} = { display => $result->{replSource} . '/' . $result->{replDestination}, + state => $result->{replState}, + offset => (time() - $result->{replSyncedAsOfTime}) + }; + + } +} + +1; + +__END__ + +=head1 MODE + +Check replication. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--unknown-status> + +Set warning threshold for status (Default: none). +Can used special variables like: %{state} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{state} =~ /initializing|recovering/i'). +Can used special variables like: %{state} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} =~ /disabledNeedsResync|uninitialized/i'). +Can used special variables like: %{state} + +=item B<--warning-*> + +Threshold warning. +Can be: 'offset'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'offset'. + +=back + +=cut diff --git a/centreon-plugins/storage/emc/DataDomain/plugin.pm b/centreon-plugins/storage/emc/DataDomain/plugin.pm index 9e760e3ef..bf7e91f9a 100644 --- a/centreon-plugins/storage/emc/DataDomain/plugin.pm +++ b/centreon-plugins/storage/emc/DataDomain/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,12 +28,12 @@ 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}} = ( 'hardware' => 'storage::emc::DataDomain::mode::hardware', 'filesystem-usage' => 'storage::emc::DataDomain::mode::filesystem', + 'replication' => 'storage::emc::DataDomain::mode::replication', ); return $self; diff --git a/centreon-plugins/storage/emc/celerra/local/mode/components/controlstation.pm b/centreon-plugins/storage/emc/celerra/local/mode/components/controlstation.pm index f33c82e24..8cac90baf 100644 --- a/centreon-plugins/storage/emc/celerra/local/mode/components/controlstation.pm +++ b/centreon-plugins/storage/emc/celerra/local/mode/components/controlstation.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/celerra/local/mode/components/datamover.pm b/centreon-plugins/storage/emc/celerra/local/mode/components/datamover.pm index 687436693..29bc1f912 100644 --- a/centreon-plugins/storage/emc/celerra/local/mode/components/datamover.pm +++ b/centreon-plugins/storage/emc/celerra/local/mode/components/datamover.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm b/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm index 0c016dd02..478ba2836 100644 --- a/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm +++ b/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/celerra/local/plugin.pm b/centreon-plugins/storage/emc/celerra/local/plugin.pm index 3a31fd6a2..882c1a4d2 100644 --- a/centreon-plugins/storage/emc/celerra/local/plugin.pm +++ b/centreon-plugins/storage/emc/celerra/local/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/emc/clariion/TODO b/centreon-plugins/storage/emc/clariion/TODO deleted file mode 100644 index b9601caa4..000000000 --- a/centreon-plugins/storage/emc/clariion/TODO +++ /dev/null @@ -1,77 +0,0 @@ -=============== -Mode Lun -=============== - -Command to test. All: getlun -uid -state -rg -type -drivetype -capacity -prb -bind - -LOGICAL UNIT NUMBER 3 -UID: 60:06:01:60:F8:C0:1E:00:A2:DC:41:39:8C:0F:E1:11 -State: Bound -RAIDGroup ID: 0 -RAID Type: RAID5 -Drive Type: SATAII -LUN Capacity(Megabytes): 1659491 -LUN Capacity(Blocks): 3398637568 -Prct Rebuilt: 100 -Prct Bound: 100 - -LOGICAL UNIT NUMBER 1 -UID: 60:06:01:60:F8:C0:1E:00:0E:A7:F5:5F:66:10:E1:11 -State: Bound -RAIDGroup ID: 101 -RAID Type: Hot Spare -Drive Type: SATAII -LUN Capacity(Megabytes): 704364 -LUN Capacity(Blocks): 1442538624 -Prct Rebuilt: N/A -Prct Bound: 100 - - -For one lun: getlun 1 -uid -state -rg -type -drivetype -capacity -prb -bind - -UID: 60:06:01:60:F8:C0:1E:00:0E:A7:F5:5F:66:10:E1:11 -State: Bound -RAIDGroup ID: 101 -RAID Type: Hot Spare -Drive Type: SATAII -LUN Capacity(Megabytes): 704364 -LUN Capacity(Blocks): 1442538624 -Prct Rebuilt: N/A -Prct Bound: 100 - -====================== -Mode pour les raid group -====================== - -La commande globale: getrg -type -tcap -ucap -prcntdf -prcntex -state - -RaidGroup ID: 40 -RaidGroup Type: r5 -Raw Capacity (Blocks): 5770154824 -Logical Capacity (Blocks): 4327616118 -Free Capacity (Blocks,non-contiguous): 246 -Percent defragmented: 100 -Percent expanded: 100 -RaidGroup State: Explicit_Remove - Valid_luns - -RaidGroup ID: 103 -RaidGroup Type: hot_spare -Raw Capacity (Blocks): 1442538706 -Logical Capacity (Blocks): 1442538706 -Free Capacity (Blocks,non-contiguous): 82 -Percent defragmented: 100 -Percent expanded: 100 -RaidGroup State: Valid_luns - - -Pour un seul: getrg 109 -type -tcap -ucap -prcntdf -prcntex -state - -RaidGroup ID: 109 -RaidGroup Type: hot_spare -Raw Capacity (Blocks): 1442538706 -Logical Capacity (Blocks): 0 -Free Capacity (Blocks,non-contiguous): 1442538706 -Percent defragmented: 100 -Percent expanded: 100 -RaidGroup State: Valid_luns diff --git a/centreon-plugins/storage/emc/clariion/plugin.pm b/centreon-plugins/storage/emc/clariion/plugin.pm index e50a2ae01..29b24abb1 100644 --- a/centreon-plugins/storage/emc/clariion/plugin.pm +++ b/centreon-plugins/storage/emc/clariion/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/emc/recoverypoint/ssh/mode/monitoredparameters.pm b/centreon-plugins/storage/emc/recoverypoint/ssh/mode/monitoredparameters.pm index db9060f3b..263391f17 100644 --- a/centreon-plugins/storage/emc/recoverypoint/ssh/mode/monitoredparameters.pm +++ b/centreon-plugins/storage/emc/recoverypoint/ssh/mode/monitoredparameters.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/recoverypoint/ssh/mode/systemstatus.pm b/centreon-plugins/storage/emc/recoverypoint/ssh/mode/systemstatus.pm index 8ef653b13..39a3f3e95 100644 --- a/centreon-plugins/storage/emc/recoverypoint/ssh/mode/systemstatus.pm +++ b/centreon-plugins/storage/emc/recoverypoint/ssh/mode/systemstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm b/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm index f3f436ff0..9d7d93854 100644 --- a/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm +++ b/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/config.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/config.pm new file mode 100644 index 000000000..65812a25f --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/config.pm @@ -0,0 +1,56 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::config; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +# ---------[ Configuration Information ]--------- +# +#... +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking config"); + $self->{components}->{config} = {name => 'config', total => 0, skip => 0}; + return if ($self->check_filter(section => 'config')); + + if ($self->{content_file_health} !~ /----\[ Configuration Information(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find config'); + return ; + } + + my $content = $1; + $self->{components}->{config}->{total}++; + + # Error if not present: + # CODE OK! + if ($content !~ /CODE OK!/msi) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("problem of configuration")); + } else { + $self->{output}->output_add(long_msg => sprintf("no configuration problem detected")); + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/director.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/director.pm new file mode 100644 index 000000000..5c8fa18ae --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/director.pm @@ -0,0 +1,92 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::director; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +# ---------------[ Director Status ]------------- +# +# 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 +# +# D ON .. .. .. .. .. .. ON ON .. .. .. .. .. .. ON +# C ON .. .. .. .. .. .. ON ON .. .. .. .. .. .. ON +# B ON .. .. .. .. .. .. DD ON .. .. .. .. .. .. ON +# A ON .. .. .. .. .. .. ON ON .. .. .. .. .. .. ON +# +# Key: +# ON - Director is online +# OF - Director is offline +# OF - DA is offline +# DD - Director is in DD state +# PR - Director is in Probe mode +# NC - Director is not comunicating +# ** - Director status is unknown + +my %mapping = ( + DD => 'DD state', + PR => 'Probe mode', + NC => 'not comunicating', + '**' => 'unknown',, + OF => 'offline', + ON => 'online',, + '..' => 'not configured', +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking directors"); + $self->{components}->{director} = {name => 'directors', total => 0, skip => 0}; + return if ($self->check_filter(section => 'director')); + + if ($self->{content_file_health} !~ /---------------\[ Director Status(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find directors'); + return ; + } + + my $content = $1; + while ($content =~ /\s([A-Z]\s+.*?)\n/msig) { + my ($director, @nums) = split /\s+/, $1; + my $i = 0; + foreach (@nums) { + $i++; + my $state = defined($mapping{$_}) ? $mapping{$_} : 'unknown'; + my $instance = $director . '.' . $i; + + next if ($self->check_filter(section => 'director', instance => $instance)); + $self->{components}->{director}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("director '%s' state is '%s'", + $instance, $state)); + my $exit = $self->get_severity(section => 'director', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Director '%s' state is '%s'", + $instance, $state)); + } + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/disk.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/disk.pm new file mode 100644 index 000000000..01f7e9c54 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/disk.pm @@ -0,0 +1,116 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::disk; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +# ------------[ Device Information ]------------- +# +# RAID6 Configured: NO +# RAID5 Configured: NO +# RDF Configured: NO_RDF + +# Verify Volume Status +# There are 16 local devices are not ready (device(DA)):- à 0 si pas de problème +# 10000(01a) 10072(01a) 20086(01a) 1009A(01a) 200AE(01a) 100C2(01a) 100EA(01a) +# 10112(01a) 20075(01d) 10089(01d) 2009D(01d) 100B1(01d) 100C9(01d) 100F1(01d) +# 10119(01d) 20061(01d) +# +# No local devices have invalid tracks +# +# Deferred disk service is NOT enabled +# +# 8 hot spares are configured, 1 are invoked, none are not ready à none si pas de problème +# +# HotSpare 16d:D5 is invoked against 1d:D4 Time: MAR/24/16 04:48:49 à récupérer si pb +# +# No DAs have any volumes with Not Ready bit set +# +# All DAs have Write Optimize enabled +# +# No devices have TimeFinder Lock +# +# No Devices Found in Transient State + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking disks"); + $self->{components}->{disk} = {name => 'disks (1 means all)', total => 0, skip => 0}; + return if ($self->check_filter(section => 'disk')); + + if ($self->{content_file_health} !~ /----\[ Device Information(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find devices'); + return ; + } + + my $content = $1; + $self->{components}->{disk}->{total}++; + + # Error if not present: + # No local devices have invalid tracks + + if ($content !~ /No local devices have invalid tracks/msi) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("problem of invalid tracks on disks")); + } else { + $self->{output}->output_add(long_msg => sprintf("no invalid tracks on disks")); + } + + # Error if not present: + # All local devices are ready + if ($content !~ /All local devices are ready/msi) { + $content =~ /There are\s+(\S+)\s+local devices are not ready.*?\n(.*?)\n\s*\n/msi; + my ($num, $disks) = ($1, $2); + $disks =~ s/\n/ /msg; + $disks =~ s/\s+/ /msg; + $disks =~ s/^\s+//; + $self->{output}->output_add(long_msg => sprintf("problem on following disks '%s'", $disks)); + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("problem on '%s' disks", $num)); + } else { + $self->{output}->output_add(long_msg => sprintf("all devices are ready")); + } + + return if ($content !~ /(\S+) hot spares are configured, (\S+) are invoked/msi); + my ($total, $used) = ($1, $2); + $used = 0 if ($used =~ /none/i); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'disk', instance => '1', value => $total - $used); + + $self->{output}->output_add(long_msg => sprintf("'%s' spare disk availables on '%s'", + $total - $used, $total)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("'%s' spare disk availables on '%s'", + $total - $used, $total)); + } + + $self->{output}->perfdata_add(label => "disk_spare_available", + value => $total - $used, + warning => $warn, + critical => $crit, min => 0, max => $total); +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm new file mode 100644 index 000000000..8edda26ae --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm @@ -0,0 +1,56 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::environment; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +# -------------[ Power Information ]------------- +# +# No Environmental Problems found +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking environment"); + $self->{components}->{environment} = {name => 'environment', total => 0, skip => 0}; + return if ($self->check_filter(section => 'environment')); + + if ($self->{content_file_health} !~ /----\[ Power Information(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find environment'); + return ; + } + + my $content = $1; + $self->{components}->{environment}->{total}++; + + # Error if not present: + # No Environmental Problems found + if ($content !~ /No Environmental Problems found/msi) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("environment problem detected")); + } else { + $self->{output}->output_add(long_msg => sprintf("no environment problem detected")); + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/memory.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/memory.pm new file mode 100644 index 000000000..e36f700d8 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/memory.pm @@ -0,0 +1,92 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::memory; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +#------------[ Memory Information ]------------- +# +# Memory Size: 80 GB +# Cache start Addr: 00088000 (Hex) +# Cache start Bank: 00000022 (Hex) +# Cache last Addr: 01400000 (Hex) +# Cache last Bank: 000004FF (Hex) +# +# Board Number M0 M1 M2 M3 M4 M5 M6 M7 +# Slot Number 10 11 12 13 14 15 16 17 +# ---------------------------------------------------------- +# Size (GB) 16 16 16 16 8 8 .. .. +# Mode OPER OPER OPER OPER OPER OPER .. .. +# Status OK OK OK OK OK OK .. .. +# +# Status Key +# OK - Board is operating normally + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking memory"); + $self->{components}->{memory} = {name => 'memory', total => 0, skip => 0}; + return if ($self->check_filter(section => 'memory')); + + if ($self->{content_file_health} !~ /----\[ Memory Information(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find memory'); + return ; + } + + my $content = $1; + + $content =~ /Board Number\s+(.*?)\n/msi; + my @board_numbers = split /\s+/, $1; + + $content =~ /Slot Number\s+(.*?)\n/msi; + my @slot_numbers = split /\s+/, $1; + + $content =~ /Mode\s+(.*?)\n/msi; + my @modes = split /\s+/, $1; + + $content =~ /Status\s+(.*?)\n/msi; + my @status = split /\s+/, $1; + + my $i = -1; + foreach my $name (@board_numbers) { + $i++; + my $instance = $name . '#' . $slot_numbers[$i]; + my $state = $modes[$i] . '/' . $status[$i]; + + next if ($self->check_filter(section => 'memory', instance => $instance)); + $self->{components}->{memory}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("memory '%s' state is '%s'", + $instance, $state)); + my $exit = $self->get_severity(section => 'memory', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' state is '%s'", + $instance, $state)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/test.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/test.pm new file mode 100644 index 000000000..09f9b05fa --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/test.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::test; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +#--------------[ Director Tests ]--------------- +# +# No offline pending DAs are present +# 1C test: All Directors Passed +# F2,SAME,,,EE test: All Directors Passed +# EE test: All Directors Passed +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking test"); + $self->{components}->{test} = {name => 'test', total => 0, skip => 0}; + return if ($self->check_filter(section => 'test')); + + if ($self->{content_file_health} !~ /----\[ Director Tests(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find tests'); + return ; + } + + my $content = $1; + $self->{components}->{test}->{total}++; + + foreach (('No offline pending DAs are present', '1C test: All Directors Passed', + 'F2,SAME,,,EE test: All Directors Passed', 'EE test: All Directors Passed')) { + if ($content !~ /$_/msi) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("test problem detected")); + } else { + $self->{output}->output_add(long_msg => sprintf("%s", $_)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/xcm.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/xcm.pm new file mode 100644 index 000000000..21b4c0505 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/xcm.pm @@ -0,0 +1,75 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::components::xcm; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +# --------------[ XCM Information ]-------------- +# +#XCM/ECM/CCM status +# XCM0 XCM1 +# EMUL EMUL +# +#Message Bus status + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking xcm"); + $self->{components}->{xcm} = {name => 'xcm', total => 0, skip => 0}; + return if ($self->check_filter(section => 'xcm')); + + if ($self->{content_file_health} !~ /----\[ XCM Information(.*?)----\[/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find xcm'); + return ; + } + + my $content = $1; + + if ($content =~ /XCM\/ECM\/CCM status\s*\n\s*(.*?)\n\s*(.*?)\n\s*\n/msig) { + my @names = split /\s+/, $1; + my @status = split /\s+/, $2; + + my $i = -1; + foreach my $name (@names) { + $i++; + my $instance = $name; + my $state = $status[$i]; + + next if ($self->check_filter(section => 'xcm', instance => $instance)); + $self->{components}->{xcm}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("xcm '%s' state is '%s'", + $instance, $state)); + my $exit = $self->get_severity(section => 'xcm', value => $state); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("XCM '%s' state is '%s'", + $instance, $state)); + } + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/hardware.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/hardware.pm new file mode 100644 index 000000000..010a6a303 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/hardware.pm @@ -0,0 +1,289 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(disk)$'; + + $self->{cb_hook1} = 'read_files'; + $self->{cb_hook4} = 'send_email'; + + $self->{thresholds} = { + director => [ + ['DD state', 'CRITICAL'], + ['Probe mode', 'CRITICAL'], + ['not comunicating', 'CRITICAL'], + ['unknown', 'CRITICAL'], + ['offline', 'OK'], + ['online', 'OK'], + ['not configured', 'OK'], + ], + xcm => [ + ['emul', 'OK'], + ['.*', 'CRITICAL'], + ], + memory => [ + ['OPER/OK', 'OK'], + ['\.\./.*', 'OK'], + ['.*', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::emc::symmetrix::dmx34::local::mode::components'; + $self->{components_module} = ['director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test']; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{statefile_cache}->check_options(%options); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "file-health:s" => { name => 'file_health' }, + "file-health-env:s" => { name => 'file_health_env' }, + # Email + "email-warning:s" => { name => 'email_warning' }, + "email-critical:s" => { name => 'email_critical' }, + "email-smtp-host:s" => { name => 'email_smtp_host' }, + "email-smtp-username:s" => { name => 'email_smtp_username' }, + "email-smtp-password:s" => { name => 'email_smtp_password' }, + "email-smtp-from:s" => { name => 'email_smtp_from' }, + "email-smtp-options:s@" => { name => 'email_smtp_options' }, + "email-memory" => { name => 'email_memory' }, + }); + + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + $self->{components_exec_load} = 0; + return $self; +} + +sub read_files { + my ($self, %options) = @_; + + if (!defined($self->{option_results}->{file_health}) || !defined($self->{option_results}->{file_health_env})) { + $self->{output}->add_option_msg(short_msg => "Please set option --file-health and --file-health-env."); + $self->{output}->option_exit(); + } + $self->{content_file_health} = do { + local $/ = undef; + if (!open my $fh, "<", $self->{option_results}->{file_health}) { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{file_health} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + + # We remove color syntax + $self->{content_file_health} =~ s/\x{1b}\[.*?m|\r//msg; + + # ***************************************************************** + #* Health Check Run From Scheduler Version 2.0 * + #* * + #* Serial: 000290103984 Run Time: 03/24/2016 12:27:07 * + #* Run Type: FULL Code Level: 5773-184-130 * + #***************************************************************** + + my ($serial, $site) = ('unknown', 'unknown'); + $serial = $1 if ($self->{content_file_health} =~ /Serial:\s*(\S+)/msi); + + $self->{output}->output_add(long_msg => sprintf('serial number: %s, site name: %s', $serial, $site)); +} + +# +# maybe we should add it in core (with cleaner code ;) +# + +sub send_email { + my ($self, %options) = @_; + + ####### + # Check SMTP options + return if (!((defined($self->{option_results}->{email_warning}) && $self->{option_results}->{email_warning} ne '') + || (defined($self->{option_results}->{email_critical}) && $self->{option_results}->{email_critical} ne ''))); + + if (!defined($self->{option_results}->{email_smtp_host})) { + $self->{output}->add_option_msg(short_msg => "Please set the --email-smtp-host option"); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{email_smtp_from})) { + $self->{output}->add_option_msg(short_msg => "Please set --email-smtp-from option"); + $self->{output}->option_exit(); + } + + my %smtp_options = ('-auth' => 'none'); + if (defined($self->{option_results}->{email_smtp_username}) && $self->{option_results}->{email_smtp_username} ne '') { + $smtp_options{-login} = $self->{option_results}->{email_smtp_username}; + delete $smtp_options{-auth}; + } + if (defined($self->{option_results}->{email_smtp_username}) && defined($self->{option_results}->{email_smtp_password})) { + $smtp_options{-pass} = $self->{option_results}->{email_smtp_password}; + } + + ####### + # Get current data + my $stdout; + { + local *STDOUT; + open STDOUT, '>', \$stdout; + $self->{output}->display(force_long_output => 1); + } + + $stdout =~ /^(.*?)(\||\n)/msi; + my $subject = $1; + my $status = lc($self->{output}->get_litteral_status()); + + foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { + next if ($option !~ /^(.+?)=(.+)$/); + my ($label, $value) = ($1, $2); + if ($label =~ /subject/i) { + $value =~ s/%\{status\}/$status/g; + $value =~ s/%\{short_msg\}/$subject/g; + $label = lc($label); + } + $smtp_options{-$label} = $value; + } + + my $send_email = 0; + $send_email = 1 if ($status ne 'ok'); + ####### + # Check memory file + if (defined($self->{option_results}->{email_memory})) { + $self->{new_datas} = { status => $status, output => $subject }; + $self->{statefile_cache}->read(statefile => "cache_emc_symmetrix_dmx34_email"); + my $prev_status = $self->{statefile_cache}->get(name => 'status'); + my $prev_output = $self->{statefile_cache}->get(name => 'output'); + # non-ok output is the same + $send_email = 0 if ($status ne 'ok' && defined($prev_output) && $prev_output eq $subject); + # recovery email + $send_email = 1 if ($status eq 'ok' && defined($prev_status) && $prev_status ne 'ok'); + $self->{statefile_cache}->write(data => $self->{new_datas}); + } + + my $smtp_to = ''; + $smtp_to = $self->{option_results}->{email_warning} if ($status eq 'warning' && defined($self->{option_results}->{email_warning} && $self->{option_results}->{email_warning}) ne ''); + $smtp_to = $self->{option_results}->{email_critical} if ($status eq 'critical' && defined($self->{option_results}->{email_critical} && $self->{option_results}->{email_critical}) ne ''); + if ($send_email == 1 && $status eq 'ok') { + my $append = ''; + foreach (('email_warning', 'email_critical')) { + if (defined($self->{option_results}->{$_}) && $self->{option_results}->{$_} ne '') { + $smtp_to .= $append . $self->{option_results}->{$_}; + $append .= ','; + } + } + } + + if ($send_email == 0) { + $self->{output}->add_option_msg(severity => 'OK', short_msg => "No email to send"); + return ; + } + + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Email::Send::SMTP::Gmail', + error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'."); + my ($mail, $error) = Email::Send::SMTP::Gmail->new(-smtp => $self->{option_results}->{email_smtp_host}, + %smtp_options); + if ($mail == -1) { + $self->{output}->add_option_msg(short_msg => "session error: " . $error); + $self->{output}->option_exit(); + } + my $result = $mail->send(-to => $smtp_to, + -from => $self->{option_results}->{email_smtp_from}, + -subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject, + -body => $stdout, + -attachments => $self->{option_results}->{file_health} . ',' . $self->{option_results}->{file_health_env}); + $mail->bye(); + if ($result == -1) { + $self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email"); + } else { + $self->{output}->add_option_msg(severity => 'OK', short_msg => "email sent"); + } +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test' + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=director --filter=xcm) +Can also exclude specific instance: --filter=director,1 + +=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='director,CRITICAL,^(?!(online)$)' + +=item B<--warning> + +Set warning threshold for disk (syntax: type,regexp,threshold) +Example: --warning='disk,.*,5:' + +=item B<--critical> + +Set critical threshold for disk (syntax: type,regexp,threshold) +Example: --critical='disk,.*,3:' + +=item B<--file-health> + +The location of the global storage file status (Should be something like: C:/xxxx/HealthCheck.log). + +=item B<--file-health-env> + +The location of the environment storage file status (Should be something like: C:/xxxx/HealthCheck_ENV.log). + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/storage/emc/symmetrix/dmx34/local/plugin.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/plugin.pm new file mode 100644 index 000000000..366220252 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::symmetrix::dmx34::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'hardware' => 'storage::emc::symmetrix::dmx34::local::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check symmetrix DMX 3 and 4. The plugin needs to be installed on Windows Management. + +=cut diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/cabling.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/cabling.pm new file mode 100644 index 000000000..c904cdd3a --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/cabling.pm @@ -0,0 +1,70 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::cabling; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Ethernet cabling: OK +# +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ +#| Cable Name | Status | Expected 'From' Port | Actual 'From' Port | Expected 'To' Port | Actual 'To' Port | Error Code | Error string | +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ +#| Cable from SRV A Adapter to MM-A ES-4 Lower port | OK | SRV A Adapter | SRV A Adapter | MM-A ES-4 Lower port | MM-A ES-4 Lower port | None | | +#| Cable from SRV B Adapter to MM-B ES-4 Lower port | OK | SRV B Adapter | SRV B Adapter | MM-B ES-4 Lower port | MM-B ES-4 Lower port | None | | +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ +#| Cable Name | Status | Expected 'From' Port | Actual 'From' Port | Expected 'To' Port | Actual 'To' Port | Error Code | Error string | +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cabling"); + $self->{components}->{cabling} = {name => 'cabling', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cabling')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Ethernet cabling.*?---------.*?Cable Name.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find cabling'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|(.*?)\|.*?\n/msig) { + my ($cabling, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'cabling', instance => $cabling)); + $self->{components}->{cabling}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cabling '%s' status is '%s'", + $cabling, $status)); + my $exit = $self->get_severity(label => 'default', section => 'cabling', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cabling '%s' status is '%s'", + $cabling, $status)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/director.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/director.pm new file mode 100644 index 000000000..93ab9d296 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/director.pm @@ -0,0 +1,72 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::director; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Directors status: OK +# +#+----------+--------+---------+-------------+---------+-----------------+-------------+ +#| Director | Type | State | Flags | Version | Address | Last Update | +#+----------+--------+---------+-------------+---------+-----------------+-------------+ +#| 07A | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.7 | 1110 | +#| 07B | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.23 | 1110 | +#| 07C | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.39 | 1110 | +#| 07D | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.55 | 1110 | +#+----------+--------+---------+-------------+---------+-----------------+-------------+ +#| Director | Type | State | Flags | Version | Address | Last Update | +#+----------+--------+---------+-------------+---------+-----------------+-------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking directors"); + $self->{components}->{director} = {name => 'directors', total => 0, skip => 0}; + return if ($self->check_filter(section => 'director')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Directors status.*?---------.*?Director.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find directors'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|.*?\|(.*?)\|.*?\n/msig) { + my ($director, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'director', instance => $director)); + $self->{components}->{director}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("director '%s' status is '%s'", + $director, $status)); + my $exit = $self->get_severity(label => 'default', section => 'director', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Director '%s' status is '%s'", + $director, $status)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/fabric.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/fabric.pm new file mode 100644 index 000000000..b2b3df797 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/fabric.pm @@ -0,0 +1,91 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::fabric; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Fabric system: OK +# +#+-------------------------------------------------+---------------------------------+ +#| Item | Status | +#+-------------------------------------------------+---------------------------------+ +#| Fabric System General Status | OK | +#| Usage Mode | Full usage - BOSCO and Ethernet | +#| Initialization Status | OK | +#| Configuration Status | OK | +#| Fabric A Availability | Available | +#| Fabric B Availability | Available | +#| Directors' Fabric Links Status | OK | +#| Dir 7 (RIO 0x0C) | All links are up | +#| Link A status | Up | +#| Link B status | Up | +#+-------------------------------------------------+---------------------------------+ +#| Item | Status | +#+-------------------------------------------------+---------------------------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fabrics"); + $self->{components}->{fabric} = {name => 'fabrics', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fabric')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Fabric system.*?---------.*?Item.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find fabrics'); + return ; + } + + my $content = $1; + + my $total_components = 0; + my @stack = ({ indent => 0, long_instance => '' }); + while ($content =~ /^\|([ \t]+)(.*?)\|(.*?)\|\n/msig) { + my ($indent, $name, $status) = (length($1), centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($3)); + + pop @stack while ($indent <= $stack[$#stack]->{indent}); + + my $long_instance = $stack[$#stack]->{long_instance} . '>' . $name; + if ($indent > $stack[$#stack]->{indent}) { + push @stack, { indent => $indent, + long_instance => $stack[$#stack]->{long_instance} . '>' . $name }; + } + + next if ($name !~ /status/i); + + next if ($self->check_filter(section => 'fabric', instance => $long_instance)); + $self->{components}->{fabric}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fabric '%s' status is '%s'", + $long_instance, $status)); + my $exit = $self->get_severity(label => 'default', section => 'fabric', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fabric '%s' status is '%s'", + $long_instance, $status)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/module.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/module.pm new file mode 100644 index 000000000..f9b1b4667 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/module.pm @@ -0,0 +1,71 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::module; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Modules status (alarms): OK +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ +#| Module | Ctrl dirs | Rep dirs | Status | Rel Status | +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ +#| Engine 4 | 07A,08A | 07A,08A | OK | | +#| Engine SPS 4A | 07A | 07A | OK | | +#| Engine SPS 4B | 08A | 08A | OK | | +#| Engine Power Supply A of ES-4 | 07A | 07A | OK | | +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ +#| Module | Ctrl dirs | Rep dirs | Status | Rel Status | +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking modules"); + $self->{components}->{module} = {name => 'modules', total => 0, skip => 0}; + return if ($self->check_filter(section => 'module')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Modules status.*?---------.*?Module.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find modules'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|.*?\|.*?\|(.*?)\|.*?\n/msig) { + my ($module, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'module', instance => $module)); + $self->{components}->{module}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("module '%s' status is '%s'", + $module, $status)); + my $exit = $self->get_severity(label => 'default', section => 'module', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Module '%s' status is '%s'", + $module, $status)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/power.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/power.pm new file mode 100644 index 000000000..5bba09a19 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/power.pm @@ -0,0 +1,95 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::power; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Power system: OK +# +#+--------------------------------------------------------+--------------------------------------+ +#| Item | Status | +#+--------------------------------------------------------+--------------------------------------+ +#| Power input type | Three Phases | +#| System Bay AC Zones Status | OK | +#| AC Status Zone A | Zone AC OK | +#| AC Status Zone B | Zone AC OK | +#| Power modules status | OK | +#| System Bay 1 | OK | +#| Engine SPS 4A | OK | +#| General Status | OK | +#| Detailed Status | OK | +#| Condition Register | OK | +#| Battery Life (sec) | 600 | +#| Days of Operation | Unknown | +#| Slot | Slot B | +#| Manufacturer Information | ASTEC,AA23540,7E, 04/11/2008 | +#+--------------------------------------------------------+--------------------------------------+ +#| Item | Status | +#+--------------------------------------------------------+--------------------------------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking powers"); + $self->{components}->{power} = {name => 'powers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'power')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Power system.*?---------.*?Item.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find powers'); + return ; + } + + my $content = $1; + + my $total_components = 0; + my @stack = ({ indent => 0, long_instance => '' }); + while ($content =~ /^\|([ \t]+)(.*?)\|(.*?)\|\n/msig) { + my ($indent, $name, $status) = (length($1), centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($3)); + + pop @stack while ($indent <= $stack[$#stack]->{indent}); + + my $long_instance = $stack[$#stack]->{long_instance} . '>' . $name; + if ($indent > $stack[$#stack]->{indent}) { + push @stack, { indent => $indent, + long_instance => $stack[$#stack]->{long_instance} . '>' . $name }; + } + + next if ($name !~ /status/i); + + next if ($self->check_filter(section => 'power', instance => $long_instance)); + $self->{components}->{power}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power '%s' status is '%s'", + $long_instance, $status)); + my $exit = $self->get_severity(label => 'default', section => 'power', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power '%s' status is '%s'", + $long_instance, $status)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/sparedisk.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/sparedisk.pm new file mode 100644 index 000000000..62834a546 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/sparedisk.pm @@ -0,0 +1,62 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::sparedisk; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +#06/15/2016 09:26:42.015 Verify Spare Status Test +#There are 1 non available Spare[s], deferred service is ON. +#06/15/2016 09:26:42.046 Verify Spare Status: Test Succeeded. + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking spare disks"); + $self->{components}->{sparedisk} = {name => 'spare disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'sparedisk')); + + if ($self->{content_file_health} !~ /There are (\d+) non available Spare/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find spare disks'); + return ; + } + + my $value = $1; + $self->{components}->{sparedisk}->{total}++; + + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'sparedisk', instance => '1', value => $value); + $self->{output}->output_add(long_msg => sprintf("'%s' spare disk non availabled", + $value)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("'%s' spare disk non availabled", + $value)); + } + + $self->{output}->perfdata_add(label => "disk_spare_non_available", + value => $value, + warning => $warn, + critical => $crit, min => 0); +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/temperature.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/temperature.pm new file mode 100644 index 000000000..b1e561074 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/temperature.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::temperature; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Temperatures check: OK +# +#+-------------------+------------+------------+------------------+--------+ +#| Module | Temp [°C] | Temp [°F] | High Limit [°C] | Status | +#+-------------------+------------+------------+------------------+--------+ +#| ES-PWS-A ES-4 | 24 | 75 | | OK | +#| ES-PWS-B ES-4 | 22 | 71 | | OK | +#| DIR-7 ES-4 | 34 | 93 | | OK | +#| DIR-8 ES-4 | 36 | 96 | | OK | +#| DIMM-0 DIR-7 ES-4 | 43 | 109 | 88 | OK | +#| DIMM-1 DIR-7 ES-4 | 48 | 118 | 91 | OK | +#+-------------------+------------+------------+------------------+--------+ +#| Module | Temp [°C] | Temp [°F] | High Limit [°C] | Status | +#+-------------------+------------+------------+------------------+--------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Temperatures check.*?---------.*?Module.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find temperatures'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|.*?\|.*?\|.*?\|(.*?)\|.*?\n/msig) { + my ($temperature, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'temperature', instance => $temperature)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s'", + $temperature, $status)); + my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", + $temperature, $status)); + } + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/voltage.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/voltage.pm new file mode 100644 index 000000000..195f17ddf --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/components/voltage.pm @@ -0,0 +1,55 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::components::voltage; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Voltages check: OK +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking voltage"); + $self->{components}->{voltage} = {name => 'voltage', total => 0, skip => 0}; + return if ($self->check_filter(section => 'voltage')); + + if ($self->{content_file_health_env} !~ /Voltages check:(.*?)\n/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find voltage'); + return ; + } + + my $content = centreon::plugins::misc::trim($1); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("voltage status is '%s'", + $content)); + my $exit = $self->get_severity(label => 'default', section => 'voltage', value => $content); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage status is '%s'", + $content)); + } +} + +1; diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/hardware.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/hardware.pm new file mode 100644 index 000000000..e8134bf2a --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/mode/hardware.pm @@ -0,0 +1,322 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(sparedisk)$'; + + $self->{cb_hook1} = 'read_files'; + $self->{cb_hook4} = 'send_email'; + + $self->{thresholds} = { + default => [ + ['Recoverable Error', 'OK'], # Fabric + ['Online', 'OK'], + ['Up', 'OK'], + ['OK', 'OK'], + ['.*', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::emc::symmetrix::vmax::local::mode::components'; + $self->{components_module} = ['module', 'temperature', 'director', 'cabling', 'power', 'fabric', 'voltage', 'sparedisk']; +} + +sub find_files { + my ($self, %options) = @_; + + if (!opendir(DIR, $self->{option_results}->{health_directory})) { + $self->{output}->add_option_msg(short_msg => "Cannot open directory: $!"); + $self->{output}->option_exit(); + } + + my $save_value = 0; + while (my $file = readdir(DIR)) { + next if (! -d $self->{option_results}->{health_directory} . '/' . $file || + $file !~ /$self->{option_results}->{health_directory_pattern}/); + if (hex($1) > $save_value) { + $self->{option_results}->{file_health} = $self->{option_results}->{health_directory} . '/' . $file . '/' . $self->{option_results}->{file_health_name}; + $self->{option_results}->{file_health_env} = $self->{option_results}->{health_directory} . '/' . $file . '/' . $self->{option_results}->{file_health_env_name}; + $save_value = hex($1); + } + } + + closedir(DIR); +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{statefile_cache}->check_options(%options); + + if (!defined($self->{option_results}->{file_health_name}) || !defined($self->{option_results}->{file_health_env_name})) { + $self->{output}->add_option_msg(short_msg => "Please set option --file-health-name and --file-health-env-name."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{health_directory}) || ! -d $self->{option_results}->{health_directory}) { + $self->{output}->add_option_msg(short_msg => "Please set right option for --health-directory."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{health_directory_pattern})) { + $self->{output}->add_option_msg(short_msg => "Please set option for --health-directory-pattern."); + $self->{output}->option_exit(); + } + + $self->find_files(); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "health-directory:s" => { name => 'health_directory' }, + "health-directory-pattern:s" => { name => 'health_directory_pattern' }, + "file-health-name:s" => { name => 'file_health_name', default => 'HealthCheck.log' }, + "file-health-env-name:s" => { name => 'file_health_env_name', default => 'sympl_env_health.log' }, + # Email + "email-warning:s" => { name => 'email_warning' }, + "email-critical:s" => { name => 'email_critical' }, + "email-smtp-host:s" => { name => 'email_smtp_host' }, + "email-smtp-username:s" => { name => 'email_smtp_username' }, + "email-smtp-password:s" => { name => 'email_smtp_password' }, + "email-smtp-from:s" => { name => 'email_smtp_from' }, + "email-smtp-options:s@" => { name => 'email_smtp_options' }, + "email-memory" => { name => 'email_memory' }, + }); + + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + $self->{components_exec_load} = 0; + return $self; +} + +sub read_files { + my ($self, %options) = @_; + + foreach (('file_health', 'file_health_env')) { + $self->{'content_' . $_} = do { + local $/ = undef; + if (!open my $fh, "<", $self->{option_results}->{$_}) { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + # We remove color syntax + $self->{'content_' . $_} =~ s/\x{1b}\[.*?m|\r//msg; + } + + #Health Check Results Log: + #Service Processor Date: 06/15/2016 09:26:41 + #Symmetrix Date from director 07c: 06/15/2016 09:33:45 + #The time difference between Service Processor and Symmetrix is : 00:07:03.672 + #System SN: 000292602920 + #System Model: VMAX20K + #mCode Level: 5876.288 + my ($serial) = ('unknown'); + $serial = $1 if ($self->{content_file_health} =~ /System SN:\s*(\S+)/msi); + + $self->{output}->output_add(long_msg => sprintf('serial number: %s', $serial)); +} + +# +# maybe we should add it in core (with cleaner code ;) +# + +sub send_email { + my ($self, %options) = @_; + + ####### + # Check SMTP options + return if (!((defined($self->{option_results}->{email_warning}) && $self->{option_results}->{email_warning} ne '') + || (defined($self->{option_results}->{email_critical}) && $self->{option_results}->{email_critical} ne ''))); + + if (!defined($self->{option_results}->{email_smtp_host})) { + $self->{output}->add_option_msg(short_msg => "Please set the --email-smtp-host option"); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{email_smtp_from})) { + $self->{output}->add_option_msg(short_msg => "Please set --email-smtp-from option"); + $self->{output}->option_exit(); + } + + my %smtp_options = ('-auth' => 'none'); + if (defined($self->{option_results}->{email_smtp_username}) && $self->{option_results}->{email_smtp_username} ne '') { + $smtp_options{-login} = $self->{option_results}->{email_smtp_username}; + delete $smtp_options{-auth}; + } + if (defined($self->{option_results}->{email_smtp_username}) && defined($self->{option_results}->{email_smtp_password})) { + $smtp_options{-pass} = $self->{option_results}->{email_smtp_password}; + } + + ####### + # Get current data + my $stdout; + { + local *STDOUT; + open STDOUT, '>', \$stdout; + $self->{output}->display(force_long_output => 1); + } + + $stdout =~ /^(.*?)(\||\n)/msi; + my $subject = $1; + my $status = lc($self->{output}->get_litteral_status()); + + foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { + next if ($option !~ /^(.+?)=(.+)$/); + my ($label, $value) = ($1, $2); + if ($label =~ /subject/i) { + $value =~ s/%\{status\}/$status/g; + $value =~ s/%\{short_msg\}/$subject/g; + $label = lc($label); + } + $smtp_options{-$label} = $value; + } + + my $send_email = 0; + $send_email = 1 if ($status ne 'ok'); + ####### + # Check memory file + if (defined($self->{option_results}->{email_memory})) { + $self->{new_datas} = { status => $status, output => $subject }; + $self->{statefile_cache}->read(statefile => "cache_emc_symmetrix_vmax_email"); + my $prev_status = $self->{statefile_cache}->get(name => 'status'); + my $prev_output = $self->{statefile_cache}->get(name => 'output'); + # non-ok output is the same + $send_email = 0 if ($status ne 'ok' && defined($prev_output) && $prev_output eq $subject); + # recovery email + $send_email = 1 if ($status eq 'ok' && defined($prev_status) && $prev_status ne 'ok'); + $self->{statefile_cache}->write(data => $self->{new_datas}); + } + + my $smtp_to = ''; + $smtp_to = $self->{option_results}->{email_warning} if ($status eq 'warning' && defined($self->{option_results}->{email_warning} && $self->{option_results}->{email_warning}) ne ''); + $smtp_to = $self->{option_results}->{email_critical} if ($status eq 'critical' && defined($self->{option_results}->{email_critical} && $self->{option_results}->{email_critical}) ne ''); + if ($send_email == 1 && $status eq 'ok') { + my $append = ''; + foreach (('email_warning', 'email_critical')) { + if (defined($self->{option_results}->{$_}) && $self->{option_results}->{$_} ne '') { + $smtp_to .= $append . $self->{option_results}->{$_}; + $append .= ','; + } + } + } + + if ($send_email == 0) { + $self->{output}->add_option_msg(severity => 'OK', short_msg => "No email to send"); + return ; + } + + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Email::Send::SMTP::Gmail', + error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'."); + my ($mail, $error) = Email::Send::SMTP::Gmail->new(-smtp => $self->{option_results}->{email_smtp_host}, + %smtp_options); + if ($mail == -1) { + $self->{output}->add_option_msg(short_msg => "session error: " . $error); + $self->{output}->option_exit(); + } + my $result = $mail->send(-to => $smtp_to, + -from => $self->{option_results}->{email_smtp_from}, + -subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject, + -body => $stdout, + -attachments => $self->{option_results}->{file_health} . "," . $self->{option_results}->{file_health_env}); + $mail->bye(); + if ($result == -1) { + $self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email"); + } else { + $self->{output}->add_option_msg(severity => 'OK', short_msg => "email sent"); + } +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'module', 'temperature', 'director, 'cabling', 'power', 'voltage', 'sparedisk'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=module) +Can also exclude specific instance: --filter=temperature,ES-PWS-A ES-4 + +=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='director,WARNING,^(?!(OK)$)' + +=item B<--warning> + +Set warning threshold for disk (syntax: type,regexp,threshold) +Example: --warning='sparedisk,.*,5:' + +=item B<--critical> + +Set critical threshold for disk (syntax: type,regexp,threshold) +Example: --critical='sparedisk,.*,3:' + +=item B<--health-directory> + +Location of health files. + +=item B<--health-directory-pattern> + +Set pattern to match the most recent directory (getting the hexa value). + +=item B<--file-health-name> + +Name of the global storage file status (Default: HealthCheck.log). + +=item B<--file-health-env-name> + +Name of the environment storage file status (Default: sympl_env_health.log). + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/storage/emc/symmetrix/vmax/local/plugin.pm b/centreon-plugins/storage/emc/symmetrix/vmax/local/plugin.pm new file mode 100644 index 000000000..18fc9a995 --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/vmax/local/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::symmetrix::vmax::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'hardware' => 'storage::emc::symmetrix::vmax::local::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check vmax storage. The plugin needs to be installed on Windows Management. + +=cut diff --git a/centreon-plugins/storage/emc/vplex/restapi/custom/vplexapi.pm b/centreon-plugins/storage/emc/vplex/restapi/custom/vplexapi.pm index 3a38b4653..d3499b8f8 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/custom/vplexapi.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/custom/vplexapi.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/clustercommunication.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/clustercommunication.pm index b1f768268..279d8fa1e 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/clustercommunication.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/clustercommunication.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/clusterdevices.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/clusterdevices.pm index 4ccdfae3c..c338aaaab 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/clusterdevices.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/clusterdevices.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/directors.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/directors.pm index bebde25da..76f1e7899 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/directors.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/directors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -126,7 +126,7 @@ sub run { $items->{$engine_name}->{$director_name}->{'communication-status'}, $items->{$engine_name}->{$director_name}->{'temperature-threshold-exceeded'}, $items->{$engine_name}->{$director_name}->{'voltage-threshold-exceeded'}, - $items->{$engine_name}->{$director_name}->{'vplex-splitter-status'})); + defined($items->{$engine_name}->{$director_name}->{'vplex-splitter-status'}) ? $items->{$engine_name}->{$director_name}->{'vplex-splitter-status'} : '-')); my $exit = $self->get_severity(section => 'director_health', instance => $instance, value => $items->{$engine_name}->{$director_name}->{'health-state'}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -152,11 +152,14 @@ sub run { short_msg => sprintf("Director '%s' voltage threshold exceeded is %s", $instance, $items->{$engine_name}->{$director_name}->{'voltage-threshold-exceeded'})); } - $exit = $self->get_severity(section => 'director_vplex_splitter', value => $items->{$engine_name}->{$director_name}->{'vplex-splitter-status'}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Director '%s' vplex splitter status is %s", + + if (defined($items->{$engine_name}->{$director_name}->{'vplex-splitter-status'})) { + $exit = $self->get_severity(section => 'director_vplex_splitter', value => $items->{$engine_name}->{$director_name}->{'vplex-splitter-status'}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Director '%s' vplex splitter status is %s", $instance, $items->{$engine_name}->{$director_name}->{'vplex-splitter-status'})); + } } } } diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/distributeddevices.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/distributeddevices.pm index c82583c9d..3e8b562db 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/distributeddevices.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/distributeddevices.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/fans.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/fans.pm index 650fe96a4..56f6f0bb0 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/fans.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/fans.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/psus.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/psus.pm index 7cb12fa7f..0b5f15897 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/psus.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/psus.pm @@ -1,4 +1,4 @@ -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/mode/storagevolumes.pm b/centreon-plugins/storage/emc/vplex/restapi/mode/storagevolumes.pm index fd6a0f01a..6f691a562 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/mode/storagevolumes.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/mode/storagevolumes.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/vplex/restapi/plugin.pm b/centreon-plugins/storage/emc/vplex/restapi/plugin.pm index 40e3e3ab9..54a9da54e 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/plugin.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/emc/xtremio/restapi/custom/xtremioapi.pm b/centreon-plugins/storage/emc/xtremio/restapi/custom/xtremioapi.pm index b766cb827..d993a9296 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/custom/xtremioapi.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/custom/xtremioapi.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/xtremio/restapi/mode/clusterhealth.pm b/centreon-plugins/storage/emc/xtremio/restapi/mode/clusterhealth.pm index c9bceb96a..25ac27600 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/mode/clusterhealth.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/mode/clusterhealth.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -131,6 +131,7 @@ sub run { name => $item); foreach my $sensor (@sensors) { + next if (!defined($details->{$sensor}) || $details->{$sensor} eq ''); $self->{output}->output_add(long_msg => sprintf("Sensor '%s' state is '%s'", $sensor, $details->{$sensor})); diff --git a/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdendurance.pm b/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdendurance.pm index 1e1680a28..a1432b7fd 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdendurance.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdendurance.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdiops.pm b/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdiops.pm index 2096ffd0c..046e74c6d 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -200,17 +200,16 @@ Check IOPS (Global, Read, Write) on each SSDs. =item B<--warning-*> -Threshold warning. -Can be: 'global' (%), 'read' (%), 'write' (%). +Threshold warning (number of iops) +Can be: 'global', 'read', 'write'. =item B<--critical-*> - -Threshold critical. -Can be: 'global' (%), 'read' (%), 'write' (%). +Threshold critical (number of iops) +Can be: 'global', 'read', 'write'. =item B<--filter-name> -Filter SSD name (can be a regexp). +Filter SSD name (can be a regexp). (e.g --filter-name '.*' for all SSDs) =back diff --git a/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvscpu.pm b/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvscpu.pm index 2ead76f0d..8c8336ff5 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvscpu.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvscpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvsstate.pm b/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvsstate.pm index 2e9a959d4..f4afe1e04 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvsstate.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/mode/xenvsstate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm b/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm index 55e37a12a..fd35ce71f 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm index 605ec01d7..47ca30fae 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/physicaldisk.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/physicaldisk.pm index 2123e2c5d..7d37f9994 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/physicaldisk.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/physicaldisk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm index c171dd872..528a78c33 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/psu.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/psu.pm index ee49f1400..40923136f 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/psu.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/raidgroups.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/raidgroups.pm index 665ddb156..fd84c38b3 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/raidgroups.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/raidgroups.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm index efd8a4eaa..f0a638e40 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm index 5fa5c22f8..f23159562 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/hitachi/hnas/snmp/plugin.pm b/centreon-plugins/storage/hitachi/hnas/snmp/plugin.pm new file mode 100644 index 000000000..31b5ef62e --- /dev/null +++ b/centreon-plugins/storage/hitachi/hnas/snmp/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2016 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::hitachi::hnas::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}} = ( + 'cluster-status' => 'centreon::common::bluearc::snmp::mode::clusterstatus', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'hardware' => 'centreon::common::bluearc::snmp::mode::hardware', + 'volume-usage' => 'centreon::common::bluearc::snmp::mode::volumeusage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Hitachi HNAS in SNMP. + +=cut diff --git a/centreon-plugins/storage/hitachi/standard/snmp/mode/components/component.pm b/centreon-plugins/storage/hitachi/standard/snmp/mode/components/component.pm new file mode 100644 index 000000000..a361de8f0 --- /dev/null +++ b/centreon-plugins/storage/hitachi/standard/snmp/mode/components/component.pm @@ -0,0 +1,101 @@ +# +# Copyright 2016 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::hitachi::standard::snmp::mode::components::component; + +use strict; +use warnings; + +my %map_status = ( + 0 => 'ok', + 1 => 'abnormal', +); +my %mapping_type = ( + 0 => 'drive', + 1 => 'spare drive', + 2 => 'data drive', + 3 => 'ENC', + 5 => 'notUsed', + 6 => 'warning', + 7 => 'Other controller', + 8 => 'UPS', + 9 => 'loop', + 10 => 'path', + 11 => 'NAS Server', + 12 => 'NAS Path', + 13 => 'NAS UPS', + 14 => 'notUsed', + 15 => 'notUsed', + 16 => 'battery', + 17 => 'power supply', + 18 => 'AC', + 19 => 'BK', + 20 => 'fan', + 21 => 'notUsed', + 22 => 'notUsed', + 23 => 'notUsed', + 24 => 'cache memory', + 25 => 'SATA spare disk', + 26 => 'SATA data drive', + 27 => 'SENC status', + 28 => 'HostConnector', + 29 => 'notUsed', + 30 => 'notUsed', + 31 => 'notUsed', + ); + +my $oid_dfRegressionStatus = '.1.3.6.1.4.1.116.5.11.1.2.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_dfRegressionStatus }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking components"); + $self->{components}->{component} = {name => 'components', total => 0, skip => 0}; + return if ($self->check_filter(section => 'component')); + + return if (!defined($self->{results}->{$oid_dfRegressionStatus}->{$oid_dfRegressionStatus . '.0'})); + + foreach my $bit_num (sort keys %mapping_type) { + my $bit_indicate = int($self->{results}->{$oid_dfRegressionStatus}->{$oid_dfRegressionStatus . '.0'}) & (1 << int($bit_num)); + $bit_indicate = 1 if ($bit_indicate > 0); + my $status = $map_status{$bit_indicate}; + next if ($self->check_filter(section => 'component', instance => $mapping_type{$bit_num})); + $self->{components}->{component}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("component '%s' status is '%s' [instance: %s].", + $mapping_type{$bit_num}, $status, + $mapping_type{$bit_num} + )); + my $exit = $self->get_severity(section => 'component', instance => $mapping_type{$bit_num}, value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Component '%s' status is '%s'", + $mapping_type{$bit_num}, $status)); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/hitachi/standard/snmp/mode/components/dkc.pm b/centreon-plugins/storage/hitachi/standard/snmp/mode/components/dkc.pm new file mode 100644 index 000000000..5abcea76a --- /dev/null +++ b/centreon-plugins/storage/hitachi/standard/snmp/mode/components/dkc.pm @@ -0,0 +1,82 @@ +# +# Copyright 2016 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::hitachi::standard::snmp::mode::components::dkc; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'noError', + 2 => 'acute', + 3 => 'serious', + 4 => 'moderate', + 5 => 'service', +); + +my $mapping = { + dkcHWProcessor => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.2', map => \%map_status, type => 'processor' }, + dkcHWCSW => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.3', map => \%map_status, type => 'bus' }, + dkcHWCache => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.4', map => \%map_status, type => 'cache' }, + dkcHWSM => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.5', map => \%map_status, type => 'memory' }, + dkcHWPS => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.6', map => \%map_status, type => 'psu' }, + dkcHWBattery => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.7', map => \%map_status, type => 'battery' }, + dkcHWFan => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.8', map => \%map_status, type => 'fan' }, + dkcHWEnvironment => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.6.1.9', map => \%map_status, type => 'environment' }, +}; +my $oid_raidExMibDKCHWEntry = '.1.3.6.1.4.1.116.5.11.4.1.1.6.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_raidExMibDKCHWEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controller chassis"); + $self->{components}->{dkc} = {name => 'dkc', total => 0, skip => 0}; + return if ($self->check_filter(section => 'dkc')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidExMibDKCHWEntry}})) { + next if ($oid !~ /^$mapping->{dkcHWProcessor}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidExMibDKCHWEntry}, instance => $instance); + + $self->{components}->{dkc}->{total}++; + + foreach (keys %{$mapping}) { + next if ($self->check_filter(section => 'dkc', instance => $1 . '.' . $mapping->{$_}->{type})); + $self->{output}->output_add(long_msg => sprintf("dkc '%s' %s status is '%s' [instance: %s].", + $instance, $mapping->{$_}->{type}, $result->{$_}, + $instance . '.' . $mapping->{$_}->{type} + )); + my $exit = $self->get_severity(label => 'dk', section => 'dkc', instance => $1 . '.' . $mapping->{$_}->{type}, value => $result->{$_}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("DKC '%s' %s status is '%s'", + $instance, $mapping->{$_}->{type}, $result->{$_})); + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/hitachi/standard/snmp/mode/components/dku.pm b/centreon-plugins/storage/hitachi/standard/snmp/mode/components/dku.pm new file mode 100644 index 000000000..dc17316b3 --- /dev/null +++ b/centreon-plugins/storage/hitachi/standard/snmp/mode/components/dku.pm @@ -0,0 +1,78 @@ +# +# Copyright 2016 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::hitachi::standard::snmp::mode::components::dku; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'noError', + 2 => 'acute', + 3 => 'serious', + 4 => 'moderate', + 5 => 'service', +); + +my $mapping = { + dkuHWPS => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.7.1.2', map => \%map_status, type => 'psu' }, + dkuHWFan => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.7.1.3', map => \%map_status, type => 'fan' }, + dkuHWEnvironment => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.7.1.4', map => \%map_status, type => 'environment' }, + dkuHWDrive => { oid => '.1.3.6.1.4.1.116.5.11.4.1.1.7.1.5', map => \%map_status, type => 'drive' }, +}; +my $oid_raidExMibDKUHWEntry = '.1.3.6.1.4.1.116.5.11.4.1.1.7.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_raidExMibDKUHWEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking drive chassis"); + $self->{components}->{dku} = {name => 'dku', total => 0, skip => 0}; + return if ($self->check_filter(section => 'dku')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidExMibDKUHWEntry}})) { + next if ($oid !~ /^$mapping->{dkuHWEnvironment}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidExMibDKUHWEntry}, instance => $instance); + + $self->{components}->{dku}->{total}++; + + foreach (keys %{$mapping}) { + next if ($self->check_filter(section => 'dku', instance => $1 . '.' . $mapping->{$_}->{type})); + $self->{output}->output_add(long_msg => sprintf("dku '%s' %s status is '%s' [instance: %s].", + $instance, $mapping->{$_}->{type}, $result->{$_}, + $instance . '.' . $mapping->{$_}->{type} + )); + my $exit = $self->get_severity(label => 'dk', section => 'dku', instance => $1 . '.' . $mapping->{$_}->{type}, value => $result->{$_}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("DKU '%s' %s status is '%s'", + $instance, $mapping->{$_}->{type}, $result->{$_})); + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/hitachi/standard/snmp/mode/hardware.pm b/centreon-plugins/storage/hitachi/standard/snmp/mode/hardware.pm new file mode 100644 index 000000000..c7e25a89d --- /dev/null +++ b/centreon-plugins/storage/hitachi/standard/snmp/mode/hardware.pm @@ -0,0 +1,106 @@ +# +# Copyright 2016 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::hitachi::standard::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(component|dkc|dku)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + component => [ + ['ok', 'OK'], + ['abnormal', 'CRITICAL'], + ], + dk => [ + ['noError', 'OK'], + ['acute', 'CRITICAL'], + ['serious', 'CRITICAL'], + ['moderate', 'UNKNOWN'], + ['service', 'OK'], + ], + }; + + $self->{components_path} = 'storage::hitachi::standard::snmp::mode::components'; + $self->{components_module} = ['component', 'dkc', 'dku']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'component', 'dkc', 'dku'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=dkc) +Can also exclude specific instance: --filter=dkc,1.fan + +=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='component,NAS Server,OK,abnormal' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/hitachi/standard/snmp/plugin.pm b/centreon-plugins/storage/hitachi/standard/snmp/plugin.pm new file mode 100644 index 000000000..da2fa06da --- /dev/null +++ b/centreon-plugins/storage/hitachi/standard/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::hitachi::standard::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}} = ( + 'hardware' => 'storage::hitachi::standard::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Hitachi Storage (9990, df600,...) in SNMP. + +=cut diff --git a/centreon-plugins/storage/hp/3par/7000/mode/battery.pm b/centreon-plugins/storage/hp/3par/7000/mode/battery.pm index 8d26ffa3a..250545729 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/battery.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/battery.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/cim.pm b/centreon-plugins/storage/hp/3par/7000/mode/cim.pm index 97ff6e092..b075930a6 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/cim.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/cim.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/iscsi.pm b/centreon-plugins/storage/hp/3par/7000/mode/iscsi.pm index 6302add0d..3dd4c1d10 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/iscsi.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/iscsi.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/node.pm b/centreon-plugins/storage/hp/3par/7000/mode/node.pm index 9ab552ffc..bb844743f 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/node.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/node.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/physicaldisk.pm b/centreon-plugins/storage/hp/3par/7000/mode/physicaldisk.pm index 22e1e1ccc..7e3edfb11 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/physicaldisk.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/physicaldisk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/psu.pm b/centreon-plugins/storage/hp/3par/7000/mode/psu.pm index 643968db1..6b615a425 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/psu.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/storage.pm b/centreon-plugins/storage/hp/3par/7000/mode/storage.pm index 2dc2dc837..33120dbf1 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/storage.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/storage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/temperature.pm b/centreon-plugins/storage/hp/3par/7000/mode/temperature.pm index 204c3d26c..0d85e2bf9 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/temperature.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/volume.pm b/centreon-plugins/storage/hp/3par/7000/mode/volume.pm index f691f9387..69876b73d 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/volume.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/volume.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/mode/wsapi.pm b/centreon-plugins/storage/hp/3par/7000/mode/wsapi.pm index b84e7c84b..cf58bfb85 100644 --- a/centreon-plugins/storage/hp/3par/7000/mode/wsapi.pm +++ b/centreon-plugins/storage/hp/3par/7000/mode/wsapi.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/3par/7000/plugin.pm b/centreon-plugins/storage/hp/3par/7000/plugin.pm index 68336b015..c11a33aff 100644 --- a/centreon-plugins/storage/hp/3par/7000/plugin.pm +++ b/centreon-plugins/storage/hp/3par/7000/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/device.pm b/centreon-plugins/storage/hp/lefthand/mode/components/device.pm index f549b6c59..de2a844fa 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/device.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/device.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/fan.pm b/centreon-plugins/storage/hp/lefthand/mode/components/fan.pm index dbb18f5f9..694dafaa8 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/fan.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/psu.pm b/centreon-plugins/storage/hp/lefthand/mode/components/psu.pm index 2dcdcc69a..a165f1eff 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/psu.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/rc.pm b/centreon-plugins/storage/hp/lefthand/mode/components/rc.pm index bed3e321a..aafdc61a7 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/rc.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/rc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/rcc.pm b/centreon-plugins/storage/hp/lefthand/mode/components/rcc.pm index c834f04ab..75bcedd70 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/rcc.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/rcc.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/ro.pm b/centreon-plugins/storage/hp/lefthand/mode/components/ro.pm index d5e117fbd..333eb2814 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/ro.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/ro.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/temperature.pm b/centreon-plugins/storage/hp/lefthand/mode/components/temperature.pm index e8ab40068..6d65c6f59 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/temperature.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/components/voltage.pm b/centreon-plugins/storage/hp/lefthand/mode/components/voltage.pm index c4ae83ef0..bb4764663 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/components/voltage.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/lefthand/mode/hardware.pm b/centreon-plugins/storage/hp/lefthand/mode/hardware.pm index bd5f0842f..691d4e219 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/hardware.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -93,7 +93,6 @@ sub component { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->get_global_information(); diff --git a/centreon-plugins/storage/hp/lefthand/plugin.pm b/centreon-plugins/storage/hp/lefthand/plugin.pm index 94f926865..1c19dc751 100644 --- a/centreon-plugins/storage/hp/lefthand/plugin.pm +++ b/centreon-plugins/storage/hp/lefthand/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/hp/msa2000/snmp/plugin.pm b/centreon-plugins/storage/hp/msa2000/snmp/plugin.pm index ab9ae08f9..3df6de7b0 100644 --- a/centreon-plugins/storage/hp/msa2000/snmp/plugin.pm +++ b/centreon-plugins/storage/hp/msa2000/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/hp/msl/snmp/mode/status.pm b/centreon-plugins/storage/hp/msl/snmp/mode/status.pm index 7e6c972b7..586fee416 100644 --- a/centreon-plugins/storage/hp/msl/snmp/mode/status.pm +++ b/centreon-plugins/storage/hp/msl/snmp/mode/status.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -68,12 +68,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -84,7 +84,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $result = $self->{snmp}->get_leef(oids => [$oid_hpHttpMgDeviceHealth], diff --git a/centreon-plugins/storage/hp/msl/snmp/plugin.pm b/centreon-plugins/storage/hp/msl/snmp/plugin.pm index b8d5fdccd..9f54755cd 100644 --- a/centreon-plugins/storage/hp/msl/snmp/plugin.pm +++ b/centreon-plugins/storage/hp/msl/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/custom.pm b/centreon-plugins/storage/hp/p2000/xmlapi/custom.pm index dfe430abd..2b5e1308e 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/custom.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/custom.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/disk.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/disk.pm index b2db95bf5..92735ebd0 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/disk.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/enclosure.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/enclosure.pm index 9f01b161e..93ac96877 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/enclosure.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/enclosure.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/fru.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/fru.pm index 577c4c68f..c7805ff84 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/fru.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/fru.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/sensors.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/sensors.pm index 3ba3b8db0..a6c90fa9b 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/sensors.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/sensors.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/vdisk.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/vdisk.pm index a44f2495c..d179207a5 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/vdisk.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/components/vdisk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/health.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/health.pm index 5737c345e..817fe5cfe 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/health.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/health.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/listvolumes.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/listvolumes.pm index 7fd3f2f67..929fc78db 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/listvolumes.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/listvolumes.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/mode/volumesstats.pm b/centreon-plugins/storage/hp/p2000/xmlapi/mode/volumesstats.pm index ac8fe0b10..6ef4c6ed4 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/mode/volumesstats.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/mode/volumesstats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm b/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm index 22f850885..371fb14ed 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm b/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm new file mode 100644 index 000000000..ebec97e7f --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm @@ -0,0 +1,196 @@ +# +# Copyright 2016 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::hp::storeonce::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use XML::Simple; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + + 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', }, + "username:s@" => { name => 'username', }, + "password:s@" => { name => '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->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; + $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{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->{hostname}) || + scalar(@{$self->{option_results}->{hostname}}) == 0) { + return 0; + } + return 1; +} + +sub build_options_for_httplib { + my ($self, %options) = @_; + + $self->{option_results}->{hostname} = $self->{hostname}; + $self->{option_results}->{timeout} = $self->{timeout}; + $self->{option_results}->{port} = 443; + $self->{option_results}->{proto} = 'https'; + $self->{option_results}->{proxyurl} = $self->{proxyurl}; + $self->{option_results}->{credentials} = 1; + $self->{option_results}->{username} = $self->{username}; + $self->{option_results}->{password} = $self->{password}; +} + +sub settings { + my ($self, %options) = @_; + + $self->build_options_for_httplib(); + $self->{http}->add_header(key => 'Accept', value => 'text/xml'); + $self->{http}->set_options(%{$self->{option_results}}); +} + +#my $xml = XMLin($biggest_reponse, ForceArray => 1); + +sub get { + my ($self, %options) = @_; + + $self->settings(); + + my $response = $self->{http}->request(url_path => '/storeonceservices' . $options{path}, + critical_status => '', warning_status => ''); + my $content; + eval { + $content = XMLin($response, ForceArray => $options{ForceArray}); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@"); + $self->{output}->option_exit(); + } + + return $content; +} + +1; + +__END__ + +=head1 NAME + +STOREONCE REST API + +=head1 SYNOPSIS + +Storeonce Rest API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +Storeonce hostname. + +=item B<--username> + +Storeonce username. + +=item B<--password> + +Storeonce password. + +=item B<--proxyurl> + +Proxy URL if any + +=item B<--timeout> + +Set HTTP timeout + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon-plugins/storage/hp/storeonce/restapi/mode/clusterusage.pm b/centreon-plugins/storage/hp/storeonce/restapi/mode/clusterusage.pm new file mode 100644 index 000000000..6a5086a27 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/mode/clusterusage.pm @@ -0,0 +1,297 @@ +# +# Copyright 2016 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::hp::storeonce::restapi::mode::clusterusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{health}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = 'used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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("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}->{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_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok' } + ]; + + $self->{maps_counters}->{cluster} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'health' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + { label => 'dedup', set => { + key_values => [ { name => 'dedup' }, { name => 'display' } ], + output_template => 'Dedup Ratio : %.2f', + perfdatas => [ + { label => 'dedup_ratio', value => 'dedup_absolute', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' }, + "critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "Cluster '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %mapping_health_level = ( + 0 => 'unknown', + 1 => 'ok', + 2 => 'information', + 3 => 'warning', + 4 => 'critical', +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cluster} = {}; + my $result = $options{custom}->get(path => '/cluster', ForceArray => ['cluster']); + if (defined($result->{cluster})) { + foreach my $entry (@{$result->{cluster}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $entry->{properties}->{applianceName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $entry->{properties}->{applianceName} . "': no matching filter.", debug => 1); + next; + } + + $self->{cluster}->{$entry->{properties}->{serialNumber}} = { + display => $entry->{properties}->{applianceName}, + health => $mapping_health_level{$entry->{properties}->{healthLevel}}, + total => $entry->{properties}->{capacity} * 1024 * 1024 * 1024, # GB + used => ($entry->{properties}->{capacity} - $entry->{properties}->{freeSpace}) * 1024 * 1024 * 1024, # GB + dedup => $entry->{properties}->{dedupeRatio} }; + } + } + + if (scalar(keys %{$self->{cluster}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No cluster found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check cluster usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter cluster name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{health} =~ /warning/). +Can used special variables like: %{health}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{health} =~ /critical/'). +Can used special variables like: %{health}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage', 'dedup'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage', 'dedup'. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=back + +=cut diff --git a/centreon-plugins/storage/hp/storeonce/restapi/mode/fcsusage.pm b/centreon-plugins/storage/hp/storeonce/restapi/mode/fcsusage.pm new file mode 100644 index 000000000..621fd26c9 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/mode/fcsusage.pm @@ -0,0 +1,235 @@ +# +# Copyright 2016 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::hp::storeonce::restapi::mode::fcsusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{health}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; + $self->{result_values}->{is_online} = $options{new_datas}->{$self->{instance} . '_is_online'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'fcs', type => 1, cb_prefix_output => 'prefix_fcs_output', message_multiple => 'All federated catalyst stores are ok' } + ]; + + $self->{maps_counters}->{fcs} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'is_online' }, { name => 'health' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'usage', set => { + key_values => [ { name => 'used' }, { name => 'display' } ], + output_template => 'Used : %s %s', + output_change_bytes => 1, + perfdatas => [ + { label => 'used', value => 'used_absolute', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'dedup', set => { + key_values => [ { name => 'dedup' }, { name => 'display' } ], + output_template => 'Dedup Ratio : %.2f', + perfdatas => [ + { label => 'dedup_ratio', value => 'dedup_absolute', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'items', set => { + key_values => [ { name => 'num_items' }, { name => 'display' } ], + output_template => 'Num Items : %s', + perfdatas => [ + { label => 'items', value => 'num_items_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '%{is_online} == 1 and %{health} =~ /warning/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{is_online} == 1 and %{health} =~ /critical/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_fcs_output { + my ($self, %options) = @_; + + return "Federated catalyst store '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %mapping_health_level = ( + 0 => 'unknown', + 1 => 'ok', + 2 => 'information', + 3 => 'warning', + 4 => 'critical', +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{fcs} = {}; + my $result = $options{custom}->get(path => '/cluster/servicesets/*all*/teaming/services/cat/stores', ForceArray => ['store']); + if (defined($result->{stores}->{store})) { + foreach my $entry (@{$result->{stores}->{store}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $entry->{properties}->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $entry->{properties}->{name} . "': no matching filter.", debug => 1); + next; + } + + $self->{fcs}->{$entry->{properties}->{id}} = { + display => $entry->{properties}->{name}, + health => $mapping_health_level{$entry->{properties}->{healthLevel}}, + is_online => $entry->{properties}->{isOnline} eq 'true' ? 1 : 0, + used => $entry->{properties}->{diskBytes}, + dedup => $entry->{properties}->{dedupeRatio}, + num_items => $entry->{properties}->{numItems} }; + } + } + + if (scalar(keys %{$self->{fcs}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No federated catalyst store found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check federated catalyst store usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{is_online} == 1 and %{health} =~ /warning/i'). +Can used special variables like: %{health}, %{is_online}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{is_online} == 1 and %{health} =~ /critical/i'). +Can used special variables like: %{health}, %{is_online}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage', 'dedup', 'items'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage', 'dedup', 'items'. + +=back + +=cut diff --git a/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm b/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm new file mode 100644 index 000000000..f18079799 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm @@ -0,0 +1,299 @@ +# +# Copyright 2016 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::hp::storeonce::restapi::mode::servicesetusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{health}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; + $self->{result_values}->{housekeeping_health} = $options{new_datas}->{$self->{instance} . '_housekeeping_health'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = 'used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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("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}->{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_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'scs', type => 1, cb_prefix_output => 'prefix_scs_output', message_multiple => 'All service sets are ok' } + ]; + + $self->{maps_counters}->{scs} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'health' }, { name => 'housekeeping_health' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + { label => 'dedup', set => { + key_values => [ { name => 'dedup' }, { name => 'display' } ], + output_template => 'Dedup Ratio : %.2f', + perfdatas => [ + { label => 'dedup_ratio', value => 'dedup_absolute', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' }, + "critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_scs_output { + my ($self, %options) = @_; + + return "Service set '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %mapping_health_level = ( + 0 => 'unknown', + 1 => 'ok', + 2 => 'information', + 3 => 'warning', + 4 => 'critical', +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{scs} = {}; + my $result = $options{custom}->get(path => '/cluster/servicesets', ForceArray => ['serviceset']); + if (defined($result->{servicesets}->{serviceset})) { + foreach my $entry (@{$result->{servicesets}->{serviceset}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $entry->{properties}->{alias} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $entry->{properties}->{alias} . "': no matching filter.", debug => 1); + next; + } + + $self->{scs}->{$entry->{properties}->{ssid}} = { + display => $entry->{properties}->{alias}, + health => $mapping_health_level{$entry->{properties}->{healthLevel}}, + housekeeping_health => $mapping_health_level{$entry->{properties}->{housekeepingHealthLevel}}, + total => $entry->{properties}->{capacityBytes}, + used => $entry->{properties}->{capacityBytes} - $entry->{properties}->{freeBytes}, + dedup => $entry->{properties}->{dedupeRatio} }; + } + } + + if (scalar(keys %{$self->{scs}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No service set found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check service set usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter service set name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{health} =~ /warning/). +Can used special variables like: %{health}, %{housekeeping_health}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{health} =~ /critical/'). +Can used special variables like: %{health}, %{housekeeping_health}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage', 'dedup'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage', 'dedup'. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=back + +=cut diff --git a/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm b/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm new file mode 100644 index 000000000..9ed7fa1d3 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2016 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::hp::storeonce::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; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cluster-usage' => 'storage::hp::storeonce::restapi::mode::clusterusage', + 'fcs-usage' => 'storage::hp::storeonce::restapi::mode::fcsusage', + 'serviceset-usage' => 'storage::hp::storeonce::restapi::mode::servicesetusage', + ); + + $self->{custom_modes}{api} = 'storage::hp::storeonce::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Hp Storeonce through HTTP/REST API. diff --git a/centreon-plugins/storage/hp/storeonce/ssh/custom/custom.pm b/centreon-plugins/storage/hp/storeonce/ssh/custom/custom.pm new file mode 100644 index 000000000..8e1f2118a --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/ssh/custom/custom.pm @@ -0,0 +1,170 @@ +# +# Copyright 2016 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::hp::storeonce::ssh::custom::custom; + +use strict; +use warnings; +use centreon::plugins::misc; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + + 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' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 45 }, + "command:s" => { name => 'command' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'SSH OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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) = @_; + + $self->{option_results}->{remote} = 1; + if (defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '') { + $self->{option_results}->{remote} = 0; + } elsif (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to set hostname option."); + $self->{output}->option_exit(); + } + + return 0; +} + +############## +# Specific methods +############## +sub execute_command { + my ($self, %options) = @_; + + $self->{ssh_commands} = ''; + foreach (@{$options{commands}}) { + $self->{ssh_commands} .= "$_\n"; + } + return centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + ssh_pipe => 1, + command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $self->{ssh_commands} . "exit\n", + command_path => $self->{option_results}->{command_path}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef); +} + +1; + +__END__ + +=head1 NAME + +ssh + +=head1 SYNOPSIS + +my ssh + +=head1 SSH OPTIONS + +=over 8 + +=item B<--hostname> + +Hostname to query. + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 45). + +=item B<--command> + +Command to get information. Used it you have output in a file. + +=item B<--command-path> + +Command path. + +=item B<--command-options> + +Command options. + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm new file mode 100644 index 000000000..904d1ee0b --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm @@ -0,0 +1,97 @@ +# +# Copyright 2016 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::hp::storeonce::ssh::mode::components::hardware; + +use strict; +use warnings; +use centreon::plugins::misc; + +sub load { + my ($self) = @_; + + #Name + #------------------------------------------------------------------ + #hp80239e8624-1 + # Dev-id = 31343337-3338-5A43-3235-323430375631 + # Status = OK + # message = - + # type = server + # model = ProLiant DL380p Gen8 + # serialNumber = CZ252407V1 + # firmwareVersion = P70 07/01/2015 + # location = - + # warrantySerialNumber = CZ35283EK4 + # warrantyPartNumber = BB896A + # SKU = 734183-B21 + # + #hp80239e8624-2 + # Dev-id = 31343337-3338-5A43-3235-323431303648 + # Status = OK + # message = - + # type = server + # model = ProLiant DL380p Gen8 + # serialNumber = CZ2524106H + # firmwareVersion = P70 07/01/2015 + # location = - + # warrantySerialNumber = CZ35283EK4 + # warrantyPartNumber = BB896A + # SKU = 734183-B21 + + push @{$self->{commands}}, "hardware show status details"; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking hardwares"); + $self->{components}->{hardware} = {name => 'hardwares', total => 0, skip => 0}; + return if ($self->check_filter(section => 'hardware')); + + return if ($self->{result} !~ /[>#]\s*hardware show status details(.*?)\n[>#]/msi); + my $content = $1; + + while ($content =~ /^(\S+[^\n]*?)\n\s+(.*?)\n\s*?\n/msgi) { + my ($name, $details) = (centreon::plugins::misc::trim($1), $2); + + $details =~ /type.*?=\s*(.*?)\n/msi; + my $type = centreon::plugins::misc::trim($1); + $details =~ /Status.*?=\s*(.*?)\n/msi; + my $status = centreon::plugins::misc::trim($1); + $details =~ /Dev-id.*?=\s*(.*?)\n/msi; + my $dev_id = centreon::plugins::misc::trim($1); + + next if ($self->check_filter(section => 'hardware', instance => $type . '.' . $dev_id)); + $self->{components}->{hardware}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance: %s, name: %s].", + $type, $dev_id, $status, + $type . '.' . $dev_id, $name + )); + my $exit = $self->get_severity(section => 'hardware', instance => $type . '.' . $dev_id, value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%s '%s' status is '%s'", + $type, $dev_id, $status)); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm new file mode 100644 index 000000000..d66455694 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm @@ -0,0 +1,85 @@ +# +# Copyright 2016 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::hp::storeonce::ssh::mode::components::serviceset; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + #Service Set 1 Status + #------------- ------- + #Overall : Running + #StoreOnce Subsystem : Running + #Virtual Tape : Running + #NAS : Running + #StoreOnce Catalyst : Running + #Replication : Running + #Housekeeping : Running + # + #Service Set 2 Status + #------------- ------- + #Overall : Running + #StoreOnce Subsystem : Running + #Virtual Tape : Running + #NAS : Running + #StoreOnce Catalyst : Running + #Replication : Running + #Housekeeping : Running + + push @{$self->{commands}}, "serviceset show status"; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking service sets"); + $self->{components}->{serviceset} = {name => 'service sets', total => 0, skip => 0}; + return if ($self->check_filter(section => 'serviceset')); + + return if ($self->{result} !~ /[>#]\s*serviceset show status(.*?)\n[>#]/msi); + my $content = $1; + + while ($content =~ /^Service Set (\d+).*?\n(.*?)\n\s*?\n/msgi) { + my ($num, $details) = ($1, $2); + + while ($details =~ /^([^\n]+?):\s*(.*?)\n/msgi) { + my ($instance, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'serviceset', instance => $num . '.' . $instance)); + $self->{components}->{serviceset}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("service set '%s' %s status is '%s' [instance: %s].", + $num, $instance, $status, + $num . '.' . $instance + )); + my $exit = $self->get_severity(section => 'serviceset', instance => $num . '.' . $instance, value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("service set '%s' %s status is '%s'", + $num, $instance, $status)); + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/hp/storeonce/ssh/mode/hardware.pm b/centreon-plugins/storage/hp/storeonce/ssh/mode/hardware.pm new file mode 100644 index 000000000..428207e54 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/ssh/mode/hardware.pm @@ -0,0 +1,126 @@ +# +# Copyright 2016 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::hp::storeonce::ssh::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(hardware|serviceset)$'; + + $self->{cb_hook2} = 'ssh_execute'; + + $self->{thresholds} = { + hardware => [ + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ['degraded', 'WARNING'], + ['missing', 'OK'], + ], + serviceset => [ + ['running', 'OK'], + ['fault', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::hp::storeonce::ssh::mode::components'; + $self->{components_module} = ['hardware', 'serviceset']; +} + +sub ssh_execute { + my ($self, %options) = @_; + + ($self->{result}, $self->{exit_code}) = $options{custom}->execute_command(commands => $self->{commands}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + $self->{commands} = []; + return $self; +} + +sub get_hasharray { + my ($self, %options) = @_; + + my $result = []; + return $result if ($options{content} eq ''); + my ($header, @lines) = split /\n/, $options{content}; + my @header_names = split /$options{delim}/, $header; + + for (my $i = 0; $i <= $#lines; $i++) { + my @content = split /$options{delim}/, $lines[$i]; + my $data = {}; + for (my $j = 0; $j <= $#header_names; $j++) { + $data->{$header_names[$j]} = $content[$j]; + } + push @$result, $data; + } + + return $result; +} + +1; + +__END__ + +=head1 MODE + +Check components (hardware and service set). + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'hardware', 'serviceset'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=hardware --filter=serviceset) +Can also exclude specific instance: --filter=hardware,storageCluster + +=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='hardware,networkSwitch,OK,degraded' + +=back + +=cut diff --git a/centreon-plugins/storage/hp/storeonce/ssh/plugin.pm b/centreon-plugins/storage/hp/storeonce/ssh/plugin.pm new file mode 100644 index 000000000..cdd48867e --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/ssh/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2016 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::hp::storeonce::ssh::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; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'components' => 'storage::hp::storeonce::ssh::mode::hardware', + ); + + $self->{custom_modes}{ssh} = 'storage::hp::storeonce::ssh::custom::custom'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check HP Storeonce in SSH. + +=cut diff --git a/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm b/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm index 9a3df4d78..55ae39f9f 100644 --- a/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm +++ b/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/ibm/DS4000/cli/plugin.pm b/centreon-plugins/storage/ibm/DS4000/cli/plugin.pm index 9410c813b..40de84be7 100644 --- a/centreon-plugins/storage/ibm/DS4000/cli/plugin.pm +++ b/centreon-plugins/storage/ibm/DS4000/cli/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/ibm/DS5000/cli/plugin.pm b/centreon-plugins/storage/ibm/DS5000/cli/plugin.pm index ba78dc956..72b3e8d64 100644 --- a/centreon-plugins/storage/ibm/DS5000/cli/plugin.pm +++ b/centreon-plugins/storage/ibm/DS5000/cli/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -29,7 +29,6 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/ibm/TS3100/mode/globalstatus.pm b/centreon-plugins/storage/ibm/TS3100/mode/globalstatus.pm index a56a6d665..a4601826a 100644 --- a/centreon-plugins/storage/ibm/TS3100/mode/globalstatus.pm +++ b/centreon-plugins/storage/ibm/TS3100/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -48,18 +48,18 @@ sub new { return $self; } -sub check_treshold_overload { +sub check_threshold_overload { my ($self, %options) = @_; $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /(.*?)=(.*)/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($filter, $threshold) = ($1, $2); if ($self->{output}->is_litteral_status(status => $threshold) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $self->{overload_th}->{$filter} = $threshold; @@ -69,6 +69,7 @@ sub check_treshold_overload { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + $self->check_threshold_overload(); } sub get_severity { @@ -85,7 +86,6 @@ sub get_severity { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_ibm3100StatusGlobalStatus = '.1.3.6.1.4.1.2.6.210.2.1.0'; diff --git a/centreon-plugins/storage/ibm/TS3100/plugin.pm b/centreon-plugins/storage/ibm/TS3100/plugin.pm index 629474cc7..f9970a392 100644 --- a/centreon-plugins/storage/ibm/TS3100/plugin.pm +++ b/centreon-plugins/storage/ibm/TS3100/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/ibm/TS3200/mode/globalstatus.pm b/centreon-plugins/storage/ibm/TS3200/mode/globalstatus.pm index 1f4a916d8..a9fec788e 100644 --- a/centreon-plugins/storage/ibm/TS3200/mode/globalstatus.pm +++ b/centreon-plugins/storage/ibm/TS3200/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -48,18 +48,18 @@ sub new { return $self; } -sub check_treshold_overload { +sub check_threshold_overload { my ($self, %options) = @_; $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /(.*?)=(.*)/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($filter, $threshold) = ($1, $2); if ($self->{output}->is_litteral_status(status => $threshold) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $self->{overload_th}->{$filter} = $threshold; @@ -69,6 +69,7 @@ sub check_treshold_overload { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + $self->check_threshold_overload(); } sub get_severity { @@ -85,7 +86,6 @@ sub get_severity { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_ibm3200StatusGlobalStatus = '.1.3.6.1.4.1.2.6.211.2.1.0'; diff --git a/centreon-plugins/storage/ibm/TS3200/plugin.pm b/centreon-plugins/storage/ibm/TS3200/plugin.pm index 7e4d372a0..583b91e15 100644 --- a/centreon-plugins/storage/ibm/TS3200/plugin.pm +++ b/centreon-plugins/storage/ibm/TS3200/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/array.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/array.pm new file mode 100644 index 000000000..f8c1eb39a --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/array.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::array; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsarray=========="; lsarray -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking arrays"); + $self->{components}->{array} = {name => 'arrays', total => 0, skip => 0}; + return if ($self->check_filter(section => 'array')); + + return if ($self->{results} !~ /==========lsarray==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'array', instance => $_->{mdisk_id})); + $self->{components}->{array}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("array '%s' status is '%s' [instance: %s].", + $_->{mdisk_name}, $_->{status}, + $_->{mdisk_id} + )); + my $exit = $self->get_severity(label => 'default', section => 'array', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Array '%s' status is '%s'", + $_->{mdisk_name}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/drive.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/drive.pm new file mode 100644 index 000000000..e0afd26d8 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/drive.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::drive; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsdrive=========="; lsdrive -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking drives"); + $self->{components}->{drive} = {name => 'drives', total => 0, skip => 0}; + return if ($self->check_filter(section => 'drive')); + + return if ($self->{results} !~ /==========lsdrive==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'drive', instance => $_->{id})); + $self->{components}->{drive}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("drive '%s' status is '%s' [instance: %s].", + $_->{id}, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(label => 'default', section => 'drive', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Drive '%s' status is '%s'", + $_->{id}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosure.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosure.pm new file mode 100644 index 000000000..c581613b0 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosure.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::enclosure; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsenclosure=========="; lsenclosure -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosures"); + $self->{components}->{enclosure} = {name => 'enclosures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'enclosure')); + + return if ($self->{results} !~ /==========lsenclosure==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'enclosure', instance => $_->{id})); + $self->{components}->{enclosure}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure '%s' status is '%s' [instance: %s].", + $_->{id}, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(label => 'default', section => 'enclosure', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure '%s' status is '%s'", + $_->{id}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm new file mode 100644 index 000000000..75d38992a --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm @@ -0,0 +1,61 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::enclosurebattery; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsenclosurebattery=========="; lsenclosurebattery -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure batteries"); + $self->{components}->{enclosurebattery} = {name => 'enclosure batteries', total => 0, skip => 0}; + return if ($self->check_filter(section => 'enclosurebattery')); + + return if ($self->{results} !~ /==========lsenclosurebattery==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + my $instance = $_->{enclosure_id} . '.' . $_->{battery_id}; + next if ($self->check_filter(section => 'enclosurebattery', instance => $instance)); + $self->{components}->{enclosurebattery}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure battery '%s' status is '%s' [instance: %s].", + $instance, $_->{status}, + $instance + )); + my $exit = $self->get_severity(label => 'default', section => 'enclosurebattery', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure battery '%s' status is '%s'", + $instance, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm new file mode 100644 index 000000000..41c78f2a2 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm @@ -0,0 +1,61 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::enclosurecanister; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsenclosurecanister=========="; lsenclosurecanister -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure canisters"); + $self->{components}->{enclosurecanister} = {name => 'enclosure canisters', total => 0, skip => 0}; + return if ($self->check_filter(section => 'enclosurecanister')); + + return if ($self->{results} !~ /==========lsenclosurecanister==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + my $instance = $_->{enclosure_id} . '.' . $_->{canister_id}; + next if ($self->check_filter(section => 'enclosurecanister', instance => $instance)); + $self->{components}->{enclosurecanister}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure canister '%s' status is '%s' [instance: %s].", + $instance, $_->{status}, + $instance + )); + my $exit = $self->get_severity(label => 'default', section => 'enclosurecanister', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure canister '%s' status is '%s'", + $instance, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm new file mode 100644 index 000000000..6f56b3b03 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm @@ -0,0 +1,61 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::enclosurepsu; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsenclosurepsu=========="; lsenclosurepsu -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosure psus"); + $self->{components}->{enclosurepsu} = {name => 'enclosure psus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'enclosurepsu')); + + return if ($self->{results} !~ /==========lsenclosurepsu==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + my $instance = $_->{enclosure_id} . '.' . $_->{PSU_id}; + next if ($self->check_filter(section => 'enclosurepsu', instance => $instance)); + $self->{components}->{enclosurepsu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure power supply '%s' status is '%s' [instance: %s].", + $instance, $_->{status}, + $instance + )); + my $exit = $self->get_severity(label => 'default', section => 'enclosurepsu', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure power supply '%s' status is '%s'", + $instance, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/host.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/host.pm new file mode 100644 index 000000000..d82f3ee8a --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/host.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::host; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lshost=========="; lshost -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking hosts"); + $self->{components}->{host} = {name => 'hosts', total => 0, skip => 0}; + return if ($self->check_filter(section => 'host')); + + return if ($self->{results} !~ /==========lshost==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'host', instance => $_->{id})); + $self->{components}->{host}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("host '%s' status is '%s' [instance: %s].", + $_->{name}, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(label => 'default', section => 'host', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Host '%s' status is '%s'", + $_->{name}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/mdisk.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/mdisk.pm new file mode 100644 index 000000000..fc6423cad --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/mdisk.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::mdisk; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsmdisk=========="; lsmdisk -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking mdisks"); + $self->{components}->{mdisk} = {name => 'mdisks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'mdisk')); + + return if ($self->{results} !~ /==========lsmdisk==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'mdisk', instance => $_->{id})); + $self->{components}->{mdisk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("mdisk '%s' status is '%s' [instance: %s].", + $_->{name}, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(section => 'mdisk', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("MDisk '%s' status is '%s'", + $_->{name}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/node.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/node.pm new file mode 100644 index 000000000..cfef24c4b --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/node.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::node; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsnode=========="; lsnode -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking nodes"); + $self->{components}->{node} = {name => 'nodes', total => 0, skip => 0}; + return if ($self->check_filter(section => 'node')); + + return if ($self->{results} !~ /==========lsnode==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'node', instance => $_->{id})); + $self->{components}->{node}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("node '%s' status is '%s' [instance: %s].", + $_->{name}, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(label => 'default', section => 'node', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Node '%s' status is '%s'", + $_->{name}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/portfc.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/portfc.pm new file mode 100644 index 000000000..9d7d6c4e1 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/portfc.pm @@ -0,0 +1,61 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::portfc; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsportfc=========="; lsportfc -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking portfc"); + $self->{components}->{portfc} = {name => 'portfc', total => 0, skip => 0}; + return if ($self->check_filter(section => 'portfc')); + + return if ($self->{results} !~ /==========lsportfc==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'portfc', instance => $_->{id})); + $self->{components}->{portfc}->{total}++; + + my $name = $_->{node_name} . "." . $_->{WWPN}; + $self->{output}->output_add(long_msg => sprintf("portfc '%s' status is '%s' [instance: %s].", + $name, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(section => 'portfc', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PortFC '%s' status is '%s'", + $name, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/portsas.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/portsas.pm new file mode 100644 index 000000000..34b9f838f --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/portsas.pm @@ -0,0 +1,61 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::portsas; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsportsas=========="; lsportsas -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking portsas"); + $self->{components}->{portsas} = {name => 'portsas', total => 0, skip => 0}; + return if ($self->check_filter(section => 'portsas')); + + return if ($self->{results} !~ /==========lsportsas==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'portsas', instance => $_->{id})); + $self->{components}->{portsas}->{total}++; + + my $name = $_->{node_name} . "." . $_->{WWPN}; + $self->{output}->output_add(long_msg => sprintf("port sas '%s' status is '%s' [instance: %s].", + $name, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(section => 'portsas', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Port sas '%s' status is '%s'", + $name, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/quorum.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/quorum.pm new file mode 100644 index 000000000..bf01dcf97 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/quorum.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::quorum; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsquorum=========="; lsquorum -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking quorums"); + $self->{components}->{quorum} = {name => 'quorums', total => 0, skip => 0}; + return if ($self->check_filter(section => 'quorum')); + + return if ($self->{results} !~ /==========lsquorum==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'quorum', instance => $_->{quorum_index})); + $self->{components}->{quorum}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("quorum '%s' status is '%s' [instance: %s].", + $_->{controller_name}, $_->{status}, + $_->{quorum_index} + )); + my $exit = $self->get_severity(label => 'default', section => 'quorum', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Quorum '%s' status is '%s'", + $_->{controller_name}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/systemstats.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/systemstats.pm new file mode 100644 index 000000000..180f460e4 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/systemstats.pm @@ -0,0 +1,63 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::systemstats; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lssystemstats=========="; lssystemstats ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking systemstats"); + $self->{components}->{systemstats} = {name => 'systemstats', total => 0, skip => 0}; + return if ($self->check_filter(section => 'systemstats')); + + return if ($self->{results} !~ /==========lssystemstats==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => '\s+'); + foreach (@$result) { + next if ($self->check_filter(section => 'systemstats', instance => $_->{stat_name})); + $self->{components}->{systemstats}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("system stat '%s' value is '%s' [instance: %s].", + $_->{stat_name}, $_->{stat_current}, + $_->{stat_name} + )); + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'systemstats', instance => $_->{stat_name}, value => $_->{stat_current}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System stat '%s' value is '%s'", $_->{stat_name}, $_->{stat_current})); + } + $self->{output}->perfdata_add(label => "sstat_" . $_->{stat_name}, + value => $_->{stat_current}, + warning => $warn, + critical => $crit); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/components/vdisk.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/vdisk.pm new file mode 100644 index 000000000..9fe8c51f3 --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/components/vdisk.pm @@ -0,0 +1,60 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::components::vdisk; + +use strict; +use warnings; + +sub load { + my ($self) = @_; + + $self->{ssh_commands} .= 'echo "==========lsvdisk=========="; lsvdisk -delim : ; echo "===============";'; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking vdisks"); + $self->{components}->{vdisk} = {name => 'vdisks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'vdisk')); + + return if ($self->{results} !~ /==========lsvdisk==.*?\n(.*?)==============/msi); + my $content = $1; + + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + next if ($self->check_filter(section => 'vdisk', instance => $_->{id})); + $self->{components}->{vdisk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("vdisk '%s' status is '%s' [instance: %s].", + $_->{name}, $_->{status}, + $_->{id} + )); + my $exit = $self->get_severity(label => 'default', section => 'vdisk', value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Vdisk '%s' status is '%s'", + $_->{name}, $_->{status})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/eventlog.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/eventlog.pm new file mode 100644 index 000000000..2ad93623a --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/eventlog.pm @@ -0,0 +1,219 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::eventlog; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use DateTime; + +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-event-id:s" => { name => 'filter_event_id' }, + "filter-message:s" => { name => 'filter_message' }, + "retention:s" => { name => 'retention' }, + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options' }, + }); + + 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}->{hostname}) && $self->{option_results}->{hostname} ne '') { + $self->{option_results}->{remote} = 1; + } + + my $last_timestamp = ''; + if (defined($self->{option_results}->{retention}) && $self->{option_results}->{retention} =~ /^\d+$/) { + # by default UTC timezone used + my $dt = DateTime->from_epoch(epoch => time() - $self->{option_results}->{retention}); + my $dt_format = sprintf("%d%02d%02d%02d%02d%02d", substr($dt->year(), 2), $dt->month(), $dt->day(), $dt->hour(), $dt->minute(), $dt->second()); + $last_timestamp = 'last_timestamp>=' . $dt_format . ":"; + } + $self->{ls_command} = "lseventlog -message no -alert yes -filtervalue '${last_timestamp}fixed=no' -delim :"; +} + +sub get_hasharray { + my ($self, %options) = @_; + + my $result = []; + return $result if ($options{content} eq ''); + my ($header, @lines) = split /\n/, $options{content}; + my @header_names = split /$options{delim}/, $header; + + for (my $i = 0; $i <= $#lines; $i++) { + my @content = split /$options{delim}/, $lines[$i]; + my $data = {}; + for (my $j = 0; $j <= $#header_names; $j++) { + $data->{$header_names[$j]} = $content[$j]; + } + push @$result, $data; + } + + return $result; +} + +sub run { + my ($self, %options) = @_; + + my $content = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $self->{ls_command} . " ; exit ;", + command_path => $self->{option_results}->{command_path}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef); + my $result = $self->get_hasharray(content => $content, delim => ':'); + + my ($num_eventlog_checked, $num_errors) = (0, 0); + foreach (@$result) { + $num_eventlog_checked++; + if (defined($self->{option_results}->{filter_message}) && $self->{option_results}->{filter_message} ne '' && + $_->{description} !~ /$self->{option_results}->{filter_message}/) { + $self->{output}->output_add(long_msg => "skipping '" . $_->{description} . "': no matching filter description.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_event_id}) && $self->{option_results}->{filter_event_id} ne '' && + $_->{event_id} !~ /$self->{option_results}->{filter_event_id}/) { + $self->{output}->output_add(long_msg => "skipping '" . $_->{event_id} . "': no matching filter event id.", debug => 1); + next; + } + + $self->{output}->output_add(long_msg => sprintf("%s : %s - %s", + scalar(localtime($_->{last_timestamp})), + $_->{event_id}, $_->{description} + ) + ); + $num_errors++; + } + + $self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_eventlog_checked)); + my $exit = $self->{perfdata}->threshold_check(value => $num_errors, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors) + ); + $self->{output}->perfdata_add(label => 'problems', + value => $num_errors, + 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 eventlogs. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=item B<--filter-event-id> + +Filter on event id. + +=item B<--filter-message> + +Filter on event message. + +=item B<--retention> + +Get eventlog of X last seconds. For the last minutes: --retention=60 + +=item B<--hostname> + +Hostname to query. + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information. Used it you have output in a file. + +=item B<--command-path> + +Command path. + +=item B<--command-options> + +Command options. + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm new file mode 100644 index 000000000..e36ed7a9e --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm @@ -0,0 +1,215 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(array|drive|enclosure|enclosurebattery|enclosurecanister|enclosurepsu|host|portfc|portsas|vdisk|node|quorum|mdisk)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(systemstats)$'; + + $self->{cb_hook2} = 'ssh_execute'; + + $self->{thresholds} = { + default => [ + ['online', 'OK'], + ['offline', 'CRITICAL'], + ['degraded', 'WARNING'], + ['excluded', 'OK'], # lsarray + ['mask', 'OK'], # lshost + ], + portfc => [ + ['active', 'OK'], + ['inactive_unconfigured', 'OK'], + ['.*', 'CRITICAL'], + ], + portsas => [ + ['online', 'OK'], + ['offline_unconfigured', 'OK'], + ['excluded', 'OK'], + ['offline', 'CRITICAL'], + ['degraded', 'WARNING'], + ], + mdisk => [ + ['online', 'OK'], + ['excluded', 'OK'], + ['offline', 'CRITICAL'], + ['degraded_paths', 'WARNING'], + ['degraded_ports', 'WARNING'], + ['degraded', 'WARNING'], + ], + }; + + $self->{components_path} = 'storage::ibm::storwize::ssh::mode::components'; + $self->{components_module} = ['array', 'drive', 'enclosure', 'enclosurebattery', 'enclosurecanister', + 'enclosurepsu', 'host', 'portfc', 'portsas', 'vdisk', 'node', 'quorum', 'mdisk', 'systemstats']; +} + +sub ssh_execute { + my ($self, %options) = @_; + + $self->{results} = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $self->{ssh_commands} . " exit ;", + command_path => $self->{option_results}->{command_path}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef); +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + $self->{option_results}->{remote} = 1; + } +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options' }, + }); + + $self->{ssh_commands} = ''; + return $self; +} + +sub get_hasharray { + my ($self, %options) = @_; + + my $result = []; + return $result if ($options{content} eq ''); + my ($header, @lines) = split /\n/, $options{content}; + my @header_names = split /$options{delim}/, $header; + + for (my $i = 0; $i <= $#lines; $i++) { + my @content = split /$options{delim}/, $lines[$i]; + my $data = {}; + for (my $j = 0; $j <= $#header_names; $j++) { + $data->{$header_names[$j]} = $content[$j]; + } + push @$result, $data; + } + + return $result; +} + +1; + +__END__ + +=head1 MODE + +Check components. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'array', 'drive', 'enclosure', 'enclosurebattery', 'enclosurecanister', +'enclosurepsu', 'host', 'portfc', 'portsas', 'vdisk', 'node', 'quorum', 'mdisk', 'systemstats'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=host --filter=enclosurecanister) +Can also exclude specific instance: --filter=host,10 + +=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='host,.*,OK,degraded' + +=item B<--warning> + +Set warning threshold for temperatures (syntax: type,regexp,threshold) +Example: --warning='systemstats,cpu_pc,30' + +=item B<--critical> + +Set critical threshold for temperatures (syntax: type,regexp,threshold) +Example: --critical='systemstats,cpu_pc,40' + +=item B<--hostname> + +Hostname to query. + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information. Used it you have output in a file. + +=item B<--command-path> + +Command path. + +=item B<--command-options> + +Command options. + +=back + +=cut diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/poolusage.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/poolusage.pm new file mode 100644 index 000000000..19437b6be --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/poolusage.pm @@ -0,0 +1,349 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::mode::poolusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = 'status : ' . $self->{result_values}->{status}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = 'used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = 'free'; + $value_perf = $self->{result_values}->{free}; + } + my $extra_label = ''; + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + my %total_options = (); + if ($instance_mode->{option_results}->{units} eq '%') { + $total_options{total} = $self->{result_values}->{total}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', + value => $value_perf, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, 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("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}->{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_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'pool', type => 1, cb_prefix_output => 'prefix_pool_output', message_multiple => 'All pools are ok' } + ]; + + $self->{maps_counters}->{pool} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /degraded/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /offline/i' }, + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + "hostname:s" => { name => 'hostname' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + $self->{option_results}->{remote} = 1; + } + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_pool_output { + my ($self, %options) = @_; + + return "Pool '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{pool} = {}; + my $content = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : "lsmdiskgrp -delim : -bytes ; exit ;", + command_path => $self->{option_results}->{command_path}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef); + my $result = $self->get_hasharray(content => $content, delim => ':'); + foreach (@$result) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $_->{name} . "': no matching filter.", debug => 1); + next; + } + + $self->{pool}->{$_->{id}} = { display => $_->{name}, + status => $_->{status}, + total => $_->{used_capacity} + $_->{free_capacity}, used => $_->{used_capacity} + }; + } + + if (scalar(keys %{$self->{pool}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No pool found."); + $self->{output}->option_exit(); + } +} + +sub get_hasharray { + my ($self, %options) = @_; + + my $result = []; + return $result if ($options{content} eq ''); + my ($header, @lines) = split /\n/, $options{content}; + my @header_names = split /$options{delim}/, $header; + + for (my $i = 0; $i <= $#lines; $i++) { + my @content = split /$options{delim}/, $lines[$i]; + my $data = {}; + for (my $j = 0; $j <= $#header_names; $j++) { + $data->{$header_names[$j]} = $content[$j]; + } + push @$result, $data; + } + + return $result; +} + +1; + +__END__ + +=head1 MODE + +Check pool usages. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--filter-name> + +Filter pool name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /degraded/i'). +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /offline/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'usage'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'usage'. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=item B<--hostname> + +Hostname to query. + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information. Used it you have output in a file. + +=item B<--command-path> + +Command path. + +=item B<--command-options> + +Command options. + +=back + +=cut diff --git a/centreon-plugins/storage/ibm/storwize/ssh/plugin.pm b/centreon-plugins/storage/ibm/storwize/ssh/plugin.pm new file mode 100644 index 000000000..59d8ca86a --- /dev/null +++ b/centreon-plugins/storage/ibm/storwize/ssh/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::ibm::storwize::ssh::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'components' => 'storage::ibm::storwize::ssh::mode::hardware', + 'pool-usage' => 'storage::ibm::storwize::ssh::mode::poolusage', + 'eventlog' => 'storage::ibm::storwize::ssh::mode::eventlog', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check IBM Storwize (v3700, v5000, v7000, SAN Volume Controller) in SSH. + +=cut diff --git a/centreon-plugins/storage/lenovo/sseries/snmp/plugin.pm b/centreon-plugins/storage/lenovo/sseries/snmp/plugin.pm new file mode 100644 index 000000000..f7eb9ec1f --- /dev/null +++ b/centreon-plugins/storage/lenovo/sseries/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::lenovo::sseries::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}} = ( + 'hardware' => 'snmp_standard::mode::hardwarefibrealliance', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Lenovo Storage S Series (S2200 and S3200) in SNMP. + +=cut diff --git a/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm b/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm index 8e5e09f88..87960e0c7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -148,7 +148,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/network/netasq/snmp/mode/hastatus.pm b/centreon-plugins/storage/netapp/snmp/mode/cacheage.pm similarity index 52% rename from centreon-plugins/network/netasq/snmp/mode/hastatus.pm rename to centreon-plugins/storage/netapp/snmp/mode/cacheage.pm index 6e6c8d109..396e30cc0 100644 --- a/centreon-plugins/network/netasq/snmp/mode/hastatus.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/cacheage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -18,7 +18,7 @@ # limitations under the License. # -package network::netasq::snmp::mode::hastatus; +package storage::netapp::snmp::mode::cacheage; use base qw(centreon::plugins::mode); @@ -33,17 +33,16 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, + "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(); @@ -51,33 +50,28 @@ sub check_options { 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{snmp} = snmp object $self->{snmp} = $options{snmp}; - - my $oid_ntqNbNode = '.1.3.6.1.4.1.11256.1.11.1.0'; - my $oid_ntqNbDeadNode = '.1.3.6.1.4.1.11256.1.11.2.0'; - my $result = $self->{snmp}->get_leef(oids => [$oid_ntqNbNode, $oid_ntqNbDeadNode], nothing_quit => 1); - - if ($result->{$oid_ntqNbNode} == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => "Only one node. No ha."); - } else { - my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_ntqNbDeadNode}, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("%d dead nodes on %d nodes", - $result->{$oid_ntqNbDeadNode}, $result->{$oid_ntqNbNode})); - $self->{output}->perfdata_add(label => 'dead_nodes', - value => $result->{$oid_ntqNbDeadNode}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => $result->{$oid_ntqNbNode}); - } - + + my $oid_cacheAge = ".1.3.6.1.4.1.789.1.2.2.23.0"; + + my $result = $self->{snmp}->get_leef(oids => [$oid_cacheAge], + nothing_quit => 1); + + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_cacheAge}, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, + { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cache age is '%s' minutes", $result->{$oid_cacheAge})); + $self->{output}->perfdata_add(label => 'cache_age', unit => 'm', + value => $result->{$oid_cacheAge}, + warning => $self->{option_results}->{warning}, + critical => $self->{option_results}->{critical}, + min => 0); $self->{output}->display(); $self->{output}->exit(); } @@ -88,17 +82,17 @@ __END__ =head1 MODE -Check ha status. +Check age in minutes of the oldest read-only blocks in the buffer cache. =over 8 =item B<--warning> -Threshold warning (number of dead nodes). +Threshold warning in minutes =item B<--critical> -Threshold critical (number of dead nodes). +Threshold critical in minutes =back diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/communication.pm b/centreon-plugins/storage/netapp/snmp/mode/components/communication.pm index c8a9b297b..c8a79299f 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/communication.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/communication.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -37,9 +37,9 @@ my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3'; my $oid_enclContactState = '.1.3.6.1.4.1.789.1.21.1.2.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_enclContactState }; + push @{$self->{request}}, { oid => $oid_enclContactState }; } sub check { @@ -47,13 +47,13 @@ sub check { $self->{output}->output_add(long_msg => "Checking communications"); $self->{components}->{communication} = {name => 'communications', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'communication')); + return if ($self->check_filter(section => 'communication')); for (my $i = 1; $i <= $self->{number_shelf}; $i++) { my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i}; my $com_state = $map_com_states{$self->{results}->{$oid_enclContactState}->{$oid_enclContactState . '.' . $i}}; - next if ($self->check_exclude(section => 'communication', instance => $shelf_addr)); + next if ($self->check_filter(section => 'communication', instance => $shelf_addr)); $self->{components}->{communication}->{total}++; $self->{output}->output_add(long_msg => sprintf("Shelve '%s' communication state is '%s'", diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/electronics.pm b/centreon-plugins/storage/netapp/snmp/mode/components/electronics.pm index f1e25de26..d5ce43f7a 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/electronics.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/electronics.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,10 +30,9 @@ my $oid_enclElectronicsPresent = '.1.3.6.1.4.1.789.1.21.1.2.1.31'; my $oid_enclElectronicsFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.33'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_enclElectronicsPresent }; - push @{$options{request}}, { oid => $oid_enclElectronicsFailed }; + push @{$self->{request}}, { oid => $oid_enclElectronicsPresent }, { oid => $oid_enclElectronicsFailed }; } sub check { @@ -41,7 +40,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking electronics"); $self->{components}->{electronics} = {name => 'electronics', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'electronics')); + return if ($self->check_filter(section => 'electronics')); for (my $i = 1; $i <= $self->{number_shelf}; $i++) { my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i}; @@ -52,7 +51,7 @@ sub check { $num = centreon::plugins::misc::trim($num); next if ($num !~ /[0-9]/); - next if ($self->check_exclude(section => 'electronics', instance => $shelf_addr . '.' . $num)); + next if ($self->check_filter(section => 'electronics', instance => $shelf_addr . '.' . $num)); $self->{components}->{electronics}->{total}++; my $status = 'ok'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/fan.pm b/centreon-plugins/storage/netapp/snmp/mode/components/fan.pm index 2f8b5ba9b..6f4f2428b 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/fan.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -31,11 +31,10 @@ my $oid_enclFansFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.18'; my $oid_enclFansSpeed = '.1.3.6.1.4.1.789.1.21.1.2.1.62'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_enclFansPresent }; - push @{$options{request}}, { oid => $oid_enclFansFailed }; - push @{$options{request}}, { oid => $oid_enclFansSpeed }; + push @{$self->{request}}, { oid => $oid_enclFansPresent }, { oid => $oid_enclFansFailed }, + { oid => $oid_enclFansSpeed }; } sub check { @@ -43,7 +42,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'fan')); + return if ($self->check_filter(section => 'fan')); for (my $i = 1; $i <= $self->{number_shelf}; $i++) { my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i}; @@ -56,7 +55,7 @@ sub check { next if ($num !~ /[0-9]/); my $current_value = (defined($current_speed[$num - 1]) && $current_speed[$num - 1] =~ /(^|\s)([0-9]+)/) ? $2 : ''; - next if ($self->check_exclude(section => 'fan', instance => $shelf_addr . '.' . $num)); + next if ($self->check_filter(section => 'fan', instance => $shelf_addr . '.' . $num)); $self->{components}->{fan}->{total}++; my $status = 'ok'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/psu.pm b/centreon-plugins/storage/netapp/snmp/mode/components/psu.pm index 5f54b8fe8..2b44753bb 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/psu.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -30,10 +30,9 @@ my $oid_enclPowerSuppliesPresent = '.1.3.6.1.4.1.789.1.21.1.2.1.13'; my $oid_enclPowerSuppliesFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.15'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_enclPowerSuppliesPresent }; - push @{$options{request}}, { oid => $oid_enclPowerSuppliesFailed }; + push @{$self->{request}}, { oid => $oid_enclPowerSuppliesPresent }, { oid => $oid_enclPowerSuppliesFailed }; } sub check { @@ -41,7 +40,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'psu')); + return if ($self->check_filter(section => 'psu')); for (my $i = 1; $i <= $self->{number_shelf}; $i++) { my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i}; @@ -52,7 +51,7 @@ sub check { $num = centreon::plugins::misc::trim($num); next if ($num !~ /[0-9]/); - next if ($self->check_exclude(section => 'psu', instance => $shelf_addr . '.' . $num)); + next if ($self->check_filter(section => 'psu', instance => $shelf_addr . '.' . $num)); $self->{components}->{psu}->{total}++; my $status = 'ok'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/raid.pm b/centreon-plugins/storage/netapp/snmp/mode/components/raid.pm index 74bc1a659..7a2c1af5f 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/raid.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/raid.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -38,9 +38,9 @@ my %map_raid_states = ( my $oid_raidPStatus = '.1.3.6.1.4.1.789.1.6.10.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_raidPStatus }; + push @{$self->{request}}, { oid => $oid_raidPStatus }; } sub check { @@ -48,14 +48,14 @@ sub check { $self->{output}->output_add(long_msg => "Checking raids"); $self->{components}->{raid} = {name => 'raids', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'raid')); + return if ($self->check_filter(section => 'raid')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidPStatus}})) { $oid =~ /^$oid_raidPStatus\.(.*)$/; my $instance = $1; my $raid_state = $map_raid_states{$self->{results}->{$oid_raidPStatus}->{$oid}}; - next if ($self->check_exclude(section => 'raid', instance => $instance)); + next if ($self->check_filter(section => 'raid', instance => $instance)); $self->{components}->{raid}->{total}++; $self->{output}->output_add(long_msg => sprintf("Raid '%s' state is '%s'", diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm b/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm index ebb6c82f9..b30ac3b54 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -53,9 +53,9 @@ my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3'; my $oid_enclEntry = '.1.3.6.1.4.1.789.1.21.1.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_enclEntry, begin => $mapping->{enclTempSensorsPresent}->{oid}, end => $mapping->{enclTempSensorsUnderTempWarnThr}->{oid} }; + push @{$self->{request}}, { oid => $oid_enclEntry, begin => $mapping->{enclTempSensorsPresent}->{oid}, end => $mapping->{enclTempSensorsUnderTempWarnThr}->{oid} }; } sub check { @@ -63,7 +63,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); for (my $i = 1; $i <= $self->{number_shelf}; $i++) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_enclEntry}, instance => $i); @@ -77,7 +77,9 @@ sub check { foreach my $num (split /,/, $result->{enclTempSensorsPresent}) { $num = centreon::plugins::misc::trim($num); - next if ($num !~ /[0-9]/); + next if ($num !~ /[0-9]/ || !defined($current_temp[$num - 1])); + + next if ($self->check_filter(section => 'temperature', instance => $shelf_addr . '.' . $num)); $warn_under_thr[$num - 1] =~ /(-*[0-9]+)C/; my $wu_thr = $1; @@ -90,7 +92,6 @@ sub check { $current_temp[$num - 1] =~ /(-*[0-9]+)C/; my $current_value = $1; - next if ($self->check_exclude(section => 'temperature', instance => $shelf_addr . '.' . $num)); $self->{components}->{temperature}->{total}++; my $status = 'ok'; @@ -134,4 +135,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/voltage.pm b/centreon-plugins/storage/netapp/snmp/mode/components/voltage.pm index e5892e6d4..273474ee5 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/voltage.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/voltage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -53,9 +53,9 @@ my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3'; my $oid_enclTable = '.1.3.6.1.4.1.789.1.21.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_enclTable, begin => $mapping->{enclVoltSensorsPresent}->{oid}, end => $mapping->{enclVoltSensorsUnderVoltWarnThr}->{oid} }; + push @{$self->{request}}, { oid => $oid_enclTable, begin => $mapping->{enclVoltSensorsPresent}->{oid}, end => $mapping->{enclVoltSensorsUnderVoltWarnThr}->{oid} }; } sub check { @@ -63,7 +63,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking voltages"); $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'voltage')); + return if ($self->check_filter(section => 'voltage')); for (my $i = 1; $i <= $self->{number_shelf}; $i++) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_enclTable}, instance => $i); @@ -78,7 +78,7 @@ sub check { my @values = defined($result->{enclVoltSensorsPresent}) ? split /,/, $result->{enclVoltSensorsPresent} : (); foreach my $num (@values) { $num = centreon::plugins::misc::trim($num); - next if ($num !~ /[0-9]/); + next if ($num !~ /[0-9]/ || !defined($current_volt[$num - 1])); my $wu_thr = (defined($warn_under_thr[$num - 1]) && $warn_under_thr[$num - 1] =~ /(^|\s)(-*[0-9]+)/) ? $2 : ''; my $cu_thr = (defined($crit_under_thr[$num - 1]) && $crit_under_thr[$num - 1] =~ /(^|\s)(-*[0-9]+)/) ? $2 : ''; @@ -86,7 +86,7 @@ sub check { my $co_thr = (defined($crit_over_thr[$num - 1]) && $crit_over_thr[$num - 1] =~ /(^|\s)(-*[0-9]+)/) ? $2 : ''; my $current_value = ($current_volt[$num - 1] =~ /(^|\s)(-*[0-9]+)/) ? $2 : ''; - next if ($self->check_exclude(section => 'voltage', instance => $shelf_addr . '.' . $num)); + next if ($self->check_filter(section => 'voltage', instance => $shelf_addr . '.' . $num)); $self->{components}->{voltage}->{total}++; my $status = 'ok'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm b/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm index 77ea71e0c..c9b4bb8b7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -180,7 +180,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/cpuload.pm b/centreon-plugins/storage/netapp/snmp/mode/cpuload.pm index e9f0f98d8..bddabaefc 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/cpuload.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/cpuload.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cpuBusyTimePerCent = '.1.3.6.1.4.1.789.1.2.1.3.0'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/diskfailed.pm b/centreon-plugins/storage/netapp/snmp/mode/diskfailed.pm index eeec10a25..bccb1e4dd 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/diskfailed.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/diskfailed.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,7 +45,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_diskFailedCount = '.1.3.6.1.4.1.789.1.6.4.7.0'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/fan.pm b/centreon-plugins/storage/netapp/snmp/mode/fan.pm index 0f2fe0d4b..deea0a679 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/fan.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,7 +45,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_envFailedFanCount = '.1.3.6.1.4.1.789.1.2.4.2'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/filesys.pm b/centreon-plugins/storage/netapp/snmp/mode/filesys.pm index 27f2ace05..27082c385 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/filesys.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/filesys.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,32 +20,56 @@ package storage::netapp::snmp::mode::filesys; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::values; -my $maps_counters = { - '000_usage' => { set => { - key_values => [ { name => 'name' }, { name => 'used' }, { name => 'total' }, - { name => 'dfCompressSavedPercent' }, { name => 'dfDedupeSavedPercent' } ], - 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, - } - }, - '001_inodes' => { set => { - key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'name' } ], - output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s", - perfdatas => [ - { label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'name_absolute' }, - ], - } - }, -}; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' }, + ]; + + $self->{maps_counters}->{fs} = [ + { label => 'usage', set => { + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + { label => 'inodes', set => { + key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'display' } ], + output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s", + perfdatas => [ + { label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'compresssaved', set => { + key_values => [ { name => 'dfCompressSavedPercent' }, { name => 'display' } ], + output_template => 'Compress Saved : %s %%', output_error_template => "Compress Saved : %s", + perfdatas => [ + { label => 'compresssaved', value => 'dfCompressSavedPercent_absolute', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'dedupsaved', set => { + key_values => [ { name => 'dfDedupeSavedPercent' }, { name => 'display' } ], + output_template => 'Dedupe Saved : %s %%', output_error_template => "Dedupe Saved : %s", + perfdatas => [ + { label => 'dedupsaved', value => 'dfDedupeSavedPercent_absolute', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} my $instance_mode; @@ -60,7 +84,7 @@ sub custom_usage_perfdata { $value_perf = $self->{result_values}->{free}; } my $extra_label = ''; - $extra_label = '_' . $self->{result_values}->{name} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); + $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); my %total_options = (); if ($instance_mode->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; @@ -72,18 +96,6 @@ sub custom_usage_perfdata { warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), min => 0, max => $self->{result_values}->{total}); - if (defined($self->{result_values}->{dfCompressSavedPercent}) && $self->{result_values}->{dfCompressSavedPercent} ne '' && - $self->{result_values}->{dfCompressSavedPercent} >= 0) { - $self->{output}->perfdata_add(label => 'compresssaved' . $extra_label, unit => '%', - value => $self->{result_values}->{dfCompressSavedPercent}, - min => 0, max => 100); - } - if (defined($self->{result_values}->{dfDedupeSavedPercent}) && $self->{result_values}->{dfDedupeSavedPercent} ne '' && - $self->{result_values}->{dfDedupeSavedPercent} >= 0) { - $self->{output}->perfdata_add(label => 'dedupsaved' . $extra_label, unit => '%', - value => $self->{result_values}->{dfDedupeSavedPercent}, - min => 0, max => 100); - } } sub custom_usage_threshold { @@ -124,11 +136,9 @@ sub custom_usage_output { sub custom_usage_calc { my ($self, %options) = @_; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; + $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}->{dfCompressSavedPercent} = $options{new_datas}->{$self->{instance} . '_dfCompressSavedPercent'}; - $self->{result_values}->{dfDedupeSavedPercent} = $options{new_datas}->{$self->{instance} . '_dfDedupeSavedPercent'}; return 0 if ($options{new_datas}->{$self->{instance} . '_total'} == 0); $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; @@ -144,6 +154,12 @@ sub custom_usage_calc { return 0; } +sub prefix_fs_output { + my ($self, %options) = @_; + + return "Filesys '" . $options{instance_value}->{display} . "' "; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -156,96 +172,17 @@ sub new { "free" => { name => 'free' }, "filter-name:s" => { name => 'filter_name' }, "filter-type:s" => { name => 'filter_type' }, - }); - - foreach (keys %{$maps_counters}) { - my ($id, $name) = split /_/; - if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { - $options{options}->add_options(arguments => { - 'warning-' . $name . ':s' => { name => 'warning-' . $name }, - 'critical-' . $name . ':s' => { name => 'critical-' . $name }, - }); - } - $maps_counters->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, - label => $name); - $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); - } - + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); - - foreach (keys %{$maps_counters}) { - $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); - } + $self->SUPER::check_options(%options); $instance_mode = $self; } -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - $self->manage_selection(); - - my $multiple = 1; - if (scalar(keys %{$self->{filesys_selected}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All filesys usages are ok'); - } - - foreach my $id (sort keys %{$self->{filesys_selected}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters}) { - $maps_counters->{$_}->{obj}->set(instance => $id); - - my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{filesys_selected}->{$id}); - - if ($value_check != 0) { - $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); - $long_msg_append = ', '; - next; - } - my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); - push @exits, $exit2; - - my $output = $maps_counters->{$_}->{obj}->output(); - $long_msg .= $long_msg_append . $output; - $long_msg_append = ', '; - - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= $short_msg_append . $output; - $short_msg_append = ', '; - } - - $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); - } - - $self->{output}->output_add(long_msg => "Filesys '" . $self->{filesys_selected}->{$id}->{name} . "' $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 => "Filesys '" . $self->{filesys_selected}->{$id}->{name} . "' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "Filesys '" . $self->{filesys_selected}->{$id}->{name} . "' $long_msg"); - } - } - - $self->{output}->display(); - $self->{output}->exit(); -} - my %map_types = ( 1 => 'traditionalVolume', 2 => 'flexibleVolume', @@ -279,45 +216,45 @@ sub manage_selection { { oid => $mapping2->{dfCompressSavedPercent}->{oid} }, { oid => $mapping2->{dfDedupeSavedPercent}->{oid} }, ]; - if (!$self->{snmp}->is_snmpv1()) { + if (!$options{snmp}->is_snmpv1()) { push @{$oids}, { oid => $mapping2->{df64TotalKBytes}->{oid} }, { oid => $mapping2->{df64UsedKBytes}->{oid} }; } - my $results = $self->{snmp}->get_multiple_table(oids => $oids, return_type => 1, nothing_quit => 1); - $self->{filesys_selected} = {}; + my $results = $options{snmp}->get_multiple_table(oids => $oids, return_type => 1, nothing_quit => 1); + $self->{fs} = {}; foreach my $oid (keys %{$results}) { next if ($oid !~ /^$mapping2->{dfFileSys}->{oid}\.(\d+)/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); - my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance); my $name = $result2->{dfFileSys}; if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $name !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter name."); + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter name.", debug => 1); next; } if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && $result->{dfType} !~ /$self->{option_results}->{filter_type}/) { - $self->{output}->output_add(long_msg => "Skipping '" . $result->{dfType} . "': no matching filter type."); + $self->{output}->output_add(long_msg => "skipping '" . $result->{dfType} . "': no matching filter type.", debug => 1); next; } - $self->{filesys_selected}->{$instance} = { name => $name }; - $self->{filesys_selected}->{$instance}->{total} = $result2->{dfKBytesTotal} * 1024; - $self->{filesys_selected}->{$instance}->{used} = $result2->{dfKBytesUsed} * 1024; + $self->{fs}->{$instance} = { display => $name }; + $self->{fs}->{$instance}->{total} = $result2->{dfKBytesTotal} * 1024; + $self->{fs}->{$instance}->{used} = $result2->{dfKBytesUsed} * 1024; if (defined($result2->{df64TotalKBytes}) && $result2->{df64TotalKBytes} > 0) { - $self->{filesys_selected}->{$instance}->{total} = $result2->{df64TotalKBytes} * 1024; - $self->{filesys_selected}->{$instance}->{used} = $result2->{df64UsedKBytes} * 1024; + $self->{fs}->{$instance}->{total} = $result2->{df64TotalKBytes} * 1024; + $self->{fs}->{$instance}->{used} = $result2->{df64UsedKBytes} * 1024; } - $self->{filesys_selected}->{$instance}->{dfCompressSavedPercent} = $result2->{dfCompressSavedPercent}; - $self->{filesys_selected}->{$instance}->{dfDedupeSavedPercent} = $result2->{dfDedupeSavedPercent}; - if ($self->{filesys_selected}->{$instance}->{total} > 0) { - $self->{filesys_selected}->{$instance}->{dfPerCentInodeCapacity} = $result2->{dfPerCentInodeCapacity}; + $self->{fs}->{$instance}->{dfCompressSavedPercent} = $result2->{dfCompressSavedPercent}; + $self->{fs}->{$instance}->{dfDedupeSavedPercent} = $result2->{dfDedupeSavedPercent}; + if ($self->{fs}->{$instance}->{total} > 0) { + $self->{fs}->{$instance}->{dfPerCentInodeCapacity} = $result2->{dfPerCentInodeCapacity}; } } - if (scalar(keys %{$self->{filesys_selected}}) <= 0) { + if (scalar(keys %{$self->{fs}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->option_exit(); } @@ -336,12 +273,12 @@ Check filesystem usage (volumes, snapshots and aggregates also). =item B<--warning-*> Threshold warning. -Can be: usage, inodes (%). +Can be: usage, inodes (%), compresssaved (%), dedupsaved (%). =item B<--critical-*> Threshold critical. -Can be: usage, inodes (%). +Can be: usage, inodes (%), compresssaved (%), dedupsaved (%). =item B<--units> diff --git a/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm b/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm index 0ebc77f72..bb369f53b 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -121,7 +121,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/listfilesys.pm b/centreon-plugins/storage/netapp/snmp/mode/listfilesys.pm index 519470b80..6fce3a9e7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/listfilesys.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/listfilesys.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -108,7 +108,6 @@ sub get_additional_information { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); @@ -143,7 +142,6 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/ndmpsessions.pm b/centreon-plugins/storage/netapp/snmp/mode/ndmpsessions.pm index 3e2847d2c..5ca68caab 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/ndmpsessions.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/ndmpsessions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_ndmpSessionOpened = '.1.3.6.1.4.1.789.1.10.2.0'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/nvram.pm b/centreon-plugins/storage/netapp/snmp/mode/nvram.pm index a7044d207..757daf3bb 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/nvram.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/nvram.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -94,7 +94,6 @@ my $mapping2 = { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_nodeName = '.1.3.6.1.4.1.789.1.25.2.1.1'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/partnerstatus.pm b/centreon-plugins/storage/netapp/snmp/mode/partnerstatus.pm index 676bbab10..9427f45c2 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/partnerstatus.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/partnerstatus.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -99,7 +99,6 @@ my $mapping4 = { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cfPartnerName = '.1.3.6.1.4.1.789.1.2.3.6'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/psu.pm b/centreon-plugins/storage/netapp/snmp/mode/psu.pm index 8f9768fbf..b035e1f6c 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/psu.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/psu.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -45,7 +45,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_envFailedPowerSupplyCount = '.1.3.6.1.4.1.789.1.2.4.4'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm b/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm index 4ad5787a3..d49e59076 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -161,7 +161,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/sharecalls.pm b/centreon-plugins/storage/netapp/snmp/mode/sharecalls.pm index b1b212326..0e681e136 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/sharecalls.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/sharecalls.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,7 +95,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); $self->{snmp_port} = $self->{snmp}->get_port(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/shelf.pm b/centreon-plugins/storage/netapp/snmp/mode/shelf.pm index 16ea5dee0..861dbb27b 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/shelf.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/shelf.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,61 +20,81 @@ package storage::netapp::snmp::mode::shelf; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - communication => [ - ['initializing', 'WARNING'], - ['transitioning', 'WARNING'], - ['inactive', 'CRITICAL'], - ['reconfiguring', 'WARNING'], - ['nonexistent', 'CRITICAL'], - ['active', 'OK'], - ], - raid => [ - ['initializing', 'WARNING'], - ['reconstructionInProgress', 'WARNING'], - ['parityVerificationInProgress', 'OK'], - ['scrubbingInProgress', 'OK'], - ['prefailed', 'CRITICAL'], - ['failed', 'CRITICAL'], - ['active', 'OK'], - ], - fan => [ - ['failed', 'CRITICAL'], - ['ok', 'OK'], - ], - psu => [ - ['failed', 'CRITICAL'], - ['ok', 'OK'], - ], - electronics => [ - ['failed', 'CRITICAL'], - ['ok', 'OK'], - ], - voltage => [ - ['under critical threshold', 'CRITICAL'], - ['under warning threshold', 'WARNING'], - ['over critical threshold', 'CRITICAL'], - ['over warning threshold', 'WARNING'], - ['ok', 'OK'], - ], - temperature => [ - ['under critical threshold', 'CRITICAL'], - ['under warning threshold', 'WARNING'], - ['over critical threshold', 'CRITICAL'], - ['over warning threshold', 'WARNING'], - ['ok', 'OK'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(voltage|temperature|fan)$'; + + $self->{cb_hook1} = 'init_shelf'; + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + communication => [ + ['initializing', 'WARNING'], + ['transitioning', 'WARNING'], + ['inactive', 'CRITICAL'], + ['reconfiguring', 'WARNING'], + ['nonexistent', 'CRITICAL'], + ['active', 'OK'], + ], + raid => [ + ['initializing', 'WARNING'], + ['reconstructionInProgress', 'WARNING'], + ['parityVerificationInProgress', 'OK'], + ['scrubbingInProgress', 'OK'], + ['prefailed', 'CRITICAL'], + ['failed', 'CRITICAL'], + ['active', 'OK'], + ], + fan => [ + ['failed', 'CRITICAL'], + ['ok', 'OK'], + ], + psu => [ + ['failed', 'CRITICAL'], + ['ok', 'OK'], + ], + electronics => [ + ['failed', 'CRITICAL'], + ['ok', 'OK'], + ], + voltage => [ + ['under critical threshold', 'CRITICAL'], + ['under warning threshold', 'WARNING'], + ['over critical threshold', 'CRITICAL'], + ['over warning threshold', 'WARNING'], + ['ok', 'OK'], + ], + temperature => [ + ['under critical threshold', 'CRITICAL'], + ['under warning threshold', 'WARNING'], + ['over critical threshold', 'CRITICAL'], + ['over warning threshold', 'WARNING'], + ['ok', 'OK'], + ], + }; + + $self->{components_path} = 'storage::netapp::snmp::mode::components'; + $self->{components_module} = ['communication', 'psu', 'fan', 'temperature', 'voltage', 'electronics', 'raid']; +} my $oid_enclNumber = '.1.3.6.1.4.1.789.1.21.1.1'; my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3'; +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); + $self->{number_shelf} = defined($self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'}) ? $self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'} : -1; + $self->{shelf_addr} = $self->{results}->{$oid_enclChannelShelfAddr}; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -83,207 +103,15 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "absent-problem:s" => { name => 'absent' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, }); - - $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->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - 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}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(voltage|temperature|fan)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: fan, voltage or temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('communication', 'psu', 'fan', 'temperature', 'voltage', 'electronics', 'raid'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "storage::netapp::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(); - } - - push @{$snmp_request}, ({ oid => $oid_enclNumber }, { oid => $oid_enclChannelShelfAddr }); - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - $self->{number_shelf} = defined($self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'}) ? $self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'} : -1; - $self->{shelf_addr} = $self->{results}->{$oid_enclChannelShelfAddr}; - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "storage::netapp::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 check_exclude { +sub init_shelf { my ($self, %options) = @_; - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $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; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -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; + push @{$self->{request}}, ({ oid => $oid_enclNumber }, { oid => $oid_enclChannelShelfAddr }); } 1; @@ -301,15 +129,15 @@ Check Shelves hardware (temperatures, voltages, electronics, fan, power supplies Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'communication', 'voltage', 'temperature', 'electronics', 'raid'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='psu#41239F00647-A#' +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=psu,41239F00647-A =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#41239F00647-fan02# +Can be specific or global: --absent-problem=fan,41239F00647-fan02 =item B<--no-component> @@ -318,19 +146,19 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='gfc,CRITICAL,^(?!(Online)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: regexp,treshold) +Set warning threshold for temperature, fan, voltage (syntax: type,regexp,threshold) Example: --warning='41239F00647-vimm46,20' --warning='41239F00647-vimm5.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: regexp,treshold) -Example: --critical='41239F00647-vimm46,25' --warning='41239F00647-vimm5.*,35' +Set critical threshold for temperature, fan, voltage (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,25' --warning='temperature,.*,35' =back diff --git a/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm b/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm index 791999cf6..d29b11def 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -97,7 +97,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/snapshotage.pm b/centreon-plugins/storage/netapp/snmp/mode/snapshotage.pm index fe4cb1bcb..137fb7eae 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/snapshotage.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/snapshotage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,7 +95,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/netapp/snmp/mode/temperature.pm b/centreon-plugins/storage/netapp/snmp/mode/temperature.pm index 2011885ba..1acc82132 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/temperature.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -50,7 +50,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_envOverTemperature = '.1.3.6.1.4.1.789.1.2.4.1'; diff --git a/centreon-plugins/storage/netapp/snmp/mode/volumeoptions.pm b/centreon-plugins/storage/netapp/snmp/mode/volumeoptions.pm index 14bfd8a04..d454992d2 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/volumeoptions.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/volumeoptions.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -90,7 +90,6 @@ sub manage_selection { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/netapp/snmp/plugin.pm b/centreon-plugins/storage/netapp/snmp/plugin.pm index 26187634a..e4a6eae99 100644 --- a/centreon-plugins/storage/netapp/snmp/plugin.pm +++ b/centreon-plugins/storage/netapp/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = ( @@ -51,6 +50,7 @@ sub new { 'snapshotage' => 'storage::netapp::snmp::mode::snapshotage', 'temperature' => 'storage::netapp::snmp::mode::temperature', 'volumeoptions' => 'storage::netapp::snmp::mode::volumeoptions', + 'cache-age' => 'storage::netapp::snmp::mode::cacheage', ); return $self; diff --git a/centreon-plugins/storage/nimble/snmp/mode/globalstats.pm b/centreon-plugins/storage/nimble/snmp/mode/globalstats.pm index 636013b7f..fe1a8a1c0 100644 --- a/centreon-plugins/storage/nimble/snmp/mode/globalstats.pm +++ b/centreon-plugins/storage/nimble/snmp/mode/globalstats.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/nimble/snmp/mode/volumeusage.pm b/centreon-plugins/storage/nimble/snmp/mode/volumeusage.pm index d2f59bbad..de45cf794 100644 --- a/centreon-plugins/storage/nimble/snmp/mode/volumeusage.pm +++ b/centreon-plugins/storage/nimble/snmp/mode/volumeusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/nimble/snmp/plugin.pm b/centreon-plugins/storage/nimble/snmp/plugin.pm index 1d7d9bfd3..74b8c1770 100644 --- a/centreon-plugins/storage/nimble/snmp/plugin.pm +++ b/centreon-plugins/storage/nimble/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/overland/neo/snmp/mode/components/drive.pm b/centreon-plugins/storage/overland/neo/snmp/mode/components/drive.pm new file mode 100644 index 000000000..94cee4e1f --- /dev/null +++ b/centreon-plugins/storage/overland/neo/snmp/mode/components/drive.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::overland::neo::snmp::mode::components::drive; + +use strict; +use warnings; + +my %map_state = ( + 0 => 'initializedNoError', + 1 => 'initializedWithError', + 2 => 'notInitialized', + 3 => 'notInstalled', + 4 => 'notInserted', +); + +my $mapping = { + dstState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.3', map => \%map_state }, + dstSerialNum => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.8' }, +}; +my $oid_driveStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_driveStatusEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking drives"); + $self->{components}->{drive} = {name => 'drives', total => 0, skip => 0}; + return if ($self->check_filter(section => 'drive')); + + # there is no instance for the table. Weird. Need to manage the two cases. + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_driveStatusEntry}})) { + next if ($oid !~ /^$mapping->{dstState}->{oid}(?:\.(.*)|$)/); + my $instance = defined($1) ? $1 : undef; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_driveStatusEntry}, instance => $instance); + + # we set a 1 to do some filters + $instance = '1' if (!defined($instance)); + next if ($self->check_filter(section => 'drive', instance => $instance)); + + $self->{components}->{drive}->{total}++; + $self->{output}->output_add(long_msg => sprintf("drive '%s' status is '%s' [instance = %s]", + $instance, $result->{dstState}, $instance)); + my $exit = $self->get_severity(section => 'drive', instance => $instance, value => $result->{dstState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("drive '%s' status is '%s'", $instance, $result->{dstState})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/overland/neo/snmp/mode/components/library.pm b/centreon-plugins/storage/overland/neo/snmp/mode/components/library.pm new file mode 100644 index 000000000..d0a492f4f --- /dev/null +++ b/centreon-plugins/storage/overland/neo/snmp/mode/components/library.pm @@ -0,0 +1,71 @@ +# +# Copyright 2016 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::overland::neo::snmp::mode::components::library; + +use strict; +use warnings; + +my %map_state = ( + 0 => 'initializing', + 1 => 'online', + 2 => 'offline', +); + +my $mapping = { + lstLibraryState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.2.1.6', map => \%map_state }, +}; +my $oid_libraryStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_libraryStatusEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking libraries"); + $self->{components}->{library} = {name => 'libraries', total => 0, skip => 0}; + return if ($self->check_filter(section => 'library')); + + # there is no instance for the table. Weird. Need to manage the two cases. + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_libraryStatusEntry}})) { + next if ($oid !~ /^$mapping->{lstLibraryState}->{oid}(?:\.(.*)|$)/); + my $instance = defined($1) ? $1 : undef; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryStatusEntry}, instance => $instance); + + # we set a 1 to do some filters + $instance = '1' if (!defined($instance)); + next if ($self->check_filter(section => 'library', instance => $instance)); + + $self->{components}->{library}->{total}++; + $self->{output}->output_add(long_msg => sprintf("library '%s' status is '%s' [instance = %s]", + $instance, $result->{lstLibraryState}, $instance)); + my $exit = $self->get_severity(section => 'library', instance => $instance, value => $result->{lstLibraryState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("library '%s' status is '%s'", $instance, $result->{lstLibraryState})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/overland/neo/snmp/mode/eventlog.pm b/centreon-plugins/storage/overland/neo/snmp/mode/eventlog.pm new file mode 100644 index 000000000..26d907e48 --- /dev/null +++ b/centreon-plugins/storage/overland/neo/snmp/mode/eventlog.pm @@ -0,0 +1,131 @@ +# +# Copyright 2016 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::overland::neo::snmp::mode::eventlog; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my %severity_map = ( + 0 => 'informational', + 1 => 'mild', + 2 => 'hard', + 3 => 'severe', +); + +my $mapping = { + errCode => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.3.1.2' }, + errSeverity => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.3.1.3', map => \%severity_map }, + errMsg => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.3.1.4' }, +}; +my $oid_errorEntry = '.1.3.6.1.4.1.3351.1.3.2.3.3.1'; + +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-severity:s" => { name => 'filter_severity', default => 'hard|severe' }, + "filter-message:s" => { name => 'filter_message' }, + "warning" => { name => 'warning' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + + my $exit = defined($self->{option_results}->{warning}) ? 'WARNING' : 'CRITICAL'; + my ($num_eventlog_checked, $num_errors) = (0, 0); + + $self->{output}->output_add(severity => 'OK', + short_msg => "No problems detected."); + + my $results = $options{snmp}->get_table(oid => $oid_errorEntry); + + foreach my $oid ($options{snmp}->oid_lex_sort(keys %$results)) { + next if ($oid !~ /^$mapping->{errSeverity}->{oid}(?:\.(.*)|$)/); + my $instance = defined($1) ? $1 : undef; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + + $num_eventlog_checked++; + + next if (defined($self->{option_results}->{filter_severity}) && $self->{option_results}->{filter_severity} ne '' && $result->{errSeverity} !~ /$self->{option_results}->{filter_severity}/); + next if (defined($self->{option_results}->{filter_message}) && $self->{option_results}->{filter_message} ne '' && $result->{errMsg} !~ /$self->{option_results}->{filter_message}/); + + $num_errors++; + $self->{output}->output_add(long_msg => sprintf("%s : %s [severity: %s]", + $result->{errCode}, + $result->{errMsg}, $result->{errSeverity} + ) + ); + + + } + + $self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_eventlog_checked)); + if ($num_errors != 0) { + # Message problem + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors) + ); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check eventlogs. + +=over 8 + +=item B<--warning> + +Use warning return instead 'critical'. + +=item B<--filter-severity> + +Filter on severity. (Default: hard|severe) +Can be: severe, hard, mild, informational. + +=item B<--filter-message> + +Filter on event message. (Default: none) + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/storage/overland/neo/snmp/mode/hardware.pm b/centreon-plugins/storage/overland/neo/snmp/mode/hardware.pm new file mode 100644 index 000000000..e5a8080a8 --- /dev/null +++ b/centreon-plugins/storage/overland/neo/snmp/mode/hardware.pm @@ -0,0 +1,107 @@ +# +# Copyright 2016 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::overland::neo::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(drive|library)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + drive => [ + ['initializedNoError', 'OK'], + ['initializedWithError', 'CRITICAL'], + ['notInitialized', 'WARNING'], + ['notInstalled', 'OK'], + ['notInserted', 'OK'], + ], + library => [ + ['initializing', 'OK'], + ['online', 'OK'], + ['offline', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::overland::neo::snmp::mode::components'; + $self->{components_module} = ['drive', 'library']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'drive', 'library', 'eventlog'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=drive) +Can also exclude specific instance: --filter=drive,1 + +=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='drive,OK,notInitialized' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/overland/neo/snmp/plugin.pm b/centreon-plugins/storage/overland/neo/snmp/plugin.pm new file mode 100644 index 000000000..8ba4baadb --- /dev/null +++ b/centreon-plugins/storage/overland/neo/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2016 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::overland::neo::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}} = ( + 'hardware' => 'storage::overland::neo::snmp::mode::hardware', + 'eventlog' => 'storage::overland::neo::snmp::mode::eventlog', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Overland Neo Series in SNMP. +Need to use --snmp-force-getnext options. + +=cut diff --git a/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm b/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm index 1d9d7a3b2..f5439250d 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cpuLoad = '.1.3.6.1.4.1.32853.1.3.1.1.1.0'; diff --git a/centreon-plugins/storage/panzura/snmp/mode/diskusagelocal.pm b/centreon-plugins/storage/panzura/snmp/mode/diskusagelocal.pm index 629dd0fc2..74c6bba44 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/diskusagelocal.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/diskusagelocal.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; if ($self->{snmp}->is_snmpv1()) { diff --git a/centreon-plugins/storage/panzura/snmp/mode/memory.pm b/centreon-plugins/storage/panzura/snmp/mode/memory.pm index c02c1c8d7..87f15ce1d 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/memory.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; if ($self->{snmp}->is_snmpv1()) { diff --git a/centreon-plugins/storage/panzura/snmp/mode/ratios.pm b/centreon-plugins/storage/panzura/snmp/mode/ratios.pm index 9feaad36a..8449aca69 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/ratios.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/ratios.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -95,7 +95,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/panzura/snmp/plugin.pm b/centreon-plugins/storage/panzura/snmp/plugin.pm index 849b66464..f365ebc96 100644 --- a/centreon-plugins/storage/panzura/snmp/plugin.pm +++ b/centreon-plugins/storage/panzura/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm b/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm index ad054a31a..ebb5eaaeb 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm b/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm index c5ddab573..6de0e134c 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm b/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm index 7b5202174..2b51667d4 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for diff --git a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm index ca6bdf4d5..2e68bbf4f 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -77,12 +77,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -117,7 +117,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $snmp_request = []; diff --git a/centreon-plugins/storage/qnap/snmp/mode/memory.pm b/centreon-plugins/storage/qnap/snmp/mode/memory.pm index d41985e99..dd2755885 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/memory.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/memory.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -76,7 +76,6 @@ sub convert_bytes { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_SystemTotalMem = '.1.3.6.1.4.1.24681.1.2.2.0'; diff --git a/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm b/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm index de83180d1..d1412bfd2 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -146,7 +146,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->manage_selection(); diff --git a/centreon-plugins/storage/qnap/snmp/plugin.pm b/centreon-plugins/storage/qnap/snmp/plugin.pm index 47d4bc1e6..9726110ab 100644 --- a/centreon-plugins/storage/qnap/snmp/plugin.pm +++ b/centreon-plugins/storage/qnap/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '0.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/quantum/scalar/snmp/plugin.pm b/centreon-plugins/storage/quantum/scalar/snmp/plugin.pm new file mode 100644 index 000000000..ae3b83bc2 --- /dev/null +++ b/centreon-plugins/storage/quantum/scalar/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::quantum::scalar::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}} = ( + 'hardware' => 'centreon::common::adic::tape::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Quantum Scalar (i6000, i500, ...) in SNMP. + +=cut diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/cap.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/cap.pm new file mode 100644 index 000000000..19b1a5b6c --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/cap.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::cap; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_status); + +my $mapping = { + slCapStatusEnum => { oid => '.1.3.6.1.4.1.1211.1.15.4.20.1.6', map => $map_status }, +}; +my $oid_slCapEntry = '.1.3.6.1.4.1.1211.1.15.4.20.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slCapEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cartridge access ports"); + $self->{components}->{cap} = {name => 'cap', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cap')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slCapEntry}})) { + next if ($oid !~ /^$mapping->{slCapStatusEnum}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slCapEntry}, instance => $instance); + + next if ($self->check_filter(section => 'cap', instance => $instance)); + $self->{components}->{cap}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cap '%s' status is '%s' [instance: %s].", + $instance, $result->{slCapStatusEnum}, + $instance + )); + my $exit = $self->get_severity(label => 'status', section => 'cap', value => $result->{slCapStatusEnum}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("cap '%s' status is '%s'", + $instance, $result->{slCapStatusEnum})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/controller.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/controller.pm new file mode 100644 index 000000000..0ae0b6479 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/controller.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::controller; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_status); + +my $mapping = { + slControllerSerialNum => { oid => '.1.3.6.1.4.1.1211.1.15.4.14.1.3' }, + slControllerStatus => { oid => '.1.3.6.1.4.1.1211.1.15.4.14.1.4', map => $map_status }, +}; +my $oid_slControllerEntry = '.1.3.6.1.4.1.1211.1.15.4.14.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slControllerEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controllers"); + $self->{components}->{controller} = {name => 'controllers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'controller')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slControllerEntry}})) { + next if ($oid !~ /^$mapping->{slControllerStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slControllerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'controller', instance => $instance)); + $self->{components}->{controller}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("controller '%s' status is '%s' [instance: %s].", + $result->{slControllerSerialNum}, $result->{slControllerStatus}, + $instance + )); + my $exit = $self->get_severity(label => 'status', section => 'controller', value => $result->{slControllerStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Controller '%s' status is '%s'", + $result->{slControllerSerialNum}, $result->{slControllerStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/elevator.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/elevator.pm new file mode 100644 index 000000000..baca22d62 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/elevator.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::elevator; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_status); + +my $mapping = { + slElevatorSerialNum => { oid => '.1.3.6.1.4.1.1211.1.15.4.12.1.5' }, + slElevatorStatusEnum => { oid => '.1.3.6.1.4.1.1211.1.15.4.12.1.8', map => $map_status }, +}; +my $oid_slElevatorEntry = '.1.3.6.1.4.1.1211.1.15.4.12.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slElevatorEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking elevators"); + $self->{components}->{elevator} = {name => 'elevators', total => 0, skip => 0}; + return if ($self->check_filter(section => 'elevator')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slElevatorEntry}})) { + next if ($oid !~ /^$mapping->{slElevatorStatusEnum}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slElevatorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'elevator', instance => $instance)); + $self->{components}->{elevator}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("elevator '%s' status is '%s' [instance: %s].", + $result->{slElevatorSerialNum}, $result->{slElevatorStatusEnum}, + $instance + )); + my $exit = $self->get_severity(label => 'status', section => 'elevator', value => $result->{slElevatorStatusEnum}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Elevator '%s' status is '%s'", + $result->{slElevatorSerialNum}, $result->{slElevatorStatusEnum})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/fan.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/fan.pm new file mode 100644 index 000000000..8bbdc8fdf --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/fan.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::fan; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_operational); + +my $mapping = { + slHdwFanName => { oid => '.1.3.6.1.4.1.1211.1.15.4.6.1.2' }, + slHdwFanOperational => { oid => '.1.3.6.1.4.1.1211.1.15.4.6.1.3', map => $map_operational }, +}; +my $oid_slHdwFanEntry = '.1.3.6.1.4.1.1211.1.15.4.6.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slHdwFanEntry }; +} + +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_slHdwFanEntry}})) { + next if ($oid !~ /^$mapping->{slHdwFanOperational}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slHdwFanEntry}, 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].", + $result->{slHdwFanName}, $result->{slHdwFanOperational}, + $instance + )); + my $exit = $self->get_severity(label => 'operational', section => 'fan', value => $result->{slHdwFanOperational}); + 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'", + $result->{slHdwFanName}, $result->{slHdwFanOperational})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/interface.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/interface.pm new file mode 100644 index 000000000..1009c158b --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/interface.pm @@ -0,0 +1,69 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::interface; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_status); + +my $mapping = { + slHostInterfaceAWWN => { oid => '.1.3.6.1.4.1.1211.1.15.4.2.1.3' }, + slHostInterfaceBWWN => { oid => '.1.3.6.1.4.1.1211.1.15.4.2.1.12' }, + slHostInterfaceStatusEnum => { oid => '.1.3.6.1.4.1.1211.1.15.4.2.1.26', map => $map_status }, +}; +my $oid_slHostInterfaceEntry = '.1.3.6.1.4.1.1211.1.15.4.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slHostInterfaceEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking interfaces"); + $self->{components}->{interface} = {name => 'interfaces', total => 0, skip => 0}; + return if ($self->check_filter(section => 'interface')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slHostInterfaceEntry}})) { + next if ($oid !~ /^$mapping->{slHostInterfaceStatusEnum}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slHostInterfaceEntry}, instance => $instance); + + next if ($self->check_filter(section => 'interface', instance => $instance)); + $self->{components}->{interface}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("interface '%s/%s' status is '%s' [instance: %s].", + $result->{slHostInterfaceAWWN}, $result->{slHostInterfaceBWWN}, $result->{slHostInterfaceStatusEnum}, + $instance + )); + my $exit = $self->get_severity(label => 'status', section => 'interface', value => $result->{slHostInterfaceStatusEnum}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Interface '%s/%s' status is '%s'", + $result->{slHostInterfaceAWWN}, $result->{slHostInterfaceBWWN}, + $result->{slHostInterfaceStatusEnum})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/psu.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/psu.pm new file mode 100644 index 000000000..3cf08b025 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/psu.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::psu; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_operational); + +my $mapping = { + slHdwSupplyName => { oid => '.1.3.6.1.4.1.1211.1.15.4.8.1.2' }, + slHdwSupplyOperational => { oid => '.1.3.6.1.4.1.1211.1.15.4.8.1.4', map => $map_operational }, +}; +my $oid_slHdwSupplyEntry = '.1.3.6.1.4.1.1211.1.15.4.8.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slHdwSupplyEntry }; +} + +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_slHdwSupplyEntry}})) { + next if ($oid !~ /^$mapping->{slHdwSupplyOperational}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slHdwSupplyEntry}, 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].", + $result->{slHdwSupplyName}, $result->{slHdwSupplyOperational}, + $instance + )); + my $exit = $self->get_severity(label => 'operational', section => 'psu', value => $result->{slHdwSupplyOperational}); + 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'", + $result->{slHdwSupplyName}, $result->{slHdwSupplyOperational})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/resources.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/resources.pm new file mode 100644 index 000000000..7f11ac901 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/resources.pm @@ -0,0 +1,46 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_status; +our $map_operational; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_status $map_operational); + +$map_operational = { + 1 => 'failed', + 2 => 'normal', +}; + +$map_status = { + 0 => 'ok', + 1 => 'error', + 2 => 'warning', + 3 => 'info', + 4 => 'trace', +}; + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/robot.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/robot.pm new file mode 100644 index 000000000..fcb0d51f8 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/robot.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::robot; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_status); + +my $mapping = { + slRobotSerialNum => { oid => '.1.3.6.1.4.1.1211.1.15.4.10.1.5' }, + slRobotStatusEnum => { oid => '.1.3.6.1.4.1.1211.1.15.4.10.1.8', map => $map_status }, +}; +my $oid_slRobotEntry = '.1.3.6.1.4.1.1211.1.15.4.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slRobotEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking robots"); + $self->{components}->{robot} = {name => 'robots', total => 0, skip => 0}; + return if ($self->check_filter(section => 'robot')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slRobotEntry}})) { + next if ($oid !~ /^$mapping->{slRobotStatusEnum}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slRobotEntry}, instance => $instance); + + next if ($self->check_filter(section => 'robot', instance => $instance)); + $self->{components}->{robot}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("robot '%s' status is '%s' [instance: %s].", + $result->{slRobotSerialNum}, $result->{slRobotStatusEnum}, + $instance + )); + my $exit = $self->get_severity(label => 'status', section => 'robot', value => $result->{slRobotStatusEnum}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Robot '%s' status is '%s'", + $result->{slRobotSerialNum}, $result->{slRobotStatusEnum})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/temperature.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..3d8481604 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/temperature.pm @@ -0,0 +1,84 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + slHdwTempSensorName => { oid => '.1.3.6.1.4.1.1211.1.15.4.4.1.2' }, + slHdwTempSensorCurrentTemp => { oid => '.1.3.6.1.4.1.1211.1.15.4.4.1.3' }, + slHdwTempSensorWarnThreshold => { oid => '.1.3.6.1.4.1.1211.1.15.4.4.1.5' }, + slHdwTempSensorFailThreshold => { oid => '.1.3.6.1.4.1.1211.1.15.4.4.1.6' }, +}; +my $oid_slHdwTempSensorEntry = '.1.3.6.1.4.1.1211.1.15.4.4.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slHdwTempSensorEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slHdwTempSensorEntry}})) { + next if ($oid !~ /^$mapping->{slHdwTempSensorCurrentTemp}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slHdwTempSensorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s degree centigrade [instance = %s]", + $result->{slHdwTempSensorName}, $result->{slHdwTempSensorCurrentTemp}, $instance, + )); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{slHdwTempSensorCurrentTemp}); + if ($checked == 0) { + my $warn_th = ':' . $result->{slHdwTempSensorWarnThreshold}; + my $crit_th = ':' . $result->{slHdwTempSensorFailThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{slHdwTempSensorCurrentTemp}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{slHdwTempSensorName}, $result->{slHdwTempSensorCurrentTemp})); + } + $self->{output}->perfdata_add(label => 'temp_' . $result->{slHdwTempSensorName}, unit => 'C', + value => $result->{slHdwTempSensorCurrentTemp}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/components/turntable.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/turntable.pm new file mode 100644 index 000000000..083823ad5 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/components/turntable.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::components::turntable; + +use strict; +use warnings; +use storage::storagetek::sl::snmp::mode::components::resources qw($map_status); + +my $mapping = { + slTurntableSerialNum => { oid => '.1.3.6.1.4.1.1211.1.15.4.22.1.5' }, + slTurntableStatusEnum => { oid => '.1.3.6.1.4.1.1211.1.15.4.22.1.8', map => $map_status }, +}; +my $oid_slTurntableEntry = '.1.3.6.1.4.1.1211.1.15.4.22.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_slTurntableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking turntables"); + $self->{components}->{turntable} = {name => 'turntables', total => 0, skip => 0}; + return if ($self->check_filter(section => 'turntable')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_slTurntableEntry}})) { + next if ($oid !~ /^$mapping->{slTurntableStatusEnum}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_slTurntableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'turntable', instance => $instance)); + $self->{components}->{turntable}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("turntable '%s' status is '%s' [instance: %s].", + $result->{slTurntableSerialNum}, $result->{slTurntableStatusEnum}, + $instance + )); + my $exit = $self->get_severity(label => 'status', section => 'turntable', value => $result->{slTurntableStatusEnum}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Turntable '%s' status is '%s'", + $result->{slTurntableSerialNum}, $result->{slTurntableStatusEnum})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/mode/hardware.pm b/centreon-plugins/storage/storagetek/sl/snmp/mode/hardware.pm new file mode 100644 index 000000000..589d29755 --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/mode/hardware.pm @@ -0,0 +1,117 @@ +# +# Copyright 2016 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::storagetek::sl::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(interface|temperature|fan|psu|robot|elevator|controller|cap|turntable)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + status => [ + ['ok', 'OK'], + ['error', 'CRITICAL'], + ['warning', 'WARNING'], + ['info', 'OK'], + ['trace', 'OK'], + ], + operational => [ + ['normal', 'OK'], + ['failed', 'WARNING'], + ], + }; + + $self->{components_path} = 'storage::storagetek::sl::snmp::mode::components'; + $self->{components_module} = ['interface', 'temperature', 'fan', 'psu', 'robot', 'elevator', 'controller', 'cap', 'turntable']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'interface', 'temperature', 'fan', 'psu', 'robot', 'elevator', 'controller', 'cap', 'turntable'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=controller) +Can also exclude specific instance: --filter=cap,1 + +=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='robot,CRITICAL,warning' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/storagetek/sl/snmp/plugin.pm b/centreon-plugins/storage/storagetek/sl/snmp/plugin.pm new file mode 100644 index 000000000..bd26593bb --- /dev/null +++ b/centreon-plugins/storage/storagetek/sl/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2016 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::storagetek::sl::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}} = ( + 'hardware' => 'storage::storagetek::sl::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check StorageTek SL Series (SL150, SL500, ...) in SNMP. + +=cut diff --git a/centreon-plugins/storage/synology/snmp/mode/components.pm b/centreon-plugins/storage/synology/snmp/mode/components.pm index 44fdf1776..0d3e6ddd1 100644 --- a/centreon-plugins/storage/synology/snmp/mode/components.pm +++ b/centreon-plugins/storage/synology/snmp/mode/components.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -143,12 +143,12 @@ sub check_options { $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $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})); @@ -159,7 +159,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; diff --git a/centreon-plugins/storage/synology/snmp/mode/temperature.pm b/centreon-plugins/storage/synology/snmp/mode/temperature.pm index bf0dc879c..3eed30c09 100644 --- a/centreon-plugins/storage/synology/snmp/mode/temperature.pm +++ b/centreon-plugins/storage/synology/snmp/mode/temperature.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_synoSystemtemperature = '.1.3.6.1.4.1.6574.1.2.0'; # in Celsius diff --git a/centreon-plugins/storage/synology/snmp/mode/ups.pm b/centreon-plugins/storage/synology/snmp/mode/ups.pm index 8d6984778..7dbb0b21b 100644 --- a/centreon-plugins/storage/synology/snmp/mode/ups.pm +++ b/centreon-plugins/storage/synology/snmp/mode/ups.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_synoUPSupsBatteryRuntimeValue = '.1.3.6.1.4.1.6574.4.3.6.1.0'; # in Seconds diff --git a/centreon-plugins/storage/synology/snmp/plugin.pm b/centreon-plugins/storage/synology/snmp/plugin.pm index dc118f5c5..0353fd243 100644 --- a/centreon-plugins/storage/synology/snmp/plugin.pm +++ b/centreon-plugins/storage/synology/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - # $options->{options} = options object $self->{version} = '1.1'; %{$self->{modes}} = ( diff --git a/centreon-plugins/storage/violin/3000/snmp/plugin.pm b/centreon-plugins/storage/violin/3000/snmp/plugin.pm index 91b381701..810fe61e6 100644 --- a/centreon-plugins/storage/violin/3000/snmp/plugin.pm +++ b/centreon-plugins/storage/violin/3000/snmp/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2015 Centreon (http://www.centreon.com/) +# Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -28,7 +28,6 @@ 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}} = (