diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/components/fan.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/components/fan.pm new file mode 100644 index 000000000..a44610dc8 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/components/fan.pm @@ -0,0 +1,99 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::snmp::mode::components::fan; + +use strict; +use warnings; + +my $mapping_fan = { + name => { oid => '.1.3.6.1.4.1.12356.112.6.4.2.1.1.2' }, # fadcDeviceFanName + speed => { oid => '.1.3.6.1.4.1.12356.112.6.4.2.1.1.3' }, # fadcDeviceFanSpeed + status => { oid => '.1.3.6.1.4.1.12356.112.6.4.2.1.1.4' } # fadcDeviceFanStatus +}; +my $oid_fanTable = '.1.3.6.1.4.1.12356.112.6.4.2.1'; # fadcDeviceFanTable + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fanTable, start => $mapping_fan->{name}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking fans'); + $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanTable}})) { + next if ($oid !~ /^$mapping_fan->{status}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping_fan, results => $self->{results}->{$oid_fanTable}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{name})); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is %s [instance: %s, speed: %s]", + $result->{name}, + $result->{status}, + $instance, + $result->{speed} + ) + ); + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{status}); + 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->{name}, $result->{status} + ) + ); + } + + next if (!defined($result->{speed})); + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, name => $result->{name}, value => $result->{speed}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "fan '%s' speed is %s rpm", + $result->{name}, + $result->{speed} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.fan.speed.rpm', + unit => 'rpm', + instances => $result->{name}, + value => $result->{speed}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +1; diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/components/temperature.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..f8224c2d5 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/components/temperature.pm @@ -0,0 +1,101 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping_cpu = { + name => { oid => '.1.3.6.1.4.1.12356.112.6.1.1.1.2' }, # fadcCPUName + current => { oid => '.1.3.6.1.4.1.12356.112.6.1.1.1.3' } # fadcCPUTemp +}; +my $oid_cpuTable = '.1.3.6.1.4.1.12356.112.6.1.1'; # fadcCPUTable + +my $mapping_temp = { + name => { oid => '.1.3.6.1.4.1.12356.112.6.4.1.1.1.2' }, # fadcDeviceTempName + current => { oid => '.1.3.6.1.4.1.12356.112.6.4.1.1.1.3' } # fadcDeviceTempValue +}; +my $oid_tempTable = '.1.3.6.1.4.1.12356.112.6.4.1.1'; # fadcDeviceTempTable + +sub load { + my ($self) = @_; + + push @{$self->{request}}, + { oid => $oid_cpuTable, start => $mapping_cpu->{name}->{oid} }, + { oid => $oid_tempTable, start => $mapping_temp->{name}->{oid} } + ; +} + +sub check_temperature { + my ($self, %options) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $options{entry} }})) { + next if ($oid !~ /^$options{mapping}->{current}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{ $options{entry} }, instance => $instance); + + $instance = $options{type} . '.' . $instance; + next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{name})); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' is %s C [instance: %s]", + $result->{name}, + $result->{current}, + $instance, + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, name => $result->{name}, value => $result->{current}); + 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 centigrate", + $result->{name}, + $result->{current} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => $result->{name}, + value => $result->{current}, + warning => $warn, + critical => $crit + ); + } +} + +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')); + + check_temperature($self, entry => $oid_cpuTable, mapping => $mapping_cpu, type => 'cpu'); + check_temperature($self, entry => $oid_tempTable, mapping => $mapping_temp, type => 'device'); +} + +1; diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/cpu.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/cpu.pm new file mode 100644 index 000000000..4267948c1 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/cpu.pm @@ -0,0 +1,182 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub prefix_cpu_avg_output { + my ($self, %options) = @_; + + return $self->{cpu_avg}->{count} . " CPU(s) average usage is "; +} + +sub prefix_cpu_core_output { + my ($self, %options) = @_; + + return "CPU '" . $options{instance_value}->{core_id} . "' usage "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu_avg', type => 0, cb_prefix_output => 'prefix_cpu_avg_output', message_separator => ' ', skipped_code => { -10 => 1 } }, + { name => 'cpu_core', type => 1, cb_prefix_output => 'prefix_cpu_core_output', message_separator => ' ', message_multiple => 'All core cpu are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{cpu_avg} = [ + { label => 'average-2s', nlabel => 'cpu.utilization.2s.percentage', set => { + key_values => [ { name => 'average_2s' } ], + output_template => '%.2f %% (2s)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { + key_values => [ { name => 'average_1m' } ], + output_template => '%.2f %% (1m)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => { + key_values => [ { name => 'average_5m' } ], + output_template => '%.2f %% (5m)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + } + ]; + + $self->{maps_counters}->{cpu_core} = [ + { label => 'core-2s', nlabel => 'core.cpu.utilization.2s.percentage', set => { + key_values => [ { name => 'cpu_2s' } ], + output_template => '%.2f %% (2s)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + }, + { label => 'core-1m', nlabel => 'core.cpu.utilization.1m.percentage', set => { + key_values => [ { name => 'cpu_1m' } ], + output_template => '%.2f %% (1m)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + }, + { label => 'core-5m', nlabel => 'core.cpu.utilization.5m.percentage', set => { + key_values => [ { name => 'cpu_5m' } ], + output_template => '%.2f %% (5m)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', 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 => { + }); + + return $self; +} + +sub check_cpu_average { + my ($self, %options) = @_; + + my $count = scalar(keys %{$self->{cpu_core}}); + my ($avg_2s, $avg_1m, $avg_5m); + foreach (values %{$self->{cpu_core}}) { + $avg_2s = defined($avg_2s) ? $avg_2s + $_->{cpu_2s} : $_->{cpu_2s} + if (defined($_->{cpu_2s})); + $avg_1m = defined($avg_1m) ? $avg_1m + $_->{cpu_1m} : $_->{cpu_1m} + if (defined($_->{cpu_1m})); + $avg_5m = defined($avg_5m) ? $avg_5m + $_->{cpu_5m} : $_->{cpu_5m} + if (defined($_->{cpu_5m})); + } + + $self->{cpu_avg} = { + average_2s => defined($avg_2s) ? $avg_2s / $count : undef, + average_1m => defined($avg_1m) ? $avg_1m / $count : undef, + average_5m => defined($avg_5m) ? $avg_5m / $count : undef, + count => $count + }; +} + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.12356.112.1.40.1.2' }, # fadcCpuName + cpu_2s => { oid => '.1.3.6.1.4.1.12356.112.1.40.1.3' }, # fadcCpu2secAvgUsage + cpu_1m => { oid => '.1.3.6.1.4.1.12356.112.1.40.1.4' }, # fadcCpu1minAvgUsage + cpu_5m => { oid => '.1.3.6.1.4.1.12356.112.1.40.1.5' } # fadcCpu5minAvgUsage +}; +my $oid_cpu_table = '.1.3.6.1.4.1.12356.112.1.40.1'; # fadcSysCpuUsageTable + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_cpu_table, + nothing_quit => 1 + ); + + $self->{cpu_avg} = {}; + $self->{cpu_core} = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{cpu_5m}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + $self->{cpu_core}->{ $result->{name} } = { core_id => $instance, %$result }; + } + + $self->check_cpu_average(); +} + +1; + +__END__ + +=head1 MODE + +Check cpu usage. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'core-2s', 'core-1m', 'core-5m', 'average-2s', 'average-1m', 'average-5m'. + +=back + +=cut diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/hardware.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/hardware.pm new file mode 100644 index 000000000..176114f7b --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/hardware.pm @@ -0,0 +1,111 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::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} = '^(fan|temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['good', 'OK'], + ['removed', 'OK'], + ['.*', 'CRITICAL'] + ] + }; + + $self->{components_path} = 'network::fortinet::fortiadc::snmp::mode::components'; + $self->{components_module} = ['fan', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, 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', 'temperature'. + +=item B<--add-name-instance> + +Add literal description for instance value (used in filter and threshold options). + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan) +Can also exclude specific instance: --filter=fan,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,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='fan,CRITICAL,removed' + +=item B<--warning> + +Set warning threshold (syntax: section,[instance,]status,regexp) +Example: --warning='temperature,.*,30' --warning='fan,.*,9500' + +=item B<--critical> + +Set critical threshold (syntax: section,[instance,]status,regexp) +Example: --critical='temperature,.*,40' + +=back + +=cut diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/interfaces.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/interfaces.pm new file mode 100644 index 000000000..50f381c99 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/interfaces.pm @@ -0,0 +1,182 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::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<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + +=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/fortinet/fortiadc/snmp/mode/listvirtualservers.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/listvirtualservers.pm new file mode 100644 index 000000000..c81b4cd88 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/listvirtualservers.pm @@ -0,0 +1,113 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::snmp::mode::listvirtualservers; + +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 $mapping = { + name => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.2' }, # fadcVSName + state => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.3' }, # fadcVSStatus + status => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.4' }, # fadcVSHealth + vdom => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.8' } # fadcVSVdom +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_table = '.1.3.6.1.4.1.12356.112.3.2'; # fadcVSTable + my $snmp_result = $options{snmp}->get_table(oid => $oid_table); + my $results = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{name}->{oid}\.(.*)$/); + + $results->{$1} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1); + $results->{$1}->{state} = lc($results->{$1}->{state}); + $results->{$1}->{status} = lc($results->{$1}->{status}); + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach my $instance (sort keys %$results) { + $self->{output}->output_add(long_msg => + join('', map("[$_: " . $results->{$instance}->{$_} . ']', keys(%$mapping))) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List virtual servers:' + ); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + %{$results->{$_}} + ); + } +} +1; + +__END__ + +=head1 MODE + +List virtual servers. + +=over 8 + +=back + +=cut diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/memory.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/memory.pm new file mode 100644 index 000000000..c06e6ce37 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/memory.pm @@ -0,0 +1,88 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::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 => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'usage', nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'used_prct' } ], + output_template => 'memory used: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' }, + ] + } + } + ]; +} + +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 => {}); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_memUsed = '.1.3.6.1.4.1.12356.112.1.5.0'; # fadcSysMemUsage + my $snmp_result = $options{snmp}->get_leef( + oids => [ $oid_memUsed ], + nothing_quit => 1 + ); + + $self->{global} = { + used_prct => $snmp_result->{$oid_memUsed} + }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (%). + +=back + +=cut diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/security.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/security.pm new file mode 100644 index 000000000..571cb771a --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/security.pm @@ -0,0 +1,97 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::snmp::mode::security; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { + label => 'ddos-status', + type => 2, + critical_default => '%{status} eq "attacking"', + set => { + key_values => [ { name => 'status' } ], + output_template => 'DDoS status is %s', + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; +} + +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 => {}); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_ddos = '.1.3.6.1.4.1.12356.112.7.1.0'; # fadcDDoSAttackStatus + my $snmp_result = $options{snmp}->get_leef( + oids => [ $oid_ddos ], + nothing_quit => 1 + ); + + $self->{global} = { + status => $snmp_result->{$oid_ddos} == 1 ? 'attacking' : 'noAttack' + }; +} + +1; + +__END__ + +=head1 MODE + +Check security. + +=over 8 + +=item B<--warning-ddos-status> + +Set warning threshold for status. +Can used special variables like: %{status} + +=item B<--critical-ddos-status> + +Set critical threshold for status (Default: '%{status} eq "attacking"'). +Can used special variables like: %{status} + +=back + +=cut diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/mode/uptime.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/uptime.pm new file mode 100644 index 000000000..56421521d --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/uptime.pm @@ -0,0 +1,77 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::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/fortinet/fortiadc/snmp/mode/virtualservers.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/virtualservers.pm new file mode 100644 index 000000000..f5c87a77a --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/mode/virtualservers.pm @@ -0,0 +1,285 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::snmp::mode::virtualservers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_throughput_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + nlabel => $self->{nlabel}, + unit => 'b/s', + instances => [$self->{result_values}->{vdom}, $self->{result_values}->{name}], + value => $self->{result_values}->{throughput}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0 + ); +} + +sub custom_connections_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + nlabel => $self->{nlabel}, + instances => [$self->{result_values}->{vdom}, $self->{result_values}->{name}], + value => $self->{result_values}->{connections}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0 + ); +} + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + "status: %s [%s]", + $self->{result_values}->{status}, + $self->{result_values}->{state} + ); +} + +sub vs_long_output { + my ($self, %options) = @_; + + return sprintf( + "checking virtual server '%s' [vdom: %s]", + $options{instance_value}->{name}, + $options{instance_value}->{vdom} + ); +} + +sub prefix_vs_output { + my ($self, %options) = @_; + + return sprintf( + "virtual server '%s' [vdom: %s] ", + $options{instance_value}->{name}, + $options{instance_value}->{vdom} + ); +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return 'Virtual servers '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', }, + { name => 'vs', type => 3, cb_prefix_output => 'prefix_vs_output', cb_long_output => 'vs_long_output', + indent_long_output => ' ', message_multiple => 'All virtual servers are ok', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'stats', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'virtualservers-detected', display_ok => 0, nlabel => 'virtual_servers.detected.count', set => { + key_values => [ { name => 'detected' } ], + output_template => 'detected: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'virtualservers-healthy', display_ok => 0, nlabel => 'virtual_servers.healthy.count', set => { + key_values => [ { name => 'healthy' } ], + output_template => 'healthy: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{status} = [ + { + label => 'status', + type => 2, + critical_default => '%{status} eq "unhealthy"', + set => { + key_values => [ + { name => 'state' }, { name => 'status' }, + { name => 'name' }, { name => 'vdom' } + ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; + + $self->{maps_counters}->{stats} = [ + { label => 'virtualserver-connections', nlabel => 'virtual_server.connections.count', set => { + key_values => [ { name => 'connections' }, { name => 'name' }, { name => 'vdom' } ], + output_template => 'connections: %s', + closure_custom_perfdata => $self->can('custom_connections_perfdata') + } + }, + { label => 'virtualserver-throughput', nlabel => 'virtual_server.throughput.bitspersecond', set => { + key_values => [ { name => 'throughput' }, { name => 'name' }, { name => 'vdom' } ], + output_template => 'throughput: %.2f %s/s', + output_change_bytes => 2, + closure_custom_perfdata => $self->can('custom_throughput_perfdata') + } + } + ]; +} + +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-name:s' => { name => 'filter_name' }, + 'filter-vdom:s' => { name => 'filter_vdom' } + }); + + return $self; +} + +my $map_plex_status = { + 1 => 'offline', 2 => 'resyncing', 3 => 'online' +}; + +my $mapping = { + state => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.3' }, # fadcVSStatus + status => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.4' }, # fadcVSHealth + connections => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.6' }, # fadcVSConcurrent + throughput => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.7' }, # fadcVSThroughputKbps + vdom => { oid => '.1.3.6.1.4.1.12356.112.3.2.1.8' } # fadcVSVdom +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_vsName = '.1.3.6.1.4.1.12356.112.3.2.1.2'; # fadcVSName + my $snmp_result = $options{snmp}->get_table(oid => $oid_vsName, nothing_quit => 1); + + $self->{global} = { detected => 0, healthy => 0, unhealthy => 0 }; + $self->{vs} = {}; + foreach my $oid (keys %$snmp_result) { + $oid =~ /^$oid_vsName\.(.*)$/; + my $instance = $1; + my $name = $snmp_result->{$oid}; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping virtual server '" . $name . "'.", debug => 1); + next; + } + + $self->{vs}->{$instance} = { name => $name }; + } + + return if (scalar(keys %{$self->{vs}}) <= 0); + + $options{snmp}->load( + oids => [ + map($_->{oid}, values(%$mapping)) + ], + instances => [ map($_, keys %{$self->{vs}}) ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + + foreach (keys %{$self->{vs}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + if (defined($self->{option_results}->{filter_vdom}) && $self->{option_results}->{filter_vdom} ne '' && + $result->{vdom} !~ /$self->{option_results}->{filter_vdom}/) { + $self->{output}->output_add(long_msg => "skipping vdom '" . $result->{vdom} . "'.", debug => 1); + next; + } + + $self->{vs}->{$_}->{vdom} = $result->{vdom}; + $self->{vs}->{$_}->{status} = { + name => $self->{vs}->{$_}->{name}, + state => lc($result->{state}), + status => lc($result->{status}), + vdom => $result->{vdom} + }; + $self->{vs}->{$_}->{stats} = { + name => $self->{vs}->{$_}->{name}, + vdom => $result->{vdom}, + connections => $result->{connections}, + throughput => $result->{throughput} * 1000 + }; + + $self->{global}->{detected}++; + $self->{global}->{ lc($result->{status}) }++; + } +} + +1; + +__END__ + +=head1 MODE + +Check virtual servers. + +=over 8 + +=item B<--filter-name> + +Filter virtual servers by name. + +=item B<--filter-vdom> + +Filter virtual servers by vdom name. + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{state}, %{name}, %{vdom} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{state}, %{name}, %{vdom} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} eq "unhealthy"'). +Can used special variables like: %{status}, %{state}, %{name}, %{vdom} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'virtualservers-detected', 'virtualservers-healthy', +'virtualserver-connections', 'virtualserver-throughput'. + +=back + +=cut diff --git a/centreon-plugins/network/fortinet/fortiadc/snmp/plugin.pm b/centreon-plugins/network/fortinet/fortiadc/snmp/plugin.pm new file mode 100644 index 000000000..473d502a8 --- /dev/null +++ b/centreon-plugins/network/fortinet/fortiadc/snmp/plugin.pm @@ -0,0 +1,55 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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::fortinet::fortiadc::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' => 'network::fortinet::fortiadc::snmp::mode::cpu', + 'hardware' => 'network::fortinet::fortiadc::snmp::mode::hardware', + 'interfaces' => 'network::fortinet::fortiadc::snmp::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-virtual-servers' => 'network::fortinet::fortiadc::snmp::mode::listvirtualservers', + 'memory' => 'network::fortinet::fortiadc::snmp::mode::memory', + 'security' => 'network::fortinet::fortiadc::snmp::mode::security', + 'uptime' => 'network::fortinet::fortiadc::snmp::mode::uptime', + 'virtual-servers' => 'network::fortinet::fortiadc::snmp::mode::virtualservers' + }; + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Fortinet FortiADC in SNMP. + +=cut diff --git a/centreon-plugins/storage/netapp/ontap/snmp/mode/plexes.pm b/centreon-plugins/storage/netapp/ontap/snmp/mode/plexes.pm index 0022c2715..3991e7bff 100644 --- a/centreon-plugins/storage/netapp/ontap/snmp/mode/plexes.pm +++ b/centreon-plugins/storage/netapp/ontap/snmp/mode/plexes.pm @@ -26,20 +26,6 @@ use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); -sub custom_temp_perfdata { - my ($self, %options) = @_; - - $self->{output}->perfdata_add( - nlabel => $self->{nlabel}, - unit => '%', - instances => [$self->{result_values}->{name}, $self->{result_values}->{aggregate}], - value => $self->{result_values}->{resync}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), - min => 0, max => 100 - ); -} - sub plex_long_output { my ($self, %options) = @_;