diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm index c684e8e76..c2d82b8f9 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm @@ -30,75 +30,65 @@ use Digest::MD5 qw(md5_hex); sub custom_status_output { my ($self, %options) = @_; - return 'status : ' . $self->{result_values}->{status} . ' [admin: ' . $self->{result_values}->{admin} . ']'; -} - -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{admin} = $options{new_datas}->{$self->{instance} . '_admin'}; - return 0; + return 'status: ' . $self->{result_values}->{status} . ' [admin: ' . $self->{result_values}->{admin} . ']'; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access points are ok', skipped_code => { -10 => 1 } }, + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access points are ok', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{ap} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'admin' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold } }, - { label => 'in-traffic', set => { + { label => 'in-traffic', nlabel => 'accesspoint.traffic.in.bitspersecond', set => { key_values => [ { name => 'in', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, - output_template => 'traffic in : %s %s/s', + output_template => 'traffic in: %s %s/s', perfdatas => [ { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, - { label => 'out-traffic', set => { + { label => 'out-traffic', nlabel => 'accesspoint.traffic.out.bitspersecond', set => { key_values => [ { name => 'out', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, - output_template => 'traffic out : %s %s/s', + output_template => 'traffic out: %s %s/s', perfdatas => [ { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, - { label => 'clients', set => { + { label => 'clients', nlabel => 'accesspoint.clients.current.count', set => { key_values => [ { name => 'clients' }, { name => 'display' } ], - output_template => 'current client connections : %s', + output_template => 'current client connections: %s', perfdatas => [ { label => 'clients', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, - { label => 'cpu', set => { + { label => 'cpu', nlabel => 'accesspoint.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu' }, { name => 'display' } ], - output_template => 'cpu usage : %.2f %%', + output_template => 'cpu usage: %.2f %%', perfdatas => [ { label => 'cpu', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } ] } }, - { label => 'memory', set => { + { label => 'memory', nlabel => 'accesspoint.memory.usage.bytes', set => { key_values => [ { name => 'memory' }, { name => 'display' } ], - output_template => 'memory usage : %.2f %%', + output_template => 'memory usage: %.2f %%', perfdatas => [ { label => 'memory', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } @@ -206,7 +196,7 @@ sub manage_selection { foreach (keys %{$self->{ap}}) { my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_); - + $self->{ap}->{$_}->{status} = $result->{fgWcWtpSessionConnectionState}; $self->{ap}->{$_}->{in} = defined($result->{fgWcWtpSessionWtpByteRxCount}) ? ($result->{fgWcWtpSessionWtpByteRxCount} * 8) : undef; $self->{ap}->{$_}->{out} = defined($result->{fgWcWtpSessionWtpByteTxCount}) ? ($result->{fgWcWtpSessionWtpByteTxCount} * 8) : undef; @@ -215,7 +205,7 @@ sub manage_selection { $self->{ap}->{$_}->{memory} = $result->{fgWcWtpSessionWtpMemoryUsage}; } - $self->{cache_name} = "fortigate_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + $self->{cache_name} = 'fortigate_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm index daaccfc37..b7c3de8bb 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm @@ -31,7 +31,7 @@ sub custom_status_output { my ($self, %options) = @_; return sprintf( - "status is '%s' [Hostname: %s] [Role: %s] [Checksum: %s]", + "status is '%s' [hostname: %s] [role: %s] [checksum: %s]", $self->{result_values}->{sync_status}, $self->{result_values}->{hostname}, $self->{result_values}->{role}, @@ -58,14 +58,14 @@ sub custom_status_calc { sub prefix_status_output { my ($self, %options) = @_; - + return "Node '" . $options{instance_value}->{serial} . "' "; } sub prefix_global_output { my ($self, %options) = @_; - - return "Nodes "; + + return 'Nodes '; } sub set_counters { @@ -77,33 +77,33 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-nodes', display_ok => 0, set => { + { label => 'total-nodes', nlabel => 'cluster.nodes.total.count', display_ok => 0, set => { key_values => [ { name => 'total_nodes' } ], - output_template => 'Total nodes: %d', + output_template => 'total nodes: %d', perfdatas => [ { label => 'total_nodes', template => '%d', min => 0 } ] } }, - { label => 'synchronized', set => { + { label => 'synchronized', nlabel => 'cluster.nodes.synchronized.count', set => { key_values => [ { name => 'synchronized' } ], - output_template => 'Synchronized: %d', + output_template => 'synchronized: %d', perfdatas => [ { label => 'synchronized_nodes', template => '%d', min => 0 } ] } }, - { label => 'not-synchronized', set => { + { label => 'not-synchronized', nlabel => 'cluster.nodes.notsynchronized.count',set => { key_values => [ { name => 'not_synchronized' } ], - output_template => 'Not Synchronized: %d', + output_template => 'not synchronized: %d', perfdatas => [ { label => 'not_synchronized_nodes', template => '%d', min => 0 } ] } }, - { label => 'total-checksums', display_ok => 0, set => { + { label => 'total-checksums', nlabel => 'cluster.checksums.total.count', display_ok => 0, set => { key_values => [ { name => 'total_checksums' } ], - output_template => 'Total Checksums: %d', + output_template => 'total checksums: %d', perfdatas => [ { label => 'total_checksums', template => '%d', min => 0 } ] @@ -140,7 +140,7 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - + $self->change_macros(macros => ['warning_status', 'critical_status']); } @@ -174,7 +174,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{output}->output_add(short_msg => "HA mode: " . $map_ha_mode->{ $mode->{$oid_fgHaSystemMode} }); + $self->{output}->output_add(short_msg => 'HA mode: ' . $map_ha_mode->{ $mode->{$oid_fgHaSystemMode} }); my $snmp_result = $options{snmp}->get_table( oid => $oid_fgHaStatsEntry, diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/disk.pm b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/disk.pm index 228838714..570788868 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/disk.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/disk.pm @@ -88,8 +88,10 @@ sub run { $prct, $size_value . " " . $size_unit ) ); + $self->{output}->perfdata_add( - label => "used", unit => 'B', + label => 'used', unit => 'B', + nlabel => 'storage.space.usage.bytes', value => $fgSysDiskUsage, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $fgSysDiskCapacity, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $fgSysDiskCapacity, cast_int => 1), diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/sessions.pm b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/sessions.pm index 038f7952b..d2be6600f 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/sessions.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/sessions.pm @@ -20,77 +20,84 @@ package centreon::common::fortinet::fortigate::snmp::mode::sessions; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_average_output { + my ($self, %options) = @_; + + return 'Average session setup rate: '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'average', type => 0, cb_prefix_output => 'prefix_average_output' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'active', nlabel => 'sessions.active.count', set => { + key_values => [ { name => 'active' } ], + output_template => 'Current active sessions: %d', + perfdatas => [ + { label => 'sessions', template => '%d', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{average} = [ + { label => 'setup-1min', nlabel => 'sessions.setup.1min.count', set => { + key_values => [ { name => 'setup_1min' } ], + output_template => '%d (1min)', + perfdatas => [ + { label => 'session_avg_setup1', template => '%d', min => 0 } + ] + } + }, + { label => 'setup-10min', nlabel => 'sessions.setup.10min.count', set => { + key_values => [ { name => 'setup_10min' } ], + output_template => '%d (10min)', + perfdatas => [ + { label => 'session_avg_setup10', template => '%d', min => 0 } + ] + } + }, + { label => 'setup-30min', nlabel => 'sessions.setup.30min.count', set => { + key_values => [ { name => 'setup_30min' } ], + output_template => '%d (30min)', + perfdatas => [ + { label => 'session_avg_setup30', template => '%d', min => 0 } + ] + } + }, + { label => 'setup-60min', nlabel => 'sessions.setup.60min.count', set => { + key_values => [ { name => 'setup_60min' } ], + output_template => '%d (60min)', + perfdatas => [ + { label => 'session_avg_setup60', template => '%d', min => 0 } + ] + } + }, + ]; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { - 'warning:s' => { name => 'warning', }, - 'critical:s' => { name => 'critical', }, - 'warning-avg:s' => { name => 'warning_avg', default => '' }, - 'critical-avg:s' => { name => 'critical_avg', default => '' }, }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - - ($self->{warn1}, $self->{warn10}, $self->{warn30}, $self->{warn60}) = split /,/, $self->{option_results}->{warning_avg}; - ($self->{crit1}, $self->{crit10}, $self->{crit30}, $self->{crit60}) = split /,/, $self->{option_results}->{critical_avg}; - - if (($self->{perfdata}->threshold_validate(label => 'warn1', value => $self->{warn1})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn10', value => $self->{warn10})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (10min) threshold '" . $self->{warn10} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn30', value => $self->{warn30})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (30min) threshold '" . $self->{warn30} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn60', value => $self->{warn60})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (60min) threshold '" . $self->{warn60} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit1', value => $self->{crit1})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit10', value => $self->{crit10})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (10min) threshold '" . $self->{crit10} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit30', value => $self->{crit30})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (30min) threshold '" . $self->{crit30} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit60', value => $self->{crit60})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (60min) threshold '" . $self->{crit60} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { +sub manage_selection { my ($self, %options) = @_; my $oid_fgSysSesCount = '.1.3.6.1.4.1.12356.101.4.1.8.0'; @@ -106,67 +113,13 @@ sub run { nothing_quit => 1 ); - my $exit = $self->{perfdata}->threshold_check( - value => $result->{$oid_fgSysSesCount}, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ] - ); - $self->{output}->output_add( - severity => $exit, - short_msg => sprintf('Current active sessions: %d', $result->{$oid_fgSysSesCount}) - ); - $self->{output}->perfdata_add( - label => "sessions", - value => $result->{$oid_fgSysSesCount}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0 - ); - - my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate1}, - threshold => [ { label => 'crit1', exit_litteral => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate10}, - threshold => [ { label => 'crit10', exit_litteral => 'critical' }, { label => 'warn10', exit_litteral => 'warning' } ]); - my $exit3 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate30}, - threshold => [ { label => 'crit30', exit_litteral => 'critical' }, { label => 'warn30', exit_litteral => 'warning' } ]); - my $exit4 = $self->{perfdata}->threshold_check(value => $result->{$oid_fgSysSesRate60}, - threshold => [ { label => 'crit60', exit_litteral => 'critical' }, { label => 'warn60', exit_litteral => 'warning' } ]); - $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3, $exit4 ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Average session setup rate: %s, %s, %s, %s (1min, 10min, 30min, 60min)", - $result->{$oid_fgSysSesRate1}, $result->{$oid_fgSysSesRate10}, - $result->{$oid_fgSysSesRate30}, $result->{$oid_fgSysSesRate60})); - - $self->{output}->perfdata_add( - label => 'session_avg_setup1', - value => $result->{$oid_fgSysSesRate1}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1'), - min => 0 - ); - $self->{output}->perfdata_add( - label => 'session_avg_setup10', - value => $result->{$oid_fgSysSesRate10}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn10'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit10'), - min => 0 - ); - $self->{output}->perfdata_add( - label => 'session_avg_setup30', - value => $result->{$oid_fgSysSesRate30}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn30'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit30'), - min => 0 - ); - $self->{output}->perfdata_add( - label => 'session_avg_setup60', - value => $result->{$oid_fgSysSesRate60}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn60'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit60'), - min => 0 - ); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{global} = { active => $result->{$oid_fgSysSesCount} }; + $self->{average} = { + setup_1min => $result->{$oid_fgSysSesRate1}, + setup_10min => $result->{$oid_fgSysSesRate10}, + setup_30min => $result->{$oid_fgSysSesRate30}, + setup_60min => $result->{$oid_fgSysSesRate60} + }; } 1; @@ -179,21 +132,10 @@ Check sessions (FORTINET-FORTIGATE-MIB). =over 8 -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Threshold warning of current active sessions. - -=item B<--critical> - -Threshold critical of current active sessions. - -=item B<--warning-avg> - -Threshold warning of average setup rate (1min,10min,30min,60min). - -=item B<--critical-avg> - -Threshold critical of average setup rate (1min,10min,30min,60min). +Thresholds. +Can be: 'active', 'setup-1min', 'setup-10min', 'setup-30min', 'setup-60min'. =back diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm index dd0707fb9..6b52882a8 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm @@ -46,7 +46,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'users', set => { + { label => 'users', nlabel => 'vpn.users.logged.count', set => { key_values => [ { name => 'users' } ], output_template => 'Logged users: %s', perfdatas => [ @@ -54,7 +54,7 @@ sub set_counters { ] } }, - { label => 'sessions', set => { + { label => 'sessions', nlabel => 'vpn.websessions.active.count', set => { key_values => [ { name => 'sessions' }], output_template => 'Active web sessions: %s', perfdatas => [ @@ -62,9 +62,9 @@ sub set_counters { ] } }, - { label => 'tunnels', set => { + { label => 'tunnels', nlabel => 'vpn.tunnels.active.count', set => { key_values => [ { name => 'tunnels' } ], - output_template => 'Active Tunnels: %s', + output_template => 'Active tunnels: %s', perfdatas => [ { label => 'active_tunnels', template => '%d', min => 0, unit => 'tunnels', label_extra_instance => 1 } ] @@ -80,19 +80,19 @@ sub set_counters { closure_custom_threshold_check => \&catalog_status_threshold } }, - { label => 'traffic-in', set => { + { label => 'traffic-in', nlabel => 'vpn.traffic.in.bitspersecond', set => { key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_change_bytes => 1, - output_template => 'Traffic In: %s %s/s', + output_template => 'Traffic in: %s %s/s', perfdatas => [ { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1 } ] } }, - { label => 'traffic-out', set => { + { label => 'traffic-out', nlabel => 'vpn.traffic.out.bitspersecond', set => { key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_change_bytes => 1, - output_template => 'Traffic Out: %s %s/s', + output_template => 'Traffic out: %s %s/s', perfdatas => [ { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1 } ] @@ -235,8 +235,8 @@ sub manage_selection { display => $name, instance => $instance, state => $result->{fgVpnTunEntStatus}, - traffic_in => $result->{fgVpnTunEntInOctets}, - traffic_out => $result->{fgVpnTunEntOutOctets}, + traffic_in => $result->{fgVpnTunEntInOctets} * 8, + traffic_out => $result->{fgVpnTunEntOutOctets} * 8 }; } }