From c42d9e35a1a91a01d55d7e071b38716b3493f541 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 23 May 2017 14:00:21 +0200 Subject: [PATCH] + add fortinet fortimanager snmp plugin --- .../fortinet/fortimanager/snmp/mode/cpu.pm | 99 +++++++ .../fortimanager/snmp/mode/devicestatus.pm | 273 ++++++++++++++++++ .../fortinet/fortimanager/snmp/mode/disk.pm | 132 +++++++++ .../fortinet/fortimanager/snmp/mode/memory.pm | 132 +++++++++ network/fortinet/fortimanager/snmp/plugin.pm | 51 ++++ 5 files changed, 687 insertions(+) create mode 100644 network/fortinet/fortimanager/snmp/mode/cpu.pm create mode 100644 network/fortinet/fortimanager/snmp/mode/devicestatus.pm create mode 100644 network/fortinet/fortimanager/snmp/mode/disk.pm create mode 100644 network/fortinet/fortimanager/snmp/mode/memory.pm create mode 100644 network/fortinet/fortimanager/snmp/plugin.pm diff --git a/network/fortinet/fortimanager/snmp/mode/cpu.pm b/network/fortinet/fortimanager/snmp/mode/cpu.pm new file mode 100644 index 000000000..773b9f7bf --- /dev/null +++ b/network/fortinet/fortimanager/snmp/mode/cpu.pm @@ -0,0 +1,99 @@ +# +# Copyright 2017 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::fortimanager::snmp::mode::cpu; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + my $oid_fmSysCpuUsage = '.1.3.6.1.4.1.12356.103.2.1.1.0'; + my $result = $self->{snmp}->get_leef(oids => [$oid_fmSysCpuUsage], nothing_quit => 1); + + my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_fmSysCpuUsage}, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU Usage : %.2f %%", $result->{$oid_fmSysCpuUsage})); + $self->{output}->perfdata_add(label => "cpu", unit => '%', + value => $result->{$oid_fmSysCpuUsage}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check current CPU usage. + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut + \ No newline at end of file diff --git a/network/fortinet/fortimanager/snmp/mode/devicestatus.pm b/network/fortinet/fortimanager/snmp/mode/devicestatus.pm new file mode 100644 index 000000000..732db8654 --- /dev/null +++ b/network/fortinet/fortimanager/snmp/mode/devicestatus.pm @@ -0,0 +1,273 @@ +# +# Copyright 2017 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::fortimanager::snmp::mode::devicestatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'device', type => 1, cb_prefix_output => 'prefix_device_output', message_multiple => 'All devices are ok' }, + ]; + + $self->{maps_counters}->{device} = [ + { label => 'device-status', threshold => 0, set => { + key_values => [ { name => 'fmDeviceEntState' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_calc_extra_options => { output_label => 'Status', name_status => 'fmDeviceEntState' }, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'device-connection-status', threshold => 0, set => { + key_values => [ { name => 'fmDeviceEntConnectState' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_calc_extra_options => { output_label => 'Connection Status', name_status => 'fmDeviceEntConnectState' }, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'device-db-status', threshold => 0, set => { + key_values => [ { name => 'fmDeviceEntDbState' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_calc_extra_options => { output_label => 'DB Status', name_status => 'fmDeviceEntDbState' }, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + { label => 'device-config-status', threshold => 0, set => { + key_values => [ { name => 'fmDeviceEntConfigState' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_calc_extra_options => { output_label => 'Configuration Status', name_status => 'fmDeviceEntConfigState' }, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + ]; +} + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + my $label = $self->{label}; + $label =~ s/-/_/g; + if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' && + eval "$instance_mode->{option_results}->{'critical_' . $label}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' && + eval "$instance_mode->{option_results}->{'warning_' . $label}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + my $msg = $self->{result_values}->{output_label} . ' : ' . $self->{result_values}->{status}; + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{output_label} = $options{extra_options}->{output_label}; + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{name_status}}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + "warning-device-status:s" => { name => 'warning_device_status', default => '' }, + "critical-device-status:s" => { name => 'critical_device_status', default => '' }, + "warning-device-con-status:s" => { name => 'warning_device_con_status', default => '' }, + "critical-device-con-status:s" => { name => 'critical_device_con_status', default => '%{status} =~ /down/i' }, + "warning-device-db-status:s" => { name => 'warning_device_db_status', default => '' }, + "critical-device-db-status:s" => { name => 'critical_device_db_status', default => '' }, + "warning-device-config-status:s" => { name => 'warning_device_config_status', default => '' }, + "critical-device-config-status:s" => { name => 'critical_device_config_status', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_device_status', 'critical_device_status', 'warning_device_con_status', 'critical_device_con_status', + 'warning_device_db_status', 'critical_device_db_status', 'warning_device_config_status', 'critical_device_config_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +sub prefix_device_output { + my ($self, %options) = @_; + + return "Device '" . $options{instance_value}->{display} . "' "; +} + +my %map_connection_state = (0 => 'unknown', 1 => 'up', 2 => 'down'); +my %map_db_state = (0 => 'unknown', 1 => 'not-modified', 2 => 'modified'); +my %map_config_state = (0 => 'unknown', 1 => 'in-sync', 2 => 'out-of-sync'); +my %map_device_state = (0 => 'none', 1 => 'unknown', 2 => 'checked-in', 3 => 'in-progress', + 4 => 'installed', 5 => 'aborted', 6 => 'sched', 7 => 'retry', 8 => 'canceled', + 9 => 'pending', 10 => 'retrieved', 11 => 'changed-conf', 12 => 'sync-fail', + 13 => 'timeout', 14 => 'rev-reverted', 15 => 'auto-updated' +); + +my $mapping = { + fmDeviceEntConnectState => { oid => '.1.3.6.1.4.1.12356.103.6.2.1.12', map => \%map_connection_state }, + fmDeviceEntDbState => { oid => '.1.3.6.1.4.1.12356.103.6.2.1.13', map => \%map_db_state }, + fmDeviceEntConfigState => { oid => '.1.3.6.1.4.1.12356.103.6.2.1.14', map => \%map_config_state }, + fmDeviceEntState => { oid => '.1.3.6.1.4.1.12356.103.6.2.1.15', map => \%map_device_state }, +}; + +my $oid_fmDeviceEntName = '.1.3.6.1.4.1.12356.103.6.2.1.2'; +my $oid_fmDeviceEntry = '.1.3.6.1.4.1.12356.103.6.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_fmDeviceEntName }, + { oid => $oid_fmDeviceEntry, start => $mapping->{fmDeviceEntConnectState}->{oid}, end => $mapping->{fmDeviceEntState}->{oid} }, + ], + nothing_quit => 1); + $self->{device} = {}; + foreach my $oid (keys %{$snmp_result->{ $oid_fmDeviceEntName }}) { + $oid =~ /^$oid_fmDeviceEntName\.(.*)$/; + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{ $oid_fmDeviceEntry }, instance => $instance); + + my $name = $snmp_result->{ $oid_fmDeviceEntName }->{$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 '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{device}->{$instance} = { + display => $name, %$result + }; + } + + if (scalar(keys %{$self->{device}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No device found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check device status. + +=over 8 + +=item B<--filter-name> + +Filter by device name (can be a regexp). + +=item B<--warning-device-status> + +Set warning threshold for device status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-device-status> + +Set critical threshold for device status +Can used special variables like: %{status}, %{display} + +=item B<--warning-con-status> + +Set warning threshold for device connection status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-con-status> + +Set critical threshold for device connection status (Default: '%{status} =~ /down/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-db-status> + +Set warning threshold for device DB status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-db-status> + +Set critical threshold for device DB status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-config-status> + +Set warning threshold for device configuration status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-config-status> + +Set critical threshold for device configuration status. +Can used special variables like: %{status}, %{display} + +=back + +=cut diff --git a/network/fortinet/fortimanager/snmp/mode/disk.pm b/network/fortinet/fortimanager/snmp/mode/disk.pm new file mode 100644 index 000000000..8cde82c53 --- /dev/null +++ b/network/fortinet/fortimanager/snmp/mode/disk.pm @@ -0,0 +1,132 @@ +# +# Copyright 2017 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::fortimanager::snmp::mode::disk; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add(label => 'used', unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + my $msg = sprintf("Disk Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_total'} - $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'disk', type => 0 } + ]; + + $self->{maps_counters}->{disk} = [ + { label => 'usage', set => { + key_values => [ { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_fmSysDiskCapacity = '.1.3.6.1.4.1.12356.103.2.1.5.0'; # MB + my $oid_fmSysDiskUsage = '.1.3.6.1.4.1.12356.103.2.1.4.0'; # MB + my $result = $options{snmp}->get_leef(oids => [$oid_fmSysDiskCapacity, $oid_fmSysDiskUsage], + nothing_quit => 1); + $self->{disk} = { used => $result->{$oid_fmSysDiskUsage} * 1024 * 1024, total => $result->{$oid_fmSysDiskCapacity} * 1024 * 1024 }; +} + +1; + +__END__ + +=head1 MODE + +Check disk usage. + +=over 8 + +=item B<--warning-usage> + +Threshold warning (in percent). + +=item B<--critical-usage> + +Threshold critical (in percent). + +=back + +=cut \ No newline at end of file diff --git a/network/fortinet/fortimanager/snmp/mode/memory.pm b/network/fortinet/fortimanager/snmp/mode/memory.pm new file mode 100644 index 000000000..9c3384d9e --- /dev/null +++ b/network/fortinet/fortimanager/snmp/mode/memory.pm @@ -0,0 +1,132 @@ +# +# Copyright 2017 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::fortimanager::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add(label => 'used', unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total}); +} + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + my $msg = sprintf("Memory Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_total'} - $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0 } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', set => { + key_values => [ { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_fmSysMemCapacity = '.1.3.6.1.4.1.12356.103.2.1.3.0'; # KB + my $oid_fmSysMemUsed = '.1.3.6.1.4.1.12356.103.2.1.2.0'; # KB + my $result = $options{snmp}->get_leef(oids => [$oid_fmSysMemCapacity, $oid_fmSysMemUsed], + nothing_quit => 1); + $self->{memory} = { used => $result->{$oid_fmSysMemUsed} * 1024, total => $result->{$oid_fmSysMemCapacity} * 1024 }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage. + +=over 8 + +=item B<--warning-usage> + +Threshold warning (in percent). + +=item B<--critical-usage> + +Threshold critical (in percent). + +=back + +=cut \ No newline at end of file diff --git a/network/fortinet/fortimanager/snmp/plugin.pm b/network/fortinet/fortimanager/snmp/plugin.pm new file mode 100644 index 000000000..f7bacad03 --- /dev/null +++ b/network/fortinet/fortimanager/snmp/plugin.pm @@ -0,0 +1,51 @@ +# +# Copyright 2017 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::fortimanager::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'network::fortinet::fortimanager::snmp::mode::cpu', + 'device-status' => 'network::fortinet::fortimanager::snmp::mode::devicestatus', + 'disk' => 'network::fortinet::fortimanager::snmp::mode::disk', + 'memory' => 'network::fortinet::fortimanager::snmp::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check FortiManager in SNMP. + +=cut