From 027c8b16e157ea9302532e1d2c9607e0603cfb29 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 21 Jul 2016 11:16:58 +0200 Subject: [PATCH 001/103] Update linux local traffic mode (ref #443) --- centreon-plugins/os/linux/local/mode/traffic.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/centreon-plugins/os/linux/local/mode/traffic.pm b/centreon-plugins/os/linux/local/mode/traffic.pm index 908b6c5df..753fd9d32 100644 --- a/centreon-plugins/os/linux/local/mode/traffic.pm +++ b/centreon-plugins/os/linux/local/mode/traffic.pm @@ -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 From 3cdad547b02975b7c3d4d6acb3438059926491ee Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 21 Jul 2016 20:31:29 +0200 Subject: [PATCH 002/103] + Ref #383 --- .../common/aruba/snmp/mode/apusers.pm | 309 ++++-------------- 1 file changed, 72 insertions(+), 237 deletions(-) diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm index b80f8309e..f9cac0524 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm @@ -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,8 +225,8 @@ 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})); @@ -408,12 +235,14 @@ sub manage_selection { $map_ap{$bssid}->{ip} !~ /$self->{option_results}->{filter_ip_address}/); 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 From 58d93a13cdd5ee1b193afee1a908ea4c1b20cea4 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 22 Jul 2016 11:59:17 +0200 Subject: [PATCH 003/103] fix option --- centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm index f9cac0524..bb85880f9 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm @@ -154,7 +154,7 @@ sub new { $options{options}->add_options(arguments => { "filter-ip-address:s" => { name => 'filter_ip_address' }, - "filter_bssid:s" => { name => 'filter_bssid' }, + "filter-bssid:s" => { name => 'filter_bssid' }, "filter-essid:s" => { name => 'filter_essid' }, }); From 6cfffee1606491e7515a42d560f19a54b56c17b3 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 26 Jul 2016 14:23:59 +0200 Subject: [PATCH 004/103] + Fix #451 --- .../powershell/dell/compellent/volumeusage.pm | 20 +++++++++++++++---- .../dell/compellent/local/mode/volumeusage.pm | 16 ++++++++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm b/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm index fc06d1a84..c8bd176e0 100644 --- a/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm +++ b/centreon-plugins/centreon/common/powershell/dell/compellent/volumeusage.pm @@ -53,11 +53,17 @@ Function display_volume_information { '; } - $ps .= ' + $ps .= ' foreach ($sc in $storageCenters) { $volumeList = Get-DellScVolume -ConnectionName $connName -StorageCenter $sc foreach ($vol in $volumeList) { - $volusage = Get-DellScVolumeStorageUsageAssociation -ConnectionName $connName -Instance $vol +'; + 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 @@ -69,8 +75,14 @@ Function display_volume_information { write-host ("[totalDiskSpace={0}]" -f $usage.TotalDiskSpace.GetByteSize()) -NoNewline write-host ("[replaySpace={0}]" -f $usage.replaySpace.GetByteSize()) } - - $diskList = Get-DellScDisk -ConnectionName $connName -StorageCenter $sc +'; + + 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 diff --git a/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm b/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm index 8da5629ab..b7062968f 100644 --- a/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm +++ b/centreon-plugins/storage/dell/compellent/local/mode/volumeusage.pm @@ -31,7 +31,7 @@ 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' }, + { 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} = [ @@ -89,6 +89,15 @@ sub prefix_volume_output { 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 { @@ -182,6 +191,7 @@ sub new { "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' }, }); @@ -310,6 +320,10 @@ Print powershell output. 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'). From 28ecf259b8bf514c9b1a65076b4c94ef8d674070 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 10:22:02 +0200 Subject: [PATCH 005/103] + fix help --- centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm b/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm index 89a1bb718..e36ed7a9e 100644 --- a/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm +++ b/centreon-plugins/storage/ibm/storwize/ssh/mode/hardware.pm @@ -145,7 +145,8 @@ Check components. =item B<--component> Which component to check (Default: '.*'). -Can be: 'array', 'drive'. +Can be: 'array', 'drive', 'enclosure', 'enclosurebattery', 'enclosurecanister', +'enclosurepsu', 'host', 'portfc', 'portsas', 'vdisk', 'node', 'quorum', 'mdisk', 'systemstats'. =item B<--filter> From 4c4f0ef65c2d9ff57228c4501a9e8f6970a2c4ac Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 13:56:38 +0200 Subject: [PATCH 006/103] + add voice cisco gateway --- .../network/cisco/vg/snmp/plugin.pm | 50 +++++ .../snmp_standard/mode/isdnusage.pm | 182 ++++++++++++++++++ 2 files changed, 232 insertions(+) create mode 100644 centreon-plugins/network/cisco/vg/snmp/plugin.pm create mode 100644 centreon-plugins/snmp_standard/mode/isdnusage.pm 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/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 From dd764be93dd70050b46143af46dfe323f7843079 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 14:09:24 +0200 Subject: [PATCH 007/103] + remove useless lines --- .../apps/activedirectory/local/plugin.pm | 1 - .../apps/activedirectory/wsman/plugin.pm | 1 - .../apps/apache/serverstatus/plugin.pm | 1 - centreon-plugins/apps/apcupsd/local/plugin.pm | 1 - centreon-plugins/apps/bluemind/plugin.pm | 1 - .../apps/centreon/local/plugin.pm | 1 - .../apps/centreon/map/jmx/mode/gates.pm | 1 - .../apps/centreon/map/jmx/mode/sessions.pm | 1 - .../apps/centreon/map/jmx/plugin.pm | 1 - centreon-plugins/apps/checkmyws/plugin.pm | 1 - centreon-plugins/apps/citrix/local/plugin.pm | 1 - centreon-plugins/apps/elasticsearch/plugin.pm | 1 - .../apps/exchange/2010/local/plugin.pm | 1 - centreon-plugins/apps/github/plugin.pm | 1 - centreon-plugins/apps/hddtemp/local/plugin.pm | 1 - .../apps/hddtemp/remote/plugin.pm | 1 - centreon-plugins/apps/iis/local/plugin.pm | 1 - centreon-plugins/apps/iis/wsman/plugin.pm | 1 - .../apps/java/peoplesoft/jmx/plugin.pm | 1 - .../apps/java/weblogic/jmx/plugin.pm | 1 - centreon-plugins/apps/jenkins/plugin.pm | 1 - centreon-plugins/apps/kayako/api/plugin.pm | 1 - centreon-plugins/apps/lmsensors/mode/fan.pm | 1 - centreon-plugins/apps/lmsensors/mode/misc.pm | 1 - .../apps/lmsensors/mode/temperature.pm | 1 - .../apps/lmsensors/mode/voltage.pm | 1 - centreon-plugins/apps/lmsensors/plugin.pm | 1 - .../apps/lotus/snmp/mode/mailstate.pm | 1 - .../apps/lotus/snmp/mode/mailtime.pm | 1 - .../lotus/snmp/mode/serveravailability.pm | 1 - .../lotus/snmp/mode/servertransactions.pm | 1 - .../apps/lotus/snmp/mode/usersessions.pm | 1 - centreon-plugins/apps/lotus/snmp/plugin.pm | 1 - centreon-plugins/apps/msmq/local/plugin.pm | 1 - .../apps/nginx/serverstatus/plugin.pm | 1 - .../apps/pacemaker/local/plugin.pm | 1 - .../apps/pfsense/snmp/mode/blockedpackets.pm | 1 - .../pfsense/snmp/mode/memorydroppedpackets.pm | 1 - .../apps/pfsense/snmp/mode/runtime.pm | 1 - centreon-plugins/apps/pfsense/snmp/plugin.pm | 1 - centreon-plugins/apps/php/apc/web/plugin.pm | 1 - centreon-plugins/apps/php/fpm/web/plugin.pm | 1 - .../apps/protocols/bgp/4/mode/bgppeerstate.pm | 1 - .../apps/protocols/bgp/4/plugin.pm | 1 - .../apps/protocols/dhcp/plugin.pm | 1 - centreon-plugins/apps/protocols/dns/plugin.pm | 1 - centreon-plugins/apps/protocols/ftp/plugin.pm | 1 - .../apps/protocols/http/plugin.pm | 1 - .../apps/protocols/imap/plugin.pm | 1 - .../apps/protocols/jmx/mode/numericvalue.pm | 1 - centreon-plugins/apps/protocols/jmx/plugin.pm | 1 - .../apps/protocols/ldap/plugin.pm | 1 - centreon-plugins/apps/protocols/ntp/plugin.pm | 1 - .../apps/protocols/radius/plugin.pm | 1 - .../apps/protocols/smtp/plugin.pm | 1 - centreon-plugins/apps/protocols/tcp/plugin.pm | 1 - centreon-plugins/apps/protocols/udp/plugin.pm | 1 - .../apps/protocols/x509/plugin.pm | 1 - centreon-plugins/apps/rrdcached/plugin.pm | 1 - centreon-plugins/apps/selenium/plugin.pm | 1 - centreon-plugins/apps/tomcat/jmx/plugin.pm | 1 - centreon-plugins/apps/tomcat/web/plugin.pm | 1 - centreon-plugins/apps/varnish/local/plugin.pm | 1 - .../apps/vmware/connector/plugin.pm | 1 - centreon-plugins/apps/vmware/wsman/plugin.pm | 1 - .../apps/voip/asterisk/remote/plugin.pm | 1 - .../voip/asterisk/snmp/mode/activecalls.pm | 1 - .../voip/asterisk/snmp/mode/externalcalls.pm | 1 - .../apps/voip/asterisk/snmp/plugin.pm | 1 - .../cisco/meetingplace/mode/audiolicenses.pm | 1 - .../cisco/meetingplace/mode/audioports.pm | 1 - .../cisco/meetingplace/mode/videolicenses.pm | 1 - .../cisco/meetingplace/mode/videoports.pm | 1 - .../apps/voip/cisco/meetingplace/plugin.pm | 1 - .../common/airespace/snmp/mode/cpu.pm | 1 - .../common/airespace/snmp/mode/memory.pm | 1 - .../common/aruba/snmp/mode/apconnections.pm | 1 - .../centreon/common/aruba/snmp/mode/cpu.pm | 1 - .../centreon/common/aruba/snmp/mode/memory.pm | 1 - .../common/aruba/snmp/mode/storage.pm | 1 - .../cisco/smallbusiness/snmp/mode/cpu.pm | 1 - .../common/cisco/standard/snmp/mode/cpu.pm | 1 - .../cisco/standard/snmp/mode/environment.pm | 1 - .../common/cisco/standard/snmp/mode/hsrp.pm | 1 - .../common/cisco/standard/snmp/mode/memory.pm | 1 - .../cisco/standard/snmp/mode/memoryflash.pm | 1 - .../common/cisco/standard/snmp/mode/stack.pm | 1 - .../powerconnect3000/mode/globalstatus.pm | 1 - .../centreon/common/fastpath/mode/cpu.pm | 1 - .../centreon/common/fastpath/mode/memory.pm | 1 - .../fortinet/fortigate/mode/clusterstatus.pm | 1 - .../common/fortinet/fortigate/mode/cpu.pm | 1 - .../common/fortinet/fortigate/mode/disk.pm | 1 - .../fortinet/fortigate/mode/hardware.pm | 1 - .../fortinet/fortigate/mode/ipsstats.pm | 1 - .../fortigate/mode/listvirtualdomains.pm | 2 - .../common/fortinet/fortigate/mode/memory.pm | 1 - .../fortinet/fortigate/mode/sessions.pm | 1 - .../common/fortinet/fortigate/mode/virus.pm | 1 - .../centreon/common/radlan/mode/cpu.pm | 1 - .../common/radlan/mode/environment.pm | 1 - centreon-plugins/centreon/plugins/output.pm | 1 - centreon-plugins/cloud/docker/plugin.pm | 1 - centreon-plugins/database/firebird/plugin.pm | 1 - .../database/informix/mode/listdatabases.pm | 1 - .../database/informix/mode/listdbspaces.pm | 1 - centreon-plugins/database/informix/plugin.pm | 1 - centreon-plugins/database/mssql/plugin.pm | 1 - centreon-plugins/database/mysql/plugin.pm | 1 - .../database/postgres/mode/listdatabases.pm | 1 - centreon-plugins/database/postgres/plugin.pm | 1 - centreon-plugins/example/mode/getvalue.pm | 1 - centreon-plugins/example/plugin_command.pm | 1 - centreon-plugins/example/plugin_custom.pm | 1 - centreon-plugins/example/plugin_snmp.pm | 1 - .../hardware/ats/apc/mode/entity.pm | 1 - .../hardware/ats/apc/mode/input.pm | 397 +++++++++--------- centreon-plugins/hardware/ats/apc/mode/psu.pm | 1 - .../hardware/ats/apc/mode/source.pm | 1 - centreon-plugins/hardware/ats/apc/plugin.pm | 1 - .../hardware/pdu/apc/snmp/plugin.pm | 1 - .../hardware/pdu/eaton/mode/group.pm | 1 - .../hardware/pdu/eaton/mode/outlet.pm | 1 - centreon-plugins/hardware/pdu/eaton/plugin.pm | 1 - .../hardware/pdu/raritan/snmp/plugin.pm | 1 - .../standard/rfc3805/mode/coverstatus.pm | 1 - .../standard/rfc3805/mode/markerimpression.pm | 1 - .../standard/rfc3805/mode/markersupply.pm | 1 - .../standard/rfc3805/mode/papertray.pm | 1 - .../printers/standard/rfc3805/plugin.pm | 1 - .../sensors/sensorip/snmp/mode/sensors.pm | 1 - .../hardware/sensors/sensorip/snmp/plugin.pm | 1 - .../sensors/sensormetrix/em01/web/plugin.pm | 1 - .../sensorgateway/snmp/mode/sensors.pm | 1 - .../serverscheck/sensorgateway/snmp/plugin.pm | 1 - .../sensors/temperhum/local/plugin.pm | 1 - .../server/cisco/ucs/mode/auditlogs.pm | 1 - .../hardware/server/cisco/ucs/mode/faults.pm | 1 - .../server/cisco/ucs/mode/serviceprofile.pm | 1 - .../hardware/server/cisco/ucs/plugin.pm | 1 - .../server/dell/cmc/snmp/mode/hardware.pm | 1 - .../hardware/server/dell/cmc/snmp/plugin.pm | 1 - .../dell/idrac/snmp/mode/globalstatus.pm | 1 - .../hardware/server/dell/idrac/snmp/plugin.pm | 1 - .../dell/openmanage/snmp/mode/hardware.pm | 1 - .../server/dell/openmanage/snmp/plugin.pm | 1 - .../hp/bladechassis/snmp/mode/hardware.pm | 1 - .../server/hp/bladechassis/snmp/plugin.pm | 1 - .../hp/proliant/snmp/mode/globalstatus.pm | 1 - .../server/hp/proliant/snmp/mode/hardware.pm | 1 - .../server/hp/proliant/snmp/plugin.pm | 1 - .../server/ibm/bladecenter/snmp/plugin.pm | 1 - .../hardware/server/ibm/hmc/ssh/plugin.pm | 1 - .../mgmt_cards/imm/snmp/mode/environment.pm | 1 - .../ibm/mgmt_cards/imm/snmp/mode/eventlog.pm | 1 - .../server/ibm/mgmt_cards/imm/snmp/plugin.pm | 1 - .../hardware/server/sun/mgmt_cards/plugin.pm | 1 - .../server/sun/mseries/mode/domains.pm | 1 - .../server/sun/mseries/mode/hardware.pm | 1 - .../hardware/server/sun/mseries/plugin.pm | 1 - .../hardware/server/sun/sfxxk/plugin.pm | 1 - .../hardware/ups/apc/snmp/plugin.pm | 1 - .../ups/mge/snmp/mode/batterystatus.pm | 1 - .../hardware/ups/mge/snmp/mode/environment.pm | 1 - .../hardware/ups/mge/snmp/mode/inputlines.pm | 1 - .../hardware/ups/mge/snmp/mode/outputlines.pm | 1 - .../ups/mge/snmp/mode/outputsource.pm | 1 - .../hardware/ups/mge/snmp/plugin.pm | 1 - .../ups/powerware/snmp/mode/alarms.pm | 1 - .../ups/powerware/snmp/mode/batterystatus.pm | 1 - .../ups/powerware/snmp/mode/environment.pm | 1 - .../ups/powerware/snmp/mode/inputlines.pm | 1 - .../ups/powerware/snmp/mode/outputlines.pm | 1 - .../ups/powerware/snmp/mode/outputsource.pm | 1 - .../hardware/ups/powerware/snmp/plugin.pm | 1 - .../ups/standard/rfc1628/snmp/mode/alarms.pm | 1 - .../rfc1628/snmp/mode/batterystatus.pm | 1 - .../standard/rfc1628/snmp/mode/outputlines.pm | 1 - .../rfc1628/snmp/mode/outputsource.pm | 1 - .../ups/standard/rfc1628/snmp/plugin.pm | 1 - .../network/alcatel/common/mode/cpu.pm | 1 - .../alcatel/common/mode/flashmemory.pm | 1 - .../network/alcatel/common/mode/hardware.pm | 1 - .../network/alcatel/common/mode/memory.pm | 1 - .../network/alcatel/omniswitch/6850/plugin.pm | 1 - centreon-plugins/network/arkoon/plugin.pm | 1 - .../network/aruba/standard/snmp/plugin.pm | 1 - .../network/atrica/snmp/plugin.pm | 1 - .../bluecoat/snmp/mode/clientconnections.pm | 1 - .../bluecoat/snmp/mode/clienttraffic.pm | 1 - .../network/bluecoat/snmp/mode/cpu.pm | 1 - .../network/bluecoat/snmp/mode/disk.pm | 1 - .../network/bluecoat/snmp/mode/memory.pm | 1 - .../bluecoat/snmp/mode/serverconnections.pm | 1 - .../network/bluecoat/snmp/plugin.pm | 1 - centreon-plugins/network/brocade/mode/cpu.pm | 1 - .../network/brocade/mode/hardware.pm | 1 - .../network/brocade/mode/memory.pm | 1 - centreon-plugins/network/brocade/plugin.pm | 1 - .../network/checkpoint/mode/connections.pm | 1 - .../network/checkpoint/mode/cpu.pm | 1 - .../network/checkpoint/mode/hastate.pm | 1 - .../network/checkpoint/mode/memory.pm | 1 - centreon-plugins/network/checkpoint/plugin.pm | 1 - .../network/cisco/WaaS/mode/sessions.pm | 1 - centreon-plugins/network/cisco/WaaS/plugin.pm | 1 - .../network/cisco/asa/mode/failover.pm | 1 - centreon-plugins/network/cisco/asa/plugin.pm | 1 - .../cisco/ironport/snmp/mode/memory.pm | 1 - .../network/cisco/ironport/snmp/plugin.pm | 1 - .../smallbusiness/standard/snmp/plugin.pm | 1 - .../network/cisco/standard/snmp/plugin.pm | 1 - .../network/cisco/wlc/snmp/plugin.pm | 1 - .../common/mode/certificatesexpire.pm | 1 - .../citrix/netscaler/common/mode/cpu.pm | 1 - .../citrix/netscaler/common/mode/hastate.pm | 1 - .../citrix/netscaler/common/mode/health.pm | 1 - .../netscaler/common/mode/listvservers.pm | 2 - .../citrix/netscaler/common/mode/memory.pm | 1 - .../citrix/netscaler/common/mode/storage.pm | 1 - .../netscaler/common/mode/vserverstatus.pm | 1 - .../citrix/netscaler/mpx8000/plugin.pm | 1 - centreon-plugins/network/dell/6200/plugin.pm | 1 - centreon-plugins/network/dell/n4000/plugin.pm | 1 - .../network/dell/sseries/snmp/plugin.pm | 1 - .../network/digi/portserverts/snmp/plugin.pm | 1 - .../network/digi/standard/snmp/mode/cpu.pm | 1 - .../network/digi/standard/snmp/mode/memory.pm | 1 - .../network/dlink/dgs3100/snmp/mode/cpu.pm | 1 - .../network/dlink/dgs3100/snmp/plugin.pm | 1 - .../network/dlink/standard/snmp/mode/cpu.pm | 1 - .../network/dlink/standard/snmp/plugin.pm | 1 - .../network/extreme/snmp/mode/stack.pm | 1 - .../network/extreme/snmp/plugin.pm | 1 - .../network/f5/bigip/mode/listnodes.pm | 2 - .../network/f5/bigip/mode/listpools.pm | 2 - .../f5/bigip/mode/listvirtualservers.pm | 2 - centreon-plugins/network/f5/bigip/plugin.pm | 1 - .../network/fortinet/fortigate/plugin.pm | 1 - centreon-plugins/network/fritzbox/plugin.pm | 1 - centreon-plugins/network/h3c/snmp/mode/cpu.pm | 1 - .../network/h3c/snmp/mode/memory.pm | 1 - centreon-plugins/network/h3c/snmp/plugin.pm | 1 - .../hirschmann/standard/snmp/mode/cpu.pm | 1 - .../hirschmann/standard/snmp/mode/memory.pm | 1 - .../standard/snmp/mode/processcount.pm | 1 - .../hirschmann/standard/snmp/plugin.pm | 1 - .../network/hp/procurve/mode/cpu.pm | 1 - .../network/hp/procurve/mode/memory.pm | 1 - .../network/hp/procurve/plugin.pm | 1 - .../network/juniper/common/ive/mode/cpu.pm | 1 - .../network/juniper/common/ive/mode/disk.pm | 1 - .../juniper/common/ive/mode/logfile.pm | 1 - .../juniper/common/junos/mode/cpsessions.pm | 1 - .../common/junos/mode/cpuforwarding.pm | 1 - .../juniper/common/junos/mode/cpurouting.pm | 1 - .../juniper/common/junos/mode/flowsessions.pm | 1 - .../common/junos/mode/memoryforwarding.pm | 1 - .../common/junos/mode/memoryrouting.pm | 1 - .../juniper/common/screenos/mode/cpu.pm | 1 - .../juniper/common/screenos/mode/memory.pm | 1 - centreon-plugins/network/juniper/ex/plugin.pm | 1 - .../network/juniper/ggsn/mode/apnstats.pm | 1 - .../network/juniper/ggsn/mode/globalstats.pm | 1 - .../network/juniper/ggsn/plugin.pm | 1 - .../juniper/mag/mode/bladetemperature.pm | 1 - .../network/juniper/mag/plugin.pm | 1 - .../network/juniper/mseries/plugin.pm | 1 - centreon-plugins/network/juniper/sa/plugin.pm | 1 - .../network/juniper/srx/plugin.pm | 1 - .../network/juniper/ssg/plugin.pm | 1 - .../network/juniper/trapeze/snmp/plugin.pm | 1 - .../network/netasq/snmp/mode/vpnstatus.pm | 1 - .../network/netasq/snmp/plugin.pm | 1 - .../network/oneaccess/snmp/mode/cpu.pm | 1 - .../network/oneaccess/snmp/mode/memory.pm | 1 - .../network/oneaccess/snmp/plugin.pm | 1 - .../paloalto/snmp/mode/clusterstatus.pm | 1 - .../network/paloalto/snmp/mode/panorama.pm | 1 - .../network/paloalto/snmp/mode/sessions.pm | 1 - .../network/paloalto/snmp/plugin.pm | 1 - .../network/radware/alteon/5224/plugin.pm | 1 - .../network/radware/alteon/common/mode/cpu.pm | 1 - .../radware/alteon/common/mode/hardware.pm | 1 - .../radware/alteon/common/mode/memory.pm | 1 - .../network/redback/snmp/mode/cpu.pm | 1 - .../network/redback/snmp/plugin.pm | 1 - .../steelhead/snmp/mode/bwoptimization.pm | 1 - .../steelhead/snmp/mode/bwpassthrough.pm | 1 - .../steelhead/snmp/mode/connections.pm | 1 - .../steelhead/snmp/mode/diskutilization.pm | 1 - .../riverbed/steelhead/snmp/mode/health.pm | 1 - .../steelhead/snmp/mode/loadaverage.pm | 1 - .../steelhead/snmp/mode/servicestatus.pm | 1 - .../steelhead/snmp/mode/serviceuptime.pm | 1 - .../steelhead/snmp/mode/temperature.pm | 1 - .../network/riverbed/steelhead/snmp/plugin.pm | 1 - .../network/ruggedcom/mode/errors.pm | 1 - .../network/ruggedcom/mode/hardware.pm | 1 - .../network/ruggedcom/mode/memory.pm | 1 - .../network/ruggedcom/mode/temperature.pm | 1 - centreon-plugins/network/ruggedcom/plugin.pm | 1 - .../network/securactive/mode/bca.pm | 1 - .../network/securactive/mode/bcn.pm | 1 - .../network/securactive/mode/listbca.pm | 2 - .../network/securactive/mode/listbcn.pm | 2 - .../network/securactive/plugin.pm | 1 - centreon-plugins/network/sonus/sbc/plugin.pm | 1 - .../stonesoft/snmp/mode/clusterload.pm | 1 - .../stonesoft/snmp/mode/clusterstate.pm | 1 - .../stonesoft/snmp/mode/connections.pm | 1 - .../network/stonesoft/snmp/mode/cpu.pm | 1 - .../stonesoft/snmp/mode/droppedpackets.pm | 1 - .../network/stonesoft/snmp/mode/memory.pm | 1 - .../stonesoft/snmp/mode/rejectedpackets.pm | 1 - .../network/stonesoft/snmp/mode/storage.pm | 1 - .../network/stonesoft/snmp/plugin.pm | 1 - .../network/ucopia/wlc/snmp/plugin.pm | 1 - centreon-plugins/os/aix/local/plugin.pm | 1 - centreon-plugins/os/aix/snmp/mode/swap.pm | 1 - centreon-plugins/os/aix/snmp/plugin.pm | 1 - .../os/freebsd/snmp/mode/memory.pm | 1 - centreon-plugins/os/freebsd/snmp/plugin.pm | 1 - .../os/linux/local/mode/connections.pm | 1 - centreon-plugins/os/linux/local/plugin.pm | 1 - centreon-plugins/os/linux/snmp/plugin.pm | 1 - centreon-plugins/os/solaris/local/plugin.pm | 1 - centreon-plugins/os/solaris/snmp/plugin.pm | 1 - centreon-plugins/os/windows/local/plugin.pm | 1 - .../os/windows/snmp/mode/memory.pm | 1 - .../os/windows/snmp/mode/service.pm | 1 - centreon-plugins/os/windows/snmp/mode/swap.pm | 1 - centreon-plugins/os/windows/snmp/plugin.pm | 1 - centreon-plugins/os/windows/wsman/plugin.pm | 1 - centreon-plugins/snmp_standard/mode/cpu.pm | 1 - .../snmp_standard/mode/cpudetailed.pm | 1 - .../snmp_standard/mode/diskusage.pm | 1 - .../snmp_standard/mode/dynamiccommand.pm | 1 - .../snmp_standard/mode/hardwaredevice.pm | 1 - .../mode/hardwarefibrealliance.pm | 1 - .../snmp_standard/mode/listdiskspath.pm | 2 - .../snmp_standard/mode/liststorages.pm | 2 - .../snmp_standard/mode/loadaverage.pm | 1 - centreon-plugins/snmp_standard/mode/memory.pm | 1 - centreon-plugins/snmp_standard/mode/ntp.pm | 1 - .../snmp_standard/mode/numericvalue.pm | 1 - .../snmp_standard/mode/printererror.pm | 1 - .../snmp_standard/mode/processcount.pm | 1 - .../snmp_standard/mode/spanningtree.pm | 1 - .../snmp_standard/mode/storage.pm | 1 - centreon-plugins/snmp_standard/mode/swap.pm | 1 - centreon-plugins/snmp_standard/mode/tcpcon.pm | 1 - centreon-plugins/snmp_standard/plugin.pm | 1 - .../storage/dell/MD3000/cli/plugin.pm | 1 - .../storage/dell/TL2000/mode/globalstatus.pm | 1 - .../storage/dell/TL2000/plugin.pm | 1 - .../dell/equallogic/snmp/mode/arraystats.pm | 1 - .../dell/equallogic/snmp/mode/diskusage.pm | 1 - .../dell/equallogic/snmp/mode/hardware.pm | 1 - .../dell/equallogic/snmp/mode/poolusage.pm | 1 - .../storage/dell/equallogic/snmp/plugin.pm | 1 - .../storage/dell/ml6000/snmp/plugin.pm | 1 - .../storage/emc/DataDomain/mode/filesystem.pm | 1 - .../storage/emc/DataDomain/plugin.pm | 1 - .../storage/emc/celerra/local/plugin.pm | 1 - .../storage/emc/clariion/plugin.pm | 1 - .../storage/emc/recoverypoint/ssh/plugin.pm | 1 - .../storage/emc/vplex/restapi/plugin.pm | 1 - .../storage/emc/xtremio/restapi/plugin.pm | 1 - .../storage/fujitsu/eternus/dx/ssh/plugin.pm | 1 - .../storage/hp/3par/7000/plugin.pm | 1 - .../storage/hp/lefthand/mode/hardware.pm | 1 - .../storage/hp/lefthand/plugin.pm | 1 - .../storage/hp/msa2000/snmp/plugin.pm | 1 - .../storage/hp/msl/snmp/mode/status.pm | 1 - .../storage/hp/msl/snmp/plugin.pm | 1 - .../storage/hp/p2000/xmlapi/plugin.pm | 1 - .../storage/ibm/DS3000/cli/plugin.pm | 1 - .../storage/ibm/DS4000/cli/plugin.pm | 1 - .../storage/ibm/DS5000/cli/plugin.pm | 1 - .../storage/ibm/TS3100/mode/globalstatus.pm | 1 - centreon-plugins/storage/ibm/TS3100/plugin.pm | 1 - .../storage/ibm/TS3200/mode/globalstatus.pm | 1 - centreon-plugins/storage/ibm/TS3200/plugin.pm | 1 - .../netapp/snmp/mode/aggregatestate.pm | 1 - .../storage/netapp/snmp/mode/cpstatistics.pm | 1 - .../storage/netapp/snmp/mode/cpuload.pm | 1 - .../storage/netapp/snmp/mode/diskfailed.pm | 1 - .../storage/netapp/snmp/mode/fan.pm | 1 - .../storage/netapp/snmp/mode/globalstatus.pm | 1 - .../storage/netapp/snmp/mode/listfilesys.pm | 2 - .../storage/netapp/snmp/mode/ndmpsessions.pm | 1 - .../storage/netapp/snmp/mode/nvram.pm | 1 - .../storage/netapp/snmp/mode/partnerstatus.pm | 1 - .../storage/netapp/snmp/mode/psu.pm | 1 - .../storage/netapp/snmp/mode/qtreeusage.pm | 1 - .../storage/netapp/snmp/mode/sharecalls.pm | 1 - .../storage/netapp/snmp/mode/snapmirrorlag.pm | 1 - .../storage/netapp/snmp/mode/snapshotage.pm | 1 - .../storage/netapp/snmp/mode/temperature.pm | 1 - .../storage/netapp/snmp/mode/volumeoptions.pm | 1 - .../storage/netapp/snmp/plugin.pm | 1 - .../storage/panzura/snmp/mode/cpucloud.pm | 1 - .../panzura/snmp/mode/diskusagelocal.pm | 1 - .../storage/panzura/snmp/mode/memory.pm | 1 - .../storage/panzura/snmp/mode/ratios.pm | 1 - .../storage/panzura/snmp/plugin.pm | 1 - .../storage/qnap/snmp/mode/hardware.pm | 1 - .../storage/qnap/snmp/mode/memory.pm | 1 - .../storage/qnap/snmp/mode/volumeusage.pm | 1 - centreon-plugins/storage/qnap/snmp/plugin.pm | 1 - .../storage/synology/snmp/mode/components.pm | 1 - .../storage/synology/snmp/mode/temperature.pm | 1 - .../storage/synology/snmp/mode/ups.pm | 1 - .../storage/synology/snmp/plugin.pm | 1 - .../storage/violin/3000/snmp/plugin.pm | 1 - 416 files changed, 198 insertions(+), 624 deletions(-) diff --git a/centreon-plugins/apps/activedirectory/local/plugin.pm b/centreon-plugins/apps/activedirectory/local/plugin.pm index 918439a2e..b78e18018 100644 --- a/centreon-plugins/apps/activedirectory/local/plugin.pm +++ b/centreon-plugins/apps/activedirectory/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/activedirectory/wsman/plugin.pm index 3e1b90591..a04c98062 100644 --- a/centreon-plugins/apps/activedirectory/wsman/plugin.pm +++ b/centreon-plugins/apps/activedirectory/wsman/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/apache/serverstatus/plugin.pm index cbbf875fa..620407bf4 100644 --- a/centreon-plugins/apps/apache/serverstatus/plugin.pm +++ b/centreon-plugins/apps/apache/serverstatus/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/apcupsd/local/plugin.pm index e8694fa6d..a653bd346 100644 --- a/centreon-plugins/apps/apcupsd/local/plugin.pm +++ b/centreon-plugins/apps/apcupsd/local/plugin.pm @@ -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/bluemind/plugin.pm b/centreon-plugins/apps/bluemind/plugin.pm index 0947ed956..c9c0bee69 100644 --- a/centreon-plugins/apps/bluemind/plugin.pm +++ b/centreon-plugins/apps/bluemind/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/centreon/local/plugin.pm index d6fb0eef2..e9b02e138 100644 --- a/centreon-plugins/apps/centreon/local/plugin.pm +++ b/centreon-plugins/apps/centreon/local/plugin.pm @@ -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/gates.pm b/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm index 250bc2fe6..62bef8224 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/gates.pm @@ -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 6d8f9052c..f0ae02058 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/sessions.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/sessions.pm @@ -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 f9bca3abd..6320d3f82 100644 --- a/centreon-plugins/apps/centreon/map/jmx/plugin.pm +++ b/centreon-plugins/apps/centreon/map/jmx/plugin.pm @@ -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/checkmyws/plugin.pm b/centreon-plugins/apps/checkmyws/plugin.pm index 1de610a64..ba1b77a53 100644 --- a/centreon-plugins/apps/checkmyws/plugin.pm +++ b/centreon-plugins/apps/checkmyws/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/citrix/local/plugin.pm index 3ac4781a1..bcb1ea708 100644 --- a/centreon-plugins/apps/citrix/local/plugin.pm +++ b/centreon-plugins/apps/citrix/local/plugin.pm @@ -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/elasticsearch/plugin.pm b/centreon-plugins/apps/elasticsearch/plugin.pm index 945302278..f071b4c2b 100644 --- a/centreon-plugins/apps/elasticsearch/plugin.pm +++ b/centreon-plugins/apps/elasticsearch/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/exchange/2010/local/plugin.pm index ca9c805e4..22a54fce9 100644 --- a/centreon-plugins/apps/exchange/2010/local/plugin.pm +++ b/centreon-plugins/apps/exchange/2010/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/github/plugin.pm index 0e5f8b7b8..cddc714f6 100644 --- a/centreon-plugins/apps/github/plugin.pm +++ b/centreon-plugins/apps/github/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/hddtemp/local/plugin.pm index 55bc83f8f..58778ed91 100644 --- a/centreon-plugins/apps/hddtemp/local/plugin.pm +++ b/centreon-plugins/apps/hddtemp/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/hddtemp/remote/plugin.pm index cc01c55e5..6b7dd8c9b 100644 --- a/centreon-plugins/apps/hddtemp/remote/plugin.pm +++ b/centreon-plugins/apps/hddtemp/remote/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/iis/local/plugin.pm index f8ce8235d..048aacc4f 100644 --- a/centreon-plugins/apps/iis/local/plugin.pm +++ b/centreon-plugins/apps/iis/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/iis/wsman/plugin.pm index c0a9c51a8..f0c9117ce 100644 --- a/centreon-plugins/apps/iis/wsman/plugin.pm +++ b/centreon-plugins/apps/iis/wsman/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm index cbd6d348d..17a0a233d 100644 --- a/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm +++ b/centreon-plugins/apps/java/peoplesoft/jmx/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/java/weblogic/jmx/plugin.pm index 122b9d8fe..00219ca31 100644 --- a/centreon-plugins/apps/java/weblogic/jmx/plugin.pm +++ b/centreon-plugins/apps/java/weblogic/jmx/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/jenkins/plugin.pm index f7cc92343..dbe2a6fd2 100644 --- a/centreon-plugins/apps/jenkins/plugin.pm +++ b/centreon-plugins/apps/jenkins/plugin.pm @@ -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/kayako/api/plugin.pm b/centreon-plugins/apps/kayako/api/plugin.pm index a8c0abcde..65bb80983 100644 --- a/centreon-plugins/apps/kayako/api/plugin.pm +++ b/centreon-plugins/apps/kayako/api/plugin.pm @@ -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/lmsensors/mode/fan.pm b/centreon-plugins/apps/lmsensors/mode/fan.pm index c18df7c63..cb6e0a3c0 100644 --- a/centreon-plugins/apps/lmsensors/mode/fan.pm +++ b/centreon-plugins/apps/lmsensors/mode/fan.pm @@ -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 34d3c4c11..7e7a663aa 100644 --- a/centreon-plugins/apps/lmsensors/mode/misc.pm +++ b/centreon-plugins/apps/lmsensors/mode/misc.pm @@ -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 71d51b19d..9151cc5d9 100644 --- a/centreon-plugins/apps/lmsensors/mode/temperature.pm +++ b/centreon-plugins/apps/lmsensors/mode/temperature.pm @@ -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 3a5e5a6ac..712426a81 100644 --- a/centreon-plugins/apps/lmsensors/mode/voltage.pm +++ b/centreon-plugins/apps/lmsensors/mode/voltage.pm @@ -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 624752644..8ebc72276 100644 --- a/centreon-plugins/apps/lmsensors/plugin.pm +++ b/centreon-plugins/apps/lmsensors/plugin.pm @@ -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 0a7c23d3e..e25d56445 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/mailstate.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/mailstate.pm @@ -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 b6fe57131..b82900a8f 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/mailtime.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/mailtime.pm @@ -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 8434c54f1..9bd2f7d1c 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/serveravailability.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/serveravailability.pm @@ -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 49392dc9f..3a49a9ffa 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/servertransactions.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/servertransactions.pm @@ -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 cabc676d6..c60449e60 100644 --- a/centreon-plugins/apps/lotus/snmp/mode/usersessions.pm +++ b/centreon-plugins/apps/lotus/snmp/mode/usersessions.pm @@ -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 70a99d8ea..6def9b5d1 100644 --- a/centreon-plugins/apps/lotus/snmp/plugin.pm +++ b/centreon-plugins/apps/lotus/snmp/plugin.pm @@ -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/msmq/local/plugin.pm b/centreon-plugins/apps/msmq/local/plugin.pm index 28694c710..f09174bae 100644 --- a/centreon-plugins/apps/msmq/local/plugin.pm +++ b/centreon-plugins/apps/msmq/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/nginx/serverstatus/plugin.pm index 74dbeda13..9f0112d81 100644 --- a/centreon-plugins/apps/nginx/serverstatus/plugin.pm +++ b/centreon-plugins/apps/nginx/serverstatus/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/pacemaker/local/plugin.pm index 8d5c56c76..f07c3de64 100644 --- a/centreon-plugins/apps/pacemaker/local/plugin.pm +++ b/centreon-plugins/apps/pacemaker/local/plugin.pm @@ -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/pfsense/snmp/mode/blockedpackets.pm b/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm index d2621b55b..481697e4f 100644 --- a/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm +++ b/centreon-plugins/apps/pfsense/snmp/mode/blockedpackets.pm @@ -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 4e10746fa..109655f7b 100644 --- a/centreon-plugins/apps/pfsense/snmp/mode/memorydroppedpackets.pm +++ b/centreon-plugins/apps/pfsense/snmp/mode/memorydroppedpackets.pm @@ -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 031ae09ba..d1cc9dc7b 100644 --- a/centreon-plugins/apps/pfsense/snmp/mode/runtime.pm +++ b/centreon-plugins/apps/pfsense/snmp/mode/runtime.pm @@ -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 03a0dd757..5746f623b 100644 --- a/centreon-plugins/apps/pfsense/snmp/plugin.pm +++ b/centreon-plugins/apps/pfsense/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/php/apc/web/plugin.pm index c15bb19a3..1415378c4 100644 --- a/centreon-plugins/apps/php/apc/web/plugin.pm +++ b/centreon-plugins/apps/php/apc/web/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/php/fpm/web/plugin.pm index 55b82dd99..fc412c18f 100644 --- a/centreon-plugins/apps/php/fpm/web/plugin.pm +++ b/centreon-plugins/apps/php/fpm/web/plugin.pm @@ -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 ca3d4a6ae..0d10eab70 100644 --- a/centreon-plugins/apps/protocols/bgp/4/mode/bgppeerstate.pm +++ b/centreon-plugins/apps/protocols/bgp/4/mode/bgppeerstate.pm @@ -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 36b24a42a..ff32f1405 100644 --- a/centreon-plugins/apps/protocols/bgp/4/plugin.pm +++ b/centreon-plugins/apps/protocols/bgp/4/plugin.pm @@ -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/dhcp/plugin.pm b/centreon-plugins/apps/protocols/dhcp/plugin.pm index eb4bc0ec4..e25a739f1 100644 --- a/centreon-plugins/apps/protocols/dhcp/plugin.pm +++ b/centreon-plugins/apps/protocols/dhcp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/dns/plugin.pm index 6b7dd0a40..f6449f70d 100644 --- a/centreon-plugins/apps/protocols/dns/plugin.pm +++ b/centreon-plugins/apps/protocols/dns/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/ftp/plugin.pm index 11515bb1d..c8bfad271 100644 --- a/centreon-plugins/apps/protocols/ftp/plugin.pm +++ b/centreon-plugins/apps/protocols/ftp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/http/plugin.pm index 9d6c1f8f0..48ded3c07 100644 --- a/centreon-plugins/apps/protocols/http/plugin.pm +++ b/centreon-plugins/apps/protocols/http/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/imap/plugin.pm index d8180d099..d10251fad 100644 --- a/centreon-plugins/apps/protocols/imap/plugin.pm +++ b/centreon-plugins/apps/protocols/imap/plugin.pm @@ -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/numericvalue.pm b/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm index 00a64d7db..04f24b667 100644 --- a/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm +++ b/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm @@ -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); diff --git a/centreon-plugins/apps/protocols/jmx/plugin.pm b/centreon-plugins/apps/protocols/jmx/plugin.pm index 1925b8156..ab813fb9e 100644 --- a/centreon-plugins/apps/protocols/jmx/plugin.pm +++ b/centreon-plugins/apps/protocols/jmx/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/ldap/plugin.pm index 7a2c457e3..7876e15a6 100644 --- a/centreon-plugins/apps/protocols/ldap/plugin.pm +++ b/centreon-plugins/apps/protocols/ldap/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/ntp/plugin.pm index 5ae6e11a5..464104da8 100644 --- a/centreon-plugins/apps/protocols/ntp/plugin.pm +++ b/centreon-plugins/apps/protocols/ntp/plugin.pm @@ -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/radius/plugin.pm b/centreon-plugins/apps/protocols/radius/plugin.pm index 99d1d9801..bf9a391db 100644 --- a/centreon-plugins/apps/protocols/radius/plugin.pm +++ b/centreon-plugins/apps/protocols/radius/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/smtp/plugin.pm index bb1758635..c0160c212 100644 --- a/centreon-plugins/apps/protocols/smtp/plugin.pm +++ b/centreon-plugins/apps/protocols/smtp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/tcp/plugin.pm index 1a3939b73..b430ee5f3 100644 --- a/centreon-plugins/apps/protocols/tcp/plugin.pm +++ b/centreon-plugins/apps/protocols/tcp/plugin.pm @@ -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/udp/plugin.pm b/centreon-plugins/apps/protocols/udp/plugin.pm index 54e1a91a4..e7f6d4c52 100644 --- a/centreon-plugins/apps/protocols/udp/plugin.pm +++ b/centreon-plugins/apps/protocols/udp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/protocols/x509/plugin.pm index b972e0898..8cea1e568 100644 --- a/centreon-plugins/apps/protocols/x509/plugin.pm +++ b/centreon-plugins/apps/protocols/x509/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/rrdcached/plugin.pm index d589ce29f..30e6fa135 100644 --- a/centreon-plugins/apps/rrdcached/plugin.pm +++ b/centreon-plugins/apps/rrdcached/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/selenium/plugin.pm index f0d299f1d..c35e4b434 100644 --- a/centreon-plugins/apps/selenium/plugin.pm +++ b/centreon-plugins/apps/selenium/plugin.pm @@ -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 7f85c5da1..945a2668b 100644 --- a/centreon-plugins/apps/tomcat/jmx/plugin.pm +++ b/centreon-plugins/apps/tomcat/jmx/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/tomcat/web/plugin.pm index 4c711e729..dff816934 100644 --- a/centreon-plugins/apps/tomcat/web/plugin.pm +++ b/centreon-plugins/apps/tomcat/web/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/varnish/local/plugin.pm index ac30a5e17..a5fb9b8b1 100644 --- a/centreon-plugins/apps/varnish/local/plugin.pm +++ b/centreon-plugins/apps/varnish/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/vmware/connector/plugin.pm index 2791ffa03..0d487db73 100644 --- a/centreon-plugins/apps/vmware/connector/plugin.pm +++ b/centreon-plugins/apps/vmware/connector/plugin.pm @@ -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/wsman/plugin.pm b/centreon-plugins/apps/vmware/wsman/plugin.pm index 7207d6af8..6e99d865d 100644 --- a/centreon-plugins/apps/vmware/wsman/plugin.pm +++ b/centreon-plugins/apps/vmware/wsman/plugin.pm @@ -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/plugin.pm b/centreon-plugins/apps/voip/asterisk/remote/plugin.pm index e7294c2b8..eb0cc05fc 100644 --- a/centreon-plugins/apps/voip/asterisk/remote/plugin.pm +++ b/centreon-plugins/apps/voip/asterisk/remote/plugin.pm @@ -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 0109fcd48..bb0f76135 100644 --- a/centreon-plugins/apps/voip/asterisk/snmp/mode/activecalls.pm +++ b/centreon-plugins/apps/voip/asterisk/snmp/mode/activecalls.pm @@ -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 056987d10..c26fabdc7 100644 --- a/centreon-plugins/apps/voip/asterisk/snmp/mode/externalcalls.pm +++ b/centreon-plugins/apps/voip/asterisk/snmp/mode/externalcalls.pm @@ -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 86aa0a944..93e7e5e5f 100644 --- a/centreon-plugins/apps/voip/asterisk/snmp/plugin.pm +++ b/centreon-plugins/apps/voip/asterisk/snmp/plugin.pm @@ -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 f643671de..d9ca5ddd7 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/audiolicenses.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/audiolicenses.pm @@ -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 32d858469..10bdeff45 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/audioports.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/audioports.pm @@ -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 b3361a63e..892ee52cf 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/videolicenses.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/videolicenses.pm @@ -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 022c947b6..222248e93 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/mode/videoports.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/mode/videoports.pm @@ -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 6bbf9f658..e27739863 100644 --- a/centreon-plugins/apps/voip/cisco/meetingplace/plugin.pm +++ b/centreon-plugins/apps/voip/cisco/meetingplace/plugin.pm @@ -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/airespace/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm index ded1c4e09..9d8771648 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm index fc494246d..1c954eff0 100644 --- a/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/airespace/snmp/mode/memory.pm @@ -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 fc41e32cd..d6be2cbc4 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/apconnections.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/apconnections.pm @@ -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/cpu.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm index 401db23ff..5cacc48ea 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm index 18b577f6e..4db707a45 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/memory.pm @@ -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 109574fbf..c18f7ed26 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/storage.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/storage.pm @@ -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/cisco/smallbusiness/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm index 842d7e81d..1c38d8562 100644 --- a/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/cisco/smallbusiness/snmp/mode/cpu.pm @@ -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/standard/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm index 2d39da097..ff6a9fd39 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/cpu.pm @@ -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 21908824b..0d57fc375 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm @@ -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'; 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 df8119165..aeeaf0357 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/hsrp.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/hsrp.pm @@ -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/memory.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm index 03e72cfbd..91c149e14 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memory.pm @@ -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 612e81fbc..e3ea795a8 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memoryflash.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/memoryflash.pm @@ -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/stack.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm index 360bc549b..e971e36e0 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/stack.pm @@ -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 b5ddb43b5..c2199f00a 100644 --- a/centreon-plugins/centreon/common/dell/powerconnect3000/mode/globalstatus.pm +++ b/centreon-plugins/centreon/common/dell/powerconnect3000/mode/globalstatus.pm @@ -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/fastpath/mode/cpu.pm b/centreon-plugins/centreon/common/fastpath/mode/cpu.pm index bb22bba21..588fb1f15 100644 --- a/centreon-plugins/centreon/common/fastpath/mode/cpu.pm +++ b/centreon-plugins/centreon/common/fastpath/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/centreon/common/fastpath/mode/memory.pm index b550e274d..6d0ea1fcd 100644 --- a/centreon-plugins/centreon/common/fastpath/mode/memory.pm +++ b/centreon-plugins/centreon/common/fastpath/mode/memory.pm @@ -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/fortinet/fortigate/mode/clusterstatus.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm index f8549a0bd..ab665e677 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/clusterstatus.pm @@ -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 5eed9649f..b39d18dc0 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/cpu.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/cpu.pm @@ -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 4f8f902db..6a06e2986 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/disk.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/disk.pm @@ -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 a3b80a363..697009092 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/hardware.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/hardware.pm @@ -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 e0d90f0ce..1f88f7c3c 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/ipsstats.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/ipsstats.pm @@ -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 9ecb34e83..992bc0161 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/listvirtualdomains.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/listvirtualdomains.pm @@ -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 6435bce0d..45c1dd18d 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/memory.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/memory.pm @@ -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 fb2ce5dae..65a2bc4e9 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm @@ -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 9ff41dda1..127663f97 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/virus.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/virus.pm @@ -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/radlan/mode/cpu.pm b/centreon-plugins/centreon/common/radlan/mode/cpu.pm index 05d7b20e5..a142ec6a4 100644 --- a/centreon-plugins/centreon/common/radlan/mode/cpu.pm +++ b/centreon-plugins/centreon/common/radlan/mode/cpu.pm @@ -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 27c567ce0..54625eaeb 100644 --- a/centreon-plugins/centreon/common/radlan/mode/environment.pm +++ b/centreon-plugins/centreon/common/radlan/mode/environment.pm @@ -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. diff --git a/centreon-plugins/centreon/plugins/output.pm b/centreon-plugins/centreon/plugins/output.pm index 1243cb1ff..59a76a87a 100644 --- a/centreon-plugins/centreon/plugins/output.pm +++ b/centreon-plugins/centreon/plugins/output.pm @@ -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; diff --git a/centreon-plugins/cloud/docker/plugin.pm b/centreon-plugins/cloud/docker/plugin.pm index c30bd8bc7..ebb0824a4 100644 --- a/centreon-plugins/cloud/docker/plugin.pm +++ b/centreon-plugins/cloud/docker/plugin.pm @@ -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/plugin.pm b/centreon-plugins/database/firebird/plugin.pm index 213943690..623c88362 100644 --- a/centreon-plugins/database/firebird/plugin.pm +++ b/centreon-plugins/database/firebird/plugin.pm @@ -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/listdatabases.pm b/centreon-plugins/database/informix/mode/listdatabases.pm index 6ffe03d42..c2fc8710d 100644 --- a/centreon-plugins/database/informix/mode/listdatabases.pm +++ b/centreon-plugins/database/informix/mode/listdatabases.pm @@ -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 d20ecb216..696050482 100644 --- a/centreon-plugins/database/informix/mode/listdbspaces.pm +++ b/centreon-plugins/database/informix/mode/listdbspaces.pm @@ -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/plugin.pm b/centreon-plugins/database/informix/plugin.pm index a78c1f03b..6d7400e59 100644 --- a/centreon-plugins/database/informix/plugin.pm +++ b/centreon-plugins/database/informix/plugin.pm @@ -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/plugin.pm b/centreon-plugins/database/mssql/plugin.pm index f36250f06..b6716d359 100644 --- a/centreon-plugins/database/mssql/plugin.pm +++ b/centreon-plugins/database/mssql/plugin.pm @@ -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/plugin.pm b/centreon-plugins/database/mysql/plugin.pm index 916f9f133..642a59745 100644 --- a/centreon-plugins/database/mysql/plugin.pm +++ b/centreon-plugins/database/mysql/plugin.pm @@ -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/mode/listdatabases.pm b/centreon-plugins/database/postgres/mode/listdatabases.pm index 48d908aeb..90055fb7a 100644 --- a/centreon-plugins/database/postgres/mode/listdatabases.pm +++ b/centreon-plugins/database/postgres/mode/listdatabases.pm @@ -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/plugin.pm b/centreon-plugins/database/postgres/plugin.pm index c72fa27d5..e7cd4e852 100644 --- a/centreon-plugins/database/postgres/plugin.pm +++ b/centreon-plugins/database/postgres/plugin.pm @@ -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/mode/getvalue.pm b/centreon-plugins/example/mode/getvalue.pm index 8757fdb35..5f0781007 100644 --- a/centreon-plugins/example/mode/getvalue.pm +++ b/centreon-plugins/example/mode/getvalue.pm @@ -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/plugin_command.pm b/centreon-plugins/example/plugin_command.pm index 75470b367..ac305263b 100644 --- a/centreon-plugins/example/plugin_command.pm +++ b/centreon-plugins/example/plugin_command.pm @@ -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 47d862cb0..8bc5bc4ba 100644 --- a/centreon-plugins/example/plugin_custom.pm +++ b/centreon-plugins/example/plugin_custom.pm @@ -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 dee41721c..d7636039e 100644 --- a/centreon-plugins/example/plugin_snmp.pm +++ b/centreon-plugins/example/plugin_snmp.pm @@ -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 298e71f55..d483d7d01 100644 --- a/centreon-plugins/hardware/ats/apc/mode/entity.pm +++ b/centreon-plugins/hardware/ats/apc/mode/entity.pm @@ -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 72cafe03e..1db77790d 100644 --- a/centreon-plugins/hardware/ats/apc/mode/input.pm +++ b/centreon-plugins/hardware/ats/apc/mode/input.pm @@ -1,199 +1,198 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES 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 c6bf55936..e6806803f 100644 --- a/centreon-plugins/hardware/ats/apc/mode/psu.pm +++ b/centreon-plugins/hardware/ats/apc/mode/psu.pm @@ -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 63048f31b..a621e8132 100644 --- a/centreon-plugins/hardware/ats/apc/mode/source.pm +++ b/centreon-plugins/hardware/ats/apc/mode/source.pm @@ -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 515a3ff64..4666c964b 100644 --- a/centreon-plugins/hardware/ats/apc/plugin.pm +++ b/centreon-plugins/hardware/ats/apc/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm index f211d46ec..c35141274 100644 --- a/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm +++ b/centreon-plugins/hardware/pdu/apc/snmp/plugin.pm @@ -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/eaton/mode/group.pm b/centreon-plugins/hardware/pdu/eaton/mode/group.pm index fce3e5528..0f0585cb6 100644 --- a/centreon-plugins/hardware/pdu/eaton/mode/group.pm +++ b/centreon-plugins/hardware/pdu/eaton/mode/group.pm @@ -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 e1272927f..db037e05d 100644 --- a/centreon-plugins/hardware/pdu/eaton/mode/outlet.pm +++ b/centreon-plugins/hardware/pdu/eaton/mode/outlet.pm @@ -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 e8aeee083..992270903 100644 --- a/centreon-plugins/hardware/pdu/eaton/plugin.pm +++ b/centreon-plugins/hardware/pdu/eaton/plugin.pm @@ -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/raritan/snmp/plugin.pm b/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm index 1539faf23..a81bb6aca 100644 --- a/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm +++ b/centreon-plugins/hardware/pdu/raritan/snmp/plugin.pm @@ -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/printers/standard/rfc3805/mode/coverstatus.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm index 09e41ba0a..a74b78778 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/coverstatus.pm @@ -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 b7dfc75f0..9ed7b58ad 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markerimpression.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markerimpression.pm @@ -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 289e7101d..94662b888 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm @@ -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'; diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm index d53d4580b..63cb45730 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm @@ -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 2d7316b4b..56db8e2c8 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/plugin.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/plugin.pm @@ -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/sensorip/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm index 01da26f5f..a5a4a8f0a 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/mode/sensors.pm @@ -122,7 +122,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/hardware/sensors/sensorip/snmp/plugin.pm b/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm index 56d2338ec..f3c8c3d59 100644 --- a/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm +++ b/centreon-plugins/hardware/sensors/sensorip/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm index f3ac631a0..a10d5973f 100644 --- a/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm +++ b/centreon-plugins/hardware/sensors/sensormetrix/em01/web/plugin.pm @@ -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/sensors.pm b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm index 8090d056d..db98f25d6 100644 --- a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/mode/sensors.pm @@ -109,7 +109,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/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm index 79c559701..85d9a8ae8 100644 --- a/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm +++ b/centreon-plugins/hardware/sensors/serverscheck/sensorgateway/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/sensors/temperhum/local/plugin.pm index 9c23af6d0..720308fdb 100644 --- a/centreon-plugins/hardware/sensors/temperhum/local/plugin.pm +++ b/centreon-plugins/hardware/sensors/temperhum/local/plugin.pm @@ -27,7 +27,6 @@ use base qw(centreon::plugins::script_simple); 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}} = ( 'environment' => 'hardware::sensors::temperhum::local::mode::environment', diff --git a/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm index 0bb5553aa..e313f366a 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/auditlogs.pm @@ -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/faults.pm b/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm index 19e445fd9..1d0ca611e 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/faults.pm @@ -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 3621b286f..3774d1075 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/mode/serviceprofile.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/mode/serviceprofile.pm @@ -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 b9e1c8dc0..c13247b49 100644 --- a/centreon-plugins/hardware/server/cisco/ucs/plugin.pm +++ b/centreon-plugins/hardware/server/cisco/ucs/plugin.pm @@ -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/hardware.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm index 5a7569509..a5df1bf37 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/mode/hardware.pm @@ -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 } ]; diff --git a/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm b/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm index d4a27e773..38b6dfc03 100644 --- a/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/dell/cmc/snmp/plugin.pm @@ -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/globalstatus.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm index 8f533d660..0accf84a8 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/globalstatus.pm @@ -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/plugin.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm index 187f1b98d..7e9b52983 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/plugin.pm @@ -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/hardware.pm b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm index 764db5c06..28e1dcd2f 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/mode/hardware.pm @@ -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 69431071e..cc228cf32 100644 --- a/centreon-plugins/hardware/server/dell/openmanage/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/dell/openmanage/snmp/plugin.pm @@ -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/hardware.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm index 49fde1f80..b6508df7b 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/mode/hardware.pm @@ -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') { diff --git a/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm b/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm index 54404f6e3..76a5e92bb 100644 --- a/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/hp/bladechassis/snmp/plugin.pm @@ -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/globalstatus.pm b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm index cd75aaf34..7e7b0ca91 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/globalstatus.pm @@ -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 ffae6eaf4..b0eb8a6f2 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/mode/hardware.pm @@ -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 ce1264c83..73441b46d 100644 --- a/centreon-plugins/hardware/server/hp/proliant/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/hp/proliant/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm index b8a858d16..86748556e 100644 --- a/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm +++ b/centreon-plugins/hardware/server/ibm/bladecenter/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm index cbb38f588..5e097bb3a 100644 --- a/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm +++ b/centreon-plugins/hardware/server/ibm/hmc/ssh/plugin.pm @@ -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/environment.pm b/centreon-plugins/hardware/server/ibm/mgmt_cards/imm/snmp/mode/environment.pm index dfa5c2f1c..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 @@ -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 c4eca0396..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 @@ -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 f8c9be29d..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 @@ -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/plugin.pm b/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm index 290df3408..1e75cb330 100644 --- a/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm +++ b/centreon-plugins/hardware/server/sun/mgmt_cards/plugin.pm @@ -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 7e387adaa..afc3b87f0 100644 --- a/centreon-plugins/hardware/server/sun/mseries/mode/domains.pm +++ b/centreon-plugins/hardware/server/sun/mseries/mode/domains.pm @@ -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 cf8dfb388..4b747f801 100644 --- a/centreon-plugins/hardware/server/sun/mseries/mode/hardware.pm +++ b/centreon-plugins/hardware/server/sun/mseries/mode/hardware.pm @@ -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 ba0baa911..919d870b0 100644 --- a/centreon-plugins/hardware/server/sun/mseries/plugin.pm +++ b/centreon-plugins/hardware/server/sun/mseries/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm index 6529033bb..9d34441ea 100644 --- a/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm +++ b/centreon-plugins/hardware/server/sun/sfxxk/plugin.pm @@ -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/plugin.pm b/centreon-plugins/hardware/ups/apc/snmp/plugin.pm index a1a69652b..5ecaf6988 100644 --- a/centreon-plugins/hardware/ups/apc/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/apc/snmp/plugin.pm @@ -26,7 +26,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/mge/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm index 105b7ae32..f223c8f5e 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/batterystatus.pm @@ -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 50c3da145..4c157a606 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/environment.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/environment.pm @@ -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 dcf6cd0f1..15d6a39c2 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/inputlines.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/inputlines.pm @@ -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 6c7d41269..ae2f0a6ae 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/outputlines.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/outputlines.pm @@ -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 245829593..34cccd84e 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/mode/outputsource.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/mode/outputsource.pm @@ -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 faea24cb3..5c685a232 100644 --- a/centreon-plugins/hardware/ups/mge/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/mge/snmp/plugin.pm @@ -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 d3d5afca6..109611366 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/alarms.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/alarms.pm @@ -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 d8261c8ef..002d01185 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/batterystatus.pm @@ -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 30331b1dc..80c0c4714 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/environment.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/environment.pm @@ -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 fbb1b99f1..8fffa3153 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/inputlines.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/inputlines.pm @@ -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 72820204a..fddc1270a 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/outputlines.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/outputlines.pm @@ -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 cebbd2fb0..72d16040c 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/mode/outputsource.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/mode/outputsource.pm @@ -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 89027ba99..c17114159 100644 --- a/centreon-plugins/hardware/ups/powerware/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/powerware/snmp/plugin.pm @@ -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 b0cebe98e..b90721176 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/alarms.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/alarms.pm @@ -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 5ee5dc174..6cf0446e2 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm @@ -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/outputlines.pm b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm index a9e4c5ea8..dba10370c 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm @@ -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 41669e631..800f171e2 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputsource.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/mode/outputsource.pm @@ -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 113fca649..d7c5a53d1 100644 --- a/centreon-plugins/hardware/ups/standard/rfc1628/snmp/plugin.pm +++ b/centreon-plugins/hardware/ups/standard/rfc1628/snmp/plugin.pm @@ -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/alcatel/common/mode/cpu.pm b/centreon-plugins/network/alcatel/common/mode/cpu.pm index 2a55d0d45..11863cf23 100644 --- a/centreon-plugins/network/alcatel/common/mode/cpu.pm +++ b/centreon-plugins/network/alcatel/common/mode/cpu.pm @@ -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 4b880533c..da23ce927 100644 --- a/centreon-plugins/network/alcatel/common/mode/flashmemory.pm +++ b/centreon-plugins/network/alcatel/common/mode/flashmemory.pm @@ -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 bc39c6f88..7d5cfe461 100644 --- a/centreon-plugins/network/alcatel/common/mode/hardware.pm +++ b/centreon-plugins/network/alcatel/common/mode/hardware.pm @@ -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 9a931b45a..7b9c90966 100644 --- a/centreon-plugins/network/alcatel/common/mode/memory.pm +++ b/centreon-plugins/network/alcatel/common/mode/memory.pm @@ -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/omniswitch/6850/plugin.pm b/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm index c8189f4ac..1779f1ad3 100644 --- a/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm +++ b/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm @@ -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/arkoon/plugin.pm b/centreon-plugins/network/arkoon/plugin.pm index 88ca4f939..975992c18 100644 --- a/centreon-plugins/network/arkoon/plugin.pm +++ b/centreon-plugins/network/arkoon/plugin.pm @@ -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 02972f050..a52067a3f 100644 --- a/centreon-plugins/network/aruba/standard/snmp/plugin.pm +++ b/centreon-plugins/network/aruba/standard/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/network/atrica/snmp/plugin.pm index 45104bdd0..da1181895 100644 --- a/centreon-plugins/network/atrica/snmp/plugin.pm +++ b/centreon-plugins/network/atrica/snmp/plugin.pm @@ -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 8c25063c0..7ad28f9c4 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/clientconnections.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/clientconnections.pm @@ -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/clienttraffic.pm b/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm index 46eb4bf47..abc9d3f77 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/clienttraffic.pm @@ -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/cpu.pm b/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm index 89564cb74..6252f2d40 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/cpu.pm @@ -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 8c7fc67eb..f0d8aa4ef 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/disk.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/disk.pm @@ -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/memory.pm b/centreon-plugins/network/bluecoat/snmp/mode/memory.pm index d4724b2b1..735e8cedb 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/memory.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/memory.pm @@ -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 266b7b03b..f481729d7 100644 --- a/centreon-plugins/network/bluecoat/snmp/mode/serverconnections.pm +++ b/centreon-plugins/network/bluecoat/snmp/mode/serverconnections.pm @@ -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 c397621b2..df6376531 100644 --- a/centreon-plugins/network/bluecoat/snmp/plugin.pm +++ b/centreon-plugins/network/bluecoat/snmp/plugin.pm @@ -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 fa013426d..36dce2469 100644 --- a/centreon-plugins/network/brocade/mode/cpu.pm +++ b/centreon-plugins/network/brocade/mode/cpu.pm @@ -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 f80fe20ea..c16bf7225 100644 --- a/centreon-plugins/network/brocade/mode/hardware.pm +++ b/centreon-plugins/network/brocade/mode/hardware.pm @@ -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 e420d9fa0..85dace029 100644 --- a/centreon-plugins/network/brocade/mode/memory.pm +++ b/centreon-plugins/network/brocade/mode/memory.pm @@ -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 5e345875f..b51bc0930 100644 --- a/centreon-plugins/network/brocade/plugin.pm +++ b/centreon-plugins/network/brocade/plugin.pm @@ -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/connections.pm b/centreon-plugins/network/checkpoint/mode/connections.pm index dd283bb73..d51b20adc 100644 --- a/centreon-plugins/network/checkpoint/mode/connections.pm +++ b/centreon-plugins/network/checkpoint/mode/connections.pm @@ -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 8416e15a3..9e545cd9f 100644 --- a/centreon-plugins/network/checkpoint/mode/cpu.pm +++ b/centreon-plugins/network/checkpoint/mode/cpu.pm @@ -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/hastate.pm b/centreon-plugins/network/checkpoint/mode/hastate.pm index b5bdec42a..61fa3f2cd 100644 --- a/centreon-plugins/network/checkpoint/mode/hastate.pm +++ b/centreon-plugins/network/checkpoint/mode/hastate.pm @@ -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 817e34b4b..bd82b0baa 100644 --- a/centreon-plugins/network/checkpoint/mode/memory.pm +++ b/centreon-plugins/network/checkpoint/mode/memory.pm @@ -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 5360d0014..2bd1c1635 100644 --- a/centreon-plugins/network/checkpoint/plugin.pm +++ b/centreon-plugins/network/checkpoint/plugin.pm @@ -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 6e0c04a14..a09191205 100644 --- a/centreon-plugins/network/cisco/WaaS/mode/sessions.pm +++ b/centreon-plugins/network/cisco/WaaS/mode/sessions.pm @@ -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 6181be111..7d883d2cd 100644 --- a/centreon-plugins/network/cisco/WaaS/plugin.pm +++ b/centreon-plugins/network/cisco/WaaS/plugin.pm @@ -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 b9dd36012..48df71ae8 100644 --- a/centreon-plugins/network/cisco/asa/mode/failover.pm +++ b/centreon-plugins/network/cisco/asa/mode/failover.pm @@ -59,7 +59,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $active_units = 0; diff --git a/centreon-plugins/network/cisco/asa/plugin.pm b/centreon-plugins/network/cisco/asa/plugin.pm index 09eaa3ba9..cabf77f22 100644 --- a/centreon-plugins/network/cisco/asa/plugin.pm +++ b/centreon-plugins/network/cisco/asa/plugin.pm @@ -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/ironport/snmp/mode/memory.pm b/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm index b838fb1d7..096e08fbf 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/mode/memory.pm @@ -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 3b5e4eda2..1f653bb1e 100644 --- a/centreon-plugins/network/cisco/ironport/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/ironport/snmp/plugin.pm @@ -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 c2258ee1a..9288d0ba9 100644 --- a/centreon-plugins/network/cisco/smallbusiness/standard/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/smallbusiness/standard/snmp/plugin.pm @@ -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 45d1a067c..558abceaa 100644 --- a/centreon-plugins/network/cisco/standard/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/standard/snmp/plugin.pm @@ -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/wlc/snmp/plugin.pm b/centreon-plugins/network/cisco/wlc/snmp/plugin.pm index 13a7b43c6..aead226c1 100644 --- a/centreon-plugins/network/cisco/wlc/snmp/plugin.pm +++ b/centreon-plugins/network/cisco/wlc/snmp/plugin.pm @@ -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 30592ef0e..ffb1b1cdb 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/certificatesexpire.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/certificatesexpire.pm @@ -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/cpu.pm b/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm index 3921cbe88..f6673a0a7 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm @@ -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 b3fac2b74..0b657397c 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm @@ -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); diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/health.pm b/centreon-plugins/network/citrix/netscaler/common/mode/health.pm index 5123dcc74..6d51e54ee 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/health.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/health.pm @@ -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); diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm b/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm index 7790aa8ff..c4564542e 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/listvservers.pm @@ -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 5fe11ae7f..687acb285 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm @@ -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 d2d174fec..fd43d4a2a 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm @@ -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 ba459818e..aabc2f759 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/vserverstatus.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/vserverstatus.pm @@ -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 e305ce568..fd2402bc5 100644 --- a/centreon-plugins/network/citrix/netscaler/mpx8000/plugin.pm +++ b/centreon-plugins/network/citrix/netscaler/mpx8000/plugin.pm @@ -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 5dafd1f26..24c68880f 100644 --- a/centreon-plugins/network/dell/6200/plugin.pm +++ b/centreon-plugins/network/dell/6200/plugin.pm @@ -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 de182deeb..a79ba5326 100644 --- a/centreon-plugins/network/dell/n4000/plugin.pm +++ b/centreon-plugins/network/dell/n4000/plugin.pm @@ -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 5af2bd23c..7cd9b8104 100644 --- a/centreon-plugins/network/dell/sseries/snmp/plugin.pm +++ b/centreon-plugins/network/dell/sseries/snmp/plugin.pm @@ -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/portserverts/snmp/plugin.pm b/centreon-plugins/network/digi/portserverts/snmp/plugin.pm index c5a856304..bcf838eed 100644 --- a/centreon-plugins/network/digi/portserverts/snmp/plugin.pm +++ b/centreon-plugins/network/digi/portserverts/snmp/plugin.pm @@ -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/standard/snmp/mode/cpu.pm b/centreon-plugins/network/digi/standard/snmp/mode/cpu.pm index 777483ee7..e7dca8d64 100644 --- a/centreon-plugins/network/digi/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/network/digi/standard/snmp/mode/cpu.pm @@ -56,7 +56,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_cpuUtil = '.1.3.6.1.4.1.16378.10000.3.1.0'; diff --git a/centreon-plugins/network/digi/standard/snmp/mode/memory.pm b/centreon-plugins/network/digi/standard/snmp/mode/memory.pm index b72e8b78a..4c316a735 100644 --- a/centreon-plugins/network/digi/standard/snmp/mode/memory.pm +++ b/centreon-plugins/network/digi/standard/snmp/mode/memory.pm @@ -55,7 +55,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_totalMemory = '.1.3.6.1.4.1.16378.10000.3.17.0'; # in Kbytes diff --git a/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm b/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm index e5062d63f..1bd126621 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/mode/cpu.pm @@ -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/plugin.pm b/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm index d63e9acf2..c4cfc74f1 100644 --- a/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm +++ b/centreon-plugins/network/dlink/dgs3100/snmp/plugin.pm @@ -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/cpu.pm b/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm index 2da549008..be8b762a8 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/cpu.pm @@ -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/plugin.pm b/centreon-plugins/network/dlink/standard/snmp/plugin.pm index 8b9bb85c0..b7007441f 100644 --- a/centreon-plugins/network/dlink/standard/snmp/plugin.pm +++ b/centreon-plugins/network/dlink/standard/snmp/plugin.pm @@ -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/stack.pm b/centreon-plugins/network/extreme/snmp/mode/stack.pm index b9a211688..7600a0b50 100644 --- a/centreon-plugins/network/extreme/snmp/mode/stack.pm +++ b/centreon-plugins/network/extreme/snmp/mode/stack.pm @@ -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 498dfd1c6..098124dc6 100644 --- a/centreon-plugins/network/extreme/snmp/plugin.pm +++ b/centreon-plugins/network/extreme/snmp/plugin.pm @@ -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/listnodes.pm b/centreon-plugins/network/f5/bigip/mode/listnodes.pm index e8644fb17..df4dbb99b 100644 --- a/centreon-plugins/network/f5/bigip/mode/listnodes.pm +++ b/centreon-plugins/network/f5/bigip/mode/listnodes.pm @@ -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 f21064bee..17916b0f6 100644 --- a/centreon-plugins/network/f5/bigip/mode/listpools.pm +++ b/centreon-plugins/network/f5/bigip/mode/listpools.pm @@ -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 d6b69c5ba..9a28037de 100644 --- a/centreon-plugins/network/f5/bigip/mode/listvirtualservers.pm +++ b/centreon-plugins/network/f5/bigip/mode/listvirtualservers.pm @@ -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/plugin.pm b/centreon-plugins/network/f5/bigip/plugin.pm index fd4a370e5..4d322b8e1 100644 --- a/centreon-plugins/network/f5/bigip/plugin.pm +++ b/centreon-plugins/network/f5/bigip/plugin.pm @@ -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 61918f05b..1c41a6d17 100644 --- a/centreon-plugins/network/fortinet/fortigate/plugin.pm +++ b/centreon-plugins/network/fortinet/fortigate/plugin.pm @@ -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/fritzbox/plugin.pm b/centreon-plugins/network/fritzbox/plugin.pm index eaf2762de..4418b7c3a 100644 --- a/centreon-plugins/network/fritzbox/plugin.pm +++ b/centreon-plugins/network/fritzbox/plugin.pm @@ -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/cpu.pm b/centreon-plugins/network/h3c/snmp/mode/cpu.pm index ff5a2ee23..5a5038f08 100644 --- a/centreon-plugins/network/h3c/snmp/mode/cpu.pm +++ b/centreon-plugins/network/h3c/snmp/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/network/h3c/snmp/mode/memory.pm index 7279b6596..2003f3269 100644 --- a/centreon-plugins/network/h3c/snmp/mode/memory.pm +++ b/centreon-plugins/network/h3c/snmp/mode/memory.pm @@ -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 b50f55d4c..87b22ae32 100644 --- a/centreon-plugins/network/h3c/snmp/plugin.pm +++ b/centreon-plugins/network/h3c/snmp/plugin.pm @@ -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/cpu.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm index 09fdc0e49..40433e169 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm index a34f50d08..6a15e5f27 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/memory.pm @@ -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 1523e1192..87f996fff 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/mode/processcount.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/mode/processcount.pm @@ -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 73dc2148a..83fe5e7d0 100644 --- a/centreon-plugins/network/hirschmann/standard/snmp/plugin.pm +++ b/centreon-plugins/network/hirschmann/standard/snmp/plugin.pm @@ -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/cpu.pm b/centreon-plugins/network/hp/procurve/mode/cpu.pm index 9edc6ac86..2336a830f 100644 --- a/centreon-plugins/network/hp/procurve/mode/cpu.pm +++ b/centreon-plugins/network/hp/procurve/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/network/hp/procurve/mode/memory.pm index 9f1866cf0..a78d23fe3 100644 --- a/centreon-plugins/network/hp/procurve/mode/memory.pm +++ b/centreon-plugins/network/hp/procurve/mode/memory.pm @@ -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 6fadf6ce6..d79ca65d3 100644 --- a/centreon-plugins/network/hp/procurve/plugin.pm +++ b/centreon-plugins/network/hp/procurve/plugin.pm @@ -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/common/ive/mode/cpu.pm b/centreon-plugins/network/juniper/common/ive/mode/cpu.pm index 1bb94eec5..54a178d03 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/cpu.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/cpu.pm @@ -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 d0d06d28e..3f95bcfee 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/disk.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/disk.pm @@ -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 602adad7f..d8fdfcb4f 100644 --- a/centreon-plugins/network/juniper/common/ive/mode/logfile.pm +++ b/centreon-plugins/network/juniper/common/ive/mode/logfile.pm @@ -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/junos/mode/cpsessions.pm b/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm index e7e575090..7b4817ad2 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/cpsessions.pm @@ -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 2d5b621fd..eec24a5ec 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/cpuforwarding.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/cpuforwarding.pm @@ -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 1d3c2dd89..478fb4639 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm @@ -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 e292e6d72..4b8c0a53a 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/flowsessions.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/flowsessions.pm @@ -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/memoryforwarding.pm b/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm index df096bdcc..ca4eefdab 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/memoryforwarding.pm @@ -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 de2274407..ab3108295 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm @@ -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/cpu.pm b/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm index 06c5f3053..25739df6e 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/cpu.pm @@ -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/memory.pm b/centreon-plugins/network/juniper/common/screenos/mode/memory.pm index 2413cfc3a..63bdd7dab 100644 --- a/centreon-plugins/network/juniper/common/screenos/mode/memory.pm +++ b/centreon-plugins/network/juniper/common/screenos/mode/memory.pm @@ -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/ex/plugin.pm b/centreon-plugins/network/juniper/ex/plugin.pm index 717b68cea..a030f80ce 100644 --- a/centreon-plugins/network/juniper/ex/plugin.pm +++ b/centreon-plugins/network/juniper/ex/plugin.pm @@ -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 d6db069a2..1b0b828a7 100644 --- a/centreon-plugins/network/juniper/ggsn/mode/apnstats.pm +++ b/centreon-plugins/network/juniper/ggsn/mode/apnstats.pm @@ -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 5c5e93f6a..02ed2e78b 100644 --- a/centreon-plugins/network/juniper/ggsn/mode/globalstats.pm +++ b/centreon-plugins/network/juniper/ggsn/mode/globalstats.pm @@ -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 fdca6fb75..4ba145741 100644 --- a/centreon-plugins/network/juniper/ggsn/plugin.pm +++ b/centreon-plugins/network/juniper/ggsn/plugin.pm @@ -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/mag/mode/bladetemperature.pm b/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm index b4f017fb0..cc4c7486d 100644 --- a/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm +++ b/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm @@ -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 a1b5e0083..551a8470c 100644 --- a/centreon-plugins/network/juniper/mag/plugin.pm +++ b/centreon-plugins/network/juniper/mag/plugin.pm @@ -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 28411f177..5ea2f60d1 100644 --- a/centreon-plugins/network/juniper/mseries/plugin.pm +++ b/centreon-plugins/network/juniper/mseries/plugin.pm @@ -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 0d51783ae..61cd57493 100644 --- a/centreon-plugins/network/juniper/sa/plugin.pm +++ b/centreon-plugins/network/juniper/sa/plugin.pm @@ -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 81c3970c5..fb1e6e866 100644 --- a/centreon-plugins/network/juniper/srx/plugin.pm +++ b/centreon-plugins/network/juniper/srx/plugin.pm @@ -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 e25d6b7cf..78bfe3d54 100644 --- a/centreon-plugins/network/juniper/ssg/plugin.pm +++ b/centreon-plugins/network/juniper/ssg/plugin.pm @@ -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/plugin.pm b/centreon-plugins/network/juniper/trapeze/snmp/plugin.pm index 46ec7ada3..9461c65b2 100644 --- a/centreon-plugins/network/juniper/trapeze/snmp/plugin.pm +++ b/centreon-plugins/network/juniper/trapeze/snmp/plugin.pm @@ -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/netasq/snmp/mode/vpnstatus.pm b/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm index 99d98dd33..11b982699 100644 --- a/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm +++ b/centreon-plugins/network/netasq/snmp/mode/vpnstatus.pm @@ -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 8152bc355..fc0f06178 100644 --- a/centreon-plugins/network/netasq/snmp/plugin.pm +++ b/centreon-plugins/network/netasq/snmp/plugin.pm @@ -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/oneaccess/snmp/mode/cpu.pm b/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm index eeb3191a4..4b7b2aaa5 100644 --- a/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm +++ b/centreon-plugins/network/oneaccess/snmp/mode/cpu.pm @@ -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 52acb6369..905b2a511 100644 --- a/centreon-plugins/network/oneaccess/snmp/mode/memory.pm +++ b/centreon-plugins/network/oneaccess/snmp/mode/memory.pm @@ -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 76a4ad438..ff696c28e 100644 --- a/centreon-plugins/network/oneaccess/snmp/plugin.pm +++ b/centreon-plugins/network/oneaccess/snmp/plugin.pm @@ -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 f28e1c60b..9a98ca90f 100644 --- a/centreon-plugins/network/paloalto/snmp/mode/clusterstatus.pm +++ b/centreon-plugins/network/paloalto/snmp/mode/clusterstatus.pm @@ -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 ], diff --git a/centreon-plugins/network/paloalto/snmp/mode/panorama.pm b/centreon-plugins/network/paloalto/snmp/mode/panorama.pm index 989576489..25d9d879d 100644 --- a/centreon-plugins/network/paloalto/snmp/mode/panorama.pm +++ b/centreon-plugins/network/paloalto/snmp/mode/panorama.pm @@ -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'; diff --git a/centreon-plugins/network/paloalto/snmp/mode/sessions.pm b/centreon-plugins/network/paloalto/snmp/mode/sessions.pm index db7c4e23e..8895209f3 100644 --- a/centreon-plugins/network/paloalto/snmp/mode/sessions.pm +++ b/centreon-plugins/network/paloalto/snmp/mode/sessions.pm @@ -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 86a8ba02a..0958ea926 100644 --- a/centreon-plugins/network/paloalto/snmp/plugin.pm +++ b/centreon-plugins/network/paloalto/snmp/plugin.pm @@ -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 7b49ccf85..fca2dcb49 100644 --- a/centreon-plugins/network/radware/alteon/5224/plugin.pm +++ b/centreon-plugins/network/radware/alteon/5224/plugin.pm @@ -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 8e7a565cb..03ea40c6a 100644 --- a/centreon-plugins/network/radware/alteon/common/mode/cpu.pm +++ b/centreon-plugins/network/radware/alteon/common/mode/cpu.pm @@ -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 3312cb132..90af5a195 100644 --- a/centreon-plugins/network/radware/alteon/common/mode/hardware.pm +++ b/centreon-plugins/network/radware/alteon/common/mode/hardware.pm @@ -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 08cf5f135..b72539938 100644 --- a/centreon-plugins/network/radware/alteon/common/mode/memory.pm +++ b/centreon-plugins/network/radware/alteon/common/mode/memory.pm @@ -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/cpu.pm b/centreon-plugins/network/redback/snmp/mode/cpu.pm index c80a19015..44d54398a 100644 --- a/centreon-plugins/network/redback/snmp/mode/cpu.pm +++ b/centreon-plugins/network/redback/snmp/mode/cpu.pm @@ -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/plugin.pm b/centreon-plugins/network/redback/snmp/plugin.pm index 897850d1a..992cf3cd8 100644 --- a/centreon-plugins/network/redback/snmp/plugin.pm +++ b/centreon-plugins/network/redback/snmp/plugin.pm @@ -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 32ccea1b8..6cf0446c9 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwoptimization.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwoptimization.pm @@ -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 5277c5360..ae377d703 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwpassthrough.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/bwpassthrough.pm @@ -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 4486dd2e0..58c4cbac4 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/connections.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/connections.pm @@ -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 17b669090..85cfb0aa3 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/diskutilization.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/diskutilization.pm @@ -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 8a918c074..362029168 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/health.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/health.pm @@ -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 042fe88fc..ecaeadc3c 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/loadaverage.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/loadaverage.pm @@ -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 6bf5e80c0..06b5a318d 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/servicestatus.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/servicestatus.pm @@ -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 e4ee22d8d..d73a24fa7 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/serviceuptime.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/serviceuptime.pm @@ -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 d1c457449..e85c9f8dc 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/mode/temperature.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/mode/temperature.pm @@ -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 c128c63cc..a97a9e48c 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm @@ -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 fb7ab3b56..8bb31d480 100644 --- a/centreon-plugins/network/ruggedcom/mode/errors.pm +++ b/centreon-plugins/network/ruggedcom/mode/errors.pm @@ -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 b7267ad9f..39bc82518 100644 --- a/centreon-plugins/network/ruggedcom/mode/hardware.pm +++ b/centreon-plugins/network/ruggedcom/mode/hardware.pm @@ -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 4c9498fc5..981549525 100644 --- a/centreon-plugins/network/ruggedcom/mode/memory.pm +++ b/centreon-plugins/network/ruggedcom/mode/memory.pm @@ -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 d526bfc62..b87f822ec 100644 --- a/centreon-plugins/network/ruggedcom/mode/temperature.pm +++ b/centreon-plugins/network/ruggedcom/mode/temperature.pm @@ -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 9ec45e9d8..86d953df6 100644 --- a/centreon-plugins/network/ruggedcom/plugin.pm +++ b/centreon-plugins/network/ruggedcom/plugin.pm @@ -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 895c0e386..b9e75eaae 100644 --- a/centreon-plugins/network/securactive/mode/bca.pm +++ b/centreon-plugins/network/securactive/mode/bca.pm @@ -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 2f48b46cb..2ae1179a4 100644 --- a/centreon-plugins/network/securactive/mode/bcn.pm +++ b/centreon-plugins/network/securactive/mode/bcn.pm @@ -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 4d2bc7d0b..ac9c1c724 100644 --- a/centreon-plugins/network/securactive/mode/listbca.pm +++ b/centreon-plugins/network/securactive/mode/listbca.pm @@ -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 61a374929..ab9bc50d6 100644 --- a/centreon-plugins/network/securactive/mode/listbcn.pm +++ b/centreon-plugins/network/securactive/mode/listbcn.pm @@ -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 cb74dce6a..5fc5ff8f5 100644 --- a/centreon-plugins/network/securactive/plugin.pm +++ b/centreon-plugins/network/securactive/plugin.pm @@ -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 index c0cc3d9cf..1eff70cc3 100644 --- a/centreon-plugins/network/sonus/sbc/plugin.pm +++ b/centreon-plugins/network/sonus/sbc/plugin.pm @@ -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/stonesoft/snmp/mode/clusterload.pm b/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm index d02028aa9..ece6d59e8 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/clusterload.pm @@ -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 4c59829e2..2a3e1c737 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/clusterstate.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/clusterstate.pm @@ -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 38eb0df01..a9ddad144 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/connections.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/connections.pm @@ -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 52d6b50cd..f54223e41 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/cpu.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/cpu.pm @@ -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 618b169f4..2097cc432 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/droppedpackets.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/droppedpackets.pm @@ -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 d4ed35afc..383868e45 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/memory.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/memory.pm @@ -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 b6fa26e9c..b3e40a24c 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/rejectedpackets.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/rejectedpackets.pm @@ -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 0c25bec82..7c69f6ecb 100644 --- a/centreon-plugins/network/stonesoft/snmp/mode/storage.pm +++ b/centreon-plugins/network/stonesoft/snmp/mode/storage.pm @@ -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 ffc2821c0..f59ecd0e7 100644 --- a/centreon-plugins/network/stonesoft/snmp/plugin.pm +++ b/centreon-plugins/network/stonesoft/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/network/ucopia/wlc/snmp/plugin.pm index daab7ca41..ad4cb5a38 100644 --- a/centreon-plugins/network/ucopia/wlc/snmp/plugin.pm +++ b/centreon-plugins/network/ucopia/wlc/snmp/plugin.pm @@ -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/os/aix/local/plugin.pm b/centreon-plugins/os/aix/local/plugin.pm index adf8ddf5a..696b7963f 100644 --- a/centreon-plugins/os/aix/local/plugin.pm +++ b/centreon-plugins/os/aix/local/plugin.pm @@ -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 62fafdc63..df11c1eaf 100644 --- a/centreon-plugins/os/aix/snmp/mode/swap.pm +++ b/centreon-plugins/os/aix/snmp/mode/swap.pm @@ -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 c420672ab..fd4095883 100644 --- a/centreon-plugins/os/aix/snmp/plugin.pm +++ b/centreon-plugins/os/aix/snmp/plugin.pm @@ -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 index 698e5f7be..06c503ad0 100644 --- a/centreon-plugins/os/freebsd/snmp/mode/memory.pm +++ b/centreon-plugins/os/freebsd/snmp/mode/memory.pm @@ -77,7 +77,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; # with bsnmpd-ucd 0.4.1 diff --git a/centreon-plugins/os/freebsd/snmp/plugin.pm b/centreon-plugins/os/freebsd/snmp/plugin.pm index 136c4a9ec..bc5fe1e80 100644 --- a/centreon-plugins/os/freebsd/snmp/plugin.pm +++ b/centreon-plugins/os/freebsd/snmp/plugin.pm @@ -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/local/mode/connections.pm b/centreon-plugins/os/linux/local/mode/connections.pm index ae28a3783..0722fe9f1 100644 --- a/centreon-plugins/os/linux/local/mode/connections.pm +++ b/centreon-plugins/os/linux/local/mode/connections.pm @@ -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/plugin.pm b/centreon-plugins/os/linux/local/plugin.pm index e1d9b849d..879ea0e84 100644 --- a/centreon-plugins/os/linux/local/plugin.pm +++ b/centreon-plugins/os/linux/local/plugin.pm @@ -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 dc4e05b39..701775fdb 100644 --- a/centreon-plugins/os/linux/snmp/plugin.pm +++ b/centreon-plugins/os/linux/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/os/solaris/local/plugin.pm index 3535e3f15..f0c12238d 100644 --- a/centreon-plugins/os/solaris/local/plugin.pm +++ b/centreon-plugins/os/solaris/local/plugin.pm @@ -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 b9d4bc45b..1be0f2586 100644 --- a/centreon-plugins/os/solaris/snmp/plugin.pm +++ b/centreon-plugins/os/solaris/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/os/windows/local/plugin.pm index 452e7b994..58736a3e7 100644 --- a/centreon-plugins/os/windows/local/plugin.pm +++ b/centreon-plugins/os/windows/local/plugin.pm @@ -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 815e570d9..5f6fad4a5 100644 --- a/centreon-plugins/os/windows/snmp/mode/memory.pm +++ b/centreon-plugins/os/windows/snmp/mode/memory.pm @@ -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 610908371..fbe477231 100644 --- a/centreon-plugins/os/windows/snmp/mode/service.pm +++ b/centreon-plugins/os/windows/snmp/mode/service.pm @@ -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 8cb773c77..7b2ddb74f 100644 --- a/centreon-plugins/os/windows/snmp/mode/swap.pm +++ b/centreon-plugins/os/windows/snmp/mode/swap.pm @@ -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 0275918cd..dbed7c263 100644 --- a/centreon-plugins/os/windows/snmp/plugin.pm +++ b/centreon-plugins/os/windows/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/os/windows/wsman/plugin.pm index 92a2324c4..d7cd1827d 100644 --- a/centreon-plugins/os/windows/wsman/plugin.pm +++ b/centreon-plugins/os/windows/wsman/plugin.pm @@ -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 f07047098..3ac2e0d04 100644 --- a/centreon-plugins/snmp_standard/mode/cpu.pm +++ b/centreon-plugins/snmp_standard/mode/cpu.pm @@ -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 7ef1eeda7..39c3cdcb0 100644 --- a/centreon-plugins/snmp_standard/mode/cpudetailed.pm +++ b/centreon-plugins/snmp_standard/mode/cpudetailed.pm @@ -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/diskusage.pm b/centreon-plugins/snmp_standard/mode/diskusage.pm index 943a9ca62..c4aec55c8 100644 --- a/centreon-plugins/snmp_standard/mode/diskusage.pm +++ b/centreon-plugins/snmp_standard/mode/diskusage.pm @@ -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 da5297202..cb5ffd34b 100644 --- a/centreon-plugins/snmp_standard/mode/dynamiccommand.pm +++ b/centreon-plugins/snmp_standard/mode/dynamiccommand.pm @@ -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 8b38cb61e..9ff8d4fa9 100644 --- a/centreon-plugins/snmp_standard/mode/hardwaredevice.pm +++ b/centreon-plugins/snmp_standard/mode/hardwaredevice.pm @@ -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 fdfbfb7e1..305cada4d 100644 --- a/centreon-plugins/snmp_standard/mode/hardwarefibrealliance.pm +++ b/centreon-plugins/snmp_standard/mode/hardwarefibrealliance.pm @@ -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 => [ diff --git a/centreon-plugins/snmp_standard/mode/listdiskspath.pm b/centreon-plugins/snmp_standard/mode/listdiskspath.pm index 80182fc02..464b2a708 100644 --- a/centreon-plugins/snmp_standard/mode/listdiskspath.pm +++ b/centreon-plugins/snmp_standard/mode/listdiskspath.pm @@ -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/liststorages.pm b/centreon-plugins/snmp_standard/mode/liststorages.pm index 62f3f5b0e..281ff3a33 100644 --- a/centreon-plugins/snmp_standard/mode/liststorages.pm +++ b/centreon-plugins/snmp_standard/mode/liststorages.pm @@ -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 d4cc8a0ae..5c04a2d0f 100644 --- a/centreon-plugins/snmp_standard/mode/loadaverage.pm +++ b/centreon-plugins/snmp_standard/mode/loadaverage.pm @@ -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 ea88d86ce..b4638ff17 100644 --- a/centreon-plugins/snmp_standard/mode/memory.pm +++ b/centreon-plugins/snmp_standard/mode/memory.pm @@ -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 441592568..9a7c606a4 100644 --- a/centreon-plugins/snmp_standard/mode/ntp.pm +++ b/centreon-plugins/snmp_standard/mode/ntp.pm @@ -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 d7f37984c..dc9264571 100644 --- a/centreon-plugins/snmp_standard/mode/numericvalue.pm +++ b/centreon-plugins/snmp_standard/mode/numericvalue.pm @@ -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 7432ac6c5..6b427f75c 100644 --- a/centreon-plugins/snmp_standard/mode/printererror.pm +++ b/centreon-plugins/snmp_standard/mode/printererror.pm @@ -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 774a7ac0b..f531cc265 100644 --- a/centreon-plugins/snmp_standard/mode/processcount.pm +++ b/centreon-plugins/snmp_standard/mode/processcount.pm @@ -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 abb5b2652..1d603577a 100644 --- a/centreon-plugins/snmp_standard/mode/spanningtree.pm +++ b/centreon-plugins/snmp_standard/mode/spanningtree.pm @@ -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 b469b442e..3d5a6a0b5 100644 --- a/centreon-plugins/snmp_standard/mode/storage.pm +++ b/centreon-plugins/snmp_standard/mode/storage.pm @@ -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/swap.pm b/centreon-plugins/snmp_standard/mode/swap.pm index 2935dc161..b022541c8 100644 --- a/centreon-plugins/snmp_standard/mode/swap.pm +++ b/centreon-plugins/snmp_standard/mode/swap.pm @@ -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 5b38eff1b..55e8e87a0 100644 --- a/centreon-plugins/snmp_standard/mode/tcpcon.pm +++ b/centreon-plugins/snmp_standard/mode/tcpcon.pm @@ -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/plugin.pm b/centreon-plugins/snmp_standard/plugin.pm index 0a9e92569..d0bf3ea14 100644 --- a/centreon-plugins/snmp_standard/plugin.pm +++ b/centreon-plugins/snmp_standard/plugin.pm @@ -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 c50f5318a..8018d43b2 100644 --- a/centreon-plugins/storage/dell/MD3000/cli/plugin.pm +++ b/centreon-plugins/storage/dell/MD3000/cli/plugin.pm @@ -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 5c055f623..499da55ca 100644 --- a/centreon-plugins/storage/dell/TL2000/mode/globalstatus.pm +++ b/centreon-plugins/storage/dell/TL2000/mode/globalstatus.pm @@ -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'; diff --git a/centreon-plugins/storage/dell/TL2000/plugin.pm b/centreon-plugins/storage/dell/TL2000/plugin.pm index 1549d1290..e44d292bb 100644 --- a/centreon-plugins/storage/dell/TL2000/plugin.pm +++ b/centreon-plugins/storage/dell/TL2000/plugin.pm @@ -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/equallogic/snmp/mode/arraystats.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm index 329b5fa25..e331abb00 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/arraystats.pm @@ -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/diskusage.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm index 27206f5ae..36e4e33c8 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/diskusage.pm @@ -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 25ae74f97..30cc22e06 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/hardware.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/hardware.pm @@ -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 } ]; diff --git a/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm b/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm index 1d1d3f278..aa870964c 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/mode/poolusage.pm @@ -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 54764b8e1..7ea205d59 100644 --- a/centreon-plugins/storage/dell/equallogic/snmp/plugin.pm +++ b/centreon-plugins/storage/dell/equallogic/snmp/plugin.pm @@ -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 index 0803e660e..6dd742036 100644 --- a/centreon-plugins/storage/dell/ml6000/snmp/plugin.pm +++ b/centreon-plugins/storage/dell/ml6000/snmp/plugin.pm @@ -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/DataDomain/mode/filesystem.pm b/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm index 44d427aa8..10f207e40 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm @@ -180,7 +180,6 @@ 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->{fs}}) { diff --git a/centreon-plugins/storage/emc/DataDomain/plugin.pm b/centreon-plugins/storage/emc/DataDomain/plugin.pm index 0c185ecaa..bf7e91f9a 100644 --- a/centreon-plugins/storage/emc/DataDomain/plugin.pm +++ b/centreon-plugins/storage/emc/DataDomain/plugin.pm @@ -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/celerra/local/plugin.pm b/centreon-plugins/storage/emc/celerra/local/plugin.pm index 2cf5bbe73..882c1a4d2 100644 --- a/centreon-plugins/storage/emc/celerra/local/plugin.pm +++ b/centreon-plugins/storage/emc/celerra/local/plugin.pm @@ -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/plugin.pm b/centreon-plugins/storage/emc/clariion/plugin.pm index 061146d5d..29b24abb1 100644 --- a/centreon-plugins/storage/emc/clariion/plugin.pm +++ b/centreon-plugins/storage/emc/clariion/plugin.pm @@ -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/plugin.pm b/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm index 8ebeb8501..9d7d93854 100644 --- a/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm +++ b/centreon-plugins/storage/emc/recoverypoint/ssh/plugin.pm @@ -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/vplex/restapi/plugin.pm b/centreon-plugins/storage/emc/vplex/restapi/plugin.pm index ea589aab6..54a9da54e 100644 --- a/centreon-plugins/storage/emc/vplex/restapi/plugin.pm +++ b/centreon-plugins/storage/emc/vplex/restapi/plugin.pm @@ -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/plugin.pm b/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm index e3a829b1f..fd35ce71f 100644 --- a/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm +++ b/centreon-plugins/storage/emc/xtremio/restapi/plugin.pm @@ -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/plugin.pm b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm index 45eeaaab1..f23159562 100644 --- a/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm +++ b/centreon-plugins/storage/fujitsu/eternus/dx/ssh/plugin.pm @@ -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/3par/7000/plugin.pm b/centreon-plugins/storage/hp/3par/7000/plugin.pm index 57f877647..c11a33aff 100644 --- a/centreon-plugins/storage/hp/3par/7000/plugin.pm +++ b/centreon-plugins/storage/hp/3par/7000/plugin.pm @@ -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/hardware.pm b/centreon-plugins/storage/hp/lefthand/mode/hardware.pm index 437ede8d3..691d4e219 100644 --- a/centreon-plugins/storage/hp/lefthand/mode/hardware.pm +++ b/centreon-plugins/storage/hp/lefthand/mode/hardware.pm @@ -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 6281dfe1e..1c19dc751 100644 --- a/centreon-plugins/storage/hp/lefthand/plugin.pm +++ b/centreon-plugins/storage/hp/lefthand/plugin.pm @@ -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 1df84e6dd..3df6de7b0 100644 --- a/centreon-plugins/storage/hp/msa2000/snmp/plugin.pm +++ b/centreon-plugins/storage/hp/msa2000/snmp/plugin.pm @@ -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 d1a15ca6b..586fee416 100644 --- a/centreon-plugins/storage/hp/msl/snmp/mode/status.pm +++ b/centreon-plugins/storage/hp/msl/snmp/mode/status.pm @@ -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 38cb5c45c..9f54755cd 100644 --- a/centreon-plugins/storage/hp/msl/snmp/plugin.pm +++ b/centreon-plugins/storage/hp/msl/snmp/plugin.pm @@ -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/plugin.pm b/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm index df83a3c0c..371fb14ed 100644 --- a/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm +++ b/centreon-plugins/storage/hp/p2000/xmlapi/plugin.pm @@ -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/DS3000/cli/plugin.pm b/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm index 8d956d994..55ae39f9f 100644 --- a/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm +++ b/centreon-plugins/storage/ibm/DS3000/cli/plugin.pm @@ -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 106e3fe21..40de84be7 100644 --- a/centreon-plugins/storage/ibm/DS4000/cli/plugin.pm +++ b/centreon-plugins/storage/ibm/DS4000/cli/plugin.pm @@ -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 c446e47a4..72b3e8d64 100644 --- a/centreon-plugins/storage/ibm/DS5000/cli/plugin.pm +++ b/centreon-plugins/storage/ibm/DS5000/cli/plugin.pm @@ -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 12eba93ad..a4601826a 100644 --- a/centreon-plugins/storage/ibm/TS3100/mode/globalstatus.pm +++ b/centreon-plugins/storage/ibm/TS3100/mode/globalstatus.pm @@ -86,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 ac764f694..f9970a392 100644 --- a/centreon-plugins/storage/ibm/TS3100/plugin.pm +++ b/centreon-plugins/storage/ibm/TS3100/plugin.pm @@ -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 1f4a13020..a9fec788e 100644 --- a/centreon-plugins/storage/ibm/TS3200/mode/globalstatus.pm +++ b/centreon-plugins/storage/ibm/TS3200/mode/globalstatus.pm @@ -86,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 5827e7e5d..583b91e15 100644 --- a/centreon-plugins/storage/ibm/TS3200/plugin.pm +++ b/centreon-plugins/storage/ibm/TS3200/plugin.pm @@ -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/netapp/snmp/mode/aggregatestate.pm b/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm index b6a934a14..87960e0c7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/aggregatestate.pm @@ -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/storage/netapp/snmp/mode/cpstatistics.pm b/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm index 36ff93368..c9b4bb8b7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/cpstatistics.pm @@ -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 c8dfe96ad..bddabaefc 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/cpuload.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/cpuload.pm @@ -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 cc2123ec3..bccb1e4dd 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/diskfailed.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/diskfailed.pm @@ -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 cd32ff61c..deea0a679 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/fan.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/fan.pm @@ -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/globalstatus.pm b/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm index 4c692ce40..bb369f53b 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/globalstatus.pm @@ -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 ce146af37..6fce3a9e7 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/listfilesys.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/listfilesys.pm @@ -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 f744f5fd6..5ca68caab 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/ndmpsessions.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/ndmpsessions.pm @@ -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 56f8395a2..757daf3bb 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/nvram.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/nvram.pm @@ -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 aa01dca13..9427f45c2 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/partnerstatus.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/partnerstatus.pm @@ -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 eeba442d4..b035e1f6c 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/psu.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/psu.pm @@ -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 35f6a2f1b..d49e59076 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/qtreeusage.pm @@ -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 de4a71180..0e681e136 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/sharecalls.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/sharecalls.pm @@ -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/snapmirrorlag.pm b/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm index 12d4aa8fb..d29b11def 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/snapmirrorlag.pm @@ -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 e12772744..137fb7eae 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/snapshotage.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/snapshotage.pm @@ -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 fcd95f6b4..1acc82132 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/temperature.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/temperature.pm @@ -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 a32e873ef..d454992d2 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/volumeoptions.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/volumeoptions.pm @@ -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 c1703ea81..e4a6eae99 100644 --- a/centreon-plugins/storage/netapp/snmp/plugin.pm +++ b/centreon-plugins/storage/netapp/snmp/plugin.pm @@ -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/panzura/snmp/mode/cpucloud.pm b/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm index dbe1c3ecb..f5439250d 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/cpucloud.pm @@ -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 991e332e0..74c6bba44 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/diskusagelocal.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/diskusagelocal.pm @@ -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 8a2743ca8..87f15ce1d 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/memory.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/memory.pm @@ -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 972212c27..8449aca69 100644 --- a/centreon-plugins/storage/panzura/snmp/mode/ratios.pm +++ b/centreon-plugins/storage/panzura/snmp/mode/ratios.pm @@ -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 787bbecad..f365ebc96 100644 --- a/centreon-plugins/storage/panzura/snmp/plugin.pm +++ b/centreon-plugins/storage/panzura/snmp/plugin.pm @@ -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/hardware.pm b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm index 9aa58aed3..2e68bbf4f 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm @@ -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 0d64ad67d..dd2755885 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/memory.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/memory.pm @@ -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 7aaa895a7..d1412bfd2 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm @@ -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 5d8fab070..9726110ab 100644 --- a/centreon-plugins/storage/qnap/snmp/plugin.pm +++ b/centreon-plugins/storage/qnap/snmp/plugin.pm @@ -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/synology/snmp/mode/components.pm b/centreon-plugins/storage/synology/snmp/mode/components.pm index 8c4d2e6c8..0d3e6ddd1 100644 --- a/centreon-plugins/storage/synology/snmp/mode/components.pm +++ b/centreon-plugins/storage/synology/snmp/mode/components.pm @@ -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 c50e15679..3eed30c09 100644 --- a/centreon-plugins/storage/synology/snmp/mode/temperature.pm +++ b/centreon-plugins/storage/synology/snmp/mode/temperature.pm @@ -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 6972339dc..7dbb0b21b 100644 --- a/centreon-plugins/storage/synology/snmp/mode/ups.pm +++ b/centreon-plugins/storage/synology/snmp/mode/ups.pm @@ -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 c8a9aea1d..0353fd243 100644 --- a/centreon-plugins/storage/synology/snmp/plugin.pm +++ b/centreon-plugins/storage/synology/snmp/plugin.pm @@ -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 656cd7a59..810fe61e6 100644 --- a/centreon-plugins/storage/violin/3000/snmp/plugin.pm +++ b/centreon-plugins/storage/violin/3000/snmp/plugin.pm @@ -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}} = ( From bd25d9f34b441f304b522fb12216c30fbd77791a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 14:12:40 +0200 Subject: [PATCH 008/103] + Fix indent --- centreon-plugins/hardware/ats/apc/mode/input.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/hardware/ats/apc/mode/input.pm b/centreon-plugins/hardware/ats/apc/mode/input.pm index 1db77790d..45b6d9f64 100644 --- a/centreon-plugins/hardware/ats/apc/mode/input.pm +++ b/centreon-plugins/hardware/ats/apc/mode/input.pm @@ -102,7 +102,7 @@ sub build_values { #if ($options{current} =~ /^$oid_inputs\.(.*)/) { if ($options{current} =~ /^$oid\.(.*)/) { $instance = $1; - #$instance =~ s/1\.1\.3\.//g; + #$instance =~ s/1\.1\.3\.//g; last; } } @@ -115,7 +115,7 @@ sub build_values { $self->{instances_done}->{$instance} = 1; $self->{counters_value}->{$instance} = {}; foreach my $oid (keys %oids) { - my $full_oid = $oid . '.' . $instance; + my $full_oid = $oid . '.' . $instance; $self->{counters_value}->{$instance}->{$oids{$oid}->{counter}} = defined($options{result}->{$oid . '.' . $instance}) ? $options{result}->{$oid . '.' . $instance} : 0; } } From b48c94f29f8974daf89a922e5446ac842aaa5f3b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 15:23:35 +0200 Subject: [PATCH 009/103] + add telnet plugin --- .../apps/protocols/telnet/mode/scenario.pm | 180 ++++++++++++++++++ .../apps/protocols/telnet/plugin.pm | 47 +++++ 2 files changed, 227 insertions(+) create mode 100644 centreon-plugins/apps/protocols/telnet/mode/scenario.pm create mode 100644 centreon-plugins/apps/protocols/telnet/plugin.pm 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..b3cd7f201 --- /dev/null +++ b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm @@ -0,0 +1,180 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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' }, + }); + + 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 = 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>; + }; + + 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 $session = new Net::Telnet(); + $session->errmode('return'); + + my $timing0 = [gettimeofday]; + 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 + +=item B<--timeout> + +Set global execution timeout (Default: 50) + +=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 From 745df38cd624e87a5a0df6c645f42d55efb2a617 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 15:49:30 +0200 Subject: [PATCH 010/103] + Add option for scenario telnet --- .../apps/protocols/telnet/mode/scenario.pm | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/apps/protocols/telnet/mode/scenario.pm b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm index b3cd7f201..09e34a43a 100644 --- a/centreon-plugins/apps/protocols/telnet/mode/scenario.pm +++ b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm @@ -39,6 +39,8 @@ sub new { "scenario:s" => { name => 'scenario' }, "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => 23 }, }); return $self; @@ -94,10 +96,18 @@ sub read_scenario { sub execute_scenario { my ($self, %options) = @_; + my $timing0 = [gettimeofday]; my $session = new Net::Telnet(); $session->errmode('return'); - my $timing0 = [gettimeofday]; + 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}}) { @@ -161,12 +171,22 @@ Check telnet scenario execution =item B<--scenario> -Scenario used +Scenario used (Required) =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) From 5b6f781700950a2802cd16e807ba75c998d4ac6d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 16:10:39 +0200 Subject: [PATCH 011/103] + enhance telnet options --- .../apps/protocols/telnet/mode/scenario.pm | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/centreon-plugins/apps/protocols/telnet/mode/scenario.pm b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm index 09e34a43a..257ae9339 100644 --- a/centreon-plugins/apps/protocols/telnet/mode/scenario.pm +++ b/centreon-plugins/apps/protocols/telnet/mode/scenario.pm @@ -75,14 +75,19 @@ sub check_options { sub read_scenario { my ($self, %options) = @_; - my $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>; - }; + 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); @@ -171,7 +176,8 @@ Check telnet scenario execution =item B<--scenario> -Scenario used (Required) +Scenario used (Required). +Can be a file or json content. =item B<--timeout> From 028664a478bf6eba44a06a953018a91687228ad7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 22:16:52 +0200 Subject: [PATCH 012/103] + enhance clariion mode --- .../common/emc/navisphere/mode/cache.pm | 1 - .../common/emc/navisphere/mode/disk.pm | 2 +- .../centreon/common/emc/navisphere/mode/sp.pm | 183 +++--------------- .../navisphere/mode/spcomponents/battery.pm | 21 +- .../emc/navisphere/mode/spcomponents/cable.pm | 21 +- .../emc/navisphere/mode/spcomponents/cpu.pm | 20 +- .../emc/navisphere/mode/spcomponents/fan.pm | 20 +- .../navisphere/mode/spcomponents/iomodule.pm | 20 +- .../emc/navisphere/mode/spcomponents/lcc.pm | 20 +- .../navisphere/mode/spcomponents/memory.pm | 20 +- .../emc/navisphere/mode/spcomponents/psu.pm | 20 +- .../emc/navisphere/mode/spcomponents/sp.pm | 20 +- 12 files changed, 97 insertions(+), 271 deletions(-) diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm index d926609c3..e1c39a72b 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/cache.pm @@ -47,7 +47,6 @@ my %states = ( ], ); - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm index 676b9f4bd..a5bf080e5 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm @@ -147,7 +147,7 @@ sub set_counters { 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' }, + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm index 778d4aaff..06eef859d 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm @@ -18,173 +18,38 @@ # limitations under the License. # -package centreon::common::emc::navisphere::mode::sp; - -use base qw(centreon::plugins::mode); +package centreon::common::emc::navisphere::mode::spcomponents::sp; 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 new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - 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' }, - }); +sub load { }; - $self->{components} = {}; - $self->{no_components} = undef; - - return $self; -} +sub check { + my ($self) = @_; -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->{output}->output_add(long_msg => "Checking sp"); + $self->{components}->{sp} = {name => 'sp', total => 0, skip => 0}; + return if ($self->check_filter(section => 'sp')); - 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'; + # SP A State: Present + while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { + my $instance = $1; + my $state = $2; + + 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) + ); + 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)); } } } -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__ - -=head1 MODE - -Check status of storage processor. - -=over 8 - -=item B<--getcrus-options> - -Set option for 'getcrus' command (Default: '-all'). -'-all' option is for some new flare version. - -=item B<--component> - -Which component to check (Default: 'all'). -Can be: 'cpu', 'psu', 'pc', 'fan', 'network', 'temperature', 'storage', 'battery'. - -=item B<--exclude> - -Exclude some parts (comma seperated list) (Example: --exclude=fan,lcc) -Can also exclude specific instance: --exclude=fan#1.2#,lcc - -=item B<--no-component> - -Return an error if no compenents are checked. -If total (with skipped) is 0. (Default: 'critical' returns). - -=back - -=cut \ No newline at end of file +1; \ No newline at end of file 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 aade7195f..5bb257dd4 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/battery.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/battery.pm @@ -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 e67ffebac..73a475465 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cable.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cable.pm @@ -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 52083daf2..4874e3b7f 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm @@ -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 5070bdcee..ea2598480 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/fan.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/fan.pm @@ -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 2590978bb..4a68e5e96 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm @@ -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 1d114955c..71cc1b105 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm @@ -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 03af85d65..002bb0956 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/memory.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/memory.pm @@ -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 86d13d2d4..b25687d83 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/psu.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/psu.pm @@ -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 70a0d4f75..06eef859d 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/sp.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/spcomponents/sp.pm @@ -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)); } } } From ccddf9c4d85ed42038695deac2d49bb1351eb5b2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 22:17:42 +0200 Subject: [PATCH 013/103] + fix mode command --- centreon-plugins/os/solaris/local/mode/fmadm.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/os/solaris/local/mode/fmadm.pm b/centreon-plugins/os/solaris/local/mode/fmadm.pm index 020fe90e4..643a6a503 100644 --- a/centreon-plugins/os/solaris/local/mode/fmadm.pm +++ b/centreon-plugins/os/solaris/local/mode/fmadm.pm @@ -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', }, }); From 30c8d99a887acb0bb325457011483a538596c8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duret?= Date: Tue, 2 Aug 2016 10:31:23 +0200 Subject: [PATCH 014/103] Possibility to skip Non/Applicable sensor value --- .../storage/netapp/snmp/mode/components/temperature.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm b/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm index a2829f392..b30ac3b54 100644 --- a/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm +++ b/centreon-plugins/storage/netapp/snmp/mode/components/temperature.pm @@ -78,6 +78,8 @@ sub check { foreach my $num (split /,/, $result->{enclTempSensorsPresent}) { $num = centreon::plugins::misc::trim($num); 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_filter(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; From 17bef655e902c113b6b24c688896ecae969a773c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jean-fran=C3=A7ois=20Rameau?= Date: Tue, 2 Aug 2016 18:10:46 +0200 Subject: [PATCH 015/103] Round remaining time to minutes --- centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm index 8b7db9daf..5f46b54c2 100644 --- a/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm @@ -204,7 +204,7 @@ sub manage_selection { 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} = $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60 if (defined($result2->{upsAdvBatteryRunTimeRemaining})); + $result2->{upsAdvBatteryRunTimeRemaining} = sprintf "%.0f", $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60 if (defined($result2->{upsAdvBatteryRunTimeRemaining})); foreach my $name (keys %{$mapping}) { $self->{global}->{$name} = $result->{$name}; From 66d6d4bb71a900b3f20ec14bc0543b820dd26d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jean-fran=C3=A7ois=20Rameau?= Date: Tue, 2 Aug 2016 18:31:46 +0200 Subject: [PATCH 016/103] Desambiguate sprintf --- centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm b/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm index 5f46b54c2..021ccf08f 100644 --- a/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm +++ b/centreon-plugins/hardware/ups/apc/snmp/mode/batterystatus.pm @@ -204,7 +204,7 @@ sub manage_selection { 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})); + $result2->{upsAdvBatteryRunTimeRemaining} = sprintf("%.0f", $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60) if (defined($result2->{upsAdvBatteryRunTimeRemaining})); foreach my $name (keys %{$mapping}) { $self->{global}->{$name} = $result->{$name}; From 578d174fd8d5da1b321fe2ef99930824c479ec18 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Aug 2016 10:53:54 +0200 Subject: [PATCH 017/103] + add clever pdu plugin --- .../hardware/pdu/clever/snmp/mode/psusage.pm | 112 ++++++++++++++++++ .../hardware/pdu/clever/snmp/plugin.pm | 48 ++++++++ 2 files changed, 160 insertions(+) create mode 100644 centreon-plugins/hardware/pdu/clever/snmp/mode/psusage.pm create mode 100644 centreon-plugins/hardware/pdu/clever/snmp/plugin.pm 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 From ce242c5f4513ec24f00d6c224dbbf7263ee44c2f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Aug 2016 15:22:58 +0200 Subject: [PATCH 018/103] + add state for memory esx --- .../apps/vmware/connector/mode/memoryhost.pm | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm b/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm index 9c6919010..09964fecd 100644 --- a/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm +++ b/centreon-plugins/apps/vmware/connector/mode/memoryhost.pm @@ -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 From b0c9aa9580a734312332a46250d2dc379a6e0b55 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Aug 2016 15:49:35 +0200 Subject: [PATCH 019/103] + Fix #457 --- centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm b/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm index c33c663fd..6caa7a169 100644 --- a/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm +++ b/centreon-plugins/apps/apache/serverstatus/mode/slotstates.pm @@ -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', From 7a0e70ce1214150e1d728d64584dec884cef726e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Aug 2016 16:00:39 +0200 Subject: [PATCH 020/103] + prepare new version --- centreon-plugins/centreon/plugins/script.pm | 2 +- centreon-plugins/changelog | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/plugins/script.pm b/centreon-plugins/centreon/plugins/script.pm index 1bd77cc03..a5f0bb9bb 100644 --- a/centreon-plugins/centreon/plugins/script.pm +++ b/centreon-plugins/centreon/plugins/script.pm @@ -30,7 +30,7 @@ use Pod::Find qw(pod_where); my %handlers = (DIE => {}); -my $global_version = 20160627; +my $global_version = 20160803; my $alternative_fatpacker = 0; sub new { diff --git a/centreon-plugins/changelog b/centreon-plugins/changelog index d4d08dcae..fbd05c73c 100644 --- a/centreon-plugins/changelog +++ b/centreon-plugins/changelog @@ -1,3 +1,13 @@ +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) From f5c0fd1fbf222448ac3358671333143d57e1b2c2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 4 Aug 2016 11:33:08 +0200 Subject: [PATCH 021/103] + add device-vm mode for vmware connector --- .../apps/vmware/connector/mode/devicevm.pm | 149 ++++++++++++++++++ .../apps/vmware/connector/plugin.pm | 3 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 centreon-plugins/apps/vmware/connector/mode/devicevm.pm 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/plugin.pm b/centreon-plugins/apps/vmware/connector/plugin.pm index 0d487db73..9eeb4c665 100644 --- a/centreon-plugins/apps/vmware/connector/plugin.pm +++ b/centreon-plugins/apps/vmware/connector/plugin.pm @@ -42,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', From 673ffac4db1eb1668b880e7f4fd93eaf5c0199f8 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 5 Aug 2016 14:08:45 +0200 Subject: [PATCH 022/103] + add some guidelines --- centreon-plugins/docs/en/developer/guide.rst | 99 +++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/docs/en/developer/guide.rst b/centreon-plugins/docs/en/developer/guide.rst index edffa0f57..bc741a169 100644 --- a/centreon-plugins/docs/en/developer/guide.rst +++ b/centreon-plugins/docs/en/developer/guide.rst @@ -10,7 +10,8 @@ But to avoid reinventing the wheel, you should first take a look at the “examp There are 3 chapters: * :ref:`Quick Start `: Howto create file structure. -* :ref:`Libraries Reference `: API description. +* :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: http://git.centreon.com/centreon-plugins.git @@ -1446,7 +1447,6 @@ This is an example of how to use **fetchrow_hashref** method: Output displays Postgres databases. - ***************** Complete examples ***************** @@ -1776,6 +1776,101 @@ 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: ******************* From b004b1ee4023f4fef1c022e9c07d044a2039d6e4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 11 Aug 2016 15:02:58 +0200 Subject: [PATCH 023/103] + Fix #462 --- .../hardware/pdu/emerson/snmp/mode/globalstatus.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm index c9a747a3d..1eeb20634 100644 --- a/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm @@ -154,9 +154,9 @@ sub manage_selection { 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 = 'unknow'; + my $status = 'unknown'; foreach (keys %bitmap_status) { - if (($result->{lgpPduEntrySysStatus} & $_)) { + if ((int($result->{lgpPduEntrySysStatus}) & $_)) { $status = $bitmap_status{$_}; last; } From db5015182e89d4340c26dd5579638a42ceba9176 Mon Sep 17 00:00:00 2001 From: Shini31 Date: Fri, 12 Aug 2016 18:56:57 +0200 Subject: [PATCH 024/103] closed #463 and #464 --- .../cloud/docker/custom/dockerapi.pm | 218 ++++++++++++++++++ centreon-plugins/cloud/docker/mode/blockio.pm | 100 ++------ .../cloud/docker/mode/containerstate.pm | 103 ++------- centreon-plugins/cloud/docker/mode/cpu.pm | 139 ++++------- centreon-plugins/cloud/docker/mode/image.pm | 58 ++--- centreon-plugins/cloud/docker/mode/info.pm | 89 +------ .../cloud/docker/mode/listcontainers.pm | 99 ++------ .../cloud/docker/mode/listnodes.pm | 154 +++++++++++++ centreon-plugins/cloud/docker/mode/memory.pm | 148 +++++------- .../cloud/docker/mode/nodestate.pm | 159 +++++++++++++ centreon-plugins/cloud/docker/mode/traffic.pm | 112 ++------- centreon-plugins/cloud/docker/plugin.pm | 17 +- 12 files changed, 744 insertions(+), 652 deletions(-) create mode 100644 centreon-plugins/cloud/docker/custom/dockerapi.pm create mode 100644 centreon-plugins/cloud/docker/mode/listnodes.pm create mode 100644 centreon-plugins/cloud/docker/mode/nodestate.pm diff --git a/centreon-plugins/cloud/docker/custom/dockerapi.pm b/centreon-plugins/cloud/docker/custom/dockerapi.pm new file mode 100644 index 000000000..15df49d8b --- /dev/null +++ b/centreon-plugins/cloud/docker/custom/dockerapi.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 cloud::docker::custom::dockerapi; + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::http; +use JSON; + +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' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "proxyurl:s" => { name => 'proxyurl' }, + "proxypac:s" => { name => 'proxypac' }, + "timeout:s" => { name => 'timeout' }, + "ssl:s" => { name => 'ssl' }, + "cert-file:s" => { name => 'cert_file' }, + "key-file:s" => { name => 'key_file' }, + "cacert-file:s" => { name => 'cacert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + }); + } + $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) = @_; + + # 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) = @_; + + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{proto}) || $self->{option_results}->{proto} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --proto option."); + $self->{output}->option_exit(); + } + +} + +sub api_request { + my ($self, %options) = @_; + + $self->{option_results}->{url_path} = $options{urlpath}; + $self->{option_results}->{port} = $options{port}; + $self->{method} = 'GET'; + $self->{option_results}->{get_param} = []; + push @{$self->{option_results}->{get_param}}, "all=true", "stream=false"; + + $self->{http}->set_options(%{$self->{option_results}}); + + my $webcontent; + my $jsoncontent = $self->{http}->request(method => $self->{method}); + + my $json = JSON->new; + + eval { + $webcontent = $json->decode($jsoncontent); + }; + + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot retrieve any information"); + $self->{output}->option_exit(); + } + + return $webcontent; +} + +1; + +__END__ + +=head1 NAME + +Docker REST API + +=head1 SYNOPSIS + +Docker Rest API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +IP Addr/FQDN of the webserver host + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=item B<--credentials> + +Specify this option if you access webpage over basic authentification + +=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<--proxyurl> + +Proxy URL + +=item B<--proxypac> + +Proxy pac file (can be an url or local file) + +=item B<--timeout> + +Threshold for HTTP timeout (Default: 5) + +=item B<--ssl> + +Specify SSL version (example : 'sslv3', 'tlsv1'...) + +=item B<--cert-file> + +Specify certificate to send to the webserver + +=item B<--key-file> + +Specify key to send to the webserver + +=item B<--cacert-file> + +Specify root certificate to send to the webserver + +=item B<--cert-pwd> + +Specify certificate's password + +=item B<--cert-pkcs12> + +Specify type of certificate (PKCS12) + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon-plugins/cloud/docker/mode/blockio.pm b/centreon-plugins/cloud/docker/mode/blockio.pm index b21a6446f..566308002 100644 --- a/centreon-plugins/cloud/docker/mode/blockio.pm +++ b/centreon-plugins/cloud/docker/mode/blockio.pm @@ -24,40 +24,29 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use centreon::plugins::http; use centreon::plugins::statefile; -use JSON; +use centreon::plugins::http; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, + "port:s" => { name => 'port' }, "name:s" => { name => 'name' }, "id:s" => { name => 'id' }, "warning-read:s" => { name => 'warning-read' }, "critical-read:s" => { name => 'critical-read' }, "warning-write:s" => { name => 'warning-write' }, "critical-write:s" => { name => 'critical-write' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "timeout:s" => { name => 'timeout' }, }); $self->{statefile_value} = centreon::plugins::statefile->new(%options); $self->{http} = centreon::plugins::http->new(output => $self->{output}); + return $self; } @@ -90,14 +79,6 @@ sub check_options { $self->{output}->option_exit(); } - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "stream=false"; - if (defined($self->{option_results}->{id})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats"; - } elsif (defined($self->{option_results}->{name})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats"; - } - $self->{http}->set_options(%{$self->{option_results}}); $self->{statefile_value}->check_options(%options); } @@ -113,20 +94,17 @@ sub run { $self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . $self->{http}->get_port() . '_' . $self->{mode}); } - my $jsoncontent = $self->{http}->request(); + my $urlpath; + if (defined($self->{option_results}->{id})) { + $urlpath = "/containers/".$self->{option_results}->{id}."/stats"; + } elsif (defined($self->{option_results}->{name})) { + $urlpath = "/containers/".$self->{option_results}->{name}."/stats"; + } + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); - } + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); my $read_bytes = $webcontent->{blkio_stats}->{io_service_bytes_recursive}->[0]->{value}; my $write_bytes = $webcontent->{blkio_stats}->{io_service_bytes_recursive}->[1]->{value}; @@ -204,23 +182,11 @@ __END__ Check Container's Block I/O usage -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker's container information (Default: '/') +Port used by Docker =item B<--id> @@ -230,6 +196,8 @@ Specify one container's id Specify one container's name +=head2 MODE OPTIONS + =item B<--warning-read> Threshold warning in B/s for Read I/O. @@ -246,38 +214,6 @@ Threshold warning in B/s for Write I/O. Threshold critical in B/s for Write I/O. -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) - =back =cut diff --git a/centreon-plugins/cloud/docker/mode/containerstate.pm b/centreon-plugins/cloud/docker/mode/containerstate.pm index 8d38e896c..05007f6bf 100644 --- a/centreon-plugins/cloud/docker/mode/containerstate.pm +++ b/centreon-plugins/cloud/docker/mode/containerstate.pm @@ -24,8 +24,6 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use centreon::plugins::http; -use JSON; my $thresholds = { state => [ @@ -43,27 +41,15 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, + "port:s" => { name => 'port' }, "name:s" => { name => 'name' }, "id:s" => { name => 'id' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "timeout:s" => { name => 'timeout' }, "threshold-overload:s@" => { name => 'threshold_overload' }, }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); return $self; } @@ -95,18 +81,6 @@ sub check_options { $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } - - if (defined($self->{option_results}->{id})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/json"; - } elsif (defined($self->{option_results}->{name})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/json"; - } else { - $self->{option_results}->{url_path} = "/containers/json"; - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "all=true"; - } - $self->{http}->set_options(%{$self->{option_results}}); - } sub get_severity { @@ -133,20 +107,17 @@ sub get_severity { sub run { my ($self, %options) = @_; - my $jsoncontent = $self->{http}->request(); - - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); + my $urlpath; + if (defined($self->{option_results}->{id})) { + $urlpath = "/containers/".$self->{option_results}->{id}."/json"; + } elsif (defined($self->{option_results}->{name})) { + $urlpath = "/containers/".$self->{option_results}->{name}."/json"; } + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; + + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); my ($result,$containername,$containertime); my $exit = 'OK'; @@ -228,23 +199,11 @@ __END__ Check Container's state -=over 8 +=head2 DOCKER OPTIONS -=item B<--hostname> +item B<--port> -IP Addr/FQDN of Docker's API - -=item B<--port> - -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker's container information (Default: '/') +Port used by Docker =item B<--id> @@ -254,37 +213,7 @@ Specify one container's id Specify one container's name -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) +=head2 MODE OPTIONS =item B<--threshold-overload> diff --git a/centreon-plugins/cloud/docker/mode/cpu.pm b/centreon-plugins/cloud/docker/mode/cpu.pm index b0f3d1f9e..17ad4c315 100644 --- a/centreon-plugins/cloud/docker/mode/cpu.pm +++ b/centreon-plugins/cloud/docker/mode/cpu.pm @@ -24,34 +24,22 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use centreon::plugins::http; use centreon::plugins::statefile; -use JSON; +use centreon::plugins::http; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, - "name:s" => { name => 'name' }, - "id:s" => { name => 'id' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "timeout:s" => { name => 'timeout' }, + "port:s" => { name => 'port' }, + "name:s" => { name => 'name' }, + "id:s" => { name => 'id' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); $self->{statefile_value} = centreon::plugins::statefile->new(%options); @@ -84,14 +72,6 @@ sub check_options { $self->{output}->option_exit(); } - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "stream=false"; - if (defined($self->{option_results}->{id})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats"; - } elsif (defined($self->{option_results}->{name})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats"; - } - $self->{http}->set_options(%{$self->{option_results}}); $self->{statefile_value}->check_options(%options); } @@ -105,32 +85,32 @@ sub run { $self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . $self->{http}->get_port() . '_' . $self->{mode}); } - my $jsoncontent = $self->{http}->request(); + my $urlpath; + if (defined($self->{option_results}->{id})) { + $urlpath = "/containers/".$self->{option_results}->{id}."/stats"; + } elsif (defined($self->{option_results}->{name})) { + $urlpath = "/containers/".$self->{option_results}->{name}."/stats"; + } + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); - } + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); my $cpu_totalusage = $webcontent->{cpu_stats}->{cpu_usage}->{total_usage}; my $cpu_systemusage = $webcontent->{cpu_stats}->{system_cpu_usage}; my @cpu_number = @{$webcontent->{cpu_stats}->{cpu_usage}->{percpu_usage}}; + my $cpu_throttledtime = $webcontent->{cpu_stats}->{throttling_data}->{throttled_time}; my $new_datas = {}; $new_datas->{cpu_totalusage} = $cpu_totalusage; $new_datas->{cpu_systemusage} = $cpu_systemusage; + $new_datas->{cpu_throttledtime} = $cpu_throttledtime; my $old_cpu_totalusage = $self->{statefile_value}->get(name => 'cpu_totalusage'); my $old_cpu_systemusage = $self->{statefile_value}->get(name => 'cpu_systemusage'); + my $old_cpu_throttledtime = $self->{statefile_value}->get(name => 'cpu_throttledtime'); - if ((!defined($old_cpu_totalusage)) || (!defined($old_cpu_systemusage))) { + if ((!defined($old_cpu_totalusage)) || (!defined($old_cpu_systemusage)) || (!defined($old_cpu_throttledtime))) { $self->{output}->output_add(severity => 'OK', short_msg => "Buffer creation..."); $self->{statefile_value}->write(data => $new_datas); @@ -147,22 +127,35 @@ sub run { $old_cpu_systemusage = 0; } + if ($new_datas->{cpu_throttledtime} < $old_cpu_throttledtime) { + # We set 0. Has reboot. + $old_cpu_throttledtime = 0; + } + my $delta_totalusage = $cpu_totalusage - $old_cpu_totalusage; my $delta_systemusage = $cpu_systemusage - $old_cpu_systemusage; + my $delta_throttledtime = $cpu_throttledtime - $old_cpu_throttledtime; + # Nano second to second + my $throttledtime = $delta_throttledtime / 10 ** 9; my $prct_cpu = (($delta_totalusage / $delta_systemusage) * scalar(@cpu_number)) * 100; my $exit = $self->{perfdata}->threshold_check(value => $prct_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%%", $prct_cpu)); + short_msg => sprintf("CPU Usage is %.2f%% (Throttled Time: %.3fs)", $prct_cpu, $throttledtime)); $self->{output}->perfdata_add(label => "cpu", unit => '%', - value => $prct_cpu, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, - max => 100, - ); + value => $prct_cpu, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, + max => 100, + ); + $self->{output}->perfdata_add(label => "throttled", unit => 's', + value => $throttledtime, + min => 0, + ); + $self->{statefile_value}->write(data => $new_datas); @@ -179,23 +172,11 @@ __END__ Check Container's CPU usage -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker's container information (Default: '/') +Port used by Docker =item B<--id> @@ -205,6 +186,8 @@ Specify one container's id Specify one container's name +=head2 MODE OPTIONS + =item B<--warning> Threshold warning in percent. @@ -213,38 +196,6 @@ Threshold warning in percent. Threshold critical in percent. -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) - =back =cut diff --git a/centreon-plugins/cloud/docker/mode/image.pm b/centreon-plugins/cloud/docker/mode/image.pm index 0c257213e..7ea69365a 100644 --- a/centreon-plugins/cloud/docker/mode/image.pm +++ b/centreon-plugins/cloud/docker/mode/image.pm @@ -32,13 +32,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, + "port:s" => { name => 'port' }, "name:s" => { name => 'name' }, "id:s" => { name => 'id' }, "image:s" => { name => 'image' }, @@ -88,32 +85,25 @@ sub check_options { $self->{output}->option_exit(); } - if (defined($self->{option_results}->{id})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/json"; - } elsif (defined($self->{option_results}->{name})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/json"; - } - $self->{http}->set_options(%{$self->{option_results}}); } sub run { my ($self, %options) = @_; - my ($jsoncontent,$jsoncontent2, $webcontent, $webcontent2); + my ($jsoncontent, $webcontent, $webcontent2); - $jsoncontent = $self->{http}->request(); - - my $json = JSON->new; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); + my $urlpath; + if (defined($self->{option_results}->{id})) { + $urlpath = "/containers/".$self->{option_results}->{id}."/stats"; + } elsif (defined($self->{option_results}->{name})) { + $urlpath = "/containers/".$self->{option_results}->{name}."/stats"; } + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; + + $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); my $container_id = $webcontent->{Image}; @@ -123,12 +113,12 @@ sub run { $self->{option_results}->{hostname} = $self->{option_results}->{registry_hostname}; $self->{http}->set_options(%{$self->{option_results}}); - $jsoncontent2 = $self->{http}->request(); + $jsoncontent = $self->{http}->request(); my $json2 = JSON->new; eval { - $webcontent2 = $json2->decode($jsoncontent2); + $webcontent2 = $json2->decode($jsoncontent); }; if ($@) { @@ -166,23 +156,11 @@ __END__ Check Container's image viability with a registry -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker's container information (Default: '/') +Port used by Docker =item B<--id> @@ -192,6 +170,8 @@ Specify the container's id Specify the container's name +=head2 MODE OPTIONS + =item B<--image> Specify the image's name diff --git a/centreon-plugins/cloud/docker/mode/info.pm b/centreon-plugins/cloud/docker/mode/info.pm index 16d84779e..e6dd0f1e4 100644 --- a/centreon-plugins/cloud/docker/mode/info.pm +++ b/centreon-plugins/cloud/docker/mode/info.pm @@ -25,62 +25,37 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::http; -use JSON; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/info' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "timeout:s" => { name => 'timeout' }, + "port:s" => { name => 'port' } }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - - $self->{http}->set_options(%{$self->{option_results}}); } sub run { my ($self, %options) = @_; + my $urlpath = "/info"; + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; - my $jsoncontent = $self->{http}->request();; + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); - } - - - $self->{output}->output_add(severity => 'OK', + $self->{output}->output_add(severity => 'OK', short_msg => sprintf("Docker is running")); $self->{output}->perfdata_add(label => "containers", @@ -122,55 +97,11 @@ __END__ Check Docker information -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker information (Default: '/') - -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) +Port used by Docker =back diff --git a/centreon-plugins/cloud/docker/mode/listcontainers.pm b/centreon-plugins/cloud/docker/mode/listcontainers.pm index e96baaf62..01c096b1a 100644 --- a/centreon-plugins/cloud/docker/mode/listcontainers.pm +++ b/centreon-plugins/cloud/docker/mode/listcontainers.pm @@ -24,46 +24,27 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use centreon::plugins::http; -use JSON; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.1'; + $self->{version} = '1.2'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "exclude:s" => { name => 'exclude' }, - "timeout:s" => { name => 'timeout' }, + "port:s" => { name => 'port' }, + "exclude:s" => { name => 'exclude' }, }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); $self->{container_infos} = (); + return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - - $self->{option_results}->{url_path} = $self->{option_results}->{url_path}."containers/json"; - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "all=true"; - - $self->{http}->set_options(%{$self->{option_results}}) } sub check_exclude { @@ -76,23 +57,15 @@ sub check_exclude { return 0; } -sub api_request { +sub listcontainer_request { my ($self, %options) = @_; - my $jsoncontent = $self->{http}->request(); + my $urlpath = "/containers/json"; + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); - } + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); foreach my $val (@$webcontent) { my $containerstate; @@ -124,7 +97,7 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - $self->api_request(); + $self->listcontainer_request(%options); foreach my $containername (keys %{$self->{container_infos}}) { $self->{output}->add_disco_entry(name => $containername, @@ -138,7 +111,7 @@ sub disco_show { sub run { my ($self, %options) = @_; - $self->api_request(); + $self->listcontainer_request(%options); foreach my $containername (keys %{$self->{container_infos}}) { $self->{output}->output_add(long_msg => sprintf("%s [id = %s , image = %s, state = %s]", @@ -164,60 +137,18 @@ __END__ List Docker containers -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') +Port used by Docker -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker containers (Default: '/') - -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver +=head2 MODE OPTIONS =item B<--exlude> Exclude specific container's state (comma seperated list) (Example: --exclude=Paused,Running) -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) - =back =cut diff --git a/centreon-plugins/cloud/docker/mode/listnodes.pm b/centreon-plugins/cloud/docker/mode/listnodes.pm new file mode 100644 index 000000000..caa9f22e5 --- /dev/null +++ b/centreon-plugins/cloud/docker/mode/listnodes.pm @@ -0,0 +1,154 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package cloud::docker::mode::listnodes; + +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 => + { + "port:s" => { name => 'port' }, + "exclude:s" => { name => 'exclude' }, + }); + + $self->{node_infos} = (); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub check_exclude { + my ($self, %options) = @_; + + if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{status}}(\s|,|$)/) { + $self->{output}->output_add(long_msg => sprintf("Skipping ${options{status}} nodes.")); + return 1; + } +return 0; +} + +sub listnode_request { + my ($self, %options) = @_; + + my $urlpath = "/nodes"; + my $port = $self->{option_results}->{port}; + + my $nodeapi = $options{custom}; + my $webcontent = $nodeapi->api_request(urlpath => $urlpath, + port => $port); + + foreach my $val (@$webcontent) { + next if ($self->check_exclude(status => $val->{Status}->{State})); + my $nodeid = $val->{ID}; + $self->{node_infos}->{$nodeid}->{hostname} = $val->{Description}->{Hostname}; + $self->{node_infos}->{$nodeid}->{role} = $val->{Spec}->{Role}; + $self->{node_infos}->{$nodeid}->{availability} = $val->{Spec}->{Availability}; + $self->{node_infos}->{$nodeid}->{state} = $val->{Status}->{State}; + if ($val->{Spec}->{Role} eq 'manager') { + $self->{node_infos}->{$nodeid}->{reachability} = $val->{ManagerStatus}->{Reachability}; + } else { + $self->{node_infos}->{$nodeid}->{reachability} = ''; + } + + } +} + +sub disco_format { + my ($self, %options) = @_; + + my $names = ['id', 'hostname', 'role', 'state', 'availability', 'reachability']; + $self->{output}->add_disco_format(elements => $names); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->listnode_request(%options); + + foreach my $nodeid (keys %{$self->{node_infos}}) { + $self->{output}->add_disco_entry(id => $nodeid, + hostname => $self->{node_infos}->{$nodeid}->{hostname}, + role => $self->{node_infos}->{$nodeid}->{role}, + state => $self->{node_infos}->{$nodeid}->{state}, + availability => $self->{node_infos}->{$nodeid}->{availability}, + reachability => $self->{node_infos}->{$nodeid}->{reachability}, + ); + } +} + +sub run { + my ($self, %options) = @_; + + $self->listnode_request(%options); + + foreach my $nodeid (keys %{$self->{node_infos}}) { + $self->{output}->output_add(long_msg => sprintf("%s [hostname = %s , role = %s, state = %s, availability = %s, reachability = %s]", + $nodeid, + $self->{node_infos}->{$nodeid}->{hostname}, + $self->{node_infos}->{$nodeid}->{role}, + $self->{node_infos}->{$nodeid}->{state}, + $self->{node_infos}->{$nodeid}->{availability}, + $self->{node_infos}->{$nodeid}->{reachability})); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List Swarm nodes:'); + + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); + + exit 0; +} + +1; + +__END__ + +=head1 MODE + +List Docker Swarm nodes + +=head2 DOCKER OPTIONS + +=item B<--port> + +Port used by Docker + +=head2 MODE OPTIONS + +=item B<--exlude> + +Exclude specific node's state (comma seperated list) (Example: --exclude=disconnected) + +=back + +=cut diff --git a/centreon-plugins/cloud/docker/mode/memory.pm b/centreon-plugins/cloud/docker/mode/memory.pm index f4300210a..8ede73677 100644 --- a/centreon-plugins/cloud/docker/mode/memory.pm +++ b/centreon-plugins/cloud/docker/mode/memory.pm @@ -24,33 +24,20 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use centreon::plugins::http; -use JSON; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, - "name:s" => { name => 'name' }, - "id:s" => { name => 'id' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "timeout:s" => { name => 'timeout' }, + "port:s" => { name => 'port' }, + "name:s" => { name => 'name' }, + "id:s" => { name => 'id' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); return $self; @@ -79,61 +66,72 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } - - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "stream=false"; - if (defined($self->{option_results}->{id})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats"; - } elsif (defined($self->{option_results}->{name})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats"; - } - - $self->{http}->set_options(%{$self->{option_results}}); } sub run { my ($self, %options) = @_; - my $jsoncontent = $self->{http}->request(); - - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); + my $urlpath; + if (defined($self->{option_results}->{id})) { + $urlpath = "/containers/".$self->{option_results}->{id}."/stats"; + } elsif (defined($self->{option_results}->{name})) { + $urlpath = "/containers/".$self->{option_results}->{name}."/stats"; } + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; + + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); my $total_size = $webcontent->{memory_stats}->{limit}; my $memory_used = $webcontent->{memory_stats}->{usage}; my $memory_free = $webcontent->{memory_stats}->{limit} - $webcontent->{memory_stats}->{usage}; my $prct_used = $memory_used * 100 / $total_size; my $prct_free = 100 - $prct_used; + my $failed_counter = $webcontent->{memory_stats}->{failcnt}; + my $memory_cached = $webcontent->{memory_stats}->{stats}->{cache}; + my $memory_rss = $webcontent->{memory_stats}->{stats}->{rss}; my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $memory_used); my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); + my ($cached_value, $cached_unit) = $self->{perfdata}->change_bytes(value => $memory_cached); + my ($rss_value, $rss_unit) = $self->{perfdata}->change_bytes(value => $memory_rss); + $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s %.2f%%)", + short_msg => sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s %.2f%%) Cached: %s RSS: %s Failed: %s", $total_value . " " . $total_unit, $used_value . " " . $used_unit, $prct_used, - $free_value . " " . $free_unit, $prct_free) + $free_value . " " . $free_unit, $prct_free, + $cached_value . " " . $cached_unit, + $rss_value . " " . $rss_unit, + $failed_counter) ); $self->{output}->perfdata_add(label => "used", - value => $webcontent->{memory_stats}->{usage}, - 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 => $webcontent->{memory_stats}->{limit}, - ); + value => $webcontent->{memory_stats}->{usage}, + 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 => $webcontent->{memory_stats}->{limit}, + ); + + $self->{output}->perfdata_add(label => "cached", + value => $webcontent->{memory_stats}->{stats}->{cache}, + min => 0, + ); + + $self->{output}->perfdata_add(label => "rss", + value => $webcontent->{memory_stats}->{stats}->{rss}, + min => 0, + ); + + $self->{output}->perfdata_add(label => "failed", + value => $webcontent->{memory_stats}->{failcnt}, + min => 0, + ); $self->{output}->display(); $self->{output}->exit(); @@ -148,23 +146,11 @@ __END__ Check Container's memory usage -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker's container information (Default: '/') +Port used by Docker =item B<--id> @@ -174,6 +160,8 @@ Specify one container's id Specify one container's name +=head2 MODE OPTIONS + =item B<--warning> Threshold warning in percent. @@ -182,38 +170,6 @@ Threshold warning in percent. Threshold critical in percent. -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) - =back =cut diff --git a/centreon-plugins/cloud/docker/mode/nodestate.pm b/centreon-plugins/cloud/docker/mode/nodestate.pm new file mode 100644 index 000000000..a4e2a48c7 --- /dev/null +++ b/centreon-plugins/cloud/docker/mode/nodestate.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 cloud::docker::mode::nodestate; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + state => [ + ['ready', 'OK'], + ['disconnected', 'WARNING'], + ['down', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ], +}; + +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 => + { + "port:s" => { name => 'port' }, + "id:s" => { name => 'id' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if ((defined($self->{option_results}->{id})) && ($self->{option_results}->{id} eq '')) { + $self->{output}->add_option_msg(short_msg => "You need to specify the id option"); + $self->{output}->option_exit(); + } + + $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 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) = @_; + + my $urlpath = "/nodes/".$self->{option_results}->{id}; + my $port = $self->{option_results}->{port}; + my $nodeapi = $options{custom}; + + my $webcontent = $nodeapi->api_request(urlpath => $urlpath, + port => $port); + + my $exit = $self->get_severity(section => 'state', value => $webcontent->{Status}->{State}); + + if (defined($webcontent->{ManagerStatus}->{Reachability})) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%s node is %s (Availability: %s - Reachability: %s)", + $webcontent->{Spec}->{Role}, + $webcontent->{Status}->{State}, + $webcontent->{Spec}->{Availability}, + $webcontent->{ManagerStatus}->{Reachability})); + } else { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%s node is %s (Availability: %s)", + $webcontent->{Spec}->{Role}, + $webcontent->{Status}->{State}, + $webcontent->{Spec}->{Availability})); + } + + $self->{output}->display(); + $self->{output}->exit(); + +} + +1; + +__END__ + +=head1 MODE + +Check Swarm Node's state + +=head2 DOCKER OPTIONS + +item B<--port> + +Port used by Docker + +=item B<--id> + +Specify one node's id + +=head2 MODE OPTIONS + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='state,CRITICAL,^(?!(disconnected)$)' + +=back + +=cut diff --git a/centreon-plugins/cloud/docker/mode/traffic.pm b/centreon-plugins/cloud/docker/mode/traffic.pm index 1318c6a5e..64d05a4bb 100644 --- a/centreon-plugins/cloud/docker/mode/traffic.pm +++ b/centreon-plugins/cloud/docker/mode/traffic.pm @@ -24,40 +24,29 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use centreon::plugins::http; use centreon::plugins::statefile; -use JSON; +use centreon::plugins::http; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '1.0'; + $self->{version} = '1.1'; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '2376'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/' }, - "name:s" => { name => 'name' }, - "id:s" => { name => 'id' }, - "warning-in:s" => { name => 'warning_in' }, - "critical-in:s" => { name => 'critical_in' }, - "warning-out:s" => { name => 'warning_out' }, - "critical-out:s" => { name => 'critical_out' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "timeout:s" => { name => 'timeout' }, + "port:s" => { name => 'port' }, + "name:s" => { name => 'name' }, + "id:s" => { name => 'id' }, + "warning-in:s" => { name => 'warning_in' }, + "critical-in:s" => { name => 'critical_in' }, + "warning-out:s" => { name => 'warning_out' }, + "critical-out:s" => { name => 'critical_out' }, }); $self->{statefile_value} = centreon::plugins::statefile->new(%options); $self->{http} = centreon::plugins::http->new(output => $self->{output}); + return $self; } @@ -90,14 +79,6 @@ sub check_options { $self->{output}->option_exit(); } - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "stream=false"; - if (defined($self->{option_results}->{id})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats"; - } elsif (defined($self->{option_results}->{name})) { - $self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats"; - } - $self->{http}->set_options(%{$self->{option_results}}); $self->{statefile_value}->check_options(%options); } @@ -113,20 +94,17 @@ sub run { $self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . $self->{http}->get_port() . '_' . $self->{mode}); } - my $jsoncontent = $self->{http}->request(); - - my $json = JSON->new; - - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); + my $urlpath; + if (defined($self->{option_results}->{id})) { + $urlpath = "/containers/".$self->{option_results}->{id}."/stats"; + } elsif (defined($self->{option_results}->{name})) { + $urlpath = "/containers/".$self->{option_results}->{name}."/stats"; } + my $port = $self->{option_results}->{port}; + my $containerapi = $options{custom}; + + my $webcontent = $containerapi->api_request(urlpath => $urlpath, + port => $port); my $rx_bytes = $webcontent->{network}->{rx_bytes}; my $tx_bytes = $webcontent->{network}->{tx_bytes}; @@ -203,23 +181,11 @@ __END__ Check Container's Network traffic usage -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of Docker's API +=head2 DOCKER OPTIONS =item B<--port> -Port used by Docker's API (Default: '2576') - -=item B<--proto> - -Specify https if needed (Default: 'https') - -=item B<--urlpath> - -Set path to get Docker's container information (Default: '/') +Port used by Docker =item B<--id> @@ -229,6 +195,8 @@ Specify one container's id Specify one container's name +=head2 MODE OPTIONS + =item B<--warning-in> Threshold warning in b/s for 'in' traffic. @@ -245,38 +213,6 @@ Threshold warning in b/s for 'out' traffic. Threshold critical in b/s for 'out' traffic. -=item B<--credentials> - -Specify this option if you access webpage over basic authentification - -=item B<--username> - -Specify username - -=item B<--password> - -Specify password - -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - -=item B<--cert-file> - -Specify certificate to send to the webserver - -=item B<--key-file> - -Specify key to send to the webserver - -=item B<--cacert-file> - -Specify root certificate to send to the webserver - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 3) - =back =cut diff --git a/centreon-plugins/cloud/docker/plugin.pm b/centreon-plugins/cloud/docker/plugin.pm index ebb0824a4..88ce56726 100644 --- a/centreon-plugins/cloud/docker/plugin.pm +++ b/centreon-plugins/cloud/docker/plugin.pm @@ -22,14 +22,14 @@ package cloud::docker::plugin; use strict; use warnings; -use base qw(centreon::plugins::script_simple); +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} = '0.2'; + $self->{version} = '0.3'; %{$self->{modes}} = ( 'blockio' => 'cloud::docker::mode::blockio', 'containerstate' => 'cloud::docker::mode::containerstate', @@ -37,12 +37,23 @@ sub new { 'image' => 'cloud::docker::mode::image', 'info' => 'cloud::docker::mode::info', 'list-containers' => 'cloud::docker::mode::listcontainers', + 'list-nodes' => 'cloud::docker::mode::listnodes', 'memory' => 'cloud::docker::mode::memory', + 'nodestate' => 'cloud::docker::mode::nodestate', 'traffic' => 'cloud::docker::mode::traffic', ); + + $self->{custom_modes}{dockerapi} = 'cloud::docker::custom::dockerapi'; return $self; } +sub init { + my ( $self, %options ) = @_; + + $self->SUPER::init(%options); +} + + 1; __END__ @@ -50,6 +61,6 @@ __END__ =head1 PLUGIN DESCRIPTION Check Docker and containers through its HTTPS Remote API (https://docs.docker.com/reference/api/docker_remote_api/). -Requirements: Docker 1.7.1+ and Docker API 1.19+ +Requirements: Docker 1.12.0+ and Docker API 1.24+ =cut From d323be5067acc0271a105228dfcf878f79ed4087 Mon Sep 17 00:00:00 2001 From: Erkan Date: Thu, 18 Aug 2016 10:10:58 +0200 Subject: [PATCH 025/103] fix typo --- .../network/alcatel/common/mode/components/powersupply.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm b/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm index 22902766c..75a6591ba 100644 --- a/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm +++ b/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm @@ -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; From 88601586abeb5061a636f7dfbd42605524f5c9df Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 19 Aug 2016 11:02:03 +0200 Subject: [PATCH 026/103] + Fix matching for extra oids --- centreon-plugins/snmp_standard/mode/listinterfaces.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/snmp_standard/mode/listinterfaces.pm b/centreon-plugins/snmp_standard/mode/listinterfaces.pm index 66985c012..f067adba8 100644 --- a/centreon-plugins/snmp_standard/mode/listinterfaces.pm +++ b/centreon-plugins/snmp_standard/mode/listinterfaces.pm @@ -126,7 +126,7 @@ sub check_options { foreach (@{$self->{option_results}->{add_extra_oid}}) { next if ($_ eq ''); my ($name, $oid, $matching) = split /,/; - $matching = '%{instance}' if (!defined($matching)); + $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(); From bde6c000470b80c427bd9e8ff08659fae7d055ac Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 24 Aug 2016 12:06:32 +0200 Subject: [PATCH 027/103] + add quantum scalar plugin in snmp --- .../tape/snmp/mode/components/component.pm | 78 ++++++++++++ .../adic/tape/snmp/mode/components/fan.pm | 117 ++++++++++++++++++ .../adic/tape/snmp/mode/components/global.pm | 30 +++-- .../snmp/mode/components/physicaldrive.pm | 60 +++++---- .../tape/snmp/mode/components/temperature.pm | 117 ++++++++++++++++++ .../common/adic/tape/snmp/mode/hardware.pm | 41 +++++- .../storage/quantum/scalar/snmp/plugin.pm | 48 +++++++ 7 files changed, 458 insertions(+), 33 deletions(-) create mode 100644 centreon-plugins/centreon/common/adic/tape/snmp/mode/components/component.pm create mode 100644 centreon-plugins/centreon/common/adic/tape/snmp/mode/components/fan.pm create mode 100644 centreon-plugins/centreon/common/adic/tape/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/storage/quantum/scalar/snmp/plugin.pm 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 index cbc31f51c..29914680d 100644 --- a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/global.pm +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/global.pm @@ -32,16 +32,29 @@ my %map_status = ( 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 = { - libraryGlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status }, + 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->{libraryGlobalStatus}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{GlobalStatus}->{oid} }, + { oid => $mapping2->{GlobalStatus}->{oid} }; } sub check { @@ -52,8 +65,11 @@ sub check { return if ($self->check_filter(section => 'global')); my $instance = '0'; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{libraryGlobalStatus}->{oid}}, instance => $instance); - if (!defined($result->{libraryGlobalStatus})) { + 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 ; } @@ -62,13 +78,13 @@ sub check { $self->{components}->{global}->{total}++; $self->{output}->output_add(long_msg => sprintf("library global status is %s [instance: %s].", - $result->{libraryGlobalStatus}, $instance + $result->{GlobalStatus}, $instance )); - my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{libraryGlobalStatus}); + 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->{libraryGlobalStatus})); + $result->{GlobalStatus})); } } 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 index f839dd943..650f04205 100644 --- a/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/components/physicaldrive.pm @@ -34,18 +34,30 @@ my %map_status = ( 7 => 'invalid', ); -# In MIB 'ADIC-TAPE-LIBRARY-MIB' my $mapping = { - 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-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_physicalDriveEntry = '.1.3.6.1.4.1.3764.1.10.10.11.3.1'; + +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_physicalDriveEntry }; + push @{$self->{request}}, { oid => $oid_table{adic_tape} }, { oid => $oid_table{adic_management} }; } sub check { @@ -54,25 +66,29 @@ sub check { $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); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_physicalDriveEntry}})) { - next if ($oid !~ /^$mapping->{phDriveRasStatus}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_physicalDriveEntry}, instance => $instance); + $result->{phDriveSerialNumber} = centreon::plugins::misc::trim($result->{phDriveSerialNumber}); - next if ($self->check_filter(section => 'physicaldrive', instance => $instance)); - $self->{components}->{physicaldrive}->{total}++; + 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].", - $instance, $result->{phDriveRasStatus}, - $instance, 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", - $instance, $result->{phDriveRasStatus})); + $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})); + } } } } 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 index 9a1ae3f0d..76683d9fd 100644 --- a/centreon-plugins/centreon/common/adic/tape/snmp/mode/hardware.pm +++ b/centreon-plugins/centreon/common/adic/tape/snmp/mode/hardware.pm @@ -28,7 +28,8 @@ use warnings; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_overload_check_section_option} = '^(global|physicaldrive|subsystem)$'; + $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'; @@ -41,11 +42,33 @@ sub set_system { ['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']; + $self->{components_module} = ['global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan']; } sub snmp_execute { @@ -57,7 +80,7 @@ sub snmp_execute { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); bless $self, $class; $self->{version} = '1.0'; @@ -81,7 +104,7 @@ Check Hardware. =item B<--component> Which component to check (Default: '.*'). -Can be: 'global', 'physicaldrive', 'subsystem'. +Can be: 'global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan'. =item B<--filter> @@ -99,6 +122,16 @@ Set to overload default threshold values (syntax: section,[instance,]status,rege 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/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 From 6a051d559d29349d970ec2aba505348da05a4143 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 24 Aug 2016 15:35:10 +0200 Subject: [PATCH 028/103] + add plugin to monitor hnas in snmp --- .../common/bluearc/snmp/mode/clusterstatus.pm | 201 ++++++++++++ .../bluearc/snmp/mode/components/fan.pm | 87 +++++ .../bluearc/snmp/mode/components/psu.pm | 72 +++++ .../bluearc/snmp/mode/components/sysdrive.pm | 73 +++++ .../snmp/mode/components/temperature.pm | 86 +++++ .../common/bluearc/snmp/mode/hardware.pm | 137 ++++++++ .../common/bluearc/snmp/mode/volumeusage.pm | 300 ++++++++++++++++++ .../storage/hitachi/hnas/snmp/plugin.pm | 52 +++ 8 files changed, 1008 insertions(+) create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/components/fan.pm create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/components/psu.pm create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/components/sysdrive.pm create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/hardware.pm create mode 100644 centreon-plugins/centreon/common/bluearc/snmp/mode/volumeusage.pm create mode 100644 centreon-plugins/storage/hitachi/hnas/snmp/plugin.pm 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/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 From d83640604db4d89c4c4bc55ab89cc89dfa7b0b80 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 26 Aug 2016 17:02:42 +0200 Subject: [PATCH 029/103] + Fix #231 --- .../snmp/mode/components/component.pm | 101 +++++++++++++++++ .../standard/snmp/mode/components/dkc.pm | 82 ++++++++++++++ .../standard/snmp/mode/components/dku.pm | 78 +++++++++++++ .../hitachi/standard/snmp/mode/hardware.pm | 106 ++++++++++++++++++ .../storage/hitachi/standard/snmp/plugin.pm | 48 ++++++++ 5 files changed, 415 insertions(+) create mode 100644 centreon-plugins/storage/hitachi/standard/snmp/mode/components/component.pm create mode 100644 centreon-plugins/storage/hitachi/standard/snmp/mode/components/dkc.pm create mode 100644 centreon-plugins/storage/hitachi/standard/snmp/mode/components/dku.pm create mode 100644 centreon-plugins/storage/hitachi/standard/snmp/mode/hardware.pm create mode 100644 centreon-plugins/storage/hitachi/standard/snmp/plugin.pm 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 From aa52322efe284abed53fff2f7d07c88433d03a75 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 29 Aug 2016 11:04:24 +0200 Subject: [PATCH 030/103] + fix clariion sp mode --- .../centreon/common/emc/navisphere/mode/sp.pm | 134 ++++++++++++++---- 1 file changed, 106 insertions(+), 28 deletions(-) diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm index 06eef859d..b8e9b7f00 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/sp.pm @@ -18,38 +18,116 @@ # limitations under the License. # -package centreon::common::emc::navisphere::mode::spcomponents::sp; +package centreon::common::emc::navisphere::mode::sp; + +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -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_filter(section => 'sp')); +sub set_system { + my ($self, %options) = @_; - # SP A State: Present - while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { - my $instance = $1; - my $state = $2; - - 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) - ); - 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)); - } - } + $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']; } -1; \ No newline at end of file +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, 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' }, + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check status of storage processor. + +=over 8 + +=item B<--getcrus-options> + +Set option for 'getcrus' command (Default: '-all'). +'-all' option is for some new flare version. + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'fan', 'lcc', 'psu', 'battery', 'memory', 'cpu', 'iomodule', 'cable'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=lcc --filter=fan) +Can also exclude specific instance: --filter=fan,1.2 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=back + +=cut \ No newline at end of file From 473436eb8f211e226b90f37e769daaf9c4a770e1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 29 Aug 2016 14:25:04 +0200 Subject: [PATCH 031/103] + add hp storeonce ssh plugin --- .../storage/hp/storeonce/ssh/custom/custom.pm | 170 ++++++++++++++++++ .../storeonce/ssh/mode/components/hardware.pm | 97 ++++++++++ .../ssh/mode/components/serviceset.pm | 85 +++++++++ .../storage/hp/storeonce/ssh/mode/hardware.pm | 126 +++++++++++++ .../storage/hp/storeonce/ssh/plugin.pm | 49 +++++ 5 files changed, 527 insertions(+) create mode 100644 centreon-plugins/storage/hp/storeonce/ssh/custom/custom.pm create mode 100644 centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm create mode 100644 centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm create mode 100644 centreon-plugins/storage/hp/storeonce/ssh/mode/hardware.pm create mode 100644 centreon-plugins/storage/hp/storeonce/ssh/plugin.pm 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..4c86dd885 --- /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..a6d44aac1 --- /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 From dd102898a30303939c0d601e5c26421c692ca939 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Sep 2016 11:45:58 +0200 Subject: [PATCH 032/103] + add plugin for overland snmp --- centreon-plugins/centreon/plugins/snmp.pm | 4 +- .../neo/snmp/mode/components/drive.pm | 74 ++++++++++ .../neo/snmp/mode/components/library.pm | 71 ++++++++++ .../overland/neo/snmp/mode/eventlog.pm | 131 ++++++++++++++++++ .../overland/neo/snmp/mode/hardware.pm | 107 ++++++++++++++ .../storage/overland/neo/snmp/plugin.pm | 50 +++++++ 6 files changed, 436 insertions(+), 1 deletion(-) create mode 100644 centreon-plugins/storage/overland/neo/snmp/mode/components/drive.pm create mode 100644 centreon-plugins/storage/overland/neo/snmp/mode/components/library.pm create mode 100644 centreon-plugins/storage/overland/neo/snmp/mode/eventlog.pm create mode 100644 centreon-plugins/storage/overland/neo/snmp/mode/hardware.pm create mode 100644 centreon-plugins/storage/overland/neo/snmp/plugin.pm diff --git a/centreon-plugins/centreon/plugins/snmp.pm b/centreon-plugins/centreon/plugins/snmp.pm index 069d8b879..448a4cada 100644 --- a/centreon-plugins/centreon/plugins/snmp.pm +++ b/centreon-plugins/centreon/plugins/snmp.pm @@ -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/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 From 72757979a26fea222002e9a00460b293dcf36ac5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Sep 2016 16:26:48 +0200 Subject: [PATCH 033/103] + add plugin for hp-ux in snmp (Fix #13) --- centreon-plugins/os/hpux/snmp/mode/cpu.pm | 159 +++++++++++++ centreon-plugins/os/hpux/snmp/mode/load.pm | 139 ++++++++++++ centreon-plugins/os/hpux/snmp/mode/memory.pm | 175 ++++++++++++++ centreon-plugins/os/hpux/snmp/mode/process.pm | 199 ++++++++++++++++ centreon-plugins/os/hpux/snmp/mode/storage.pm | 214 ++++++++++++++++++ centreon-plugins/os/hpux/snmp/plugin.pm | 54 +++++ 6 files changed, 940 insertions(+) create mode 100644 centreon-plugins/os/hpux/snmp/mode/cpu.pm create mode 100644 centreon-plugins/os/hpux/snmp/mode/load.pm create mode 100644 centreon-plugins/os/hpux/snmp/mode/memory.pm create mode 100644 centreon-plugins/os/hpux/snmp/mode/process.pm create mode 100644 centreon-plugins/os/hpux/snmp/mode/storage.pm create mode 100644 centreon-plugins/os/hpux/snmp/plugin.pm 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..426885d78 --- /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', + 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', + 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', + 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', + 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 From cd0529625ff3916d13611e860867d1fe484d982e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 2 Sep 2016 10:21:22 +0200 Subject: [PATCH 034/103] + prepare new version --- centreon-plugins/centreon/plugins/script.pm | 2 +- centreon-plugins/changelog | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/plugins/script.pm b/centreon-plugins/centreon/plugins/script.pm index a5f0bb9bb..91dec7855 100644 --- a/centreon-plugins/centreon/plugins/script.pm +++ b/centreon-plugins/centreon/plugins/script.pm @@ -30,7 +30,7 @@ use Pod::Find qw(pod_where); my %handlers = (DIE => {}); -my $global_version = 20160803; +my $global_version = 20160902; my $alternative_fatpacker = 0; sub new { diff --git a/centreon-plugins/changelog b/centreon-plugins/changelog index fbd05c73c..5ca6549db 100644 --- a/centreon-plugins/changelog +++ b/centreon-plugins/changelog @@ -1,3 +1,11 @@ +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 From 0b4034a2eee41de3d7df6d793baa46387a62af86 Mon Sep 17 00:00:00 2001 From: Zehir Date: Fri, 2 Sep 2016 16:01:02 +0200 Subject: [PATCH 035/103] Update git url http://git.centreon.com/centreon-plugins.git do not exist --- centreon-plugins/docs/fr/developer/guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/docs/fr/developer/guide.rst b/centreon-plugins/docs/fr/developer/guide.rst index 294e1dbd1..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 From db3ea6cfcfa5f49b3ed86d5b8c0deaab2c3f51e5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 2 Sep 2016 16:13:19 +0200 Subject: [PATCH 036/103] + minor update doc --- centreon-plugins/README.md | 2 +- centreon-plugins/docs/en/developer/guide.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/docs/en/developer/guide.rst b/centreon-plugins/docs/en/developer/guide.rst index bc741a169..41dc32334 100644 --- a/centreon-plugins/docs/en/developer/guide.rst +++ b/centreon-plugins/docs/en/developer/guide.rst @@ -14,7 +14,7 @@ There are 3 chapters: * :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: http://git.centreon.com/centreon-plugins.git +The lastest version is available on following git repository: https://github.com/centreon/centreon-plugins.git .. _quick-start: From 43572301395f2c83922d6cc3e47b1bf006f26993 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 5 Sep 2016 14:44:20 +0200 Subject: [PATCH 037/103] + add storagetek SLxxx SNMP plugin --- .../storagetek/sl/snmp/mode/components/cap.pm | 66 ++++++++++ .../sl/snmp/mode/components/controller.pm | 67 ++++++++++ .../sl/snmp/mode/components/elevator.pm | 67 ++++++++++ .../storagetek/sl/snmp/mode/components/fan.pm | 67 ++++++++++ .../sl/snmp/mode/components/interface.pm | 69 +++++++++++ .../storagetek/sl/snmp/mode/components/psu.pm | 67 ++++++++++ .../sl/snmp/mode/components/resources.pm | 46 +++++++ .../sl/snmp/mode/components/robot.pm | 67 ++++++++++ .../sl/snmp/mode/components/temperature.pm | 84 +++++++++++++ .../sl/snmp/mode/components/turntable.pm | 67 ++++++++++ .../storagetek/sl/snmp/mode/hardware.pm | 117 ++++++++++++++++++ .../storage/storagetek/sl/snmp/plugin.pm | 48 +++++++ 12 files changed, 832 insertions(+) create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/cap.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/controller.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/elevator.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/fan.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/interface.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/psu.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/resources.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/robot.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/components/turntable.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/mode/hardware.pm create mode 100644 centreon-plugins/storage/storagetek/sl/snmp/plugin.pm 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 From 264d4f5ae3c177a8e771e8efd459de96fb054575 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 6 Sep 2016 17:55:44 +0200 Subject: [PATCH 038/103] + Fix #486 --- centreon-plugins/network/h3c/snmp/mode/hardware.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/h3c/snmp/mode/hardware.pm b/centreon-plugins/network/h3c/snmp/mode/hardware.pm index 8e1903c03..55000458d 100644 --- a/centreon-plugins/network/h3c/snmp/mode/hardware.pm +++ b/centreon-plugins/network/h3c/snmp/mode/hardware.pm @@ -170,7 +170,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $self->{statefile_cache}->check_options(%options); } From 38384a22233f0d2158db14e67c855cb4790b300f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 8 Sep 2016 15:10:12 +0200 Subject: [PATCH 039/103] + add plugin hp storeonce rest api (WIP) --- .../hp/storeonce/restapi/custom/api.pm | 196 ++++++++++++ .../storeonce/restapi/mode/servicesetusage.pm | 289 ++++++++++++++++++ .../storage/hp/storeonce/restapi/plugin.pm | 47 +++ 3 files changed, 532 insertions(+) create mode 100644 centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm create mode 100644 centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm create mode 100644 centreon-plugins/storage/hp/storeonce/restapi/plugin.pm 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..ebdc6155f --- /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); + }; + 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/servicesetusage.pm b/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm new file mode 100644 index 000000000..680c5729b --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.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::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}->{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 => '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 => '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'), + } + }, + { 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 => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /^(?!(running)$)/i' }, + "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; + } + } +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{scs} = {}; + my $result = $options{custom}->get(path => '/cluster/servicesets'); + 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}, + status => $entry->{properties}->{status}, + 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: -). +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /^(?!(running)$)/'). +Can used special variables like: %{status}, %{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..3cc9e4817 --- /dev/null +++ b/centreon-plugins/storage/hp/storeonce/restapi/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 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}} = ( + '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. From 8e7fb2b339ebf6ec9004440ab2010324ef8f6810 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 9 Sep 2016 11:52:23 +0200 Subject: [PATCH 040/103] + Enhance error message --- .../apps/protocols/udp/mode/connection.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/centreon-plugins/apps/protocols/udp/mode/connection.pm b/centreon-plugins/apps/protocols/udp/mode/connection.pm index 2c12f81da..47ce6af46 100644 --- a/centreon-plugins/apps/protocols/udp/mode/connection.pm +++ b/centreon-plugins/apps/protocols/udp/mode/connection.pm @@ -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})); From d66a69d80eba396dc773f31160d754d47db5c110 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 9 Sep 2016 15:28:02 +0200 Subject: [PATCH 041/103] + Fix #490 --- .../hardware/printers/standard/rfc3805/mode/markersupply.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm index 94662b888..a8ce3512b 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/markersupply.pm @@ -103,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) { From 921b83c5d23bf1c4847865ca22eebcc4d1a749d4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 9 Sep 2016 15:44:03 +0200 Subject: [PATCH 042/103] + Fix command for root user --- .../storage/hp/storeonce/ssh/mode/components/hardware.pm | 2 +- .../storage/hp/storeonce/ssh/mode/components/serviceset.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm index 4c86dd885..904d1ee0b 100644 --- a/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm +++ b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/hardware.pm @@ -65,7 +65,7 @@ sub check { $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); + return if ($self->{result} !~ /[>#]\s*hardware show status details(.*?)\n[>#]/msi); my $content = $1; while ($content =~ /^(\S+[^\n]*?)\n\s+(.*?)\n\s*?\n/msgi) { diff --git a/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm index a6d44aac1..d66455694 100644 --- a/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm +++ b/centreon-plugins/storage/hp/storeonce/ssh/mode/components/serviceset.pm @@ -56,7 +56,7 @@ sub check { $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); + return if ($self->{result} !~ /[>#]\s*serviceset show status(.*?)\n[>#]/msi); my $content = $1; while ($content =~ /^Service Set (\d+).*?\n(.*?)\n\s*?\n/msgi) { From 95a028fb30eafa7486f8c5043171f844cc2c4ca5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 12 Sep 2016 16:39:17 +0200 Subject: [PATCH 043/103] + Ref #468 (WIP) --- .../standard/snmp/mode/components/card.pm | 67 ++++++++ .../standard/snmp/mode/components/entity.pm | 69 ++++++++ .../standard/snmp/mode/components/fan.pm | 78 +++++++++ .../standard/snmp/mode/components/psu.pm | 66 ++++++++ .../snmp/mode/components/resources.pm | 68 ++++++++ .../snmp/mode/components/temperature.pm | 70 ++++++++ .../network/nortel/standard/snmp/mode/cpu.pm | 155 ++++++++++++++++++ .../nortel/standard/snmp/mode/hardware.pm | 138 ++++++++++++++++ .../network/nortel/standard/snmp/plugin.pm | 52 ++++++ 9 files changed, 763 insertions(+) create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/components/card.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/components/entity.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/components/fan.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/components/psu.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/components/resources.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/cpu.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/hardware.pm create mode 100644 centreon-plugins/network/nortel/standard/snmp/plugin.pm 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/plugin.pm b/centreon-plugins/network/nortel/standard/snmp/plugin.pm new file mode 100644 index 000000000..225edd25e --- /dev/null +++ b/centreon-plugins/network/nortel/standard/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 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', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Nortel switch/routers in SNMP. +Can be used for avaya equipments also. + +=cut From 9af27e0b1796e256217be494e9336e1321c69941 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Sep 2016 10:45:10 +0200 Subject: [PATCH 044/103] + fix hp-ux cpu threshold --- centreon-plugins/os/hpux/snmp/mode/cpu.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/centreon-plugins/os/hpux/snmp/mode/cpu.pm b/centreon-plugins/os/hpux/snmp/mode/cpu.pm index 426885d78..baba0bc0b 100644 --- a/centreon-plugins/os/hpux/snmp/mode/cpu.pm +++ b/centreon-plugins/os/hpux/snmp/mode/cpu.pm @@ -36,7 +36,7 @@ sub set_counters { { 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', + 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 => '%' }, ], @@ -45,7 +45,7 @@ sub set_counters { { 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', + 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 => '%' }, ], @@ -54,7 +54,7 @@ sub set_counters { { 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', + 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 => '%' }, ], @@ -63,7 +63,7 @@ sub set_counters { { 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', + 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 => '%' }, ], From 6b02bac75f010f3c64486b631e4d6d899a96e3cd Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Sep 2016 11:15:04 +0200 Subject: [PATCH 045/103] + Fix #468 --- .../nortel/standard/snmp/mode/memory.pm | 107 ++++++++++++++++++ .../network/nortel/standard/snmp/plugin.pm | 1 + 2 files changed, 108 insertions(+) create mode 100644 centreon-plugins/network/nortel/standard/snmp/mode/memory.pm 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 index 225edd25e..5d64bc2e9 100644 --- a/centreon-plugins/network/nortel/standard/snmp/plugin.pm +++ b/centreon-plugins/network/nortel/standard/snmp/plugin.pm @@ -35,6 +35,7 @@ sub new { '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; From a4b1beb4f0ec223bc99231a20e25c05a449c04fa Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Sep 2016 15:07:42 +0200 Subject: [PATCH 046/103] + Fix division by zero --- .../centreon/common/emc/navisphere/mode/disk.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm index a5bf080e5..3971afccc 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm @@ -81,7 +81,11 @@ sub custom_utils_calc { 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; From f3bd0f59957f975e13ea942b9befb9d25d3d7a18 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Sep 2016 15:24:04 +0200 Subject: [PATCH 047/103] + upde hp storeonce restapi --- .../hp/storeonce/restapi/custom/api.pm | 2 +- .../hp/storeonce/restapi/mode/clusterusage.pm | 297 ++++++++++++++++++ .../hp/storeonce/restapi/mode/fcsusage.pm | 235 ++++++++++++++ .../storeonce/restapi/mode/servicesetusage.pm | 34 +- .../storage/hp/storeonce/restapi/plugin.pm | 2 + 5 files changed, 557 insertions(+), 13 deletions(-) create mode 100644 centreon-plugins/storage/hp/storeonce/restapi/mode/clusterusage.pm create mode 100644 centreon-plugins/storage/hp/storeonce/restapi/mode/fcsusage.pm diff --git a/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm b/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm index ebdc6155f..ebec97e7f 100644 --- a/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm +++ b/centreon-plugins/storage/hp/storeonce/restapi/custom/api.pm @@ -141,7 +141,7 @@ sub get { critical_status => '', warning_status => ''); my $content; eval { - $content = XMLin($response); + $content = XMLin($response, ForceArray => $options{ForceArray}); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@"); 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 index 680c5729b..f18079799 100644 --- a/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm +++ b/centreon-plugins/storage/hp/storeonce/restapi/mode/servicesetusage.pm @@ -54,14 +54,15 @@ sub custom_status_threshold { sub custom_status_output { my ($self, %options) = @_; - my $msg = 'status : ' . $self->{result_values}->{status}; + my $msg = 'status : ' . $self->{result_values}->{health}; return $msg; } sub custom_status_calc { my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + + $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; } @@ -139,7 +140,7 @@ sub set_counters { $self->{maps_counters}->{scs} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'display' } ], + 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; }, @@ -176,8 +177,8 @@ sub new { $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} =~ /^(?!(running)$)/i' }, + "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' }, }); @@ -209,11 +210,19 @@ sub change_macros { } } +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'); + 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 '' && @@ -224,7 +233,8 @@ sub manage_selection { $self->{scs}->{$entry->{properties}->{ssid}} = { display => $entry->{properties}->{alias}, - status => $entry->{properties}->{status}, + 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} }; @@ -258,13 +268,13 @@ Filter service set name (can be a regexp). =item B<--warning-status> -Set warning threshold for status (Default: -). -Can used special variables like: %{status}, %{display} +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: '%{status} =~ /^(?!(running)$)/'). -Can used special variables like: %{status}, %{display} +Set critical threshold for status (Default: '%{health} =~ /critical/'). +Can used special variables like: %{health}, %{housekeeping_health}, %{display} =item B<--warning-*> diff --git a/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm b/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm index 3cc9e4817..9ed7fa1d3 100644 --- a/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm +++ b/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm @@ -31,6 +31,8 @@ sub new { $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', ); From 0c5b6ae8b8302fdf307f50ae2b93e8663b754e04 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 13 Sep 2016 16:40:38 +0200 Subject: [PATCH 048/103] + update regex --- .../centreon/common/emc/navisphere/mode/hbastate.pm | 2 +- .../centreon/common/emc/navisphere/mode/portstate.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm index 3870a8cf3..4cb719d17 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/hbastate.pm @@ -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/portstate.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm index 517f3c340..6a01c8327 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/portstate.pm @@ -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 From 61465484418af80b905377f99f641871b036a4d3 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 14 Sep 2016 14:58:36 +0200 Subject: [PATCH 049/103] + enhance cisco asa failover mode (WIP) --- .../network/cisco/asa/mode/failover.pm | 188 +++++++++++++++--- 1 file changed, 157 insertions(+), 31 deletions(-) diff --git a/centreon-plugins/network/cisco/asa/mode/failover.pm b/centreon-plugins/network/cisco/asa/mode/failover.pm index 48df71ae8..b38fe66d3 100644 --- a/centreon-plugins/network/cisco/asa/mode/failover.pm +++ b/centreon-plugins/network/cisco/asa/mode/failover.pm @@ -20,33 +20,97 @@ 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 %map_failover = ( - 1 => 'other', - 2 => 'up', # for '.4' index - 3 => 'down', # can be - 4 => 'error', # maybe - 5 => 'overTemp', - 6 => 'busy', - 7 => 'noMedia', - 8 => 'backup', - 9 => 'active', # can be - 10 => 'standby' # can be -); +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_change_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_change_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', diff => 1 }, { name => 'secondary_state', diff => 1 }, { 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); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "dont-warn-notstandby" => { name => 'dont_warn_notstandby' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '' }, }); return $self; @@ -54,7 +118,20 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%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; + } + } } sub run { @@ -63,20 +140,9 @@ sub run { 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); - 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})) { @@ -97,6 +163,45 @@ sub run { $self->{output}->exit(); } +my %map_failover = ( + 1 => 'other', + 2 => 'up', # for '.4' index + 3 => 'down', # can be + 4 => 'error', # maybe + 5 => 'overTemp', + 6 => 'busy', + 7 => 'noMedia', + 8 => 'backup', + 9 => 'active', # can be + 10 => 'standby' # can be +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = {}; + + # 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 = $options{snmp}->get_leef(oids => [$oid_cfwHardwareStatusValue_primary, $oid_cfwHardwareStatusValue_secondary, + $oid_cfwHardwareStatusDetail_primary, $oid_cfwHardwareStatusDetail_secondary], nothing_quit => 1); + + $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->{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; __END__ @@ -107,9 +212,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 From cdcd68c43efaa78bf6cef2ae5f2d97b0bac72355 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 14 Sep 2016 16:26:52 +0200 Subject: [PATCH 050/103] + Fix failover asa mode --- .../network/cisco/asa/mode/failover.pm | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/centreon-plugins/network/cisco/asa/mode/failover.pm b/centreon-plugins/network/cisco/asa/mode/failover.pm index b38fe66d3..74e5ad9ff 100644 --- a/centreon-plugins/network/cisco/asa/mode/failover.pm +++ b/centreon-plugins/network/cisco/asa/mode/failover.pm @@ -52,7 +52,7 @@ sub custom_status_threshold { return $status; } -sub custom_change_output { +sub custom_status_output { my ($self, %options) = @_; my $msg = sprintf("Primary unit is '%s' [details: '%s'], Secondary unit is '%s' [details : '%s']", @@ -61,7 +61,7 @@ sub custom_change_output { return $msg; } -sub custom_change_calc { +sub custom_status_calc { my ($self, %options) = @_; $self->{result_values}->{primaryStateLast} = $options{old_datas}->{$self->{instance} . '_primary_state'}; @@ -91,7 +91,7 @@ sub set_counters { } }, { label => 'status', threshold => 0, set => { - key_values => [ { name => 'primary_state', diff => 1 }, { name => 'secondary_state', diff => 1 }, { name => 'primary_details' }, { name => 'secondary_details' } ], + 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; }, @@ -134,35 +134,6 @@ sub change_macros { } } -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $active_units = 0; - my $exit = 'ok'; - - - - if ($active_units == 0) { - $exit = 'critical'; - } elsif ($active_units == 1 && !defined($self->{option_results}->{dont_warn_notstandby})) { - # No redundant interface - $exit = 'warning'; - } - - $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(); -} - my %map_failover = ( 1 => 'other', 2 => 'up', # for '.4' index From 36a636906902dd0d8fd25b8c3035ff2ae694e955 Mon Sep 17 00:00:00 2001 From: Bertrand Cournaud Date: Thu, 15 Sep 2016 08:30:39 +0200 Subject: [PATCH 051/103] MAP 4 - Add element check --- .../apps/centreon/map/jmx/mode/elements.pm | 112 ++++++++++++++++++ .../apps/centreon/map/jmx/plugin.pm | 1 + 2 files changed, 113 insertions(+) create mode 100644 centreon-plugins/apps/centreon/map/jmx/mode/elements.pm diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm b/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm new file mode 100644 index 000000000..7546b8ceb --- /dev/null +++ b/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm @@ -0,0 +1,112 @@ +# 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::centreon::map::jmx::mode::elements; + +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) = @_; + # $options{snmp} = snmp object + $self->{connector} = $options{custom}; + + $self->{request} = [ + { mbean => "com.centreon.studio.map:name=BusinessElement,type=repo" } + ]; + + my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); + + my $elements = $result->{"com.centreon.studio.map:name=BusinessElements,type=repo"}->{LoadedModelCount}; + + my $exit = $self->{perfdata}->threshold_check(value => $elements, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Element loaded : %d", + $result->{"com.centreon.studio.map:name=BusinessElements,type=repo"}->{LoadedModelCount})); + + $self->{output}->perfdata_add(label => 'elements', + value => $result->{"com.centreon.studio.map:name=BusinessElements,type=repo"}->{LoadedModelCount}, + 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 Centreon Map Open Gates + +Example: + +perl centreon_plugins.pl --plugin=apps::centreon::map::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=elements + +=over 8 + +=item B<--warning> + +Set this threshold if you want a warning if opened gates match condition + +=item B<--critical> + +Set this threshold if you want a warning if opened gates match condition + +=back + +=cut + diff --git a/centreon-plugins/apps/centreon/map/jmx/plugin.pm b/centreon-plugins/apps/centreon/map/jmx/plugin.pm index 2fb2c9626..b10314136 100644 --- a/centreon-plugins/apps/centreon/map/jmx/plugin.pm +++ b/centreon-plugins/apps/centreon/map/jmx/plugin.pm @@ -32,6 +32,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( 'gates' => 'apps::centreon::map::jmx::mode::gates', + 'elements' => 'apps::centreon::map::jmx::mode::elements', 'sessions' => 'apps::centreon::map::jmx::mode::sessions', 'event-queue' => 'apps::centreon::map::jmx::mode::eventqueue', 'event-statistics' => 'apps::centreon::map::jmx::mode::eventstatistics', From f1b68786b5aa1a5664d28c359fffcb4f3b986bb1 Mon Sep 17 00:00:00 2001 From: Bertrand Cournaud Date: Thu, 15 Sep 2016 08:49:45 +0200 Subject: [PATCH 052/103] MAP 4 - Fix element mode --- centreon-plugins/apps/centreon/map/jmx/mode/elements.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm b/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm index 7546b8ceb..2a32cc591 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm @@ -64,17 +64,17 @@ sub run { my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); - my $elements = $result->{"com.centreon.studio.map:name=BusinessElements,type=repo"}->{LoadedModelCount}; + my $elements = $result->{"com.centreon.studio.map:name=BusinessElement,type=repo"}->{LoadedModelCount}; my $exit = $self->{perfdata}->threshold_check(value => $elements, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Element loaded : %d", - $result->{"com.centreon.studio.map:name=BusinessElements,type=repo"}->{LoadedModelCount})); + $result->{"com.centreon.studio.map:name=BusinessElement,type=repo"}->{LoadedModelCount})); $self->{output}->perfdata_add(label => 'elements', - value => $result->{"com.centreon.studio.map:name=BusinessElements,type=repo"}->{LoadedModelCount}, + value => $result->{"com.centreon.studio.map:name=BusinessElement,type=repo"}->{LoadedModelCount}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); From 055a884da5307c5e6d39c50f1082d93cc513a96c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 15 Sep 2016 10:38:47 +0200 Subject: [PATCH 053/103] + fix indent --- centreon-plugins/apps/centreon/map/jmx/mode/elements.pm | 1 - centreon-plugins/apps/centreon/map/jmx/plugin.pm | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm b/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm index 2a32cc591..d9a6d9f26 100644 --- a/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm +++ b/centreon-plugins/apps/centreon/map/jmx/mode/elements.pm @@ -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 3735d109e..f36f661f1 100644 --- a/centreon-plugins/apps/centreon/map/jmx/plugin.pm +++ b/centreon-plugins/apps/centreon/map/jmx/plugin.pm @@ -31,7 +31,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( 'gates' => 'apps::centreon::map::jmx::mode::gates', - 'elements' => 'apps::centreon::map::jmx::mode::elements', + 'elements' => 'apps::centreon::map::jmx::mode::elements', 'sessions' => 'apps::centreon::map::jmx::mode::sessions', 'event-queue' => 'apps::centreon::map::jmx::mode::eventqueue', 'event-statistics' => 'apps::centreon::map::jmx::mode::eventstatistics', From 78c6de7774fa70c6179ae904fca5ef1a90bfba6d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 19 Sep 2016 15:14:22 +0200 Subject: [PATCH 054/103] + add plugin gorgy ntp server snmp --- .../gorgy/ntpserver/snmp/mode/globalstatus.pm | 243 ++++++++++++++++++ .../devices/gorgy/ntpserver/snmp/plugin.pm | 50 ++++ 2 files changed, 293 insertions(+) create mode 100644 centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm create mode 100644 centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/plugin.pm diff --git a/centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm b/centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm new file mode 100644 index 000000000..8cf1ce05b --- /dev/null +++ b/centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm @@ -0,0 +1,243 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::devices::gorgy::ntpserver::snmp::mode::globalstatus; + +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_' . $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_sync_status_output { + my ($self, %options) = @_; + + my $msg = 'Current synchronization status : ' . $self->{result_values}->{sync_status}; + return $msg; +} + +sub custom_timebase_status_output { + my ($self, %options) = @_; + + my $msg = 'Internal time base status : ' . $self->{result_values}->{timebase_status}; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{$options{extra_options}->{label_ref}} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}}; + $self->{result_values}->{label} = $options{extra_options}->{label_ref}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, message_separator => ' - ' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'sync-status', threshold => 0, set => { + key_values => [ { name => 'sync_status' } ], + closure_custom_calc => $self->can('custom_status_calc'), closure_custom_calc_extra_options => { label_ref => 'sync_status' }, + closure_custom_output => $self->can('custom_sync_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'timebase-status', threshold => 0, set => { + key_values => [ { name => 'timebase_status' } ], + closure_custom_calc => $self->can('custom_status_calc'), closure_custom_calc_extra_options => { label_ref => 'timebase_status' }, + closure_custom_output => $self->can('custom_timebase_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'ntp-requests', set => { + key_values => [ { name => 'ntp_requests', diff => 1 } ], + output_template => 'Number of ntp requests : %s', + perfdatas => [ + { label => 'ntp_requests', value => 'ntp_requests_absolute', template => '%s', + min => 0 }, + ], + } + }, + ]; +} + +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-sync-status:s" => { name => 'warning_sync_status', default => '%{sync_status} =~ /Running with autonomy|Free running/i' }, + "critical-sync-status:s" => { name => 'critical_sync_status', default => '%{sync_status} =~ /Server locked|Never synchronized|Server not synchronized/i' }, + "warning-timebase-status:s" => { name => 'warning_timebase_status', default => '%{timebase_status} =~ /^(?!(XO|XO OK|TCXO Precision < 2usec|OCXO Precision < 1usec)$)/i' }, + "critical-timebase-status:s" => { name => 'critical_timebase_status', default => '%{timebase_status} =~ /^XO$/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_sync_status', 'critical_sync_status', 'warning_timebase_status', 'critical_timebase_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +# timeBaseState values: +# XO Warming up... +# XO OK +# TCXO +# TCXO Precision > 25usec +# 2usec < TCXO Precision < 25usec +# TCXO Precision < 2usec +# OCXO Warming up... +# OCXO Precision > 20usec +# 1usec < OCXO Precision < 20usec +# OCXO Precision < 1usec +# XO + +# currentSyncState values: +# Server locked +# Free running +# Never synchronized +# Server synchronized +# Running with autonomy +# Server not synchronized +# Computing synchronization + +my $mapping = { + currentSyncState => { oid => '.1.3.6.1.4.1.8955.1.8.1.10' }, + timeBaseState => { oid => '.1.3.6.1.4.1.8955.1.8.1.12' }, + powerDownFlags => { oid => '.1.3.6.1.4.1.8955.1.8.1.20' }, + ntpRequestsNumber => { oid => '.1.3.6.1.4.1.8955.1.8.2.3' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef(oids => [ + $mapping->{currentSyncState}->{oid} . '.0', + $mapping->{timeBaseState}->{oid} . '.0', + $mapping->{powerDownFlags}->{oid} . '.0', + $mapping->{ntpRequestsNumber}->{oid} . '.0', + ], + nothing_quit => 1); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0'); + $self->{global} = { sync_status => $result->{currentSyncState}, + timebase_status => $result->{timeBaseState}, + ntp_requests => $result->{ntpRequestsNumber} }; + + $self->{cache_name} = "gorgy_ntpserver_" . $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 ntp server status. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^sync-status$' + +=item B<--warning-sync-status> + +Set warning threshold for status (Default: '%{sync_status} =~ /Running with autonomy|Free running/i'). +Can used special variables like: %{sync_status} + +=item B<--critical-sync-status> + +Set critical threshold for status (Default: '%{sync_status} =~ /Server locked|Never synchronized|Server not synchronized/i'). +Can used special variables like: %{sync_status} + +=item B<--warning-timebase-status> + +Set warning threshold for status (Default: '%{timebase_status} =~ /^(?!(XO|XO OK|TCXO Precision < 2usec|OCXO Precision < 1usec)$)/i'). +Can used special variables like: %{timebase_status} + +=item B<--critical-timebase-status> + +Set critical threshold for status (Default: '%{timebase_status} =~ /^XO$/i'). +Can used special variables like: %{timebase_status} + +=item B<--warning-*> + +Threshold warning. +Can be: 'ntp-requests'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'ntp-requests'. + +=back + +=cut diff --git a/centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/plugin.pm b/centreon-plugins/hardware/devices/gorgy/ntpserver/snmp/plugin.pm new file mode 100644 index 000000000..6e6c2427d --- /dev/null +++ b/centreon-plugins/hardware/devices/gorgy/ntpserver/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::devices::gorgy::ntpserver::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::devices::gorgy::ntpserver::snmp::mode::globalstatus', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Gorgy ntp servers in SNMP. + +=cut From b2c09b78799a715ee8c33e35c396a19269a5f366 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 20 Sep 2016 15:33:16 +0200 Subject: [PATCH 055/103] + Fix session fortigate issue threshold Signed-off-by: garnier-quentin --- .../common/fortinet/fortigate/mode/sessions.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm index 65a2bc4e9..277df996e 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm @@ -56,7 +56,7 @@ sub check_options { } ($self->{warn1}, $self->{warn10}, $self->{warn30}, $self->{warn60}) = split /,/, $self->{option_results}->{warning_avg}; - ($self->{crit1}, $self->{crit10}, $self->{crit30}, $self->{warn60}) = split /,/, $self->{option_results}->{critical_avg}; + ($self->{crit1}, $self->{crit10}, $self->{crit30}, $self->{crit60}) = split /,/, $self->{option_results}->{critical_avg}; if (($self->{perfdata}->threshold_validate(label => 'warn1', value => $self->{warn1})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1} . "'."); @@ -115,13 +115,13 @@ sub run { min => 0); my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate1}, - threshold => [ { label => 'crit1', 'exit_litteral' => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit1', exit_litteral' => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate10}, - threshold => [ { label => 'crit10', 'exit_litteral' => 'critical' }, { label => 'warn10', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit10', exit_litteral => 'critical' }, { label => 'warn10', exit_litteral => 'warning' } ]); my $exit3 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate30}, - threshold => [ { label => 'crit30', 'exit_litteral' => 'critical' }, { label => 'warn30', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit30', exit_litteral => 'critical' }, { label => 'warn30', exit_litteral => 'warning' } ]); my $exit4 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate60}, - threshold => [ { label => 'crit60', 'exit_litteral' => 'critical' }, { label => 'warn60', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit60', exit_litteral => 'critical' }, { label => 'warn60', exit_litteral => 'warning' } ]); $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3, $exit4 ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Averate session setup rate: %s, %s, %s, %s (1min, 10min, 30min, 60min)", From 4802b0ecbd8f9351628787aac2d6f8af0081bb1c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 20 Sep 2016 15:51:28 +0200 Subject: [PATCH 056/103] + fix quote issue --- .../centreon/common/fortinet/fortigate/mode/sessions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm index 277df996e..e713285c3 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/mode/sessions.pm @@ -115,7 +115,7 @@ sub run { min => 0); my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate1}, - threshold => [ { label => 'crit1', exit_litteral' => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]); + threshold => [ { label => 'crit1', exit_litteral => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate10}, threshold => [ { label => 'crit10', exit_litteral => 'critical' }, { label => 'warn10', exit_litteral => 'warning' } ]); my $exit3 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate30}, From 79cdeb2b346a3eaf23654ccdf0876d7547cb4d18 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 20 Sep 2016 16:37:21 +0200 Subject: [PATCH 057/103] + some minor change --- centreon-plugins/centreon/plugins/options.pm | 2 +- centreon-plugins/centreon/plugins/perfdata.pm | 4 ++-- centreon-plugins/centreon/plugins/script.pm | 12 ++++++------ centreon-plugins/centreon/plugins/script_snmp.pm | 6 +++--- centreon-plugins/centreon/plugins/snmp.pm | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/centreon-plugins/centreon/plugins/options.pm b/centreon-plugins/centreon/plugins/options.pm index bbbc59b03..9395294ef 100644 --- a/centreon-plugins/centreon/plugins/options.pm +++ b/centreon-plugins/centreon/plugins/options.pm @@ -28,7 +28,7 @@ use warnings; my $alternative = 1; sub new { - my $class = shift; + my ($class) = @_; my $self = {}; bless $self, $class; diff --git a/centreon-plugins/centreon/plugins/perfdata.pm b/centreon-plugins/centreon/plugins/perfdata.pm index c857737fb..31dceeb79 100644 --- a/centreon-plugins/centreon/plugins/perfdata.pm +++ b/centreon-plugins/centreon/plugins/perfdata.pm @@ -114,9 +114,9 @@ sub trim { } sub parse_threshold { - my $self = shift; + my ($self, $perf) = @_; - my $perf = $self->trim($_[0]); + $perf = $self->trim($perf); my $arobase = 0; my $infinite_neg = 0; diff --git a/centreon-plugins/centreon/plugins/script.pm b/centreon-plugins/centreon/plugins/script.pm index 91dec7855..92a0e4a9e 100644 --- a/centreon-plugins/centreon/plugins/script.pm +++ b/centreon-plugins/centreon/plugins/script.pm @@ -34,7 +34,7 @@ my $global_version = 20160902; my $alternative_fatpacker = 0; sub new { - my $class = shift; + my ($class) = @_; my $self = {}; bless $self, $class; @@ -50,7 +50,7 @@ sub new { } sub prepare_destroy { - my $self = shift; + my ($self) = @_; delete $handlers{DIE}->{$self}; } @@ -79,7 +79,7 @@ sub handle_DIE { } sub get_plugin { - my $self = shift; + my ($self) = @_; ###### # Need to load global 'Output' and 'Options' @@ -122,7 +122,7 @@ sub get_plugin { } sub display_local_help { - my $self = shift; + my ($self) = @_; my $stdout; if ($self->{help}) { @@ -167,7 +167,7 @@ sub check_directory { } sub display_list_plugin { - my $self = shift; + my ($self) = @_; $self->{plugins_result} = {}; # Search file 'plugin.pm' @@ -247,7 +247,7 @@ sub check_relaunch { } sub run { - my $self = shift; + my ($self) = @_; $self->get_plugin(); diff --git a/centreon-plugins/centreon/plugins/script_snmp.pm b/centreon-plugins/centreon/plugins/script_snmp.pm index d04dbb017..e8d029a9e 100644 --- a/centreon-plugins/centreon/plugins/script_snmp.pm +++ b/centreon-plugins/centreon/plugins/script_snmp.pm @@ -125,7 +125,7 @@ sub init { } sub run { - my $self = shift; + my ($self) = @_; if ($self->{output}->is_disco_format()) { $self->{mode}->disco_format(); @@ -154,13 +154,13 @@ sub is_mode { } sub version { - my $self = shift; + my ($self) = @_; $self->{output}->add_option_msg(short_msg => "Plugin Version: " . $self->{version}); $self->{output}->option_exit(nolabel => 1); } sub list_mode { - my $self = shift; + my ($self) = @_; $self->{options}->display_help(); $self->{output}->add_option_msg(long_msg => "Modes Available:"); diff --git a/centreon-plugins/centreon/plugins/snmp.pm b/centreon-plugins/centreon/plugins/snmp.pm index 448a4cada..723cc43eb 100644 --- a/centreon-plugins/centreon/plugins/snmp.pm +++ b/centreon-plugins/centreon/plugins/snmp.pm @@ -596,7 +596,7 @@ sub set { } sub is_snmpv1 { - my $self = shift; + my ($self) = @_; if ($self->{snmp_params}->{Version} eq '1') { return 1; @@ -605,15 +605,15 @@ sub is_snmpv1 { } sub clean_oid { - my $self = shift; + my ($self, $oid) = @_; - $_[0] =~ s/\.$//; - $_[0] =~ s/^(\d)/\.$1/; - return $_[0]; + $oid =~ s/\.$//; + $oid =~ s/^(\d)/\.$1/; + return $oid; } sub check_oid_up { - my $self = shift; + my ($self) = @_; my ($current_oid, $end_oid) = @_; my @current_oid_splitted = split /\./, $current_oid; From a06f5d83c1daa3362de0bfcd88fe6be8ddc3893e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 22 Sep 2016 13:41:46 +0200 Subject: [PATCH 058/103] + enhance emc dmx plugin --- .../local/mode/components/environment.pm | 56 -------------- .../dmx34/local/mode/components/fru.pm | 75 +++++++++++++++++++ .../symmetrix/dmx34/local/mode/hardware.pm | 30 +++++--- 3 files changed, 93 insertions(+), 68 deletions(-) delete mode 100644 centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm create mode 100644 centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/fru.pm 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 deleted file mode 100644 index 8edda26ae..000000000 --- a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES 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/fru.pm b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/fru.pm new file mode 100644 index 000000000..c22b628dc --- /dev/null +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/components/fru.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::fru; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#FRU status (alarms) table: +# +#+---------------------+--------------------+-----------+ +#| Description | FRU/Alarm Status | Comm. | +#+---------------------+--------------------+-----------+ +#| Dir 01 | OK | 01A | +#| Dir 02 | OK | 02A | +#... +#| Backplane | OK | 01A,16A | +#+---------------------+--------------------+-----------+ +#| Description | FRU/Alarm Status | Comm. | +#+---------------------+--------------------+-----------+ +# +# +#Analog readings: + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking frus"); + $self->{components}->{fru} = {name => 'frus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fru')); + + if ($self->{content_file_health_env} !~ /FRU status .*? table:.*?---------.*?Description.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find frus'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|(.*?)\|.*?\n/msig) { + my ($fru, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'fru', instance => $fru)); + $self->{components}->{fru}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fru '%s' status is '%s'", + $fru, $status)); + my $exit = $self->get_severity(section => 'fru', value => $status); + 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'", + $fru, $status)); + } + } +} + +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 index 010a6a303..4ca886dad 100644 --- a/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/hardware.pm +++ b/centreon-plugins/storage/emc/symmetrix/dmx34/local/mode/hardware.pm @@ -54,10 +54,14 @@ sub set_system { ['\.\./.*', 'OK'], ['.*', 'CRITICAL'], ], + fru => [ + ['OK', 'OK'], + ['.*', 'CRITICAL'], + ], }; $self->{components_path} = 'storage::emc::symmetrix::dmx34::local::mode::components'; - $self->{components_module} = ['director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test']; + $self->{components_module} = ['director', 'xcm', 'disk', 'memory', 'config', 'test', 'fru']; } sub check_options { @@ -100,17 +104,19 @@ sub read_files { $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; + 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 Run From Scheduler Version 2.0 * @@ -247,7 +253,7 @@ Check hardware. =item B<--component> Which component to check (Default: '.*'). -Can be: 'director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test' +Can be: 'director', 'xcm', 'disk', 'memory', 'config', 'fru', 'test' =item B<--filter> From 8582dd6cba7f2de70b9ce338a80a96ebc6053210 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 22 Sep 2016 16:02:50 +0200 Subject: [PATCH 059/103] + add windows standalone exe procedure --- centreon-plugins/docs/en/user/guide.rst | 154 +++++++++++++++++++++++- 1 file changed, 153 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/docs/en/user/guide.rst b/centreon-plugins/docs/en/user/guide.rst index a6bca69b0..bc6e032d3 100644 --- a/centreon-plugins/docs/en/user/guide.rst +++ b/centreon-plugins/docs/en/user/guide.rst @@ -573,7 +573,159 @@ Build the standalone Perl file: 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='' + # 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='' + +--------------------------------------------- +Howto build a standalone Windows executable ? +--------------------------------------------- + +This is only useful if you want to compile your own "centreon_plugins.exe". You won't need to install perl on your windows server. + +* Install on Windows Strawberry Perl 5.24.x (Download on http://strawberryperl.com/) +* Trunk of centreon-plugins repository (Download on https://github.com/centreon/centreon-plugins/archive/master.zip) + +Once everything is installed, install CPAN Module "PAR::Packer" (replace ): +:: + + cmd> \perl\bin\cpan.bat + cpan> install PAR::Packer + +It can take several minutes to install the CPAN Module. + +In the parent directory containing the directory "centreon-plugins", create a "build.bat" file (replace ````). +We exclude the module ``IO::Socket::INET6`` (Perl 5.14 has the full set of IPv6 functions as part of its core Socket module). + +:: + + set PERL_INSTALL_DIR= + + chdir /d %~dp0 + set PAR_VERBATIM=1 + + cmd /C %PERL_INSTALL_DIR%\perl\site\bin\pp --lib=centreon-plugins\ -o centreon_plugins.exe centreon-plugins\centreon_plugins.pl ^ + --unicode ^ + -X IO::Socket::INET6 ^ + --link=%PERL_INSTALL_DIR%\c\bin\libxml2-2__.dll ^ + --link=%PERL_INSTALL_DIR%\c\bin\libiconv-2__.dll ^ + --link=%PERL_INSTALL_DIR%\c\bin\liblzma-5__.dll ^ + --link=%PERL_INSTALL_DIR%\c\bin\zlib1__.dll ^ + -M Win32::Job ^ + -M centreon::plugins::script ^ + -M centreon::plugins::alternative::Getopt ^ + -M apps::backup::netbackup::local::plugin ^ + -M apps::backup::netbackup::local::mode::dedupstatus ^ + -M apps::backup::netbackup::local::mode::drivecleaning ^ + -M apps::backup::netbackup::local::mode::drivestatus ^ + -M apps::backup::netbackup::local::mode::jobstatus ^ + -M apps::backup::netbackup::local::mode::listpolicies ^ + -M apps::backup::netbackup::local::mode::tapeusage ^ + -M apps::activedirectory::local::plugin ^ + -M apps::activedirectory::local::mode::dcdiag ^ + -M apps::activedirectory::local::mode::netdom ^ + -M apps::citrix::local::plugin ^ + -M apps::citrix::local::mode::license ^ + -M apps::citrix::local::mode::session ^ + -M apps::citrix::local::mode::zone ^ + -M apps::citrix::local::mode::folder ^ + -M apps::iis::local::plugin ^ + -M apps::iis::local::mode::listapplicationpools ^ + -M apps::iis::local::mode::applicationpoolstate ^ + -M apps::iis::local::mode::listsites ^ + -M apps::iis::local::mode::webservicestatistics ^ + -M apps::exchange::2010::local::plugin ^ + -M apps::exchange::2010::local::mode::activesyncmailbox ^ + -M apps::exchange::2010::local::mode::databases ^ + -M apps::exchange::2010::local::mode::listdatabases ^ + -M apps::exchange::2010::local::mode::imapmailbox ^ + -M apps::exchange::2010::local::mode::mapimailbox ^ + -M apps::exchange::2010::local::mode::outlookwebservices ^ + -M apps::exchange::2010::local::mode::owamailbox ^ + -M apps::exchange::2010::local::mode::queues ^ + -M apps::exchange::2010::local::mode::replicationhealth ^ + -M apps::exchange::2010::local::mode::services ^ + -M centreon::common::powershell::exchange::2010::powershell ^ + -M apps::cluster::mscs::local::plugin ^ + -M apps::cluster::mscs::local::mode::listnodes ^ + -M apps::cluster::mscs::local::mode::listresources ^ + -M apps::cluster::mscs::local::mode::networkstatus ^ + -M apps::cluster::mscs::local::mode::nodestatus ^ + -M apps::cluster::mscs::local::mode::resourcestatus ^ + -M apps::cluster::mscs::local::mode::resourcegroupstatus ^ + -M os::windows::local::plugin ^ + -M os::windows::local::mode::ntp ^ + -M os::windows::local::mode::rdpsessions ^ + -M storage::dell::compellent::local::plugin ^ + -M storage::dell::compellent::local::mode::hbausage ^ + -M storage::dell::compellent::local::mode::volumeusage ^ + --verbose + + pause + +Add plugins and modes you need in "centreon_plugins.exe" (the example add some plugins). +Eventually, execute "build.bat" file to create executable "centreon_plugins.exe". + +If you want to change the executable version and ico file, add following code after ``PERL_INSTALL_DIR`` first line: +:: + + set ICO_FILE=centreon.ico + set RC_FILE=centreon.rc + + chdir /d %~dp0 + + for /f "tokens=4 delims= " %%i in ('type centreon-plugins\centreon\plugins\script.pm ^| findstr global_version ^| findstr my') do set "VERSION_PLUGIN=%%i" + set VERSION_PLUGIN=%VERSION_PLUGIN:~0,8% + + ( + echo #define PP_MANIFEST_FILEFLAGS 0 + echo #include ^ + echo. + echo CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "winres\\pp.manifest" + echo. + echo VS_VERSION_INFO VERSIONINFO + echo FILEVERSION 0,0,0,0 + echo PRODUCTVERSION 0,0,0,0 + echo FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + echo FILEFLAGS PP_MANIFEST_FILEFLAGS + echo FILEOS VOS_NT_WINDOWS32 + echo FILETYPE VFT_APP + echo FILESUBTYPE VFT2_UNKNOWN + echo BEGIN + echo BLOCK "StringFileInfo" + echo BEGIN + echo BLOCK "000004B0" + echo BEGIN + echo VALUE "CompanyName", "Centreon\0" + echo VALUE "FileDescription", " \0" + echo VALUE "FileVersion", "1.0.0.0\0" + echo VALUE "InternalName", " \0" + echo VALUE "LegalCopyright", " \0" + echo VALUE "LegalTrademarks", " \0" + echo VALUE "OriginalFilename", " \0" + echo VALUE "ProductName", "centreon-plugins\0" + echo VALUE "ProductVersion", "%VERSION_PLUGIN%.0\0" + echo END + echo END + echo BLOCK "VarFileInfo" + echo BEGIN + echo VALUE "Translation", 0x00, 0x04B0 + echo END + echo END + echo. + echo WINEXE ICON winres\\pp.ico + )> %RC_FILE% + + for /f "delims=" %%i in ('dir /ad /B %PERL_INSTALL_DIR%\cpan\build\PAR-Packer-*') do set "PAR_PACKER_DIRNAME=%%i" + SET PAR_PACKER_SRC=%PERL_INSTALL_DIR%\cpan\build\%PAR_PACKER_DIRNAME% + + copy /Y %ICO_FILE% %PAR_PACKER_SRC%\myldr\winres\pp.ico + copy /Y centreon.rc %PAR_PACKER_SRC%\myldr\winres\pp.rc + del %PAR_PACKER_SRC%\myldr\ppresource.coff + cd /D %PAR_PACKER_SRC%\myldr\ && perl Makefile.PL + cd /D %PAR_PACKER_SRC%\myldr\ && dmake boot.exe + cd /D %PAR_PACKER_SRC%\myldr\ && dmake Static.pm + attrib -R %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm + copy /Y %PAR_PACKER_SRC%\myldr\Static.pm %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm + *************** Troubleshooting From fdcff50c2b0f393af005bff446717c2c6a82ca47 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 23 Sep 2016 10:47:37 +0200 Subject: [PATCH 060/103] + add french procedure --- centreon-plugins/docs/en/user/guide.rst | 15 ++- centreon-plugins/docs/fr/user/guide.rst | 156 ++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/docs/en/user/guide.rst b/centreon-plugins/docs/en/user/guide.rst index bc6e032d3..59f680b23 100644 --- a/centreon-plugins/docs/en/user/guide.rst +++ b/centreon-plugins/docs/en/user/guide.rst @@ -579,12 +579,12 @@ The plugin works in the same way: Howto build a standalone Windows executable ? --------------------------------------------- -This is only useful if you want to compile your own "centreon_plugins.exe". You won't need to install perl on your windows server. +This is only useful if you want to compile your own ``centreon_plugins.exe``. You won't need to install Perl on your windows server. * Install on Windows Strawberry Perl 5.24.x (Download on http://strawberryperl.com/) * Trunk of centreon-plugins repository (Download on https://github.com/centreon/centreon-plugins/archive/master.zip) -Once everything is installed, install CPAN Module "PAR::Packer" (replace ): +Once everything is installed, install CPAN Module ``PAR::Packer`` (replace ````): :: cmd> \perl\bin\cpan.bat @@ -592,7 +592,7 @@ Once everything is installed, install CPAN Module "PAR::Packer" (replace ``). +In the parent directory containing the directory ``centreon-plugins``, create a ``build.bat`` file (replace ````). We exclude the module ``IO::Socket::INET6`` (Perl 5.14 has the full set of IPv6 functions as part of its core Socket module). :: @@ -661,8 +661,8 @@ We exclude the module ``IO::Socket::INET6`` (Perl 5.14 has the full set of IPv6 pause -Add plugins and modes you need in "centreon_plugins.exe" (the example add some plugins). -Eventually, execute "build.bat" file to create executable "centreon_plugins.exe". +Add plugins and modes you need in ``centreon_plugins.exe`` (the example add some plugins). +Eventually, execute ``build.bat`` file to create executable ``centreon_plugins.exe``. If you want to change the executable version and ico file, add following code after ``PERL_INSTALL_DIR`` first line: :: @@ -726,6 +726,11 @@ If you want to change the executable version and ico file, add following code af attrib -R %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm copy /Y %PAR_PACKER_SRC%\myldr\Static.pm %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm +You can build a 32 bits binary from a Windows 64 bits: + +* Install Strawberry Perl 5.24.x 32 bits on Windows (Download on http://strawberryperl.com/) +* Install cpan module ``PAR::Packer`` +* Add following line in the build script : PATH=%PERL_INSTALL_DIR%\c\bin;%PERL_INSTALL_DIR%\perl\bin;C:\Windows\System32 *************** Troubleshooting diff --git a/centreon-plugins/docs/fr/user/guide.rst b/centreon-plugins/docs/fr/user/guide.rst index 6bdc66be1..83231273e 100644 --- a/centreon-plugins/docs/fr/user/guide.rst +++ b/centreon-plugins/docs/fr/user/guide.rst @@ -574,7 +574,163 @@ 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='' + +------------------------------------------ +Comment puis-je créer un binaire Windows ? +------------------------------------------ + +Cette procédure permet d'utiliser les sondes sans installer installer Perl sur le système Windows. + +* Installer Strawberry Perl 5.24.x sur un Windows (Télécharger sur http://strawberryperl.com/) +* Récupérer la dernière version des centreon-plugins (Télécharger https://github.com/centreon/centreon-plugins/archive/master.zip) + +Après les installations, installer le module ``PAR::Packer`` (remplacer ````): +:: + + cmd> \perl\bin\cpan.bat + cpan> install PAR::Packer + +L'installation peut prendre plusieurs minutes. + +Dans un dossier contenant le répertoire ``centreon-plugins``, créer un fichier ``build.bat`` (remplacer ````). +Nous excluons le module ``IO::Socket::INET6`` (Perl 5.14 intègre la fonctionnalité IPv6 en natif). + +:: + + set PERL_INSTALL_DIR= + + chdir /d %~dp0 + set PAR_VERBATIM=1 + cmd /C %PERL_INSTALL_DIR%\perl\site\bin\pp --lib=centreon-plugins\ -o centreon_plugins.exe centreon-plugins\centreon_plugins.pl ^ + --unicode ^ + -X IO::Socket::INET6 ^ + --link=%PERL_INSTALL_DIR%\c\bin\libxml2-2__.dll ^ + --link=%PERL_INSTALL_DIR%\c\bin\libiconv-2__.dll ^ + --link=%PERL_INSTALL_DIR%\c\bin\liblzma-5__.dll ^ + --link=%PERL_INSTALL_DIR%\c\bin\zlib1__.dll ^ + -M Win32::Job ^ + -M centreon::plugins::script ^ + -M centreon::plugins::alternative::Getopt ^ + -M apps::backup::netbackup::local::plugin ^ + -M apps::backup::netbackup::local::mode::dedupstatus ^ + -M apps::backup::netbackup::local::mode::drivecleaning ^ + -M apps::backup::netbackup::local::mode::drivestatus ^ + -M apps::backup::netbackup::local::mode::jobstatus ^ + -M apps::backup::netbackup::local::mode::listpolicies ^ + -M apps::backup::netbackup::local::mode::tapeusage ^ + -M apps::activedirectory::local::plugin ^ + -M apps::activedirectory::local::mode::dcdiag ^ + -M apps::activedirectory::local::mode::netdom ^ + -M apps::citrix::local::plugin ^ + -M apps::citrix::local::mode::license ^ + -M apps::citrix::local::mode::session ^ + -M apps::citrix::local::mode::zone ^ + -M apps::citrix::local::mode::folder ^ + -M apps::iis::local::plugin ^ + -M apps::iis::local::mode::listapplicationpools ^ + -M apps::iis::local::mode::applicationpoolstate ^ + -M apps::iis::local::mode::listsites ^ + -M apps::iis::local::mode::webservicestatistics ^ + -M apps::exchange::2010::local::plugin ^ + -M apps::exchange::2010::local::mode::activesyncmailbox ^ + -M apps::exchange::2010::local::mode::databases ^ + -M apps::exchange::2010::local::mode::listdatabases ^ + -M apps::exchange::2010::local::mode::imapmailbox ^ + -M apps::exchange::2010::local::mode::mapimailbox ^ + -M apps::exchange::2010::local::mode::outlookwebservices ^ + -M apps::exchange::2010::local::mode::owamailbox ^ + -M apps::exchange::2010::local::mode::queues ^ + -M apps::exchange::2010::local::mode::replicationhealth ^ + -M apps::exchange::2010::local::mode::services ^ + -M centreon::common::powershell::exchange::2010::powershell ^ + -M apps::cluster::mscs::local::plugin ^ + -M apps::cluster::mscs::local::mode::listnodes ^ + -M apps::cluster::mscs::local::mode::listresources ^ + -M apps::cluster::mscs::local::mode::networkstatus ^ + -M apps::cluster::mscs::local::mode::nodestatus ^ + -M apps::cluster::mscs::local::mode::resourcestatus ^ + -M apps::cluster::mscs::local::mode::resourcegroupstatus ^ + -M os::windows::local::plugin ^ + -M os::windows::local::mode::ntp ^ + -M os::windows::local::mode::rdpsessions ^ + -M storage::dell::compellent::local::plugin ^ + -M storage::dell::compellent::local::mode::hbausage ^ + -M storage::dell::compellent::local::mode::volumeusage ^ + --verbose + + pause + +Lancer le fichier "build.bat" pour créer le binaire "centreon_plugins.exe". + +Pour changer la version et l'icône du binaire, ajouter le code suivant après ``PERL_INSTALL_DIR`` (première ligne) : +:: + + set ICO_FILE=centreon.ico + set RC_FILE=centreon.rc + + chdir /d %~dp0 + + for /f "tokens=4 delims= " %%i in ('type centreon-plugins\centreon\plugins\script.pm ^| findstr global_version ^| findstr my') do set "VERSION_PLUGIN=%%i" + set VERSION_PLUGIN=%VERSION_PLUGIN:~0,8% + + ( + echo #define PP_MANIFEST_FILEFLAGS 0 + echo #include ^ + echo. + echo CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "winres\\pp.manifest" + echo. + echo VS_VERSION_INFO VERSIONINFO + echo FILEVERSION 0,0,0,0 + echo PRODUCTVERSION 0,0,0,0 + echo FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + echo FILEFLAGS PP_MANIFEST_FILEFLAGS + echo FILEOS VOS_NT_WINDOWS32 + echo FILETYPE VFT_APP + echo FILESUBTYPE VFT2_UNKNOWN + echo BEGIN + echo BLOCK "StringFileInfo" + echo BEGIN + echo BLOCK "000004B0" + echo BEGIN + echo VALUE "CompanyName", "Centreon\0" + echo VALUE "FileDescription", " \0" + echo VALUE "FileVersion", "1.0.0.0\0" + echo VALUE "InternalName", " \0" + echo VALUE "LegalCopyright", " \0" + echo VALUE "LegalTrademarks", " \0" + echo VALUE "OriginalFilename", " \0" + echo VALUE "ProductName", "centreon-plugins\0" + echo VALUE "ProductVersion", "%VERSION_PLUGIN%.0\0" + echo END + echo END + echo BLOCK "VarFileInfo" + echo BEGIN + echo VALUE "Translation", 0x00, 0x04B0 + echo END + echo END + echo. + echo WINEXE ICON winres\\pp.ico + )> %RC_FILE% + + for /f "delims=" %%i in ('dir /ad /B %PERL_INSTALL_DIR%\cpan\build\PAR-Packer-*') do set "PAR_PACKER_DIRNAME=%%i" + SET PAR_PACKER_SRC=%PERL_INSTALL_DIR%\cpan\build\%PAR_PACKER_DIRNAME% + + copy /Y %ICO_FILE% %PAR_PACKER_SRC%\myldr\winres\pp.ico + copy /Y centreon.rc %PAR_PACKER_SRC%\myldr\winres\pp.rc + del %PAR_PACKER_SRC%\myldr\ppresource.coff + cd /D %PAR_PACKER_SRC%\myldr\ && perl Makefile.PL + cd /D %PAR_PACKER_SRC%\myldr\ && dmake boot.exe + cd /D %PAR_PACKER_SRC%\myldr\ && dmake Static.pm + attrib -R %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm + copy /Y %PAR_PACKER_SRC%\myldr\Static.pm %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm + +Il est possible de compiler un binaire 32 bits depuis une version 64 bits Windows : + +* Installer Strawberry Perl 5.24.x version 32 bits sur un Windows (Télécharger sur http://strawberryperl.com/) +* Installer le module cpan "PAR::Packer" +* Ajouter la ligne suivante au début du script : PATH=%PERL_INSTALL_DIR%\c\bin;%PERL_INSTALL_DIR%\perl\bin;C:\Windows\System32 + ********* Dépannage From bf8d699f3f3eb06facee914040647fe061ecf749 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 26 Sep 2016 13:39:43 +0200 Subject: [PATCH 061/103] + fix #499 --- centreon-plugins/snmp_standard/mode/inodes.pm | 135 ++++-------------- 1 file changed, 31 insertions(+), 104 deletions(-) diff --git a/centreon-plugins/snmp_standard/mode/inodes.pm b/centreon-plugins/snmp_standard/mode/inodes.pm index 40430f3fe..b8bec5722 100644 --- a/centreon-plugins/snmp_standard/mode/inodes.pm +++ b/centreon-plugins/snmp_standard/mode/inodes.pm @@ -20,26 +20,36 @@ package snmp_standard::mode::inodes; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::values; -my $maps_counters = { - disk => { - '000_usage' => { - set => { +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'disk', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All inode partitions are ok' } + ]; + + $self->{maps_counters}->{disk} = [ + { label => 'usage', set => { key_values => [ { name => 'usage' }, { name => 'display' } ], output_template => 'Used: %s %%', output_error_template => "%s", perfdatas => [ { label => 'used', value => 'usage_absolute', template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, ], - }, + } }, - } -}; + ]; +} + +sub prefix_disk_output { + my ($self, %options) = @_; + + return "Inode partition '" . $options{instance_value}->{display} . "' "; +} sub new { my ($class, %options) = @_; @@ -58,97 +68,9 @@ sub new { "display-transform-dst:s" => { name => 'display_transform_dst' }, }); - foreach my $key (('disk')) { - 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 (('disk')) { - foreach (keys %{$maps_counters->{$key}}) { - $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); - } - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - $self->manage_selection(); - - my $multiple = 1; - if (scalar(keys %{$self->{disk_selected}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All inode partitions are ok'); - } - - foreach my $id (sort keys %{$self->{disk_selected}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters->{disk}}) { - my $obj = $maps_counters->{disk}->{$_}->{obj}; - $obj->set(instance => $id); - - my ($value_check) = $obj->execute(values => $self->{disk_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 => "Inode partition '" . $self->{disk_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 => "Inode partition '" . $self->{disk_selected}->{$id}->{display} . "' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "Inode partition '" . $self->{disk_selected}->{$id}->{display} . "' $long_msg"); - } - } - - $self->{output}->display(); - $self->{output}->exit(); -} - my $mapping = { dskPath => { oid => '.1.3.6.1.4.1.2021.9.1.2' }, dskDevice => { oid => '.1.3.6.1.4.1.2021.9.1.3' }, @@ -158,16 +80,16 @@ my $mapping = { sub manage_selection { my ($self, %options) = @_; - my $results = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{dskPath}->{oid} }, + my $results = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{dskPath}->{oid} }, { oid => $mapping->{dskDevice}->{oid} }, { oid => $mapping->{dskPercentNode}->{oid} } ], return_type => 1, nothing_quit => 1); - $self->{disk_selected} = {}; - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$results})) { + $self->{disk} = {}; + foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$results})) { next if ($oid !~ /^$mapping->{dskPath}->{oid}\.(.*)/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); $result->{dskPath} = $self->get_display_value(value => $result->{dskPath}); $self->{output}->output_add(long_msg => sprintf("disk path : '%s', device : '%s'", $result->{dskPath}, $result->{dskDevice}), debug => 1); @@ -176,6 +98,10 @@ sub manage_selection { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : no inode usage value", $result->{dskPath}), debug => 1); next; } + if (defined($self->{disk}->{$result->{dskPath}})) { + $self->{output}->output_add(long_msg => sprintf("skipping '%s' : duplicated entry", $result->{dskPath}), debug => 1); + next; + } if (defined($result->{dskDevice}) && defined($self->{option_results}->{filter_device}) && $self->{option_results}->{filter_device} ne '' && $result->{dskDevice} !~ /$self->{option_results}->{filter_device}/) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk device", $result->{dskPath}), debug => 1); @@ -202,11 +128,12 @@ sub manage_selection { } } - $self->{disk_selected}->{$instance} = { display => $result->{dskPath}, - usage => $result->{dskPercentNode} }; + + $self->{disk}->{$result->{dskPath}} = { display => $result->{dskPath}, + usage => $result->{dskPercentNode} }; } - if (scalar(keys %{$self->{disk_selected}}) <= 0) { + if (scalar(keys %{$self->{disk}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->option_exit(); } From 933e128edb43a3aae08c553d17458e16d2eef3bc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 26 Sep 2016 14:00:47 +0200 Subject: [PATCH 062/103] + Fix #494 --- .../notification/slack/mode/alert.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/centreon-plugins/notification/slack/mode/alert.pm b/centreon-plugins/notification/slack/mode/alert.pm index 6b5a2fe14..644d6af2c 100644 --- a/centreon-plugins/notification/slack/mode/alert.pm +++ b/centreon-plugins/notification/slack/mode/alert.pm @@ -153,19 +153,22 @@ sub host_message { } 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} }; + push @{$self->{payload_attachment}->{fields}}, { title => 'output', value => $self->{option_results}->{host_output}, short => 'true' }; + } + if (defined($self->{option_results}->{host_state}) && $self->{option_results}->{host_state} ne '') { + push @{$self->{payload_attachment}->{fields}}, { title => 'State', value => $self->{option_results}->{host_state}, short => 'true'}; } } sub service_message { my ($self, %options) = @_; - my $url_service = $self->{option_results}->{service_description}; + my $url_service = "Host: " . $self->{option_results}->{host_name} . " | 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; + $self->{payload_attachment}->{text} = $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}; @@ -189,15 +192,18 @@ sub service_message { if (defined($self->{option_results}->{graph_url}) && $self->{option_results}->{graph_url} ne '') { $self->{payload_attachment}->{image_url} = $self->{option_results}->{graph_url}; } + if (defined($self->{option_results}->{service_state}) && $self->{option_results}->{service_state} ne '') { + push @{$self->{payload_attachment}->{fields}}, { title => 'State', value => $self->{option_results}->{service_state}, short => 'true'}; + } } sub set_payload { my ($self, %options) = @_; - if (!defined($self->{option_results}->{service_description}) && $self->{option_results}->{service_description} ne '') { - $self->host_message(); - } else { + if (defined($self->{option_results}->{service_description}) && $self->{option_results}->{service_description} ne '') { $self->service_message(); + } else { + $self->host_message(); } if (defined($self->{option_results}->{slack_color}) && $self->{option_results}->{slack_color} ne '') { From 143d2f878d2d2004bdb0d52604b2084530066b1b Mon Sep 17 00:00:00 2001 From: Kevin LABOURDETTE Date: Tue, 27 Sep 2016 16:15:21 +0200 Subject: [PATCH 063/103] Fixed found translation. --- .../apps/protocols/http/mode/jsoncontent.pm | 12 +++---- .../apps/protocols/http/mode/soapcontent.pm | 14 ++++---- .../common/bluearc/snmp/mode/clusterstatus.pm | 34 +++++++++---------- .../juniper/trapeze/snmp/mode/apusers.pm | 30 ++++++++-------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm b/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm index c4f4e7b58..60163f11c 100644 --- a/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm +++ b/centreon-plugins/apps/protocols/http/mode/jsoncontent.pm @@ -71,9 +71,9 @@ sub new { "warning-time:s" => { name => 'warning_time' }, "critical-time:s" => { name => 'critical_time' }, "threshold-value:s" => { name => 'threshold_value', default => 'count' }, - "format-ok:s" => { name => 'format_ok', default => '%{count} element(s) finded' }, - "format-warning:s" => { name => 'format_warning', default => '%{count} element(s) finded' }, - "format-critical:s" => { name => 'format_critical', default => '%{count} element(s) finded' }, + "format-ok:s" => { name => 'format_ok', default => '%{count} element(s) found' }, + "format-warning:s" => { name => 'format_warning', default => '%{count} element(s) found' }, + "format-critical:s" => { name => 'format_critical', default => '%{count} element(s) found' }, "values-separator:s" => { name => 'values_separator', default => ', ' }, }); $self->{count} = 0; @@ -296,7 +296,7 @@ FORMAT OPTIONS: =item B<--format-ok> -Output format (Default: '%{count} element(s) finded') +Output format (Default: '%{count} element(s) found') Can used: '%{values}' = display all values (also text string) '%{values_ok}' = values from attributes and text node only (seperated by option values-separator) @@ -304,11 +304,11 @@ Can used: =item B<--format-warning> -Output warning format (Default: %{count} element(s) finded') +Output warning format (Default: %{count} element(s) found') =item B<--format-critical> -Output critical format (Default: %{count} element(s) finded') +Output critical format (Default: %{count} element(s) found') =item B<--values-separator> diff --git a/centreon-plugins/apps/protocols/http/mode/soapcontent.pm b/centreon-plugins/apps/protocols/http/mode/soapcontent.pm index bdccf9de2..6b16b75d9 100644 --- a/centreon-plugins/apps/protocols/http/mode/soapcontent.pm +++ b/centreon-plugins/apps/protocols/http/mode/soapcontent.pm @@ -70,9 +70,9 @@ sub new { "warning-time:s" => { name => 'warning_time' }, "critical-time:s" => { name => 'critical_time' }, "threshold-value:s" => { name => 'threshold_value', default => 'count' }, - "format-ok:s" => { name => 'format_ok', default => '%{count} element(s) finded' }, - "format-warning:s" => { name => 'format_warning', default => '%{count} element(s) finded' }, - "format-critical:s" => { name => 'format_critical', default => '%{count} element(s) finded' }, + "format-ok:s" => { name => 'format_ok', default => '%{count} element(s) found' }, + "format-warning:s" => { name => 'format_warning', default => '%{count} element(s) found' }, + "format-critical:s" => { name => 'format_critical', default => '%{count} element(s) found' }, "values-separator:s" => { name => 'values_separator', default => ', ' }, }); $self->{count} = 0; @@ -120,7 +120,7 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "You need to specify data."); $self->{output}->option_exit(); } - + $self->{http}->set_options(%{$self->{option_results}}); $self->{http}->add_header(key => 'SOAPAction', value => $self->{option_results}->{service_soap}); } @@ -309,7 +309,7 @@ FORMAT OPTIONS: =item B<--format-ok> -Output format (Default: '%{count} element(s) finded') +Output format (Default: '%{count} element(s) found') Can used: '%{values}' = display all values (also text string) '%{values_ok}' = values from attributes and text node only (seperated by option values-separator) @@ -317,11 +317,11 @@ Can used: =item B<--format-warning> -Output warning format (Default: %{count} element(s) finded') +Output warning format (Default: %{count} element(s) found') =item B<--format-critical> -Output critical format (Default: %{count} element(s) finded') +Output critical format (Default: %{count} element(s) found') =item B<--values-separator> diff --git a/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm b/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm index edb7156fa..eaf323a7a 100644 --- a/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm +++ b/centreon-plugins/centreon/common/bluearc/snmp/mode/clusterstatus.pm @@ -27,11 +27,11 @@ 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' } ], @@ -47,14 +47,14 @@ sub set_counters { my $instance_mode; sub custom_threshold_output { - my ($self, %options) = @_; + 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'; @@ -75,14 +75,14 @@ sub custom_threshold_output { 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; @@ -90,7 +90,7 @@ sub custom_status_calc { sub prefix_node_output { my ($self, %options) = @_; - + return "Node '" . $options{instance_value}->{display} . "' "; } @@ -98,7 +98,7 @@ 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 => { @@ -114,14 +114,14 @@ sub new { 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; @@ -129,7 +129,7 @@ sub change_macros { } } -my %map_vnode_status = ( +my %map_vnode_status = ( 1 => 'unknown', 2 => 'onLine', 3 => 'offLine', @@ -156,14 +156,14 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $result->{clusterVNodeName} . "': no matching filter.", debug => 1); next; } - - $self->{node}->{$instance} = { display => $result->{clusterVNodeName}, + + $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'); + short_msg => 'No node(s) found'); } } @@ -198,4 +198,4 @@ Can used special variables like: %{state}, %{display} =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm b/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm index d2c1b124d..f8e2b5192 100644 --- a/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm +++ b/centreon-plugins/network/juniper/trapeze/snmp/mode/apusers.pm @@ -27,31 +27,31 @@ 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', + { 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', + { label => 'ssid', value => 'total_absolute', template => '%s', unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } @@ -76,20 +76,20 @@ 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} . "' "; } @@ -114,11 +114,11 @@ sub manage_selection { $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; @@ -130,7 +130,7 @@ sub manage_selection { $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 '' && + 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; @@ -140,17 +140,17 @@ sub manage_selection { $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 ? '); + short_msg => 'No AP nor SSID found, check your filter or maybe we are on a slave controller ? '); } } From 126541362495be6b3fada6f3aafbedb49e5692e3 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 29 Sep 2016 14:34:01 +0200 Subject: [PATCH 064/103] + Fix #514 --- centreon-plugins/storage/qnap/snmp/mode/hardware.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm index 2e68bbf4f..bc1860b18 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm @@ -35,6 +35,7 @@ my $thresholds = { ], smartdisk => [ ['GOOD', 'OK'], + ['NORMAL', 'WARNING'], ['--', 'OK'], ['.*', 'CRITICAL'], ], From e7c0fe883c49e45393394a944472d443f9b247a1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 30 Sep 2016 19:27:23 +0200 Subject: [PATCH 065/103] + Fix typo --- centreon-plugins/network/juniper/mag/mode/bladetemperature.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm b/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm index cc4c7486d..8fdf8d875 100644 --- a/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm +++ b/centreon-plugins/network/juniper/mag/mode/bladetemperature.pm @@ -62,9 +62,9 @@ sub run { my $result = $self->{snmp}->get_leef(oids => [$oid_iveTemperature], nothing_quit => 1); my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_iveTemperature}, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Blade Temperautre is %.2f C", + short_msg => sprintf("Blade Temperature is %.2f C", $result->{$oid_iveTemperature})); $self->{output}->perfdata_add(label => 'temperature', unit => 'C', value => sprintf("%.2f", $result->{$oid_iveTemperature}), From a3cfd84d88993782ebace5887ccda24154680d55 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 6 Oct 2016 12:12:58 +0200 Subject: [PATCH 066/103] + add vtom plugin restapi --- .../apps/vtom/restapi/custom/api.pm | 209 +++++++++++ .../apps/vtom/restapi/mode/jobstatus.pm | 334 ++++++++++++++++++ centreon-plugins/apps/vtom/restapi/plugin.pm | 49 +++ 3 files changed, 592 insertions(+) create mode 100644 centreon-plugins/apps/vtom/restapi/custom/api.pm create mode 100644 centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm create mode 100644 centreon-plugins/apps/vtom/restapi/plugin.pm diff --git a/centreon-plugins/apps/vtom/restapi/custom/api.pm b/centreon-plugins/apps/vtom/restapi/custom/api.pm new file mode 100644 index 000000000..3a8629712 --- /dev/null +++ b/centreon-plugins/apps/vtom/restapi/custom/api.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 apps::vtom::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use JSON::XS; + +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' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "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->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : 30080; + $self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'http'; + $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} = $self->{port}; + $self->{option_results}->{proto} = $self->{proto}; + $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}->set_options(%{$self->{option_results}}); +} + +sub get { + my ($self, %options) = @_; + + $self->settings(); + + my $response = $self->{http}->request(url_path => $options{path}, + critical_status => '', warning_status => ''); + my $content; + eval { + $content = JSON::XS->new->utf8->decode($response); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); + $self->{output}->option_exit(); + } + if (defined($content->{errmsg})) { + $self->{output}->add_option_msg(short_msg => "Cannot get data: " . $content->{errmsg}); + $self->{output}->option_exit(); + } + + return $content; +} + +1; + +__END__ + +=head1 NAME + +VTOM REST API + +=head1 SYNOPSIS + +VTOM Rest API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +VTOM hostname. + +=item B<--port> + +Port used (Default: 30080) + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=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/apps/vtom/restapi/mode/jobstatus.pm b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm new file mode 100644 index 000000000..0169276b4 --- /dev/null +++ b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm @@ -0,0 +1,334 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::vtom::restapi::mode::jobstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; + +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'}; + $self->{result_values}->{exit_code} = $options{new_datas}->{$self->{instance} . '_exit_code'}; + 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'}; + + return -11 if ($self->{result_values}->{status} !~ /Running/i); + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', }, + { name => 'job', type => 1, cb_prefix_output => 'prefix_job_output', message_multiple => 'All jobs are ok', , skipped_code => { -11 => 1 } }, + ]; + + $self->{maps_counters}->{job} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' }, { name => 'exit_code' } ], + 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' } ], + 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'), + } + }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total-error', set => { + key_values => [ { name => 'error' }, { name => 'total' } ], + output_template => 'Error : %s', + perfdatas => [ + { label => 'total_error', value => 'error_absolute', template => '%s', + min => 0, max => 'total_absolute' }, + ], + } + }, + { label => 'total-running', set => { + key_values => [ { name => 'running' }, { name => 'total' } ], + output_template => 'Running : %s', + perfdatas => [ + { label => 'total_running', value => 'running_absolute', template => '%s', + min => 0, max => 'total_absolute' }, + ], + } + }, + { label => 'total-unplanned', set => { + key_values => [ { name => 'unplanned' }, { name => 'total' } ], + output_template => 'Unplanned : %s', + perfdatas => [ + { label => 'total_unplanned', value => 'unplanned_absolute', template => '%s', + min => 0, max => 'total_absolute' }, + ], + } + }, + { label => 'total-finished', set => { + key_values => [ { name => 'finished' }, { name => 'total' } ], + output_template => 'Finished : %s', + perfdatas => [ + { label => 'total_finished', value => 'finished_absolute', template => '%s', + min => 0, max => 'total_absolute' }, + ], + } + }, + { label => 'total-coming', set => { + key_values => [ { name => 'coming' }, { name => 'total' } ], + output_template => 'Coming : %s', + perfdatas => [ + { label => 'total_coming', value => 'coming_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 => + { + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /Error/i' }, + "warning-long:s" => { name => 'warning_long' }, + "critical-long:s" => { name => 'critical_long' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return "Total Job "; +} + +sub prefix_job_output { + my ($self, %options) = @_; + + return "job '" . $options{instance_value}->{display} . "' "; +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status', 'warning_long', 'critical_long')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my %mapping_job_status = ( + R => 'Running', + U => 'Unplanned', + F => 'Finished', + W => 'Coming', + E => 'Error', +); + +sub manage_selection { + my ($self, %options) = @_; + + $self->{job} = {}; + $self->{global} = { total => 0, running => 0, unplanned => 0, finished => 0, coming => 0, error => 0 }; + my $result = $options{custom}->get(path => '/api/job/getAll'); + + my $current_time = time(); + if (defined($result->{result})) { + foreach my $entry (@{$result->{result}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $entry->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $entry->{name} . "': no matching filter.", debug => 1); + next; + } + + my $elapsed_time = $current_time - $entry->{timeBegin}; + + $self->{global}->{total} += 1; + $self->{global}->{lc($mapping_job_status{$entry->{status}})} += 1; + $self->{job}->{$entry->{id}} = { + display => $entry->{name}, + status => $mapping_job_status{$entry->{status}}, + exit_code => $entry->{retcode}, + elapsed => $elapsed_time + }; + } + } + + if (scalar(keys %{$self->{job}}) <= 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<--filter-name> + +Filter name (can be a regexp). + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^total-error$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'total-error', 'total-running', 'total-unplanned', +'total-finished', 'total-coming'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'total-error', 'total-running', 'total-unplanned', +'total-finished', 'total-coming'. + +=item B<--warning-status> + +Set warning threshold for status (Default: -) +Can used special variables like: %{display}, %{status}, %{exit_code} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{exit_code} =~ /Error/i'). +Can used special variables like: %{display}, %{status}, %{exit_code} + +=item B<--warning-long> + +Set warning threshold for long jobs (Default: none) +Can used special variables like: %{display}, %{status}, %{elapsed} + +=item B<--critical-long> + +Set critical threshold for long jobs (Default: none). +Can used special variables like: %{display}, %{status}, %{elapsed} + +=back + +=cut diff --git a/centreon-plugins/apps/vtom/restapi/plugin.pm b/centreon-plugins/apps/vtom/restapi/plugin.pm new file mode 100644 index 000000000..5a4bb9f4f --- /dev/null +++ b/centreon-plugins/apps/vtom/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 apps::vtom::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}} = ( + 'job-status' => 'apps::vtom::restapi::mode::jobstatus', + ); + + $self->{custom_modes}{api} = 'apps::vtom::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check VTOM software through HTTP/REST API. + +=cut From 28be849aa3907d19af46e0d217416acf37c6910c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 6 Oct 2016 12:13:26 +0200 Subject: [PATCH 067/103] + fix pod --- centreon-plugins/storage/hp/storeonce/restapi/plugin.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm b/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm index 9ed7fa1d3..e393c6785 100644 --- a/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm +++ b/centreon-plugins/storage/hp/storeonce/restapi/plugin.pm @@ -47,3 +47,5 @@ __END__ =head1 PLUGIN DESCRIPTION Check Hp Storeonce through HTTP/REST API. + +=cut From 99b415012bb68f02a61b379153b6274665d58a7d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 6 Oct 2016 15:43:24 +0200 Subject: [PATCH 068/103] + add family for vtom --- .../apps/vtom/restapi/mode/jobstatus.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm index 0169276b4..74f018948 100644 --- a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm +++ b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm @@ -65,6 +65,8 @@ sub custom_status_calc { $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{exit_code} = $options{new_datas}->{$self->{instance} . '_exit_code'}; + $self->{result_values}->{family} = $options{new_datas}->{$self->{instance} . '_family'}; + return 0; } @@ -105,6 +107,7 @@ sub custom_long_calc { $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}->{family} = $options{new_datas}->{$self->{instance} . '_family'}; return -11 if ($self->{result_values}->{status} !~ /Running/i); @@ -121,7 +124,7 @@ sub set_counters { $self->{maps_counters}->{job} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'display' }, { name => 'exit_code' } ], + key_values => [ { name => 'status' }, { name => 'display' }, { name => 'exit_code' }, { name => 'family' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, @@ -129,7 +132,7 @@ sub set_counters { } }, { label => 'long', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'display' }, { name => 'elapsed' } ], + key_values => [ { name => 'status' }, { name => 'display' }, { name => 'elapsed' }, { name => 'family' } ], closure_custom_calc => $self->can('custom_long_calc'), closure_custom_output => $self->can('custom_long_output'), closure_custom_perfdata => sub { return 0; }, @@ -267,6 +270,7 @@ sub manage_selection { display => $entry->{name}, status => $mapping_job_status{$entry->{status}}, exit_code => $entry->{retcode}, + family => defined($entry->{family}) ? $entry->{family} : '-', elapsed => $elapsed_time }; } @@ -312,22 +316,22 @@ Can be: 'total-error', 'total-running', 'total-unplanned', =item B<--warning-status> Set warning threshold for status (Default: -) -Can used special variables like: %{display}, %{status}, %{exit_code} +Can used special variables like: %{display}, %{status}, %{exit_code}, %{family} =item B<--critical-status> Set critical threshold for status (Default: '%{exit_code} =~ /Error/i'). -Can used special variables like: %{display}, %{status}, %{exit_code} +Can used special variables like: %{display}, %{status}, %{exit_code}, %{family} =item B<--warning-long> Set warning threshold for long jobs (Default: none) -Can used special variables like: %{display}, %{status}, %{elapsed} +Can used special variables like: %{display}, %{status}, %{elapsed}, %{family} =item B<--critical-long> Set critical threshold for long jobs (Default: none). -Can used special variables like: %{display}, %{status}, %{elapsed} +Can used special variables like: %{display}, %{status}, %{elapsed}, %{family} =back From 88909416edd8c3127ca2435e790fd9a7d7d4a225 Mon Sep 17 00:00:00 2001 From: tcharles Date: Thu, 6 Oct 2016 16:16:48 +0200 Subject: [PATCH 069/103] Update ec2instancenetwork.pm --- centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm b/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm index 414bdb09d..cdd5c71a8 100644 --- a/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm +++ b/centreon-plugins/cloud/aws/mode/metrics/ec2instancenetwork.pm @@ -47,6 +47,7 @@ $Param[1] = { 'NameSpace' => 'AWS/EC2', 'MetricName' => 'NetworkOut', 'ObjectName' => 'InstanceId', + 'Unit' => 'Bytes', 'Labels' => { 'ShortOutput' => "Traffic Out %s Bytes", 'LongOutput' => "Traffic Out %s Bytes", From a2fd817c6483ac9f3b3c835abb4670fd0ebe5da9 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 7 Oct 2016 17:23:02 +0200 Subject: [PATCH 070/103] + move emc celerra --- .../local/mode/components/controlstation.pm | 8 +- .../local/mode/components/datamover.pm | 8 +- .../emc/celerra/local/mode/getreason.pm | 226 +++++------------- 3 files changed, 68 insertions(+), 174 deletions(-) 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 8cac90baf..a548cabbd 100644 --- a/centreon-plugins/storage/emc/celerra/local/mode/components/controlstation.pm +++ b/centreon-plugins/storage/emc/celerra/local/mode/components/controlstation.pm @@ -29,24 +29,26 @@ my %map_cs_status = ( 11 => 'Secondary Control Station', ); +sub load { } + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking control stations"); $self->{components}->{controlstation} = {name => 'control stations', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'controlstation')); + return if ($self->check_filter(section => 'controlstation')); foreach my $line (split /\n/, $self->{stdout}) { next if ($line !~ /^\s*(\d+)\s+-\s+(\S+)/); my ($code, $instance) = ($1, $2); next if (!defined($map_cs_status{$code})); - return if ($self->check_exclude(section => 'controlstation', instance => $instance)); + return if ($self->check_filter(section => 'controlstation', instance => $instance)); $self->{components}->{controlstation}->{total}++; $self->{output}->output_add(long_msg => sprintf("Control station '%s' status is '%s'", $instance, $map_cs_status{$code})); - my $exit = $self->get_severity(section => 'controlstation', value => $map_cs_status{$code}); + my $exit = $self->get_severity(section => 'controlstation', instance => $instance, value => $map_cs_status{$code}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Control station '%s' status is '%s'", 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 29bc1f912..c010b02d7 100644 --- a/centreon-plugins/storage/emc/celerra/local/mode/components/datamover.pm +++ b/centreon-plugins/storage/emc/celerra/local/mode/components/datamover.pm @@ -46,24 +46,26 @@ my %map_dm_status = ( 25 => 'DM T2NET Error. Unable to get blade reason code due to management switch problems', ); +sub load { } + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking data movers"); $self->{components}->{datamover} = {name => 'data movers', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'datamover')); + return if ($self->check_filter(section => 'datamover')); foreach my $line (split /\n/, $self->{stdout}) { next if ($line !~ /^\s*(\d+)\s+-\s+(\S+)/); my ($code, $instance) = ($1, $2); next if (!defined($map_dm_status{$code})); - return if ($self->check_exclude(section => 'datamover', instance => $instance)); + return if ($self->check_filter(section => 'datamover', instance => $instance)); $self->{components}->{datamover}->{total}++; $self->{output}->output_add(long_msg => sprintf("Data mover '%s' status is '%s'", $instance, $map_dm_status{$code})); - my $exit = $self->get_severity(section => 'datamover', value => $map_dm_status{$code}); + my $exit = $self->get_severity(section => 'datamover', instance => $instance, value => $map_dm_status{$code}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Data mover '%s' status is '%s'", diff --git a/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm b/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm index 478ba2836..a694cdcc8 100644 --- a/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm +++ b/centreon-plugins/storage/emc/celerra/local/mode/getreason.pm @@ -20,45 +20,68 @@ package storage::emc::celerra::local::mode::getreason; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; use centreon::plugins::misc; -my $thresholds = { - controlstation => [ - ['Primary Control Station', 'OK'], # 10 - ['Secondary Control Station', 'OK'], # 11 - ['Control Station is ready, but is not running NAS service', 'CRITICAL'], # 6 - ], - datamover => [ - ['Reset (or unknown state)', 'WARNING'], - ['DOS boot phase, BIOS check, boot sequence', 'WARNING'], - ['SIB POST failures (that is, hardware failures)', 'CRITICAL'], - ['DART is loaded on Data Mover, DOS boot and execution of boot.bat, boot.cfg', 'WARNING'], - ['DART is ready on Data Mover, running, and MAC threads started', 'WARNING'], - ['DART is in contact with Control Station box monitor', 'OK'], - ['DART is in panic state', 'CRITICAL'], - ['DART reboot is pending or in halted state', 'WARNING'], - ['DART panicked and completed memory dump', 'CRITICAL'], - ['DM Misc problems', 'CRITICAL'], # code 14 - ['Data Mover is flashing firmware. DART is flashing BIOS and/or POST firmware. Data Mover cannot be reset', 'CRITICAL'], - ['Data Mover Hardware fault detected', 'CRITICAL'], - ['DM Memory Test Failure. BIOS detected memory error', 'CRITICAL'], - ['DM POST Test Failure. General POST error', 'CRITICAL'], - ['DM POST NVRAM test failure. Invalid NVRAM content error', 'CRITICAL'], - ['DM POST invalid peer Data Mover type', 'CRITICAL'], - ['DM POST invalid Data Mover part number', 'CRITICAL'], - ['DM POST Fibre Channel test failure. Error in blade Fibre connection', 'CRITICAL'], - ['DM POST network test failure. Error in Ethernet controller', 'CRITICAL'], - ['DM T2NET Error. Unable to get blade reason code due to management switch problems', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(controlstation|datamover)$'; + + $self->{cb_hook2} = 'cmd_execute'; + + $self->{thresholds} = { + controlstation => [ + ['Primary Control Station', 'OK'], # 10 + ['Secondary Control Station', 'OK'], # 11 + ['Control Station is ready, but is not running NAS service', 'CRITICAL'], # 6 + ], + datamover => [ + ['Reset (or unknown state)', 'WARNING'], + ['DOS boot phase, BIOS check, boot sequence', 'WARNING'], + ['SIB POST failures (that is, hardware failures)', 'CRITICAL'], + ['DART is loaded on Data Mover, DOS boot and execution of boot.bat, boot.cfg', 'WARNING'], + ['DART is ready on Data Mover, running, and MAC threads started', 'WARNING'], + ['DART is in contact with Control Station box monitor', 'OK'], + ['DART is in panic state', 'CRITICAL'], + ['DART reboot is pending or in halted state', 'WARNING'], + ['DART panicked and completed memory dump', 'CRITICAL'], + ['DM Misc problems', 'CRITICAL'], # code 14 + ['Data Mover is flashing firmware. DART is flashing BIOS and/or POST firmware. Data Mover cannot be reset', 'CRITICAL'], + ['Data Mover Hardware fault detected', 'CRITICAL'], + ['DM Memory Test Failure. BIOS detected memory error', 'CRITICAL'], + ['DM POST Test Failure. General POST error', 'CRITICAL'], + ['DM POST NVRAM test failure. Invalid NVRAM content error', 'CRITICAL'], + ['DM POST invalid peer Data Mover type', 'CRITICAL'], + ['DM POST invalid Data Mover part number', 'CRITICAL'], + ['DM POST Fibre Channel test failure. Error in blade Fibre connection', 'CRITICAL'], + ['DM POST network test failure. Error in Ethernet controller', 'CRITICAL'], + ['DM T2NET Error. Unable to get blade reason code due to management switch problems', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::emc::celerra::local::mode::components'; + $self->{components_module} = ['controlstation', 'datamover']; +} + +sub cmd_execute { + my ($self, %options) = @_; + + ($self->{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}); +} 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'; @@ -74,144 +97,11 @@ sub new { "command:s" => { name => 'command', default => 'getreason' }, "command-path:s" => { name => 'command_path', default => '/nas/sbin' }, "command-options:s" => { name => 'command_options', default => '2>&1' }, - "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) = @_; - - ($self->{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}, - no_quit => 1); - my @components = ('controlstation', 'datamover'); - my $components = 0; - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "storage::emc::celerra::local::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - $components = 1; - } - } - - if ($components == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "storage::emc::celerra::local::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__ @@ -227,10 +117,10 @@ Check control stations and data movers status (use 'getreason' command). Which component to check (Default: '.*'). Can be: 'controlstation', 'datamover'. -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=datamover) -Can also exclude specific instance: --exclude='datamover#slot_2#' +Exclude some parts (comma seperated list) (Example: --filter=datamover) +Can also exclude specific instance: --filter=datamover,slot_2 =item B<--no-component> @@ -239,7 +129,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='datamover,CRITICAL,^(?!(normal)$)' From 124d6080a995b95c4072c85366b4d58286630d7d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 13 Oct 2016 15:18:29 +0200 Subject: [PATCH 071/103] + add database sybase plugin --- .../database/sybase/mode/blockedprocesses.pm | 99 ++++++++ .../database/sybase/mode/connectedusers.pm | 99 ++++++++ .../database/sybase/mode/databasessize.pm | 217 ++++++++++++++++++ centreon-plugins/database/sybase/plugin.pm | 104 +++++++++ 4 files changed, 519 insertions(+) create mode 100644 centreon-plugins/database/sybase/mode/blockedprocesses.pm create mode 100644 centreon-plugins/database/sybase/mode/connectedusers.pm create mode 100644 centreon-plugins/database/sybase/mode/databasessize.pm create mode 100644 centreon-plugins/database/sybase/plugin.pm diff --git a/centreon-plugins/database/sybase/mode/blockedprocesses.pm b/centreon-plugins/database/sybase/mode/blockedprocesses.pm new file mode 100644 index 000000000..4065cb973 --- /dev/null +++ b/centreon-plugins/database/sybase/mode/blockedprocesses.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 database::sybase::mode::blockedprocesses; + +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) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + + $self->{sql}->connect(); + $self->{sql}->query(query => q{SELECT count(*) FROM master.dbo.sysprocesses WHERE blocked <> 0}); + my $blocked = $self->{sql}->fetchrow_array(); + + my $exit_code = $self->{perfdata}->threshold_check(value => $blocked, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("%i blocked process(es).", $blocked)); + $self->{output}->perfdata_add(label => 'blocked_processes', + value => $blocked, + 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 MSSQL blocked processes. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/centreon-plugins/database/sybase/mode/connectedusers.pm b/centreon-plugins/database/sybase/mode/connectedusers.pm new file mode 100644 index 000000000..a903f7df4 --- /dev/null +++ b/centreon-plugins/database/sybase/mode/connectedusers.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 database::sybase::mode::connectedusers; + +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) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + + $self->{sql}->connect(); + $self->{sql}->query(query => q{SELECT count(*) FROM master..sysprocesses WHERE spid >= 51}); + my $users = $self->{sql}->fetchrow_array(); + + my $exit_code = $self->{perfdata}->threshold_check(value => $users, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("%i Connected user(s).", $users)); + $self->{output}->perfdata_add(label => 'connected_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 MSSQL connected users. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/centreon-plugins/database/sybase/mode/databasessize.pm b/centreon-plugins/database/sybase/mode/databasessize.pm new file mode 100644 index 000000000..2146a2dc4 --- /dev/null +++ b/centreon-plugins/database/sybase/mode/databasessize.pm @@ -0,0 +1,217 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::sybase::mode::databasessize; + +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', message_separator => ' - ' }, + ]; + + $self->{maps_counters}->{database} = [ + { label => 'data', set => { + key_values => [ { name => 'data_used' }, { name => 'data_size' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'data' }, + 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 => 'log', set => { + key_values => [ { name => 'log_used' }, { name => 'log_size' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'log' }, + 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 custom_usage_perfdata { + my ($self, %options) = @_; + + my $label = $self->{result_values}->{label} . '_used'; + my $value_perf = $self->{result_values}->{used}; + if (defined($instance_mode->{option_results}->{free})) { + $label = $self->{result_values}->{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("Total %s: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + ucfirst($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, $self->{result_values}->{prct_free}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + my $label = $options{extra_options}->{label_ref}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_' . $label . '_size'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_' . $label . '_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}; + $self->{result_values}->{label} = $label; + + 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-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::check_options(%options); + + $instance_mode = $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $options{sql}->connect(); + $options{sql}->query(query => q{ + select db_name(d.dbid) as db_name, +ceiling(sum(case when u.segmap != 4 then u.size/1.*@@maxpagesize end )) as data_size, +ceiling(sum(case when u.segmap != 4 then size - curunreservedpgs(u.dbid, u.lstart, u.unreservedpgs) end)/1.*@@maxpagesize) as data_used, +ceiling(sum(case when u.segmap = 4 then u.size/1.*@@maxpagesize end)) as log_size, +ceiling(sum(case when u.segmap = 4 then u.size/1.*@@maxpagesize end) - lct_admin("logsegment_freepages",d.dbid)/1.*@@maxpagesize) as log_used +from master..sysdatabases d, master..sysusages u +where u.dbid = d.dbid and d.status not in (256,4096) +group by d.dbid +order by db_name(d.dbid) + }); + + my $result = $options{sql}->fetchall_arrayref(); + + foreach my $row (@$result) { + if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' && + $$row[0] !~ /$self->{option_results}->{filter_database}/) { + $self->{output}->output_add(long_msg => "skipping '" . $$row[0] . "': no matching filter.", debug => 1); + next; + } + + $self->{database}->{$$row[0]} = { data_size => $$row[1], data_used => $$row[2], + log_size => $$row[3], log_used => $$row[4], + display => lc($$row[0]) }; + } +} + +1; + +__END__ + +=head1 MODE + +Check MSSQL Database usage + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'data', 'log'. + +=item B<--critical-*> + +Threshold warning. +Can be: 'data', 'log'. + +=item B<--filter-database> + +Filter database by name. Can be a regex + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=back + +=cut diff --git a/centreon-plugins/database/sybase/plugin.pm b/centreon-plugins/database/sybase/plugin.pm new file mode 100644 index 000000000..b85f4ee2b --- /dev/null +++ b/centreon-plugins/database/sybase/plugin.pm @@ -0,0 +1,104 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::sybase::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_sql); + +sub new { + my ($class, %options) = @_; + + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'blocked-processes' => 'database::sybase::mode::blockedprocesses', + 'connected-users' => 'database::sybase::mode::connectedusers', + 'connection-time' => 'centreon::common::protocols::sql::mode::connectiontime', + 'databases-size' => 'database::sybase::mode::databasessize', + 'sql' => 'centreon::common::protocols::sql::mode::sql', + ); + + return $self; +} + +sub init { + my ($self, %options) = @_; + + $self->{options}->add_options( + arguments => { + 'hostname:s@' => { name => 'hostname' }, + 'port:s@' => { name => 'port' }, + 'tds-level:s@' => { name => 'tds_level' }, + 'database:s' => { name => 'database' }, + } + ); + $self->{options}->parse_options(); + my $options_result = $self->{options}->get_options(); + $self->{options}->clean(); + + if (defined($options_result->{hostname})) { + @{$self->{sqldefault}->{dbi}} = (); + for (my $i = 0; $i < scalar(@{$options_result->{hostname}}); $i++) { + $self->{sqldefault}->{dbi}[$i] = { data_source => 'Sybase:host=' . $options_result->{hostname}[$i] }; + my $port = defined($options_result->{port}[$i]) && $options_result->{port}[$i] ne '' + ? $options_result->{port}[$i] : 2638; + $self->{sqldefault}->{dbi}[$i]->{data_source} .= ';port=' . $port; + + my $tds_level = defined($options_result->{tds_level}[$i]) && $options_result->{tds_level}[$i] ne '' + ? $options_result->{tds_level}[$i] : 'CS_TDS_50'; + $self->{sqldefault}->{dbi}[$i]->{data_source} .= ';tdsLevel=' . $tds_level; + + if ((defined($options_result->{database})) && ($options_result->{database} ne '')) { + $self->{sqldefault}->{dbi}[$i]->{data_source} .= ';database=' . $options_result->{database}; + } + } + } + $self->SUPER::init(%options); +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Sybase Server. + +=over 8 + +=item B<--hostname> + +Hostname to query. + +=item B<--port> + +Database Server Port (Default: 2638). + +=item B<--tds-level> + +TDS protocol level to use (Default: 'CS_TDS_50') + +=back + +=cut From 75e719884faea0b6aa4e170cc0b01ff035871e39 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 13 Oct 2016 22:52:03 +0200 Subject: [PATCH 072/103] + Fix #489 --- centreon-plugins/database/postgres/mode/hitratio.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/database/postgres/mode/hitratio.pm b/centreon-plugins/database/postgres/mode/hitratio.pm index c9b3e482b..335e730e7 100644 --- a/centreon-plugins/database/postgres/mode/hitratio.pm +++ b/centreon-plugins/database/postgres/mode/hitratio.pm @@ -105,8 +105,8 @@ WHERE d.oid=sd.datid my %prcts = (); my $total_read_requests = $new_datas->{$$row[2] . '_blks_hit'} - $old_blks_hit; my $total_read_disk = $new_datas->{$$row[2] . '_blks_read'} - $old_blks_read; - $prcts{hitratio_now} = ($total_read_requests == 0) ? 100 : ($total_read_requests - $total_read_disk) * 100 / $total_read_requests; - $prcts{hitratio} = ($new_datas->{$$row[2] . '_blks_hit'} == 0) ? 100 : ($new_datas->{$$row[2] . '_blks_hit'} - $new_datas->{$$row[2] . '_blks_read'}) * 100 / $new_datas->{$$row[2] . '_blks_hit'}; + $prcts{hitratio_now} = (($total_read_requests + $total_read_disk) == 0) ? 100 : $total_read_requests * 100 / ($total_read_requests + $total_read_disk); + $prcts{hitratio} = (($new_datas->{$$row[2] . '_blks_hit'} + + $new_datas->{$$row[2] . '_blks_read'}) == 0) ? 100 : $new_datas->{$$row[2] . '_blks_hit'} * 100 / ($new_datas->{$$row[2] . '_blks_hit'} + $new_datas->{$$row[2] . '_blks_read'}); my $exit_code = $self->{perfdata}->threshold_check(value => $prcts{'hitratio' . ((defined($self->{option_results}->{lookback})) ? '' : '_now' )}, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(long_msg => sprintf("Database '%s' hitratio at %.2f%%", From de50601fe2398210037344279b4c5d21dbb67cfc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 14 Oct 2016 12:12:17 +0200 Subject: [PATCH 073/103] + enhance vtom mode --- .../apps/vtom/restapi/mode/jobstatus.pm | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm index 74f018948..ec3eb05f0 100644 --- a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm +++ b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm @@ -55,6 +55,9 @@ sub custom_status_threshold { sub custom_status_output { my ($self, %options) = @_; my $msg = 'status : ' . $self->{result_values}->{status}; + if ($self->{result_values}->{information} ne '') { + $msg .= ' [information: ' . $self->{result_values}->{information} . ']'; + } return $msg; } @@ -66,6 +69,7 @@ sub custom_status_calc { $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{exit_code} = $options{new_datas}->{$self->{instance} . '_exit_code'}; $self->{result_values}->{family} = $options{new_datas}->{$self->{instance} . '_family'}; + $self->{result_values}->{information} = $options{new_datas}->{$self->{instance} . '_information'}; return 0; } @@ -124,7 +128,7 @@ sub set_counters { $self->{maps_counters}->{job} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'display' }, { name => 'exit_code' }, { name => 'family' } ], + key_values => [ { name => 'status' }, { name => 'display' }, { name => 'exit_code' }, { name => 'family' }, { name => 'information' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, @@ -199,6 +203,7 @@ sub new { $options{options}->add_options(arguments => { "filter-name:s" => { name => 'filter_name' }, + "filter-family:s" => { name => 'filter_family' }, "warning-status:s" => { name => 'warning_status' }, "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /Error/i' }, "warning-long:s" => { name => 'warning_long' }, @@ -261,16 +266,24 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $entry->{name} . "': no matching filter.", debug => 1); next; } + my $family = defined($entry->{family}) ? $entry->{family} : '-'; + if (defined($self->{option_results}->{filter_family}) && $self->{option_results}->{filter_family} ne '' && + $family !~ /$self->{option_results}->{filter_family}/) { + $self->{output}->output_add(long_msg => "skipping '" . $family . "': no matching filter.", debug => 1); + next; + } + my $information = defined($entry->{information}) ? $entry->{information} : ''; + $information =~ s/\|/-/msg; my $elapsed_time = $current_time - $entry->{timeBegin}; $self->{global}->{total} += 1; $self->{global}->{lc($mapping_job_status{$entry->{status}})} += 1; $self->{job}->{$entry->{id}} = { display => $entry->{name}, - status => $mapping_job_status{$entry->{status}}, + status => $mapping_job_status{$entry->{status}}, information => $information, exit_code => $entry->{retcode}, - family => defined($entry->{family}) ? $entry->{family} : '-', + family => $family, elapsed => $elapsed_time }; } @@ -296,6 +309,10 @@ Check job status. Filter name (can be a regexp). +=item B<--filter-family> + +Filter family (can be a regexp). + =item B<--filter-counters> Only display some counters (regexp can be used). @@ -316,12 +333,14 @@ Can be: 'total-error', 'total-running', 'total-unplanned', =item B<--warning-status> Set warning threshold for status (Default: -) -Can used special variables like: %{display}, %{status}, %{exit_code}, %{family} +Can used special variables like: %{display}, %{status}, +%{exit_code}, %{family}, %{information} =item B<--critical-status> Set critical threshold for status (Default: '%{exit_code} =~ /Error/i'). -Can used special variables like: %{display}, %{status}, %{exit_code}, %{family} +Can used special variables like: %{display}, %{status}, +%{exit_code}, %{family}, %{information} =item B<--warning-long> From 610c261cc2013de0c850c2ea07cbff89ba4ff6db Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 14 Oct 2016 15:31:46 +0200 Subject: [PATCH 074/103] + Ref #517 --- .../network/cyberoam/snmp/mode/cpu.pm | 99 ++++++++++ .../network/cyberoam/snmp/mode/memory.pm | 177 ++++++++++++++++++ .../network/cyberoam/snmp/mode/requests.pm | 151 +++++++++++++++ .../network/cyberoam/snmp/mode/storage.pm | 134 +++++++++++++ .../network/cyberoam/snmp/plugin.pm | 53 ++++++ 5 files changed, 614 insertions(+) create mode 100644 centreon-plugins/network/cyberoam/snmp/mode/cpu.pm create mode 100644 centreon-plugins/network/cyberoam/snmp/mode/memory.pm create mode 100644 centreon-plugins/network/cyberoam/snmp/mode/requests.pm create mode 100644 centreon-plugins/network/cyberoam/snmp/mode/storage.pm create mode 100644 centreon-plugins/network/cyberoam/snmp/plugin.pm diff --git a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm new file mode 100644 index 000000000..5fda445f4 --- /dev/null +++ b/centreon-plugins/network/cyberoam/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::cyberoam::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_cpuPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.2.1.0'; + my $result = $self->{snmp}->get_leef(oids => [$oid_cpuPercentUsage], nothing_quit => 1); + + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_cpuPercentUsage}, + 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_cpuPercentUsage})); + $self->{output}->perfdata_add(label => "cpu", + value => $result->{$oid_cpuPercentUsage}, + 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/cyberoam/snmp/mode/memory.pm b/centreon-plugins/network/cyberoam/snmp/mode/memory.pm new file mode 100644 index 000000000..f54c2103f --- /dev/null +++ b/centreon-plugins/network/cyberoam/snmp/mode/memory.pm @@ -0,0 +1,177 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::cyberoam::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_memoryCapacity = '.1.3.6.1.4.1.21067.2.1.2.4.1.0'; # in MB + my $oid_memoryPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.4.2.0'; + my $oid_swapCapacity = '.1.3.6.1.4.1.21067.2.1.2.4.3.0'; # in MB + my $oid_swapPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.4.4.0'; + + my $result = $options{snmp}->get_leef(oids => [$oid_memoryCapacity, $oid_memoryPercentUsage, + $oid_swapCapacity, $oid_swapPercentUsage], + nothing_quit => 1); + my $memory_used = $result->{$oid_memoryPercentUsage} * $result->{$oid_memoryCapacity} * 1024 * 1024 / 100; + my $swap_used = $result->{$oid_swapPercentUsage} * $result->{$oid_swapCapacity} * 1024 * 1024 / 100; + $self->{memory} = { + free => $result->{$oid_memoryCapacity} * 1024 * 1024 - $memory_used, + used => $memory_used, + }; + $self->{swap} = { + free => $result->{$oid_swapCapacity} * 1024 * 1024 - $swap_used, + used => $swap_used, + }; +} + +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/network/cyberoam/snmp/mode/requests.pm b/centreon-plugins/network/cyberoam/snmp/mode/requests.pm new file mode 100644 index 000000000..7a84d7dd4 --- /dev/null +++ b/centreon-plugins/network/cyberoam/snmp/mode/requests.pm @@ -0,0 +1,151 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::cyberoam::snmp::mode::requests; + +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 => 'http-hits', set => { + key_values => [ { name => 'http_hits', diff => 1 } ], + output_template => 'http hits = %s', + perfdatas => [ + { label => 'http_hits', value => 'http_hits_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'ftp-hits', set => { + key_values => [ { name => 'ftp_hits', diff => 1 } ], + output_template => 'ftp hits = %s', + perfdatas => [ + { label => 'ftp_hits', value => 'ftp_hits_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'pop3-hits', set => { + key_values => [ { name => 'pop3_hits', diff => 1 } ], + output_template => 'pop3 hits = %s', + perfdatas => [ + { label => 'pop3_hits', value => 'pop3_hits_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'imap-hits', set => { + key_values => [ { name => 'imap_hits', diff => 1 } ], + output_template => 'imap hits = %s', + perfdatas => [ + { label => 'imap_hits', value => 'imap_hits_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'smtp-hits', set => { + key_values => [ { name => 'smtp_hits', diff => 1 } ], + output_template => 'smtp hits = %s', + perfdatas => [ + { label => 'smtp_hits', value => 'smtp_hits_absolute', template => '%s', min => 0 }, + ], + } + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Requests: "; +} + +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) = @_; + + if ($options{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + my $oid_httpHits = '.1.3.6.1.4.1.21067.2.1.2.7.0'; + my $oid_ftpHits = '.1.3.6.1.4.1.21067.2.1.2.8.0'; + my $oid_pop3Hits = '.1.3.6.1.4.1.21067.2.1.2.9.1.0'; + my $oid_imapHits = '.1.3.6.1.4.1.21067.2.1.2.9.2.0'; + my $oid_smtpHits = '.1.3.6.1.4.1.21067.2.1.2.9.3.0'; + my $result = $options{snmp}->get_leef(oids => [$oid_httpHits, $oid_ftpHits, $oid_pop3Hits, + $oid_imapHits, $oid_smtpHits], nothing_quit => 1); + + $self->{cache_name} = "cyberoam_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + $self->{global} = { http_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.1.0'}, + ftp_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.2.0'}, + pop3_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.3.0'}, + imap_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.4.0'}, + smtp_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.5.0'} }; +} + +1; + +__END__ + +=head1 MODE + +Check request statistics. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='http-hits' + +=item B<--warning-*> + +Threshold warning. +Can be: http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits. + +=item B<--critical-*> + +Threshold critical. +Can be: http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits. + +=back + +=cut diff --git a/centreon-plugins/network/cyberoam/snmp/mode/storage.pm b/centreon-plugins/network/cyberoam/snmp/mode/storage.pm new file mode 100644 index 000000000..d1643bd7a --- /dev/null +++ b/centreon-plugins/network/cyberoam/snmp/mode/storage.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 network::cyberoam::snmp::mode::storage; + +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("Storage 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} . '_used'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_total'} - $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'storage', type => 0 } + ]; + + $self->{maps_counters}->{storage} = [ + { label => 'usage', set => { + key_values => [ { 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 => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_diskCapacity = '.1.3.6.1.4.1.21067.2.1.2.3.1.0'; # in MB + my $oid_diskPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.3.2.0'; + my $result = $options{snmp}->get_leef(oids => [$oid_diskCapacity, $oid_diskPercentUsage], + nothing_quit => 1); + my $memory_used = $result->{$oid_memoryPercentUsage} * $result->{$oid_memoryCapacity} * 1024 * 1024 / 100; + $self->{memory} = { used => $result->{$oid_diskPercentUsage} * $result->{$oid_diskCapacity} * 1024 * 1024 / 100;, + total => $result->{$oid_diskCapacity} * 1024 * 1024 }; +} + +1; + +__END__ + +=head1 MODE + +Check storage 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/cyberoam/snmp/plugin.pm b/centreon-plugins/network/cyberoam/snmp/plugin.pm new file mode 100644 index 000000000..173b00067 --- /dev/null +++ b/centreon-plugins/network/cyberoam/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::cyberoam::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' => 'network::cyberoam::snmp::mode::cpu', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::cyberoam::snmp::mode::memory', + 'requests' => 'network::cyberoam::snmp::mode::requests', + 'storage' => 'network::cyberoam::snmp::mode::storage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Cyberoam equipments in SNMP. + +=cut From 51a3c200e0ce475daa076dfca33a142ffa2c87bc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 14 Oct 2016 15:51:31 +0200 Subject: [PATCH 075/103] + Fix #517 --- centreon-plugins/network/cyberoam/snmp/mode/cpu.pm | 2 +- .../network/cyberoam/snmp/mode/requests.pm | 10 +++++----- centreon-plugins/network/cyberoam/snmp/mode/storage.pm | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm index 5fda445f4..4392467f6 100644 --- a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm +++ b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm @@ -66,7 +66,7 @@ sub run { $self->{output}->output_add(severity => $exit, short_msg => sprintf("CPU Usage : %.2f", $result->{$oid_cpuPercentUsage})); $self->{output}->perfdata_add(label => "cpu", - value => $result->{$oid_cpuPercentUsage}, + value => sprintf("%.2f", $result->{$oid_cpuPercentUsage}), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); diff --git a/centreon-plugins/network/cyberoam/snmp/mode/requests.pm b/centreon-plugins/network/cyberoam/snmp/mode/requests.pm index 7a84d7dd4..c67433565 100644 --- a/centreon-plugins/network/cyberoam/snmp/mode/requests.pm +++ b/centreon-plugins/network/cyberoam/snmp/mode/requests.pm @@ -114,11 +114,11 @@ sub manage_selection { $self->{cache_name} = "cyberoam_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - $self->{global} = { http_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.1.0'}, - ftp_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.2.0'}, - pop3_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.3.0'}, - imap_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.4.0'}, - smtp_hits => $result->{'.1.3.6.1.4.1.3417.2.11.3.1.1.5.0'} }; + $self->{global} = { http_hits => $result->{$oid_httpHits}, + ftp_hits => $result->{$oid_ftpHits}, + pop3_hits => $result->{$oid_pop3Hits}, + imap_hits => $result->{$oid_imapHits}, + smtp_hits => $result->{$oid_smtpHits} }; } 1; diff --git a/centreon-plugins/network/cyberoam/snmp/mode/storage.pm b/centreon-plugins/network/cyberoam/snmp/mode/storage.pm index d1643bd7a..026016b75 100644 --- a/centreon-plugins/network/cyberoam/snmp/mode/storage.pm +++ b/centreon-plugins/network/cyberoam/snmp/mode/storage.pm @@ -106,8 +106,7 @@ sub manage_selection { my $oid_diskPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.3.2.0'; my $result = $options{snmp}->get_leef(oids => [$oid_diskCapacity, $oid_diskPercentUsage], nothing_quit => 1); - my $memory_used = $result->{$oid_memoryPercentUsage} * $result->{$oid_memoryCapacity} * 1024 * 1024 / 100; - $self->{memory} = { used => $result->{$oid_diskPercentUsage} * $result->{$oid_diskCapacity} * 1024 * 1024 / 100;, + $self->{storage} = { used => $result->{$oid_diskPercentUsage} * $result->{$oid_diskCapacity} * 1024 * 1024 / 100, total => $result->{$oid_diskCapacity} * 1024 * 1024 }; } From abee2108233ad5b211fd41cfe14915edc9437180 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 14 Oct 2016 15:53:49 +0200 Subject: [PATCH 076/103] + add unit in perfdata --- centreon-plugins/network/cyberoam/snmp/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm index 4392467f6..127a2d6c1 100644 --- a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm +++ b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm @@ -65,7 +65,7 @@ sub run { 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_cpuPercentUsage})); - $self->{output}->perfdata_add(label => "cpu", + $self->{output}->perfdata_add(label => "cpu", unit => '%', value => sprintf("%.2f", $result->{$oid_cpuPercentUsage}), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), From f231465c9631df9620c666280ab39c5cacd9a8e8 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 14 Oct 2016 15:54:58 +0200 Subject: [PATCH 077/103] + add percent in output --- centreon-plugins/network/cyberoam/snmp/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm index 127a2d6c1..458c83af3 100644 --- a/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm +++ b/centreon-plugins/network/cyberoam/snmp/mode/cpu.pm @@ -64,7 +64,7 @@ sub run { my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_cpuPercentUsage}, 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_cpuPercentUsage})); + short_msg => sprintf("CPU Usage : %.2f %%", $result->{$oid_cpuPercentUsage})); $self->{output}->perfdata_add(label => "cpu", unit => '%', value => sprintf("%.2f", $result->{$oid_cpuPercentUsage}), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), From 43d70b1ba859343c479f012ee53ebf54ff6f5e95 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 14 Oct 2016 16:02:40 +0200 Subject: [PATCH 078/103] + prepare release --- centreon-plugins/centreon/plugins/script.pm | 2 +- centreon-plugins/changelog | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/plugins/script.pm b/centreon-plugins/centreon/plugins/script.pm index 92a0e4a9e..cb46d945c 100644 --- a/centreon-plugins/centreon/plugins/script.pm +++ b/centreon-plugins/centreon/plugins/script.pm @@ -30,7 +30,7 @@ use Pod::Find qw(pod_where); my %handlers = (DIE => {}); -my $global_version = 20160902; +my $global_version = 20161014; my $alternative_fatpacker = 0; sub new { diff --git a/centreon-plugins/changelog b/centreon-plugins/changelog index 5ca6549db..3fd6a9beb 100644 --- a/centreon-plugins/changelog +++ b/centreon-plugins/changelog @@ -1,3 +1,13 @@ +2016-10-14 Quentin Garnier + * Plugin added: to check StorageTek SLxxx + * Plugin added: to check HP Storeonce Rest API + * Plugin added: to check Gorgy ntpserver SNMP + * Plugin added: to check Nortel/Avaya SNMP + * Plugin added: to check Vtom Rest API + * Plugin added: to check Sybase + * Plugin added: to check Cyberoam SNMP (#517) + * Minor fixes and enhancement + 2016-09-02 Quentin Garnier * Plugin added: to check HP-UX SNMP (#13) * Plugin added: to check Hitachi HNAS From efdbb021bb42a0f6c67bf6f3a1fe1e0b31c2d5a2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 17 Oct 2016 23:05:40 +0200 Subject: [PATCH 079/103] + factorize code --- .../standard/snmp/mode/components/fan.pm | 11 +- .../standard/snmp/mode/components/module.pm | 8 +- .../standard/snmp/mode/components/physical.pm | 8 +- .../standard/snmp/mode/components/psu.pm | 11 +- .../standard/snmp/mode/components/sensor.pm | 8 +- .../snmp/mode/components/temperature.pm | 8 +- .../standard/snmp/mode/components/voltage.pm | 8 +- .../cisco/standard/snmp/mode/environment.pm | 371 +++++------------- 8 files changed, 121 insertions(+), 312 deletions(-) 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 a869a541b..808494ad4 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 @@ -43,10 +43,9 @@ my $oid_cefcFanTrayOperStatus = '.1.3.6.1.4.1.9.9.117.1.4.1.1.1'; # CISCO-ENTITY my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_ciscoEnvMonFanStatusEntry }; - push @{$options{request}}, { oid => $oid_cefcFanTrayOperStatus }; + push @{$self->{request}}, { oid => $oid_ciscoEnvMonFanStatusEntry }, { oid => $oid_cefcFanTrayOperStatus }; } sub check_fan_envmon { @@ -64,7 +63,7 @@ sub check_fan_envmon { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonFanStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($result->{ciscoEnvMonFanState} =~ /not present/i && $self->absent_problem(section => 'fan', instance => $instance)); $self->{components}->{fan}->{total}++; @@ -95,7 +94,7 @@ sub check_fan_entity { my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, 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]", @@ -113,7 +112,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')); check_fan_envmon($self); check_fan_entity($self); 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 36987ed71..43838e7e1 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 @@ -61,9 +61,9 @@ my $oid_cefcModuleOperStatus = '.1.3.6.1.4.1.9.9.117.1.2.1.1.2'; my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_cefcModuleOperStatus }; + push @{$self->{request}}, { oid => $oid_cefcModuleOperStatus }; } sub check { @@ -71,7 +71,7 @@ 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_cefcModuleOperStatus}})) { $oid =~ /\.([0-9]+)$/; @@ -79,7 +79,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance); my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $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' status is %s [instance: %s]", 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 debfd9d0f..5462e5c5c 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 @@ -38,9 +38,9 @@ my $oid_cefcPhysicalStatus = '.1.3.6.1.4.1.9.9.117.1.5.1.1.1'; my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_cefcPhysicalStatus }; + push @{$self->{request}}, { oid => $oid_cefcPhysicalStatus }; } sub check { @@ -48,7 +48,7 @@ sub check { $self->{output}->output_add(long_msg => "Checking physicals"); $self->{components}->{physical} = {name => 'physical', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'physical')); + return if ($self->check_filter(section => 'physical')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcPhysicalStatus}})) { $oid =~ /\.([0-9]+)$/; @@ -61,7 +61,7 @@ sub check { next; } - next if ($self->check_exclude(section => 'physical', instance => $instance)); + next if ($self->check_filter(section => 'physical', instance => $instance)); $self->{components}->{physical}->{total}++; $self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]", 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 f92712a58..77549657b 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 @@ -58,10 +58,9 @@ my $oid_cefcFRUPowerOperStatus = '.1.3.6.1.4.1.9.9.117.1.1.2.1.2'; # CISCO-ENTIT my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_ciscoEnvMonSupplyStatusEntry }; - push @{$options{request}}, { oid => $oid_cefcFRUPowerOperStatus }; + push @{$self->{request}}, { oid => $oid_ciscoEnvMonSupplyStatusEntry }, { oid => $oid_cefcFRUPowerOperStatus }; } sub check_psu_envmon { @@ -80,7 +79,7 @@ sub check_psu_envmon { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}, instance => $instance); - next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($self->check_filter(section => 'psu', instance => $instance)); next if ($result->{ciscoEnvMonSupplyState} =~ /not present/i && $self->absent_problem(section => 'psu', instance => $instance)); $self->{components}->{psu}->{total}++; @@ -111,7 +110,7 @@ sub check_psu_entity { my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, 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]", @@ -129,7 +128,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')); check_psu_envmon($self); check_psu_entity($self); 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 8b0c93814..829cba91a 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 @@ -112,9 +112,9 @@ my $oid_entSensorThresholdEntry = '.1.3.6.1.4.1.9.9.91.1.2.1.1'; my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_entSensorValueEntry }, { oid => $oid_entSensorThresholdEntry }; + push @{$self->{request}}, { oid => $oid_entSensorValueEntry }, { oid => $oid_entSensorThresholdEntry }; } sub get_default_warning_threshold { @@ -178,7 +178,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_entSensorValueEntry}})) { next if ($oid !~ /^$mapping->{entSensorStatus}->{oid}\.(.*)$/); @@ -188,7 +188,7 @@ sub check { next if (!defined($self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance})); my $sensor_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; - next if ($self->check_exclude(section => 'sensor', instance => $instance)); + next if ($self->check_filter(section => 'sensor', instance => $instance)); $self->{components}->{sensor}->{total}++; $result->{entSensorValue} = defined($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 b9d045787..f5cd20453 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 @@ -42,9 +42,9 @@ my $mapping = { my $oid_ciscoEnvMonTemperatureStatusEntry = '.1.3.6.1.4.1.9.9.13.1.3.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_ciscoEnvMonTemperatureStatusEntry }; + push @{$self->{request}}, { oid => $oid_ciscoEnvMonTemperatureStatusEntry }; } sub check { @@ -52,14 +52,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_ciscoEnvMonTemperatureStatusEntry}})) { next if ($oid !~ /^$mapping->{ciscoEnvMonTemperatureState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, 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' status is %s [instance: %s] [value: %s C]", 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 9124f5e61..c77fe33a7 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 @@ -43,9 +43,9 @@ my $mapping = { my $oid_ciscoEnvMonVoltageStatusEntry = '.1.3.6.1.4.1.9.9.13.1.2.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_ciscoEnvMonVoltageStatusEntry }; + push @{$self->{request}}, { oid => $oid_ciscoEnvMonVoltageStatusEntry }; } sub check { @@ -53,14 +53,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_ciscoEnvMonVoltageStatusEntry}})) { next if ($oid !~ /^$mapping->{ciscoEnvMonVoltageState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, 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("Voltage '%s' status is %s [instance: %s] [value: %s C]", 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 0d57fc375..eeedf96ba 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm @@ -20,11 +20,86 @@ package centreon::common::cisco::standard::snmp::mode::environment; -use base qw(centreon::plugins::mode); +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|temperature|voltage|module|physical|sensor)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|sensor)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['unknown', 'UNKNOWN'], + ['down', 'CRITICAL'], + ['up', 'OK'], + + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['not present', 'OK'], + ['not functioning', 'WARNING'], + ], + psu => [ + ['^off*', 'WARNING'], + ['failed', 'CRITICAL'], + ['onButFanFail|onButInlinePowerFail', 'WARNING'], + ['on', 'OK'], + + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['not present', 'OK'], + ['not functioning', 'WARNING'], + ], + temperature => [ + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['not present', 'OK'], + ['not functioning', 'WARNING'], + ], + voltage => [ + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], + ['not present', 'OK'], + ['not functioning', 'WARNING'], + ], + module => [ + ['unknown|mdr', 'UNKNOWN'], + ['disabled|okButDiagFailed|missing|mismatchWithParent|mismatchConfig|dormant|outOfServiceAdmin|outOfServiceEnvTemp|powerCycled|okButPowerOverWarning|okButAuthFailed|fwMismatchFound|fwDownloadFailure', 'WARNING'], + ['failed|diagFailed|poweredDown|powerDenied|okButPowerOverCritical', 'CRITICAL'], + ['boot|selfTest|poweredUp|syncInProgress|upgrading|fwDownloadSuccess|ok', 'OK'], + ], + physical => [ + ['other', 'UNKNOWN'], + ['incompatible|unsupported', 'CRITICAL'], + ['supported', 'OK'], + ], + sensor => [ + ['ok', 'OK'], + ['unavailable', 'OK'], + ['nonoperational', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'centreon::common::cisco::standard::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor']; +} + +my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; +my $oid_ciscoEnvMonPresent = ".1.3.6.1.4.1.9.9.13.1.1"; + my %map_type_mon = ( 1 => 'oldAgs', 2 => 'ags', @@ -41,65 +116,17 @@ my %map_type_mon = ( 14 => 'other' ); -my $thresholds = { - fan => [ - ['unknown', 'UNKNOWN'], - ['down', 'CRITICAL'], - ['up', 'OK'], - - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['not present', 'OK'], - ['not functioning', 'WARNING'], - ], - psu => [ - ['^off*', 'WARNING'], - ['failed', 'CRITICAL'], - ['onButFanFail|onButInlinePowerFail', 'WARNING'], - ['on', 'OK'], - - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['not present', 'OK'], - ['not functioning', 'WARNING'], - ], - temperature => [ - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['not present', 'OK'], - ['not functioning', 'WARNING'], - ], - voltage => [ - ['normal', 'OK'], - ['warning', 'WARNING'], - ['critical', 'CRITICAL'], - ['shutdown', 'CRITICAL'], - ['not present', 'OK'], - ['not functioning', 'WARNING'], - ], - module => [ - ['unknown|mdr', 'UNKNOWN'], - ['disabled|okButDiagFailed|missing|mismatchWithParent|mismatchConfig|dormant|outOfServiceAdmin|outOfServiceEnvTemp|powerCycled|okButPowerOverWarning|okButAuthFailed|fwMismatchFound|fwDownloadFailure', 'WARNING'], - ['failed|diagFailed|poweredDown|powerDenied|okButPowerOverCritical', 'CRITICAL'], - ['boot|selfTest|poweredUp|syncInProgress|upgrading|fwDownloadSuccess|ok', 'OK'], - ], - physical => [ - ['other', 'UNKNOWN'], - ['incompatible|unsupported', 'CRITICAL'], - ['supported', 'OK'], - ], - sensor => [ - ['ok', 'OK'], - ['unavailable', 'OK'], - ['nonoperational', 'CRITICAL'], - ], -}; +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + + push @{$self->{request}}, { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent }; + $self->{results} = $self->{snmp}->get_multiple_table(oids => ); + $self->{output}->output_add(long_msg => sprintf("Environment type: %s", + defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ? + $map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} : 'unknown')); +} sub new { my ($class, %options) = @_; @@ -109,227 +136,11 @@ 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}}) { - 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|fan|psu)$/) { - $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}}) { - 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|sensor)/i) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature, voltage or sensor)."); - $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) = @_; - $self->{snmp} = $options{snmp}; - - my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2'; - my $oid_ciscoEnvMonPresent = ".1.3.6.1.4.1.9.9.13.1.1"; - my $snmp_request = [ { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent } ]; - - my @components = ('fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::cisco::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}) == 2) { - $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); - - $self->{output}->output_add(long_msg => sprintf("Environment type: %s", - defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ? - $map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} : 'unknown')); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "centreon::common::cisco::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}/i) { - 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__ @@ -345,15 +156,15 @@ Check environment (Power Supplies, Fans, Temperatures, Voltages, Modules, Physic Which component to check (Default: '.*'). Can be: 'fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'. -=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> From 791c0f6945382eebbcb29c9dcaa94d65586076e6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 18 Oct 2016 15:42:12 +0200 Subject: [PATCH 080/103] + Fix cisco --- .../centreon/common/cisco/standard/snmp/mode/environment.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 eeedf96ba..bbc007155 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/environment.pm @@ -122,7 +122,7 @@ sub snmp_execute { $self->{snmp} = $options{snmp}; push @{$self->{request}}, { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent }; - $self->{results} = $self->{snmp}->get_multiple_table(oids => ); + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); $self->{output}->output_add(long_msg => sprintf("Environment type: %s", defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ? $map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} : 'unknown')); From 1728fce77ad05e31f6feff300355f582bf083b12 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 20 Oct 2016 15:33:19 +0200 Subject: [PATCH 081/103] + update vtom --- .../apps/vtom/restapi/custom/api.pm | 42 ++++++ .../apps/vtom/restapi/mode/jobstatus.pm | 123 ++++++++++++------ 2 files changed, 124 insertions(+), 41 deletions(-) diff --git a/centreon-plugins/apps/vtom/restapi/custom/api.pm b/centreon-plugins/apps/vtom/restapi/custom/api.pm index 3a8629712..a5477323d 100644 --- a/centreon-plugins/apps/vtom/restapi/custom/api.pm +++ b/centreon-plugins/apps/vtom/restapi/custom/api.pm @@ -133,6 +133,48 @@ sub settings { $self->{http}->set_options(%{$self->{option_results}}); } +sub cache_environment { + my ($self, %options) = @_; + + my $has_cache_file = $options{statefile}->read(statefile => 'cache_vtom_env_' . $self->{hostname} . '_' . $self->{port}); + my $timestamp_cache = $options{statefile}->get(name => 'last_timestamp'); + my $environments = $options{statefile}->get(name => 'environments'); + if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($options{reload_cache_time}) * 60))) { + $environments = {}; + my $datas = { last_timestamp => time(), environments => $environments }; + my $result = $self->get(path => '/api/environment/list'); + if (defined($result->{result}->{rows})) { + foreach (@{$result->{result}->{rows}}) { + $environments->{$_->{id}} = $_->{name}; + } + } + $options{statefile}->write(data => $datas); + } + + return $environments; +} + +sub cache_application { + my ($self, %options) = @_; + + my $has_cache_file = $options{statefile}->read(statefile => 'cache_vtom_app_' . $self->{hostname} . '_' . $self->{port}); + my $timestamp_cache = $options{statefile}->get(name => 'last_timestamp'); + my $applications = $options{statefile}->get(name => 'applications'); + if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($options{reload_cache_time}) * 60))) { + $applications = {}; + my $datas = { last_timestamp => time(), applications => $applications }; + my $result = $self->get(path => '/api/application/list'); + if (defined($result->{result}->{rows})) { + foreach (@{$result->{result}->{rows}}) { + $applications->{$_->{id}} = { name => $_->{name}, envSId => $_->{envSId} }; + } + } + $options{statefile}->write(data => $datas); + } + + return $applications; +} + sub get { my ($self, %options) = @_; diff --git a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm index ec3eb05f0..5f63bbf91 100644 --- a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm +++ b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::misc; +use centreon::plugins::statefile; my $instance_mode; @@ -66,7 +67,9 @@ 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}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; + $self->{result_values}->{environment} = $options{new_datas}->{$self->{instance} . '_environment'}; + $self->{result_values}->{application} = $options{new_datas}->{$self->{instance} . '_application'}; $self->{result_values}->{exit_code} = $options{new_datas}->{$self->{instance} . '_exit_code'}; $self->{result_values}->{family} = $options{new_datas}->{$self->{instance} . '_family'}; $self->{result_values}->{information} = $options{new_datas}->{$self->{instance} . '_information'}; @@ -109,7 +112,9 @@ 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}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; + $self->{result_values}->{environment} = $options{new_datas}->{$self->{instance} . '_environment'}; + $self->{result_values}->{application} = $options{new_datas}->{$self->{instance} . '_application'}; $self->{result_values}->{elapsed} = $options{new_datas}->{$self->{instance} . '_elapsed'}; $self->{result_values}->{family} = $options{new_datas}->{$self->{instance} . '_family'}; @@ -128,7 +133,8 @@ sub set_counters { $self->{maps_counters}->{job} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'display' }, { name => 'exit_code' }, { name => 'family' }, { name => 'information' } ], + key_values => [ { name => 'status' }, { name => 'name' }, { name => 'environment' }, + { name => 'application' }, { name => 'exit_code' }, { name => 'family' }, { name => 'information' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, @@ -136,7 +142,8 @@ sub set_counters { } }, { label => 'long', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'display' }, { name => 'elapsed' }, { name => 'family' } ], + key_values => [ { name => 'status' }, { name => 'name' }, { name => 'environment' }, + { name => 'application' }, { name => 'elapsed' }, { name => 'family' } ], closure_custom_calc => $self->can('custom_long_calc'), closure_custom_output => $self->can('custom_long_output'), closure_custom_perfdata => sub { return 0; }, @@ -202,14 +209,18 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { + "filter-application:s" => { name => 'filter_application' }, "filter-name:s" => { name => 'filter_name' }, "filter-family:s" => { name => 'filter_family' }, "warning-status:s" => { name => 'warning_status' }, "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /Error/i' }, "warning-long:s" => { name => 'warning_long' }, "critical-long:s" => { name => 'critical_long' }, + "reload-cache-time:s" => { name => 'reload_cache_time', default => 180 }, }); - + $self->{statefile_cache_app} = centreon::plugins::statefile->new(%options); + $self->{statefile_cache_env} = centreon::plugins::statefile->new(%options); + return $self; } @@ -217,6 +228,8 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); + $self->{statefile_cache_app}->check_options(%options); + $self->{statefile_cache_env}->check_options(%options); $instance_mode = $self; $self->change_macros(); } @@ -230,7 +243,7 @@ sub prefix_global_output { sub prefix_job_output { my ($self, %options) = @_; - return "job '" . $options{instance_value}->{display} . "' "; + return "job '" . $options{instance_value}->{environment} . '/' . $options{instance_value}->{application} . '/' . $options{instance_value}->{name} . "' "; } sub change_macros { @@ -254,39 +267,57 @@ my %mapping_job_status = ( sub manage_selection { my ($self, %options) = @_; + my $environments = $options{custom}->cache_environment(statefile => $self->{statefile_cache_env}, + reload_cache_time => $self->{option_results}->{reload_cache_time}); + my $applications = $options{custom}->cache_application(statefile => $self->{statefile_cache_app}, + reload_cache_time => $self->{option_results}->{reload_cache_time}); + $self->{job} = {}; $self->{global} = { total => 0, running => 0, unplanned => 0, finished => 0, coming => 0, error => 0 }; - my $result = $options{custom}->get(path => '/api/job/getAll'); - + my $path = '/api/job/getAll'; + if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '') { + $path = '/api/job/list?applicationName=' . $self->{option_results}->{filter_application}; + } + my $result = $options{custom}->get(path => $path); + my $entries = defined($result->{result}) && ref($result->{result}) eq 'ARRAY' ? + $result->{result} : (defined($result->{result}->{rows}) ? + $result->{result}->{rows} : []); + my $current_time = time(); - if (defined($result->{result})) { - foreach my $entry (@{$result->{result}}) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $entry->{name} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $entry->{name} . "': no matching filter.", debug => 1); - next; - } - my $family = defined($entry->{family}) ? $entry->{family} : '-'; - if (defined($self->{option_results}->{filter_family}) && $self->{option_results}->{filter_family} ne '' && - $family !~ /$self->{option_results}->{filter_family}/) { - $self->{output}->output_add(long_msg => "skipping '" . $family . "': no matching filter.", debug => 1); - next; - } - - my $information = defined($entry->{information}) ? $entry->{information} : ''; - $information =~ s/\|/-/msg; - my $elapsed_time = $current_time - $entry->{timeBegin}; - - $self->{global}->{total} += 1; - $self->{global}->{lc($mapping_job_status{$entry->{status}})} += 1; - $self->{job}->{$entry->{id}} = { - display => $entry->{name}, - status => $mapping_job_status{$entry->{status}}, information => $information, - exit_code => $entry->{retcode}, - family => $family, - elapsed => $elapsed_time - }; + foreach my $entry (@{$entries}) { + my $application_sid = defined($entry->{applicationSId}) ? $entry->{applicationSId} : + (defined($entry->{appSId}) ? $entry->{appSId} : undef); + my $application = defined($application_sid) && defined($applications->{$application_sid}) ? + $applications->{$application_sid}->{name} : 'unknown'; + my $environment = defined($application_sid) && defined($applications->{$application_sid}) && defined($environments->{$applications->{$application_sid}->{envSId}}) ? + $environments->{$applications->{$application_sid}->{envSId}} : 'unknown'; + my $display = $environment . '/' . $application . '/' . $entry->{name}; + + 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; } + my $family = defined($entry->{family}) ? $entry->{family} : '-'; + if (defined($self->{option_results}->{filter_family}) && $self->{option_results}->{filter_family} ne '' && + $family !~ /$self->{option_results}->{filter_family}/) { + $self->{output}->output_add(long_msg => "skipping '" . $family . "': no matching filter.", debug => 1); + next; + } + + + my $information = defined($entry->{information}) ? $entry->{information} : ''; + $information =~ s/\|/-/msg; + + $self->{global}->{total} += 1; + $self->{global}->{lc($mapping_job_status{$entry->{status}})} += 1; + $self->{job}->{$entry->{id}} = { + name => $entry->{name}, + status => $mapping_job_status{$entry->{status}}, information => $information, + exit_code => defined($entry->{retcode}) ? $entry->{retcode} : '-', + family => $family, application => $application, environment => $environment, + elapsed => defined($entry->{timeBegin}) ? ( $current_time - $entry->{timeBegin}) : undef, + }; } if (scalar(keys %{$self->{job}}) <= 0) { @@ -305,6 +336,10 @@ Check job status. =over 8 +=item B<--filter-application> + +Filter application name (cannot be a regexp). + =item B<--filter-name> Filter name (can be a regexp). @@ -333,24 +368,30 @@ Can be: 'total-error', 'total-running', 'total-unplanned', =item B<--warning-status> Set warning threshold for status (Default: -) -Can used special variables like: %{display}, %{status}, -%{exit_code}, %{family}, %{information} +Can used special variables like: %{name}, %{status}, +%{exit_code}, %{family}, %{information}, %{environment}, %{application} =item B<--critical-status> Set critical threshold for status (Default: '%{exit_code} =~ /Error/i'). -Can used special variables like: %{display}, %{status}, -%{exit_code}, %{family}, %{information} +Can used special variables like: %{name}, %{status}, +%{exit_code}, %{family}, %{information}, %{environment}, %{application} =item B<--warning-long> Set warning threshold for long jobs (Default: none) -Can used special variables like: %{display}, %{status}, %{elapsed}, %{family} +Can used special variables like: %{name}, %{status}, %{elapsed}, +%{family}, %{environment}, %{application} =item B<--critical-long> Set critical threshold for long jobs (Default: none). -Can used special variables like: %{display}, %{status}, %{elapsed}, %{family} +Can used special variables like: %{name}, %{status}, %{elapsed}, +%{family}, %{environment}, %{application} + +=item B<--reload-cache-time> + +Time in seconds before reloading cache file (default: 180). =back From 4918545d572b646a93a9bf30800973f79dc727af Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 20 Oct 2016 15:37:23 +0200 Subject: [PATCH 082/103] + update vtom plugin mode --- centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm index 5f63bbf91..e376da865 100644 --- a/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm +++ b/centreon-plugins/apps/vtom/restapi/mode/jobstatus.pm @@ -210,6 +210,7 @@ sub new { $options{options}->add_options(arguments => { "filter-application:s" => { name => 'filter_application' }, + "filter-environment:s" => { name => 'filter_environment' }, "filter-name:s" => { name => 'filter_name' }, "filter-family:s" => { name => 'filter_family' }, "warning-status:s" => { name => 'warning_status' }, @@ -277,6 +278,9 @@ sub manage_selection { my $path = '/api/job/getAll'; if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '') { $path = '/api/job/list?applicationName=' . $self->{option_results}->{filter_application}; + } + if (defined($self->{option_results}->{filter_environment}) && $self->{option_results}->{filter_environment} ne '') { + $path = '/api/job/list?environmentName=' . $self->{option_results}->{filter_environment}; } my $result = $options{custom}->get(path => $path); my $entries = defined($result->{result}) && ref($result->{result}) eq 'ARRAY' ? @@ -336,6 +340,10 @@ Check job status. =over 8 +=item B<--filter-environment> + +Filter environment name (cannot be a regexp). + =item B<--filter-application> Filter application name (cannot be a regexp). From d8232223bae655751721e6c6b181ecf7e787577e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 21 Oct 2016 09:49:17 +0200 Subject: [PATCH 083/103] + update hwgste --- .../hwgste/snmp/mode/components/humidity.pm | 70 +++++ .../hwgste/snmp/mode/components/resources.pm | 57 ++++ .../snmp/mode/components/temperature.pm | 70 +++++ .../sensors/hwgste/snmp/mode/sensors.pm | 257 +++--------------- 4 files changed, 242 insertions(+), 212 deletions(-) create mode 100644 centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/humidity.pm create mode 100644 centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/resources.pm create mode 100644 centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/temperature.pm diff --git a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/humidity.pm b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/humidity.pm new file mode 100644 index 000000000..25e4437d9 --- /dev/null +++ b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/humidity.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 hardware::sensors::hwgste::snmp::mode::components::humidity; + +use strict; +use warnings; +use hardware::sensors::hwgste::snmp::mode::components::resources qw($mapping); + +my $oid_sensEntry = '.1.3.6.1.4.1.21796.4.1.3.1'; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking humidity"); + $self->{components}->{humidity} = {name => 'humidity', total => 0, skip => 0}; + return if ($self->check_filter(section => 'humidity')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_sensEntry}})) { + next if ($oid !~ /^$mapping->{sensState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sensEntry}, instance => $instance); + + next if (!(defined($result->{sensUnit}) && $result->{sensUnit} eq '%')); + next if ($self->check_filter(section => 'humidity', instance => $instance)); + $self->{components}->{humidity}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("humidity '%s' state is '%s' [instance: %s, value: %s]", + $result->{sensName}, $result->{sensState}, $instance, $result->{sensTemp})); + my $exit = $self->get_severity(section => 'humidity', label => 'default', + instance => $instance, value => $result->{sensState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("humidity '%s' state is '%s'", $result->{sensName}, $result->{sensState})); + } + + if ($result->{sensTemp} =~ /\d+/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{sensTemp}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("humidity '%s' value is %s %s", $result->{sensName}, $result->{sensTemp}, $result->{sensUnit})); + } + $self->{output}->perfdata_add(label => 'sensor_' . $result->{sensName}, unit => $result->{sensUnit}, + value => $result->{sensTemp}, + warning => $warn, + critical => $crit, min => 0, max => 100); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/resources.pm b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/resources.pm new file mode 100644 index 000000000..197d6a8a8 --- /dev/null +++ b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/resources.pm @@ -0,0 +1,57 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::hwgste::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %map_sens_unit; +our %map_sens_state; +our $mapping; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($mapping); + +%map_sens_state = ( + 0 => 'invalid', + 1 => 'normal', + 2 => 'outOfRangeLo', + 3 => 'outOfRangeHi', + 4 => 'alarmLo', + 5 => 'alarmHi', +); +%map_sens_unit = ( + 0 => '', # none + 1 => 'C', + 2 => 'F', + 3 => 'K', + 4 => '%', +); + +$mapping = { + sensName => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.2' }, + sensState => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.3', map => \%map_sens_state }, + sensTemp => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.4' }, + sensUnit => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.7', map => \%map_sens_unit }, +}; + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..6df7dadea --- /dev/null +++ b/centreon-plugins/hardware/sensors/hwgste/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 hardware::sensors::hwgste::snmp::mode::components::temperature; + +use strict; +use warnings; +use hardware::sensors::hwgste::snmp::mode::components::resources qw($mapping); + +my $oid_sensEntry = '.1.3.6.1.4.1.21796.4.1.3.1'; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperature"); + $self->{components}->{temperature} = {name => 'temperature', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_sensEntry}})) { + next if ($oid !~ /^$mapping->{sensState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sensEntry}, instance => $instance); + + next if (!(defined($result->{sensUnit}) && $result->{sensUnit} =~ /C|F|K/i)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' state is '%s' [instance: %s, value: %s]", + $result->{sensName}, $result->{sensState}, $instance, $result->{sensTemp})); + my $exit = $self->get_severity(section => 'temperature', label => 'default', + instance => $instance, value => $result->{sensState}); + 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->{sensName}, $result->{sensState})); + } + + if ($result->{sensTemp} =~ /\d+/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{sensTemp}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("temperature '%s' value is %s %s", $result->{sensName}, $result->{sensTemp}, $result->{sensUnit})); + } + $self->{output}->perfdata_add(label => 'sensor_' . $result->{sensName}, unit => $result->{sensUnit}, + value => $result->{sensTemp}, + warning => $warn, + critical => $crit); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm index 87a05108c..5794707b0 100644 --- a/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/hwgste/snmp/mode/sensors.pm @@ -20,226 +20,54 @@ package hardware::sensors::hwgste::snmp::mode::sensors; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::values; -my $thresholds = { - sensor => [ - ['invalid', 'UNKNOWN'], - ['normal', 'OK'], - ['outOfRangeLo', 'WARNING'], - ['outOfRangeHi', 'WARNING'], - ['alarmLo', 'CRITICAL'], - ['alarmHi', 'CRITICAL'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|humidity)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['invalid', 'UNKNOWN'], + ['normal', 'OK'], + ['outOfRangeLo', 'WARNING'], + ['outOfRangeHi', 'WARNING'], + ['alarmLo', 'CRITICAL'], + ['alarmHi', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::sensors::hwgste::snmp::mode::components'; + $self->{components_module} = ['temperature', 'humidity']; +} -my %map_temp_status = ( - 0 => 'invalid', - 1 => 'normal', - 2 => 'outOfRangeLo', - 3 => 'outOfRangeHi', - 4 => 'alarmLo', - 5 => 'alarmHi', -); -my %map_temp_unit = ( - 0 => '', # none - 1 => 'C', - 2 => 'F', - 3 => 'K', - 4 => '%', -); - -my $mapping = { - sensName => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.2' }, - sensState => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.3', map => \%map_temp_status }, - sensTemp => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.4' }, - sensUnit => { oid => '.1.3.6.1.4.1.21796.4.1.3.1.7', map => \%map_temp_unit }, -}; +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + my $oid_sensEntry = '.1.3.6.1.4.1.21796.4.1.3.1'; + push @{$self->{request}}, { oid => $oid_sensEntry }; + $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} = '0.9'; + + $self->{version} = '1.0'; $options{options}->add_options(arguments => - { - "filter:s@" => { name => 'filter' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, + { }); - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - $self->{filter} = []; - foreach my $val (@{$self->{option_results}->{filter}}) { - next if (!defined($val) || $val eq ''); - my @values = split (/,/, $val); - push @{$self->{filter}}, { filter => $values[0], instance => $values[1] }; - } - $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}}) { - 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 !~ /^(sensor)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: sensor)."); - $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) = @_; - $self->{snmp} = $options{snmp}; - - $self->{index} = {}; - my $oid_sensEntry = '.1.3.6.1.4.1.21796.4.1.3.1'; - - $self->{results} = $self->{snmp}->get_table(oid => $oid_sensEntry, nothing_quit => 1); - foreach my $oid (keys %{$self->{results}}) { - next if ($oid !~ /$mapping->{sensState}->{oid}\.(\d+)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); - - next if ($self->check_filter(section => 'sensor', instance => $instance)); - - $self->{output}->output_add(long_msg => sprintf("Sensor '%s' state is '%s' [instance: %s, value: %s]", - $result->{sensName}, $result->{sensState}, $instance, $result->{sensTemp})); - my $exit = $self->get_severity(section => 'sensor', - instance => $instance, value => $result->{sensState}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Sensor '%s' state is '%s'", $result->{sensName}, $result->{sensState})); - } - - if ($result->{sensTemp} =~ /\d+/) { - my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensor', instance => $instance, value => $result->{sensTemp}); - if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("Sensor '%s' value is %s %s", $result->{sensName}, $result->{sensTemp}, $result->{sensUnit})); - } - $self->{output}->perfdata_add(label => 'sensor_' . $result->{sensName}, unit => $result->{sensUnit}, - value => $result->{sensTemp}, - warning => $warn, - critical => $crit); - } - } - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All sensors are ok.")); - $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} =~ /$_->{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 && - (!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; + return $self; } 1; @@ -252,6 +80,11 @@ Check HWg-STE sensors. =over 8 +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'temperature', 'humidity'. + =item B<--filter> Exclude some parts. @@ -265,13 +98,13 @@ Example: --threshold-overload='sensor,CRITICAL,^(?!(normal)$)' =item B<--warning> -Set warning threshold for temperatures (syntax: type,instance,threshold) -Example: --warning='sensor,.*,30' +Set warning threshold for temperature, humidity (syntax: type,instance,threshold) +Example: --warning='temperature,.*,30' =item B<--critical> -Set critical threshold for temperatures (syntax: type,instance,threshold) -Example: --critical='sensor,.*,40' +Set critical threshold for temperature, humidity (syntax: type,instance,threshold) +Example: --critical='humidty,.*,40' =back From 9458d4726dd966ce43db8424be413415b4ab0da4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 27 Oct 2016 17:42:28 +0200 Subject: [PATCH 084/103] + Fix #523 --- centreon-plugins/snmp_standard/mode/storage.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/centreon-plugins/snmp_standard/mode/storage.pm b/centreon-plugins/snmp_standard/mode/storage.pm index 3d5a6a0b5..f1dcd18cb 100644 --- a/centreon-plugins/snmp_standard/mode/storage.pm +++ b/centreon-plugins/snmp_standard/mode/storage.pm @@ -162,6 +162,18 @@ sub run { foreach (sort @{$self->{storage_id_selected}}) { my $name_storage = $self->get_display_value(id => $_); + if (!defined($result->{$oid_hrStorageAllocationUnits . "." . $_})) { + if ($multiple == 0) { + $self->{output}->add_option_msg(severity => 'UNKNOWN', + short_msg => sprintf("Skipping storage '%s': not found (need to reload the cache)", + $name_storage)); + } else { + $self->{output}->add_option_msg(long_msg => sprintf("Skipping storage '%s': not found (need to reload the cache)", + $name_storage)); + } + next; + } + # in bytes hrStorageAllocationUnits my $total_size = $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_}; if ($total_size <= 0) { From 21e13c5f7caf74d675a74a4fa6c2e7605d112483 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 2 Nov 2016 11:15:43 +0100 Subject: [PATCH 085/103] + add jacarta plugin snmp --- .../jacarta/snmp/mode/components/humidity.pm | 110 +++++++++++++++ .../jacarta/snmp/mode/components/input.pm | 68 ++++++++++ .../jacarta/snmp/mode/components/resources.pm | 54 ++++++++ .../snmp/mode/components/temperature.pm | 111 ++++++++++++++++ .../sensors/jacarta/snmp/mode/sensors.pm | 125 ++++++++++++++++++ .../hardware/sensors/jacarta/snmp/plugin.pm | 48 +++++++ 6 files changed, 516 insertions(+) create mode 100644 centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm create mode 100644 centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/input.pm create mode 100644 centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/resources.pm create mode 100644 centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/hardware/sensors/jacarta/snmp/mode/sensors.pm create mode 100644 centreon-plugins/hardware/sensors/jacarta/snmp/plugin.pm diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm new file mode 100644 index 000000000..27a8b2b29 --- /dev/null +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm @@ -0,0 +1,110 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::jacarta::snmp::mode::components::humidity; + +use strict; +use warnings; +use hardware::sensors::jacarta::snmp::mode::components::resources qw(%map_default_status %map_state); + +my $mapping = { + isDeviceMonitorHumidityName => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.2' }, + isDeviceMonitorHumidity => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.3' }, + isDeviceMonitorHumidityAlarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.4', map => \%map_default_status }, +}; +my $mapping2 = { + isDeviceConfigHumidityLowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.3' }, + isDeviceConfigHumidityLowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.4' }, + isDeviceConfigHumidityHighWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.5' }, + isDeviceConfigHumidityHighCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.6' }, + isDeviceConfigHumidityLowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.9', map => \%map_state }, + isDeviceConfigHumidityLowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.10', map => \%map_state }, + isDeviceConfigHumidityHighWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.11', map => \%map_state }, + isDeviceConfigHumidityHighCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.12', map => \%map_state }, +}; +my $oid_isDeviceMonitorHumidityEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1'; +my $oid_isDeviceConfigHumidityEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_isDeviceMonitorHumidityEntry }, { oid => $oid_isDeviceConfigHumidityEntry }; +} + +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_isDeviceMonitorHumidityEntry}})) { + next if ($oid !~ /^$mapping->{isDeviceMonitorHumidityAlarm}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_isDeviceMonitorHumidityEntry}, instance => $instance); + my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_isDeviceConfigHumidityEntry}, instance => $instance); + + next if ($self->check_filter(section => 'humidity', instance => $instance)); + $self->{components}->{humidity}->{total}++; + + $result->{isDeviceMonitorHumidity} *= 0.01; + $self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]", + $result->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidityAlarm}, $instance, + $result->{isDeviceMonitorHumidity})); + + my $exit = $self->get_severity(label => 'default', section => 'humidity', value => $result->{isDeviceMonitorHumidityAlarm}); + 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->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidityAlarm})); + next; + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{isDeviceMonitorHumidity}); + if ($checked == 0) { + $result2->{isDeviceConfigHumidityLowWarning} = ($result2->{isDeviceConfigHumidityLowWarningState} eq 'enabled') ? + $result2->{isDeviceConfigHumidityLowWarning} * 0.01 : ''; + $result2->{isDeviceConfigHumidityLowCritical} = ($result2->{isDeviceConfigHumidityLowCriticalState} eq 'enabled') ? + $result2->{isDeviceConfigHumidityLowCritical} * 0.01 : ''; + $result2->{isDeviceConfigHumidityHighWarning} = ($result2->{isDeviceConfigHumidityHighWarningState} eq 'enabled') ? + $result2->{isDeviceConfigHumidityHighWarning} * 0.01 : ''; + $result2->{isDeviceConfigHumidityHighCritical} = ($result2->{isDeviceConfigHumidityHighCriticalState} eq 'enabled') ? + $result2->{isDeviceConfigHumidityHighCritical} * 0.01 : ''; + my $warn_th = $result2->{isDeviceConfigHumidityLowWarning} . ':' . $result2->{isDeviceConfigHumidityHighWarning}; + my $crit_th = $result2->{isDeviceConfigHumidityLowCritical} . ':' . $result2->{isDeviceConfigHumidityHighCritical}; + $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->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidity})); + } + $self->{output}->perfdata_add(label => 'humidity_' . $result->{isDeviceMonitorHumidityName}, unit => '%', + value => $result->{isDeviceMonitorHumidity}, + warning => $warn, + critical => $crit, + min => 0, max => 100); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/input.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/input.pm new file mode 100644 index 000000000..6d5f790c9 --- /dev/null +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/input.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 hardware::sensors::jacarta::snmp::mode::components::input; + +use strict; +use warnings; +use hardware::sensors::jacarta::snmp::mode::components::resources qw(%map_input_status); + +my $mapping = { + isDeviceMonitorDigitalInName => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.2' }, + isDeviceMonitorDigitalIn => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.3' }, + isDeviceMonitorDigitalInAlarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.4', map => \%map_input_status }, +}; +my $oid_isDeviceMonitorDigitalInEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_isDeviceMonitorDigitalInEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking digial inputs"); + $self->{components}->{input} = {name => 'inputs', total => 0, skip => 0}; + return if ($self->check_filter(section => 'input')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_isDeviceMonitorDigitalInEntry}})) { + next if ($oid !~ /^$mapping->{isDeviceMonitorDigitalInAlarm}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_isDeviceMonitorDigitalInEntry}, instance => $instance); + + next if ($self->check_filter(section => 'input', instance => $instance)); + $self->{components}->{input}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("input '%s' status is '%s' [instance = %s]", + $result->{isDeviceMonitorDigitalInName}, $result->{isDeviceMonitorDigitalInAlarm}, $instance, + )); + + my $exit = $self->get_severity(section => 'input', value => $result->{isDeviceMonitorDigitalInAlarm}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Input '%s' status is '%s'", $result->{isDeviceMonitorDigitalInName}, $result->{isDeviceMonitorDigitalInAlarm})); + next; + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/resources.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/resources.pm new file mode 100644 index 000000000..78e79a5a4 --- /dev/null +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/resources.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 hardware::sensors::jacarta::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %map_default_status; +our %map_input_status; +our %map_state; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(%map_default_status %map_input_status %map_state); + +%map_default_status = ( + 1 => 'unknown', + 2 => 'disable', + 3 => 'normal', + 4 => 'below-low-warning', + 5 => 'below-low-critical', + 6 => 'above-high-warning', + 7 => 'above-high-critical', +); + +%map_input_status = ( + 1 => 'normal', + 2 => 'triggered', +); + +%map_state = ( + 1 => 'enabled', + 2 => 'disabled', +); + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..4ccb84f00 --- /dev/null +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/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 hardware::sensors::jacarta::snmp::mode::components::temperature; + +use strict; +use warnings; +use hardware::sensors::jacarta::snmp::mode::components::resources qw(%map_default_status %map_state); + +my $mapping = { + isDeviceMonitorTemperatureName => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.2' }, + isDeviceMonitorTemperature => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.3' }, + isDeviceMonitorTemperatureAlarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.4', map => \%map_default_status }, +}; +my $mapping2 = { + isDeviceConfigTemperatureLowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.3' }, + isDeviceConfigTemperatureLowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.4' }, + isDeviceConfigTemperatureHighWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.5' }, + isDeviceConfigTemperatureHighCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.6' }, + isDeviceConfigTemperatureLowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.9', map => \%map_state }, + isDeviceConfigTemperatureLowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.10', map => \%map_state }, + isDeviceConfigTemperatureHighWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.11', map => \%map_state }, + isDeviceConfigTemperatureHighCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.12', map => \%map_state }, +}; + +my $oid_isDeviceMonitorTemperatureEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1'; +my $oid_isDeviceConfigTemperatureEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_isDeviceMonitorTemperatureEntry }, { oid => $oid_isDeviceConfigTemperatureEntry }; +} + +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_isDeviceMonitorTemperatureEntry}})) { + next if ($oid !~ /^$mapping->{isDeviceMonitorTemperatureAlarm}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_isDeviceMonitorTemperatureEntry}, instance => $instance); + my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_isDeviceConfigTemperatureEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $result->{isDeviceMonitorTemperature} *= 0.01; + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]", + $result->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperatureAlarm}, $instance, + $result->{isDeviceMonitorTemperature})); + + my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{isDeviceMonitorTemperatureAlarm}); + 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->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperatureAlarm})); + next; + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{isDeviceMonitorTemperature}); + if ($checked == 0) { + $result2->{isDeviceConfigTemperatureLowWarning} = ($result2->{isDeviceConfigTemperatureLowWarningState} eq 'enabled') ? + $result2->{isDeviceConfigTemperatureLowWarning} * 0.01 : ''; + $result2->{isDeviceConfigTemperatureLowCritical} = ($result2->{isDeviceConfigTemperatureLowCriticalState} eq 'enabled') ? + $result2->{isDeviceConfigTemperatureLowCritical} * 0.01 : ''; + $result2->{isDeviceConfigTemperatureHighWarning} = ($result2->{isDeviceConfigTemperatureHighWarningState} eq 'enabled') ? + $result2->{isDeviceConfigTemperatureHighWarning} * 0.01 : ''; + $result2->{isDeviceConfigTemperatureHighCritical} = ($result2->{isDeviceConfigTemperatureHighCriticalState} eq 'enabled') ? + $result2->{isDeviceConfigTemperatureHighCritical} * 0.01 : ''; + my $warn_th = $result2->{isDeviceConfigTemperatureLowWarning} . ':' . $result2->{isDeviceConfigTemperatureHighWarning}; + my $crit_th = $result2->{isDeviceConfigTemperatureLowCritical} . ':' . $result2->{isDeviceConfigTemperatureHighCritical}; + $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->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperature}, $self->{temperature_unit})); + } + $self->{output}->perfdata_add(label => 'temperature_' . $result->{isDeviceMonitorTemperatureName}, unit => $self->{temperature_unit}, + value => $result->{isDeviceMonitorTemperature}, + warning => $warn, + critical => $crit, + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/sensors.pm new file mode 100644 index 000000000..0618b2b69 --- /dev/null +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/sensors.pm @@ -0,0 +1,125 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::jacarta::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|input)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['unknown', 'UNKNOWN'], + ['disable', 'OK'], + ['normal', 'OK'], + ['below-low-warning', 'WARNING'], + ['below-low-critical', 'CRITICAL'], + ['above-high-warning', 'WARNING'], + ['above-high-critical', 'CRITICAL'], + ['sensorError', 'CRITICAL'], + ], + input => [ + ['normal', 'OK'], + ['triggered', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::sensors::jacarta::snmp::mode::components'; + $self->{components_module} = ['temperature', 'humidity', 'input']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + my $oid_isConfigTemperatureUnit = '.1.3.6.1.4.1.19011.1.3.2.1.2.16'; # .0 + push @{$self->{request}}, { oid => $oid_isConfigTemperatureUnit }; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); + + $self->{temperature_unit} = defined($self->{results}->{$oid_isConfigTemperatureUnit}->{$oid_isConfigTemperatureUnit . '.0'}) && $self->{results}->{$oid_isConfigTemperatureUnit}->{$oid_isConfigTemperatureUnit . '.0'} == 1 ? + 'C' : 'F'; +} + +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', 'input'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=input) +Can also exclude specific instance: --filter=temperature,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='temperature,CRITICAL,^(?!(normal)$)' + +=item B<--warning> + +Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,50' + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/plugin.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/plugin.pm new file mode 100644 index 000000000..4e6f24221 --- /dev/null +++ b/centreon-plugins/hardware/sensors/jacarta/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::jacarta::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::jacarta::snmp::mode::sensors', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Jacarta sensors in SNMP. + +=cut From 228c14f06b0ba12ac39326fb8cd7469341263641 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 2 Nov 2016 11:16:01 +0100 Subject: [PATCH 086/103] + update help --- .../hardware/sensors/akcp/snmp/mode/sensors.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm b/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm index 02c20526e..7dd909846 100644 --- a/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm +++ b/centreon-plugins/hardware/sensors/akcp/snmp/mode/sensors.pm @@ -92,8 +92,8 @@ 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 +Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=humidity) +Can also exclude specific instance: --filter=fan,1 =item B<--no-component> @@ -104,17 +104,17 @@ If total (with skipped) is 0. (Default: 'critical' returns). Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). -Example: --threshold-overload='psu,CRITICAL,^(?!(presentOK)$)' +Example: --threshold-overload='temperature,CRITICAL,^(?!(normal)$)' =item B<--warning> Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold) -Example: --warning='temperature,1,30' +Example: --warning='temperature,.*,30' =item B<--critical> Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold) -Example: --warning='temperature,1,50' +Example: --warning='temperature,.*,50' =back From 118ad05574b8cea44cba6649097658f1b49b0595 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 2 Nov 2016 14:13:54 +0100 Subject: [PATCH 087/103] + update sensor --- .../hardware/sensors/jacarta/snmp/mode/components/humidity.pm | 1 - .../hardware/sensors/jacarta/snmp/mode/components/temperature.pm | 1 - 2 files changed, 2 deletions(-) diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm index 27a8b2b29..658e4a80e 100644 --- a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/humidity.pm @@ -73,7 +73,6 @@ sub check { 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->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidityAlarm})); - next; } my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{isDeviceMonitorHumidity}); diff --git a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm index 4ccb84f00..a1ebc20eb 100644 --- a/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/sensors/jacarta/snmp/mode/components/temperature.pm @@ -74,7 +74,6 @@ sub check { 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->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperatureAlarm})); - next; } my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{isDeviceMonitorTemperature}); From 9ac132a7688cd702da4428f9485d0624fa1f5f66 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 3 Nov 2016 11:02:26 +0100 Subject: [PATCH 088/103] + add hsm safenet plugin --- .../mode/components/hwstatus.pm | 47 +++++ .../mode/components/temperature.pm | 50 ++++++ .../hsm/protecttoolkit/mode/hardware.pm | 170 ++++++++++++++++++ .../safenet/hsm/protecttoolkit/plugin.pm | 48 +++++ 4 files changed, 315 insertions(+) create mode 100644 centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/hwstatus.pm create mode 100644 centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/temperature.pm create mode 100644 centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm create mode 100644 centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/plugin.pm diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/hwstatus.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/hwstatus.pm new file mode 100644 index 000000000..db18a01c1 --- /dev/null +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/hwstatus.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 hardware::devices::safenet::hsm::protecttoolkit::mode::components::hwstatus; + +use strict; +use warnings; + +sub load { } + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking hardware status"); + return if ($self->check_filter(section => 'hwstatus')); + + return if ($self->{stdout} !~ /^Hardware Status\s+:\s+(.*?)\n/msi); + my $status = $1; + + $self->{output}->output_add(long_msg => sprintf("hardware status is '%s'", + $status)); + my $exit = $self->get_severity(section => 'hwstatus', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Hardware status is '%s'", + $status)); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/temperature.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/temperature.pm new file mode 100644 index 000000000..d4b87bdf1 --- /dev/null +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/temperature.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::devices::safenet::hsm::protecttoolkit::mode::components::temperature; + +use strict; +use warnings; + +sub load { } + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperature"); + return if ($self->check_filter(section => 'temperature')); + + return if ($self->{stdout} !~ /^Temperature\s+:\s+(\d+)/msi); + my $temperature = $1; + + $self->{output}->output_add(long_msg => sprintf("temperature is %d C", + $temperature)); + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => '0', value => $temperature); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature is %s C", $temperature)); + } + $self->{output}->perfdata_add(label => "temp", unit => 'C', + value => $temperature, + warning => $warn, + critical => $crit); +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm new file mode 100644 index 000000000..2741a5cf2 --- /dev/null +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.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 hardware::devices::safenet::hsm::protecttoolkit::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use centreon::plugins::misc; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(hwstatus|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + + $self->{cb_hook2} = 'cmd_execute'; + + $self->{thresholds} = { + hwstatus => [ + ['BATTERY OK', 'OK'], + ['.*', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'hardware::devices::safenet::hsm::protecttoolkit::mode::components'; + $self->{components_module} = ['hwstatus', 'temperature']; +} + +sub cmd_execute { + my ($self, %options) = @_; + + ($self->{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->{stdout} =~ s/\r//msg; +} + +sub display { + my ($self, %options) = @_; + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Hardware status is OK") + ); +} + +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' }, + "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 => 'ctconf' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-v 2>&1' }, + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check HSM hardware status. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'hwstatus', 'temperature'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=temperature) + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='hwstats,CRITICAL,^(?!(OK)$)' + +=item B<--warning> + +Set warning threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,50' + +=item B<--critical> + +Set critical threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,60' + +=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: 'ctconf'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: ''). + +=item B<--command-options> + +Command options (Default: '-v 2>&1'). + +=back + +=cut + diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/plugin.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/plugin.pm new file mode 100644 index 000000000..a57036928 --- /dev/null +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/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::devices::safenet::hsm::protecttoolkit::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' => 'hardware::devices::safenet::hsm::protecttoolkit::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Safenet HSM with ProtectToolkit. + +=cut From 34c5d8455e6b9b4c66db36df959e558ac7facba1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 3 Nov 2016 11:03:15 +0100 Subject: [PATCH 089/103] + add centreon hardware --- .../centreon/plugins/templates/hardware.pm | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/centreon-plugins/centreon/plugins/templates/hardware.pm b/centreon-plugins/centreon/plugins/templates/hardware.pm index d01a5e600..763d4323c 100644 --- a/centreon-plugins/centreon/plugins/templates/hardware.pm +++ b/centreon-plugins/centreon/plugins/templates/hardware.pm @@ -245,21 +245,8 @@ sub exec_components { } } -sub run { +sub display { 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_hook2}, %options); - $self->exec_components(%options); - $self->call_object_callback(method_name => $self->{cb_hook3}, %options); my $total_components = 0; my $display_by_component = ''; @@ -283,6 +270,25 @@ sub run { $self->{output}->output_add(severity => $self->{no_components}, short_msg => 'No components are checked.'); } +} + +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_hook2}, %options); + $self->exec_components(%options); + $self->call_object_callback(method_name => $self->{cb_hook3}, %options); + + $self->display(); $self->call_object_callback(method_name => $self->{cb_hook4}, %options); From 769aabd3c6b665614dc96b13062a712ecb02bea9 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 3 Nov 2016 15:44:18 +0100 Subject: [PATCH 090/103] + Fix #526 --- .../apps/protocols/x509/mode/validity.pm | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/centreon-plugins/apps/protocols/x509/mode/validity.pm b/centreon-plugins/apps/protocols/x509/mode/validity.pm index 1061fa6f3..0cc712ef0 100644 --- a/centreon-plugins/apps/protocols/x509/mode/validity.pm +++ b/centreon-plugins/apps/protocols/x509/mode/validity.pm @@ -26,7 +26,8 @@ use strict; use warnings; use IO::Socket::SSL; use Net::SSLeay; -use Date::Manip; +use Socket; +use centreon::plugins::misc; sub new { my ($class, %options) = @_; @@ -79,7 +80,6 @@ sub run { my ($self, %options) = @_; # Global variables - my $client = IO::Socket::SSL->new( PeerHost => $self->{option_results}->{hostname}, PeerPort => $self->{option_results}->{port}, @@ -101,22 +101,25 @@ sub run { $self->{output}->display(); $self->{output}->exit() } + + 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 #Expiration Date if ($self->{option_results}->{validity_mode} eq 'expiration') { + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Date::Manip', + error_msg => "Cannot load module 'Date::Manip'."); (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 $daysbefore = int((Date::Manip::UnixDate(Date::Manip::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)); + short_msg => sprintf("Certificate expiration for '%s' in days: %s - Validity Date: %s", $subject, $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 { @@ -124,16 +127,17 @@ sub run { } 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]; + for (my $i = 0; $i < $#subject_alt_names; $i += 2) { + my ($type, $name) = ($subject_alt_names[$i], $subject_alt_names[$i + 1]); + if ($type == GEN_IPADD) { + $name = inet_ntoa($name); + } + if ($name =~ /$self->{option_results}->{subjectname}/mi) { + push @subject_matched, $name; } else { - $self->{output}->output_add(long_msg => sprintf("Subject Name '%s' is also present in Certificate", $subject_alt_names[$i]), debug => 1); + $self->{output}->output_add(long_msg => sprintf("Subject Name '%s' is also present in Certificate", $name), debug => 1); } } - - if (@subject_matched == 0) { $self->{output}->output_add(severity => 'CRITICAL', @@ -148,10 +152,10 @@ sub run { 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)); + short_msg => sprintf("Issuer Name '%s' is present in Certificate '%s': %s", $self->{option_results}->{issuername}, $subject, $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)); + short_msg => sprintf("Issuer Name '%s' is not present in Certificate '%s': %s", $self->{option_results}->{issuername}, $subject, $issuer_name)); } } From ada6191fded40e75b1755ba40782393650b2687b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 3 Nov 2016 16:17:42 +0100 Subject: [PATCH 091/103] + Fix #528 --- .../centreon/common/aruba/snmp/mode/apusers.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm index bb85880f9..53293e32e 100644 --- a/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm +++ b/centreon-plugins/centreon/common/aruba/snmp/mode/apusers.pm @@ -122,11 +122,11 @@ sub set_counters { $self->{maps_counters}->{ap} = [ { label => 'total-ap', set => { - key_values => [ { name => 'users' }, { name => 'bssid' } ], + key_values => [ { name => 'users' }, { name => 'ap_id' } ], output_template => 'users : %s', perfdatas => [ { label => 'ap', value => 'users_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'bssid_absolute' }, + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'ap_id_absolute' }, ], } }, @@ -142,7 +142,7 @@ sub prefix_essid_output { sub prefix_ap_output { my ($self, %options) = @_; - return "AP '" . $options{instance_value}->{bssid} . "' "; + return "AP '" . $options{instance_value}->{ap_id} . "' "; } sub new { @@ -188,6 +188,7 @@ my $oid_wlsxUserEntry = '.1.3.6.1.4.1.14823.2.2.1.4.1.2.1'; my $oid_wlsxSwitchRole = '.1.3.6.1.4.1.14823.2.2.1.1.1.4'; my $oid_apESSID = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.2'; my $oid_apIpAddress = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.5'; +my $oid_wlanAPName = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3'; sub manage_selection { my ($self, %options) = @_; @@ -204,6 +205,7 @@ sub manage_selection { { oid => $mapping2->{nUserApBSSID}->{oid} }, { oid => $oid_apESSID }, { oid => $oid_apIpAddress }, + { oid => $oid_wlanAPName }, ], nothing_quit => 1); @@ -238,7 +240,10 @@ sub manage_selection { next if (defined($self->{option_results}->{filter_bssid}) && $self->{option_results}->{filter_bssid} ne '' && $bssid !~ /$self->{option_results}->{filter_bssid}/); - $self->{ap}->{$bssid} = { users => 0, bssid => $bssid } if (!defined($self->{ap}->{$bssid})); + my $ap_id = $bssid; + $ap_id = $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid} + if (defined($self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}) && $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid} ne ''); + $self->{ap}->{$bssid} = { users => 0, ap_id => $ap_id } if (!defined($self->{ap}->{$bssid})); $self->{ap}->{$bssid}->{users}++; $self->{essid}->{$map_ap{$bssid}->{essid}} = { users => 0, essid => $map_ap{$bssid}->{essid} } if (!defined($self->{essid}->{$map_ap{$bssid}->{essid}})); From 70734bd6c5ce1ee44077e5d792af839e94839481 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 3 Nov 2016 17:21:07 +0100 Subject: [PATCH 092/103] + enhance plugin --- .../protecttoolkit/mode/components/memory.pm | 51 +++++++++++++++++++ .../hsm/protecttoolkit/mode/hardware.pm | 21 +++++--- 2 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm new file mode 100644 index 000000000..46e0746b9 --- /dev/null +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.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 hardware::devices::safenet::hsm::protecttoolkit::mode::components::memory; + +use strict; +use warnings; + +sub load { } + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking memory"); + return if ($self->check_filter(section => 'memory')); + + return if ($self->{stdout} !~ /^Free Memory\s+:\s+(\d+)/msi); + my $free_memory = $1; + + my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free_memory); + $self->{output}->output_add(long_msg => sprintf("free memory is %s %s", + $free_value, $free_unit)); + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'memory', instance => '0', value => $free_memory); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Free memory is %s %s", $free_value, $free_unit)); + } + $self->{output}->perfdata_add(label => "free_memory", unit => 'B', + value => $free_memory, + warning => $warn, + critical => $crit, min => 0); +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm index 2741a5cf2..89f7960dd 100644 --- a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm @@ -29,8 +29,8 @@ use centreon::plugins::misc; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_overload_check_section_option} = '^(hwstatus|temperature)$'; - $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + $self->{regexp_threshold_overload_check_section_option} = '^(hwstatus|temperature|memory)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|memory)$'; $self->{cb_hook2} = 'cmd_execute'; @@ -42,7 +42,7 @@ sub set_system { }; $self->{components_path} = 'hardware::devices::safenet::hsm::protecttoolkit::mode::components'; - $self->{components_module} = ['hwstatus', 'temperature']; + $self->{components_module} = ['hwstatus', 'temperature', 'memory']; } sub cmd_execute { @@ -55,6 +55,15 @@ sub cmd_execute { command_path => $self->{option_results}->{command_path}, command_options => $self->{option_results}->{command_options}); $self->{stdout} =~ s/\r//msg; + my ($model, $firmware, $fm_status, $transport_mode, $security_mode) = ('unknown', 'unknown', 'unknown', 'unknown', 'unknown'); + $model = $1 if ($self->{stdout} =~ /^Model\s+:\s+(.*?)\s*\n/msi); + $firmware = $1 if ($self->{stdout} =~ /^Firmware Version\s+:\s+(.*?)\s*\n/msi); + $fm_status = $1 if ($self->{stdout} =~ /^FM Status\s+:\s+(.*?)\s*\n/msi); + $transport_mode = $1 if ($self->{stdout} =~ /^Transport Mode\s+:\s+(.*?)\s*\n/msi); + $security_mode = $1 if ($self->{stdout} =~ /^Security Mode\s+:\s+(.*?)\s*\n/msi); + $self->{output}->output_add(long_msg => sprintf("model: %s, firmware version: %s", $model, $firmware)); + $self->{output}->output_add(long_msg => sprintf("fm status: '%s', transport mode: '%s', security mode: '%s'", + $fm_status, $transport_mode, $security_mode)); } sub display { @@ -101,7 +110,7 @@ Check HSM hardware status. =item B<--component> Which component to check (Default: '.*'). -Can be: 'hwstatus', 'temperature'. +Can be: 'hwstatus', 'temperature', 'memory'. =item B<--filter> @@ -115,12 +124,12 @@ Example: --threshold-overload='hwstats,CRITICAL,^(?!(OK)$)' =item B<--warning> -Set warning threshold for 'temperature' (syntax: type,regexp,threshold) +Set warning threshold for 'temperature', 'memory' (syntax: type,regexp,threshold) Example: --warning='temperature,.*,50' =item B<--critical> -Set critical threshold for 'temperature' (syntax: type,regexp,threshold) +Set critical threshold for 'temperature', 'memory' (syntax: type,regexp,threshold) Example: --critical='temperature,.*,60' =item B<--remote> From 76a0d810d67f6b1977bb21de3722d82c4bc77730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duret?= Date: Fri, 4 Nov 2016 10:31:44 +0100 Subject: [PATCH 093/103] Add mode time --- centreon-plugins/os/aix/snmp/plugin.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/centreon-plugins/os/aix/snmp/plugin.pm b/centreon-plugins/os/aix/snmp/plugin.pm index fd4095883..3ba1d4b4d 100644 --- a/centreon-plugins/os/aix/snmp/plugin.pm +++ b/centreon-plugins/os/aix/snmp/plugin.pm @@ -38,6 +38,7 @@ sub new { 'processcount' => 'snmp_standard::mode::processcount', 'storage' => 'snmp_standard::mode::storage', 'swap' => 'os::aix::snmp::mode::swap', + 'time' => 'snmp_standard::mode::ntp', ); return $self; From 6f53d9df6add4f1b27951dd345cec260ae46e39c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 4 Nov 2016 11:38:59 +0100 Subject: [PATCH 094/103] + Fix #532 --- centreon-plugins/network/sonus/sbc/snmp/{ => mode}/callstats.pm | 0 centreon-plugins/network/sonus/sbc/snmp/{ => mode}/channels.pm | 0 centreon-plugins/network/sonus/sbc/snmp/{ => mode}/dspstats.pm | 0 centreon-plugins/network/sonus/sbc/{ => snmp}/plugin.pm | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename centreon-plugins/network/sonus/sbc/snmp/{ => mode}/callstats.pm (100%) rename centreon-plugins/network/sonus/sbc/snmp/{ => mode}/channels.pm (100%) rename centreon-plugins/network/sonus/sbc/snmp/{ => mode}/dspstats.pm (100%) rename centreon-plugins/network/sonus/sbc/{ => snmp}/plugin.pm (100%) diff --git a/centreon-plugins/network/sonus/sbc/snmp/callstats.pm b/centreon-plugins/network/sonus/sbc/snmp/mode/callstats.pm similarity index 100% rename from centreon-plugins/network/sonus/sbc/snmp/callstats.pm rename to centreon-plugins/network/sonus/sbc/snmp/mode/callstats.pm diff --git a/centreon-plugins/network/sonus/sbc/snmp/channels.pm b/centreon-plugins/network/sonus/sbc/snmp/mode/channels.pm similarity index 100% rename from centreon-plugins/network/sonus/sbc/snmp/channels.pm rename to centreon-plugins/network/sonus/sbc/snmp/mode/channels.pm diff --git a/centreon-plugins/network/sonus/sbc/snmp/dspstats.pm b/centreon-plugins/network/sonus/sbc/snmp/mode/dspstats.pm similarity index 100% rename from centreon-plugins/network/sonus/sbc/snmp/dspstats.pm rename to centreon-plugins/network/sonus/sbc/snmp/mode/dspstats.pm diff --git a/centreon-plugins/network/sonus/sbc/plugin.pm b/centreon-plugins/network/sonus/sbc/snmp/plugin.pm similarity index 100% rename from centreon-plugins/network/sonus/sbc/plugin.pm rename to centreon-plugins/network/sonus/sbc/snmp/plugin.pm From a888c8fae4f3d502faa66aac082f41558cfa171b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 4 Nov 2016 14:55:27 +0100 Subject: [PATCH 095/103] + update safenet hsm plugin --- .../protecttoolkit/mode/components/memory.pm | 28 ++++++++++++------- .../hsm/protecttoolkit/mode/hardware.pm | 4 +-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm index 46e0746b9..d6eb5e758 100644 --- a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/components/memory.pm @@ -31,21 +31,29 @@ sub check { $self->{output}->output_add(long_msg => "Checking memory"); return if ($self->check_filter(section => 'memory')); - return if ($self->{stdout} !~ /^Free Memory\s+:\s+(\d+)/msi); - my $free_memory = $1; + return if ($self->{stdout} !~ /^SM Size Free\/Total\s*:\s+(\d+)\/(\d+)/msi); + my ($free, $total) = ($1, $2); + my $used = $total - $free; + my $prct_used = $used * 100 / $total; + my $prct_free = 100 - $prct_used; - my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free_memory); - $self->{output}->output_add(long_msg => sprintf("free memory is %s %s", - $free_value, $free_unit)); - my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'memory', instance => '0', value => $free_memory); + my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free); + my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used); + my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total); + my $message = sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_value . " " . $total_unit, + $used_value . " " . $used_unit, $prct_used, + $free_value . " " . $free_unit, $prct_free); + $self->{output}->output_add(long_msg => $message); + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'memory', instance => '0', value => $prct_used); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Free memory is %s %s", $free_value, $free_unit)); + short_msg => $message); } - $self->{output}->perfdata_add(label => "free_memory", unit => 'B', - value => $free_memory, + $self->{output}->perfdata_add(label => "used_memory", unit => 'B', + value => $used, warning => $warn, - critical => $crit, min => 0); + critical => $crit, min => 0, total => $total); } 1; \ No newline at end of file diff --git a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm index 89f7960dd..171d41b27 100644 --- a/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm +++ b/centreon-plugins/hardware/devices/safenet/hsm/protecttoolkit/mode/hardware.pm @@ -91,7 +91,7 @@ sub new { "sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'ctconf' }, "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '-v 2>&1' }, + "command-options:s" => { name => 'command_options', default => '-v' }, }); return $self; @@ -171,7 +171,7 @@ Command path (Default: ''). =item B<--command-options> -Command options (Default: '-v 2>&1'). +Command options (Default: '-v'). =back From 66bd11554137892c86fa9be7c6b155a82843e55d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 4 Nov 2016 14:55:54 +0100 Subject: [PATCH 096/103] + Fix #10 : add ilo plugin --- .../server/hp/ilo/xmlapi/custom/api.pm | 337 ++++++++++++++++++ .../hp/ilo/xmlapi/mode/components/battery.pm | 68 ++++ .../hp/ilo/xmlapi/mode/components/cpu.pm | 68 ++++ .../hp/ilo/xmlapi/mode/components/ctrl.pm | 68 ++++ .../ilo/xmlapi/mode/components/driveencl.pm | 69 ++++ .../hp/ilo/xmlapi/mode/components/fan.pm | 83 +++++ .../hp/ilo/xmlapi/mode/components/ldrive.pm | 72 ++++ .../hp/ilo/xmlapi/mode/components/memory.pm | 74 ++++ .../hp/ilo/xmlapi/mode/components/nic.pm | 65 ++++ .../hp/ilo/xmlapi/mode/components/pdrive.pm | 117 ++++++ .../hp/ilo/xmlapi/mode/components/psu.pm | 69 ++++ .../ilo/xmlapi/mode/components/temperature.pm | 83 +++++ .../hp/ilo/xmlapi/mode/components/vrm.pm | 61 ++++ .../server/hp/ilo/xmlapi/mode/hardware.pm | 128 +++++++ .../hardware/server/hp/ilo/xmlapi/plugin.pm | 49 +++ 15 files changed, 1411 insertions(+) create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/custom/api.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/battery.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/cpu.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/ctrl.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/driveencl.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/fan.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/ldrive.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/memory.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/nic.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/pdrive.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/psu.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/temperature.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/vrm.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/hardware.pm create mode 100644 centreon-plugins/hardware/server/hp/ilo/xmlapi/plugin.pm diff --git a/centreon-plugins/hardware/server/hp/ilo/xmlapi/custom/api.pm b/centreon-plugins/hardware/server/hp/ilo/xmlapi/custom/api.pm new file mode 100644 index 000000000..b7b4a1d30 --- /dev/null +++ b/centreon-plugins/hardware/server/hp/ilo/xmlapi/custom/api.pm @@ -0,0 +1,337 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::hp::ilo::xmlapi::custom::api; + +use strict; +use warnings; +use IO::Socket::SSL; +use LWP::UserAgent; +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' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "port:s" => { name => 'port', default => 443 }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + 'ssl-opt:s%' => { name => 'ssl_opt' }, + "force-ilo3" => { name => 'force_ilo3' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'XML API 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) = @_; + + if (!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(); + } + if (!defined($self->{option_results}->{username}) || $self->{option_results}->{username} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to set username option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{password})) { + $self->{output}->add_option_msg(short_msg => "Need to set password option."); + $self->{output}->option_exit(); + } + + $self->{ssl_opts} = ''; + if (!defined($self->{option_results}->{ssl_opt})) { + $self->{ssl_opts} = 'SSL_verify_mode => SSL_VERIFY_NONE'; + } else { + foreach (keys %{$self->{option_results}->{ssl_opt}}) { + $self->{ssl_opts} .= "$_ => " . $self->{option_results}->{ssl_opt}->{$_} . ", "; + } + } + + return 0; +} + +sub find_ilo_version { + my ($self, %options) = @_; + + ($self->{ilo2}, $self->{ilo3}) = (0, 0); + my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}, + eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout}); + if (!$client) { + $self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR"); + $self->{output}->option_exit(); + } + + print $client 'POST /ribcl HTTP/1.1' . "\r\n"; + print $client "HOST: me" . "\r\n"; # Mandatory for http 1.1 + print $client "User-Agent: locfg-Perl-script/3.0\r\n"; + print $client "Content-length: 30" . "\r\n"; # Mandatory for http 1.1 + print $client 'Connection: Close' . "\r\n"; # Required + print $client "\r\n"; # End of http header + print $client "\r\n"; # Used by Content-length + my $ln = <$client>; + if ($ln =~ m/HTTP.1.1 200 OK/) { + $self->{ilo3} = 1; + } else { + $self->{ilo2} = 1; + } + close $client; +} + +sub get_ilo2_data { + my ($self, %options) = @_; + + my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}, + eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout}); + if (!$client) { + $self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR"); + $self->{output}->option_exit(); + } + print $client '' . "\r\n"; + print $client '' . "\r\n"; + print $client '' . "\r\n"; + print $client '' . "\r\n"; + print $client '' . "\r\n"; + print $client '' . "\r\n"; + print $client '' . "\r\n"; + print $client '' . "\r\n"; + + while (my $line = <$client>) { + $self->{content} .= $line; + } + close $client; +} + +sub get_ilo3_data { + my ($self, %options) = @_; + + my $xml_script = " + {option_results}->{username}\" PASSWORD=\"$self->{option_results}->{password}\"> + + + + + +"; + + my $ua = LWP::UserAgent->new(keep_alive => 0, protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout}); + my $req = HTTP::Request->new(POST => "https://" . $self->{option_results}->{hostname} . '/ribcl'); + $req->content_length(length($xml_script)); + $req->content($xml_script); + $req->header(TE => 'chunked'); + $req->header(Connection => 'Close'); + + my $context = new IO::Socket::SSL::SSL_Context(eval $self->{ssl_opts}); + IO::Socket::SSL::set_default_context($context); + + my $response = $ua->request($req); + $self->{content} = $response->content; + if (!$response->is_success) { + $self->{output}->add_option_msg(short_msg => "Cannot get data: $response->status_line"); + $self->{output}->option_exit(); + } +} + +sub check_ilo_error { + my ($self, %options) = @_; + + # Looking for: + # + while ($self->{content} =~ /]*?status="0x(.*?)"[^>]*?message='(.*?)'/msig) { + my ($status_code, $message) = ($1, $2); + if ($status_code !~ /^0+$/) { + $self->{output}->add_option_msg(short_msg => "Cannot get data: $2"); + $self->{output}->option_exit(); + } + } +} + +sub change_shitty_xml { + my ($self, %options) = @_; + + # Can be like that the root ???!! + $options{response} =~ s///mg; + # ILO2 can send: + # + # + # + # + # + # + # + # + # + # + # + # + $options{response} =~ s///mg; + + return $options{response}; +} + +sub get_ilo_response { + my ($self, %options) = @_; + + # ilo result is so shitty. We get the good result from size... + my ($length, $response) = (0, ''); + foreach (split /<\?xml.*?\?>/, $self->{content}) { + if (length($_) > $length) { + $response = $_; + $length = length($_); + } + } + + $response = $self->change_shitty_xml(response => $response); + my $xml_result; + eval { + $xml_result = XMLin($response, + ForceArray => ['FAN', 'TEMP', 'MODULE', 'SUPPLY', 'PROCESSOR', 'NIC', + 'SMART_STORAGE_BATTERY', 'CONTROLLER', 'DRIVE_ENCLOSURE', + 'LOGICAL_DRIVE', 'PHYSICAL_DRIVE', 'DRIVE_BAY']); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@"); + $self->{output}->option_exit(); + } + + return $xml_result; +} + +sub get_ilo_data { + my ($self, %options) = @_; + + $self->{content} = ''; + if (!defined($self->{option_results}->{force_ilo3})) { + $self->find_ilo_version(); + } else { + $self->{ilo3} = 1; + } + + if ($self->{ilo3} == 1) { + $self->get_ilo3_data(); + } else { + $self->get_ilo2_data(); + } + + $self->{content} =~ s/\r//sg; + $self->{output}->output_add(long_msg => $self->{content}, debug => 1); + + $self->check_ilo_error(); + return $self->get_ilo_response(); +} + +1; + +__END__ + +=head1 NAME + +ILO API + +=head1 SYNOPSIS + +ilo api + +=head1 XML API OPTIONS + +=over 8 + +=item B<--hostname> + +Hostname to query. + +=item B<--username> + +ILO username. + +=item B<--password> + +ILO password. + +=item B<--port> + +ILO Port (Default: 443). + +=item B<--timeout> + +Set timeout (Default: 30). + +=item B<--force-ilo3> + +Don't try to find ILO version. + +=item B<--ssl-opt> + +Set SSL Options (--ssl-opt="SSL_version=SSLv3"). +Default: --ssl-opt="SSL_version=SSL_VERIFY_NONE" + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/battery.pm b/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/battery.pm new file mode 100644 index 000000000..9f413f63f --- /dev/null +++ b/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/battery.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 hardware::server::hp::ilo::xmlapi::mode::components::battery; + +use strict; +use warnings; + +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_filter(section => 'battery')); + return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{POWER_SUPPLIES}->{SMART_STORAGE_BATTERY})); + + # + # + # + + foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{POWER_SUPPLIES}->{SMART_STORAGE_BATTERY}}) { + my $instance = $result->{LABEL}->{VALUE}; + + next if ($self->check_filter(section => 'battery', instance => $instance)); + next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i && + $self->absent_problem(section => 'battery', instance => $instance)); + + $self->{components}->{battery}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("battery '%s' status is '%s' [instance = %s]", + $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance)); + + my $exit = $self->get_severity(label => 'default', section => 'battery', value => $result->{STATUS}->{VALUE}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Battery '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/cpu.pm b/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/cpu.pm new file mode 100644 index 000000000..56d81ddf5 --- /dev/null +++ b/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/cpu.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 hardware::server::hp::ilo::xmlapi::mode::components::cpu; + +use strict; +use warnings; + +sub load { } + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cpu"); + $self->{components}->{cpu} = {name => 'cpu', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cpu')); + return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{PROCESSORS}->{PROCESSOR})); + + # + # + # + foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{PROCESSORS}->{PROCESSOR}}) { + my $instance = $result->{LABEL}->{VALUE}; + + next if ($self->check_filter(section => 'cpu', instance => $instance)); + next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i && + $self->absent_problem(section => 'cpu', instance => $instance)); + + $self->{components}->{cpu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cpu '%s' status is '%s' [instance = %s]", + $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance)); + + my $exit = $self->get_severity(label => 'default', section => 'CPU', value => $result->{STATUS}->{VALUE}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/ctrl.pm b/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/ctrl.pm new file mode 100644 index 000000000..70cb4e342 --- /dev/null +++ b/centreon-plugins/hardware/server/hp/ilo/xmlapi/mode/components/ctrl.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 hardware::server::hp::ilo::xmlapi::mode::components::ctrl; + +use strict; +use warnings; + +sub load { } + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking controllers"); + $self->{components}->{ctrl} = {name => 'ctrl', total => 0, skip => 0}; + return if ($self->check_filter(section => 'ctrl')); + return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER})); + + # + # + #