diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/components/fan.pm b/centreon-plugins/network/microsens/g6/snmp/mode/components/fan.pm new file mode 100644 index 000000000..c4efad11a --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/components/fan.pm @@ -0,0 +1,57 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::components::fan; + +use strict; +use warnings; + +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_filter(section => 'fan')); + + return if (!defined($self->{results}->{fan_status}) || $self->check_filter(section => 'fan', instance => 1)); + + $self->{output}->output_add( + long_msg => sprintf( + "fan '1' status is %s", + $self->{results}->{fan_status} + ) + ); + $self->{components}->{fan}->{total}++; + + my $exit = $self->get_severity(section => 'fan', instance => 1, value => $self->{results}->{fan_status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "fan '1' status is %s", + $self->{results}->{fan_status} + ) + ); + } +} + +1; diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/components/psu.pm b/centreon-plugins/network/microsens/g6/snmp/mode/components/psu.pm new file mode 100644 index 000000000..2f49ad39e --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/components/psu.pm @@ -0,0 +1,76 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::components::psu; + +use strict; +use warnings; + +sub load {} + +sub check_psu { + my ($self, %options) = @_; + + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is %s", + $options{name}, + $options{value} + ) + ); + $self->{components}->{psu}->{total}++; + + my $exit = $self->get_severity(section => 'psu', instance => $options{name}, value => $options{value}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "power supply '1' status is %s", + $options{name}, + $options{value} + ) + ); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking power supplies'); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + if (defined($self->{results}->{psu1_status}) && !$self->check_filter(section => 'psu', instance => 1)) { + check_psu( + $self, + value => $self->{results}->{psu1_status}, + name => 1 + ); + } + if (defined($self->{results}->{psu2_status}) && !$self->check_filter(section => 'psu', instance => 2)) { + check_psu( + $self, + value => $self->{results}->{psu2_status}, + name => 2 + ); + } +} + +1; diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/components/sdcard.pm b/centreon-plugins/network/microsens/g6/snmp/mode/components/sdcard.pm new file mode 100644 index 000000000..9fd69fc62 --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/components/sdcard.pm @@ -0,0 +1,57 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::components::sdcard; + +use strict; +use warnings; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking sd cards'); + $self->{components}->{sdcard} = { name => 'sdcard', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'sdcard')); + + return if (!defined($self->{results}->{sdcard_status}) || $self->check_filter(section => 'sdcard', instance => 1)); + + $self->{output}->output_add( + long_msg => sprintf( + "sd card '1' status is %s", + $self->{results}->{sdcard_status} + ) + ); + $self->{components}->{sdcard}->{total}++; + + my $exit = $self->get_severity(section => 'sdcard', instance => 1, value => $self->{results}->{sdcard_status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "sd card '1' status is %s", + $self->{results}->{sdcard_status} + ) + ); + } +} + +1; diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/components/temperature.pm b/centreon-plugins/network/microsens/g6/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..db0ccde02 --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/components/temperature.pm @@ -0,0 +1,65 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::components::temperature; + +use strict; +use warnings; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking temperatures'); + $self->{components}->{temperature} = { name => 'temperature', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + return if (!defined($self->{results}->{system_temp}) || $self->check_filter(section => 'temperature', instance => 1)); + + $self->{output}->output_add( + long_msg => sprintf( + "temperature system is %s C", + $self->{results}->{system_temp} + ) + ); + $self->{components}->{temperature}->{total}++; + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => 'system', value => $self->{results}->{system_temp}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "temperature system is '%s' C", $self->{results}->{system_temp} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => 'system', + value => $self->{results}->{system_temp}, + warning => $warn, + critical => $crit, + min => 0 + ); +} + +1; diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/cpudetailed.pm b/centreon-plugins/network/microsens/g6/snmp/mode/cpudetailed.pm new file mode 100644 index 000000000..55abfb29f --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/cpudetailed.pm @@ -0,0 +1,59 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::cpudetailed; + +use base qw(snmp_standard::mode::cpudetailed); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check system CPUs (UCD-SNMP-MIB) (User, Nice, System, Idle, Wait, Kernel, Interrupt, SoftIRQ, Steal, Guest, GuestNice) +An average of all CPUs. + +=over 8 + +=item B<--warning-*> + +Threshold warning in percent. +Can be: 'user', 'nice', 'system', 'idle', 'wait', 'kernel', 'interrupt', 'softirq', 'steal', 'guest', 'guestnice'. + +=item B<--critical-*> + +Threshold critical in percent. +Can be: 'user', 'nice', 'system', 'idle', 'wait', 'kernel', 'interrupt', 'softirq', 'steal', 'guest', 'guestnice'. + +=back + +=cut diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/hardware.pm b/centreon-plugins/network/microsens/g6/snmp/mode/hardware.pm new file mode 100644 index 000000000..e85a50595 --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/hardware.pm @@ -0,0 +1,144 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['ok', 'OK'], + ['unused', 'OK'], + ['degraded', 'WARNING'], + ['fail', 'CRITICAL'], + ['missing', 'OK'] + ], + psu => [ + ['ok', 'OK'], + ['overload', 'WARNING'], + ['inputLow', 'OK'], + ['fuseFail', 'CRITICAL'], + ['notApplicable', 'OK'], + ['unmanaged', 'OK'], + ['notInstalled', 'OK'], + ], + sdcard => [ + ['empty', 'OK'], + ['inserted', 'OK'], + ['writeProtected', 'OK'], + ['writing', 'OK'] + ] + }; + + $self->{components_path} = 'network::microsens::g6::snmp::mode::components'; + $self->{components_module} = ['fan', 'psu', 'sdcard', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + my $map_psu_status = { + 0 => 'ok', 1 => 'overload', 2 => 'inputLow', + 3 => 'fuseFail', 4 => 'notApplicable', + 5 => 'unmanaged', 6 => 'notInstalled' + }; + my $map_fan_status = { + 0 => 'unused', 1 => 'ok', 2 => 'degraded', + 3 => 'fail', 4 => 'missing' + }; + my $map_sdcard_status = { + 0 => 'empty', 1 => 'inserted', 2 => 'writeProtected', 3 => 'writing' + }; + my $mapping = { + system_temp => { oid => '.1.3.6.1.4.1.3181.10.6.1.30.104' }, # systemTemperature + psu1_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.100', map => $map_psu_status }, # hardwarePowerSupply1Status + psu2_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.101', map => $map_psu_status }, # hardwarePowerSupply2Status + fan_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.103', map => $map_fan_status }, # hardwareFanStatus + sdcard_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.104', map => $map_sdcard_status } # hardwareSdCardStatus + }; + + my $snmp_result = $options{snmp}->get_leef(oids => [ map($_->{oid} . '.0', values(%$mapping)) ]); + $self->{results} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1); + bless $self, $class; + + $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', 'sdcard', 'temperature'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan) +Can also exclude specific instance: --filter=psu,2 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='sdcard,WARNING,empty' + +=item B<--warning> + +Set warning threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,40' + +=item B<--critical> + +Set critical threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,50' + +=back + +=cut diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm b/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm new file mode 100644 index 000000000..260743e4b --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm @@ -0,0 +1,178 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::interfaces; + +use base qw(snmp_standard::mode::interfaces); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check interfaces. + +=over 8 + +=item B<--add-global> + +Check global port statistics (By default if no --add-* option is set). + +=item B<--add-status> + +Check interface status. + +=item B<--add-duplex-status> + +Check duplex status (with --warning-status and --critical-status). + +=item B<--add-traffic> + +Check interface traffic. + +=item B<--add-errors> + +Check interface errors. + +=item B<--add-cast> + +Check interface cast. + +=item B<--add-speed> + +Check interface speed. + +=item B<--add-volume> + +Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). +Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', +'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', +'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast', +'speed' (b/s). + +=item B<--units-traffic> + +Units of thresholds for the traffic (Default: 'percent_delta') ('percent_delta', 'bps', 'counter'). + +=item B<--units-errors> + +Units of thresholds for errors/discards (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter'). + +=item B<--units-cast> + +Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter'). + +=item B<--nagvis-perfdata> + +Display traffic perfdata to be compatible with nagvis widget. + +=item B<--interface> + +Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). + +=item B<--name> + +Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) + +=item B<--speed> + +Set interface speed for incoming/outgoing traffic (in Mb). + +=item B<--speed-in> + +Set interface speed for incoming traffic (in Mb). + +=item B<--speed-out> + +Set interface speed for outgoing traffic (in Mb). + +=item B<--map-speed-dsl> + +Get interface speed configuration for interface type 'adsl' and 'vdsl2'. + +Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name + +E.g: --map-speed-dsl=Et0.835,Et0-vdsl2 + +=item B<--force-counters64> + +Force to use 64 bits counters only. Can be used to improve performance. + +=item B<--force-counters32> + +Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy. + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--oid-filter> + +Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr). + +=item B<--oid-display> + +Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr). + +=item B<--oid-extra-display> + +Add an OID to display. + +=item B<--display-transform-src> + +Regexp src to transform display value. + +=item B<--display-transform-dst> + +Regexp dst to transform display value. + +=item B<--show-cache> + +Display cache interface datas. + +=back + +=cut diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/listsfp.pm b/centreon-plugins/network/microsens/g6/snmp/mode/listsfp.pm new file mode 100644 index 000000000..7460c0edb --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/listsfp.pm @@ -0,0 +1,134 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::listsfp; + +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; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $map_status = { + 0 => 'ok', 1 => 'laserDisabled', 2 => 'lossOfSignal', + 3 => 'txFailure', 4 => 'readError' +}; +my $map_type = { + 0 => 'empty', 1 => 'unknown', 2 => 'sfp', + 3 => 'gbic', 4 => 'sff', 5 => 'dwdmSfp', + 7 => 'xfp', 8 => 'csfpA', 9 => 'csfpB', + 10 => 'dwdmXfp', 11 => 'sfpPlus' +}; +my $mapping = { + port => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.2' }, # informationPort + location => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.3' }, # informationLocation + status => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.4', map => $map_status }, # informationLocation + type => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.5', map => $map_type } # informationLocation +}; +my $oid_sfp_entry = '.1.3.6.1.4.1.3181.10.6.1.34.100.1'; # informationEntry + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_sfp_entry, + start => $mapping->{port}->{oid}, + end => $mapping->{type}->{oid} + ); + + my $ports = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{port}->{oid}\.(.*)$/); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1); + $ports->{$1} = $result; + } + + return $ports; +} + +sub run { + my ($self, %options) = @_; + + my $ports = $self->manage_selection(%options); + foreach (sort keys %$ports) { + $self->{output}->output_add( + long_msg => sprintf( + '[port: %s] [location: %s] [status: %s] [type: %s]', + $ports->{$_}->{port}, + $ports->{$_}->{location}, + $ports->{$_}->{status}, + $ports->{$_}->{type} + ) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List sfp ports:' + ); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $ports = $self->manage_selection(%options); + foreach (sort keys %$ports) { + $self->{output}->add_disco_entry( + %{$ports->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List sfp ports. + +=over 8 + +=back + +=cut + diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/load.pm b/centreon-plugins/network/microsens/g6/snmp/mode/load.pm new file mode 100644 index 000000000..557d1beb3 --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/load.pm @@ -0,0 +1,60 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::load; + +use base qw(snmp_standard::mode::loadaverage); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +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). + +=item B<--average> + +Load average for the number of CPUs. + +=back + +=cut diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/memory.pm b/centreon-plugins/network/microsens/g6/snmp/mode/memory.pm new file mode 100644 index 000000000..46d0f5c93 --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/memory.pm @@ -0,0 +1,67 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::memory; + +use base qw(snmp_standard::mode::memory); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage (UCD-SNMP-MIB). + +=over 8 + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'absolute') (Deprecated. Please use new counters directly) + +=item B<--free> + +Thresholds are on free space left (Deprecated. Please use new counters directly) + +=item B<--swap> + +Check swap also. + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%), +'swap' (B), 'swap-free' (B), 'swap-prct' (%), +'buffer' (B), 'cached' (B), 'shared' (B). + +=back + +=cut diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/sfp.pm b/centreon-plugins/network/microsens/g6/snmp/mode/sfp.pm new file mode 100644 index 000000000..a5d8ff0cf --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/sfp.pm @@ -0,0 +1,215 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::sfp; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub sfp_long_output { + my ($self, %options) = @_; + + return sprintf( + "checking sfp port '%s'%s", + $options{instance}, + $options{instance_value}->{location} ne '' ? ' [location: ' . $options{instance_value}->{location} . ']' : '' + ); +} + +sub prefix_sfp_output { + my ($self, %options) = @_; + + return return sprintf( + "sfp port '%s'%s ", + $options{instance}, + $options{instance_value}->{location} ne '' ? ' [location: ' . $options{instance_value}->{location} . ']' : '' + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'sfp', type => 3, cb_prefix_output => 'prefix_sfp_output', cb_long_output => 'sfp_long_output', indent_long_output => ' ', message_multiple => 'All sfp ports are ok', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'power', type => 0, skipped_code => { -10 => 1 } }, + { name => 'temperature', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{status} = [ + { label => 'status', type => 2, critical_default => '%{status} =~ /txFailure|lossOfSignal|readError/', set => { + key_values => [ { name => 'status' }, { name => 'location' }, { name => 'port' } ], + output_template => 'status: %s', + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; + + $self->{maps_counters}->{power} = [ + { label => 'input-power', nlabel => 'port.input.power.dbm', set => { + key_values => [ { name => 'input' } ], + output_template => 'input power: %s dBm', + perfdatas => [ + { template => '%s', unit => 'dBm', label_extra_instance => 1 } + ] + } + }, + { label => 'output-power', nlabel => 'port.output.power.dbm', set => { + key_values => [ { name => 'output' } ], + output_template => 'output power: %s dBm', + perfdatas => [ + { template => '%s', unit => 'dBm', label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{temperature} = [ + { label => 'temperature', nlabel => 'port.temperature.celsius', set => { + key_values => [ { name => 'temperature' } ], + output_template => 'temperature: %.2f C', + perfdatas => [ + { template => '%s', unit => 'C', label_extra_instance => 1 } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-port:s' => { name => 'filter_port' } + }); + + return $self; +} + +my $map_status = { + 0 => 'ok', 1 => 'laserDisabled', 2 => 'lossOfSignal', + 3 => 'txFailure', 4 => 'readError' +}; +my $mapping = { + location => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.3' }, # informationLocation + status => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.4', map => $map_status }, # informationStatus + output_power => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.18' }, # informationTxPower + input_power => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.19' }, # informationRxPower + temperature => { oid => '.1.3.6.1.4.1.3181.10.6.1.34.100.1.20' } # informationTemperature +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_port = '.1.3.6.1.4.1.3181.10.6.1.34.100.1.2'; # informationPort + my $snmp_result = $options{snmp}->get_table( + oid => $oid_port, + nothing_quit => 1 + ); + + $self->{sfp} = {}; + foreach my $oid (keys %$snmp_result) { + $oid =~ /^$oid_port\.(.*)$/; + my $instance = $1; + + my $port = $snmp_result->{$oid}; + next if ($port == 0); + + if (defined($self->{option_results}->{filter_port}) && $self->{option_results}->{filter_port} ne '' && + $port !~ /$self->{option_results}->{filter_port}/) { + $self->{output}->output_add(long_msg => "skipping '" . $port . "': no matching filter.", debug => 1); + next; + } + + $self->{sfp}->{$port} = { + instance => $instance, + status => { port => $port }, + power => {}, + temperature => {} + }; + } + + if (scalar(keys %{$self->{sfp}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No sfp port found.'); + $self->{output}->option_exit(); + } + + $options{snmp}->load( + oids => [ + map($_->{oid}, values(%$mapping)) + ], + instances => [ map($_->{instance}, values(%{$self->{sfp}})) ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); + + foreach (keys %{$self->{sfp}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $self->{sfp}->{$_}->{instance}); + $self->{sfp}->{$_}->{status}->{status} = $result->{status}; + $self->{sfp}->{$_}->{location} = $result->{location}; + $self->{sfp}->{$_}->{status}->{location} = $result->{location}; + + $self->{sfp}->{$_}->{power}->{output} = $1 if ($result->{output_power} =~ /([0-9\.]+)/); + $self->{sfp}->{$_}->{power}->{input} = $1 if ($result->{input_power} =~ /([0-9\.]+)/); + $self->{sfp}->{$_}->{temperature}->{temperature} = $1 if ($result->{temperature} =~ /([0-9\.]+)\s*C/); + } +} + +1; + +__END__ + +=head1 MODE + +Check sfp ports. + +=over 8 + +=item B<--filter-port> + +Filter ports by index (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{name}, %{location} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /txFailure|lossOfSignal|readError/'). +Can used special variables like: %{status}, %{port}, %{location} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'temperature', 'input-power', 'output-power'. + +=back + +=cut diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/uptime.pm b/centreon-plugins/network/microsens/g6/snmp/mode/uptime.pm new file mode 100644 index 000000000..79e4d3f18 --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/mode/uptime.pm @@ -0,0 +1,77 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::snmp::mode::uptime; + +use base qw(snmp_standard::mode::uptime); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check system uptime. + +=over 8 + +=item B<--warning-uptime> + +Threshold warning. + +=item B<--critical-uptime> + +Threshold critical. + +=item B<--add-sysdesc> + +Display system description. + +=item B<--force-oid> + +Can choose your oid (numeric format only). + +=item B<--check-overload> + +Uptime counter limit is 4294967296 and overflow. +With that option, we manage the counter going back. But there is a few chance we can miss a reboot. + +=item B<--reboot-window> + +To be used with check-overload option. Time in milliseconds (Default: 5000) +You increase the chance of not missing a reboot if you decrease that value. + +=item B<--unit> + +Select the unit for performance data and thresholds. May be 's' for seconds, 'm' for minutes, +'h' for hours, 'd' for days, 'w' for weeks. Default is seconds + +=back diff --git a/centreon-plugins/network/microsens/g6/snmp/plugin.pm b/centreon-plugins/network/microsens/g6/snmp/plugin.pm new file mode 100644 index 000000000..9ddf82f3b --- /dev/null +++ b/centreon-plugins/network/microsens/g6/snmp/plugin.pm @@ -0,0 +1,55 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::microsens::g6::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->{modes} = { + 'cpu-detailed' => 'network::microsens::g6::snmp::mode::cpudetailed', + 'hardware' => 'network::microsens::g6::snmp::mode::hardware', + 'interfaces' => 'network::microsens::g6::snmp::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-sfp' => 'network::microsens::g6::snmp::mode::listsfp', + 'load' => 'network::microsens::g6::snmp::mode::load', + 'memory' => 'network::microsens::g6::snmp::mode::memory', + 'sfp' => 'network::microsens::g6::snmp::mode::sfp', + 'uptime' => 'network::microsens::g6::snmp::mode::uptime' + }; + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Microsens Generation 6 Ethernet Switches in SNMP. + +=cut