diff --git a/network/stormshield/snmp/mode/connections.pm b/network/stormshield/snmp/mode/connections.pm index 8ab96dbfb..3a806dce6 100644 --- a/network/stormshield/snmp/mode/connections.pm +++ b/network/stormshield/snmp/mode/connections.pm @@ -32,6 +32,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, ]; + $self->{maps_counters}->{global} = [ { label => 'udp', set => { key_values => [ { name => 'udp', per_second => 1 } ], @@ -65,16 +66,20 @@ sub new { sub manage_selection { my ($self, %options) = @_; - $self->{cache_name} = "fw_stormshield_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . md5_hex('all'); + + $self->{cache_name} = 'fw_stormshield_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . md5_hex('all'); my $oid_ntqASQStatsStatefulUdpConn = '.1.3.6.1.4.1.11256.1.12.1.33.0'; my $oid_ntqASQStatsStatefulTcpConn = '.1.3.6.1.4.1.11256.1.12.1.23.0'; - my $result = $options{snmp}->get_leef(oids => [ $oid_ntqASQStatsStatefulUdpConn, $oid_ntqASQStatsStatefulTcpConn ], - nothing_quit => 1); + my $result = $options{snmp}->get_leef( + oids => [ $oid_ntqASQStatsStatefulUdpConn, $oid_ntqASQStatsStatefulTcpConn ], + nothing_quit => 1 + ); + $self->{global} = { udp => $result->{$oid_ntqASQStatsStatefulUdpConn}, - tcp => $result->{$oid_ntqASQStatsStatefulTcpConn}, + tcp => $result->{$oid_ntqASQStatsStatefulTcpConn} }; } diff --git a/network/stormshield/snmp/mode/hanodes.pm b/network/stormshield/snmp/mode/hanodes.pm index ace387afd..683921fd2 100644 --- a/network/stormshield/snmp/mode/hanodes.pm +++ b/network/stormshield/snmp/mode/hanodes.pm @@ -29,9 +29,11 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_node_perfdata { my ($self, %options) = @_; - $self->{output}->perfdata_add(label => 'dead_nodes', - value => sprintf("%d", $self->{result_values}->{dead_nodes}), - min => 0, max => $self->{result_values}->{total_nodes}); + $self->{output}->perfdata_add( + label => 'dead_nodes', + value => sprintf("%d", $self->{result_values}->{dead_nodes}), + min => 0, max => $self->{result_values}->{total_nodes} + ); } sub custom_node_threshold { @@ -64,8 +66,7 @@ sub custom_node_calc { sub custom_state_output { my ($self, %options) = @_; - my $msg = sprintf("state is '%s' [role: %s]", $self->{result_values}->{state}, $self->{result_values}->{role}); - return $msg; + return sprintf("state is '%s' [role: %s]", $self->{result_values}->{state}, $self->{result_values}->{role}); } sub custom_state_calc { @@ -77,12 +78,18 @@ sub custom_state_calc { return 0; } +sub prefix_node_output { + my ($self, %options) = @_; + + return "Node '" . $options{instance_value}->{display} . "' "; +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'nodes', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All HA nodes are OK' }, + { name => 'nodes', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All HA nodes are OK' } ]; $self->{maps_counters}->{global} = [ @@ -91,49 +98,44 @@ sub set_counters { closure_custom_calc => $self->can('custom_node_calc'), closure_custom_output => $self->can('custom_node_output'), closure_custom_threshold_check => $self->can('custom_node_threshold'), - closure_custom_perfdata => $self->can('custom_node_perfdata'), + closure_custom_perfdata => $self->can('custom_node_perfdata') } } ]; + $self->{maps_counters}->{nodes} = [ { label => 'state', threshold => 0, set => { key_values => [ { name => 'ntqOnline' }, { name => 'ntqHALicence' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_state_calc'), closure_custom_output => $self->can('custom_state_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'health', set => { key_values => [ { name => 'ntqHAQuality' }, { name => 'display' } ], output_template => 'health: %s%%', perfdatas => [ - { label => 'health', value => 'ntqHAQuality', template => '%d', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'health', template => '%d', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' } + ] } } ]; } -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; - $options{options}->add_options(arguments => - { - "filter-node:s" => { name => 'filter_node' }, - "percent" => { name => 'percent' }, - "warning-state:s" => { name => 'warning_state', default => '' }, - "critical-state:s" => { name => 'critical_state', default => '%{state} =~ /offline/i' }, - }); + $options{options}->add_options(arguments => { + 'filter-node:s' => { name => 'filter_node' }, + 'percent' => { name => 'percent' }, + 'warning-state:s' => { name => 'warning_state', default => '' }, + 'critical-state:s' => { name => 'critical_state', default => '%{state} =~ /offline/i' } + }); + return $self; } @@ -163,12 +165,13 @@ sub manage_selection { my ($self, %options) = @_; my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_ntqNbNode, $oid_ntqNbDeadNode ], nothing_quit => 1); - - my $prct_dead = $snmp_result->{$oid_ntqNbDeadNode} * 100 / $snmp_result->{$oid_ntqNbNode}; - $self->{global} = { dead_nodes => $snmp_result->{$oid_ntqNbDeadNode}, - total_nodes => $snmp_result->{$oid_ntqNbNode}, - prct_dead => $prct_dead }; + my $prct_dead = $snmp_result->{$oid_ntqNbDeadNode} * 100 / $snmp_result->{$oid_ntqNbNode}; + $self->{global} = { + dead_nodes => $snmp_result->{$oid_ntqNbDeadNode}, + total_nodes => $snmp_result->{$oid_ntqNbNode}, + prct_dead => $prct_dead + }; $snmp_result = $options{snmp}->get_table(oid => $oid_ntqFwSerial, nothing_quit => 1); $self->{nodes} = {}; @@ -196,7 +199,7 @@ sub manage_selection { foreach (keys %{$self->{nodes}}) { my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); - + foreach my $name (keys %$mapping) { $self->{nodes}->{$_}->{$name} = $result->{$name}; } diff --git a/network/stormshield/snmp/mode/memorydetailed.pm b/network/stormshield/snmp/mode/memorydetailed.pm new file mode 100644 index 000000000..673a5ac4b --- /dev/null +++ b/network/stormshield/snmp/mode/memorydetailed.pm @@ -0,0 +1,175 @@ +# +# 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::stormshield::snmp::mode::memorydetailed; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub prefix_memory_output { + my ($self, %options) = @_; + + return 'Memory usage '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_memory_output', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'total' } ], + output_template => 'total: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'host', nlabel => 'memory.protected_host.percentage', set => { + key_values => [ { name => 'host' } ], + output_template => 'protected host: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'frag', nlabel => 'memory.fragmented.percentage', set => { + key_values => [ { name => 'frag' } ], + output_template => 'fragmented: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'conn', nlabel => 'memory.connections.percentage', set => { + key_values => [ { name => 'conn' } ], + output_template => 'connections: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'icmp', nlabel => 'memory.icmp.percentage', set => { + key_values => [ { name => 'icmp' } ], + output_template => 'icmp: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'dtrack', nlabel => 'memory.data_tracking.percentage', set => { + key_values => [ { name => 'dtrack' } ], + output_template => 'data tracking: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'dyn', nlabel => 'memory.dynamic.percentage', set => { + key_values => [ { name => 'dyn' } ], + output_template => 'dynamic: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'etherstate', nlabel => 'memory.ether_state.percentage', set => { + key_values => [ { name => 'ether_state' } ], + output_template => 'ether state: %.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_snsMem = '.1.3.6.1.4.1.11256.1.10.3.0'; + my $snmp_result = $options{snmp}->get_leef( + oids => [ $oid_snsMem ], + nothing_quit => 1 + ); + + # host,frag,icmp,conn,dtrack,dyn + # host,frag,icmp,conn,ether_state,dtrack,dyn + + my @values = split(/,/, $snmp_result->{$oid_snsMem}); + my $fields = scalar(@values); + if ($fields == 7) { + $self->{global} = { + total => $values[0] + $values[1] + $values[2] + $values[3] + $values[4] + $values[5] + $values[6], + host => $values[0], + frag => $values[1], + icmp => $values[2], + conn => $values[3], + ether_state => $values[4], + dtrack => $values[5], + dyn => $values[6] + }; + } elsif ($fields == 6) { + $self->{global} = { + total => $values[0] + $values[1] + $values[2] + $values[3] + $values[4] + $values[5], + host => $values[0], + frag => $values[1], + icmp => $values[2], + conn => $values[3], + dtrack => $values[4], + dyn => $values[5] + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check memory detailed. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total', 'host', 'frag', 'conn', 'icmp', +'dtrack', 'dyn', 'etherstate'. + +=back + +=cut diff --git a/network/stormshield/snmp/mode/vpnstatus.pm b/network/stormshield/snmp/mode/vpnstatus.pm index d21105094..a1087d02b 100644 --- a/network/stormshield/snmp/mode/vpnstatus.pm +++ b/network/stormshield/snmp/mode/vpnstatus.pm @@ -52,7 +52,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), output_template => 'status: %s', output_error_template => 'Status : %s', closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_threshold_output'), + closure_custom_threshold_check => $self->can('custom_threshold_output') } }, { label => 'traffic', nlabel => 'vpn.traffic.bitspersecond', set => { @@ -61,16 +61,16 @@ sub set_counters { output_change_bytes => 2, perfdatas => [ { label => 'traffic', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'num' }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'num' } + ] } - }, + } ]; } sub prefix_vpn_output { my ($self, %options) = @_; - + return "VPN '$options{instance_value}->{num}/$options{instance_value}->{ntqVPNIPSrc}/$options{instance_value}->{ntqVPNIPDst}' "; } @@ -79,8 +79,8 @@ my $thresholds = { ['larval', 'WARNING'], ['mature', 'OK'], ['dying', 'CRITICAL'], - ['dead', 'CRITICAL'], - ], + ['dead', 'CRITICAL'] + ] }; sub new { diff --git a/network/stormshield/snmp/plugin.pm b/network/stormshield/snmp/plugin.pm index 865e2bf9d..65983744a 100644 --- a/network/stormshield/snmp/plugin.pm +++ b/network/stormshield/snmp/plugin.pm @@ -31,19 +31,20 @@ sub new { $self->{version} = '1.0'; $self->{modes} = { - 'cpu' => 'snmp_standard::mode::cpu', - 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', - 'connections' => 'network::stormshield::snmp::mode::connections', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'load' => 'snmp_standard::mode::loadaverage', - 'ha-nodes' => 'network::stormshield::snmp::mode::hanodes', - 'health' => 'network::stormshield::snmp::mode::health', - 'memory' => 'os::freebsd::snmp::mode::memory', - 'qos' => 'network::stormshield::snmp::mode::qos', - 'storage' => 'snmp_standard::mode::storage', - 'swap' => 'snmp_standard::mode::swap', - 'vpn-status' => 'network::stormshield::snmp::mode::vpnstatus' + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'connections' => 'network::stormshield::snmp::mode::connections', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'load' => 'snmp_standard::mode::loadaverage', + 'ha-nodes' => 'network::stormshield::snmp::mode::hanodes', + 'health' => 'network::stormshield::snmp::mode::health', + 'memory' => 'os::freebsd::snmp::mode::memory', + 'memory-detailed' => 'network::stormshield::snmp::mode::memorydetailed', + 'qos' => 'network::stormshield::snmp::mode::qos', + 'storage' => 'snmp_standard::mode::storage', + 'swap' => 'snmp_standard::mode::swap', + 'vpn-status' => 'network::stormshield::snmp::mode::vpnstatus' }; return $self;