(plugin) network::fortinet::fortimail::snmp - new (#4484)

This commit is contained in:
qgarnier 2023-07-05 10:14:59 +02:00 committed by GitHub
parent 08aec2900a
commit fdffb72f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1289 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"libsnmp-perl"
]
}

View File

@ -0,0 +1,14 @@
{
"pkg_name": "centreon-plugin-Network-Fortinet-Fortimail-Snmp",
"pkg_summary": "Centreon Plugin Fortinet FortiMail SNMP",
"plugin_name": "centreon_fortinet_fortimail_snmp.pl",
"files": [
"centreon/plugins/script_snmp.pm",
"centreon/plugins/snmp.pm",
"snmp_standard/mode/interfaces.pm",
"snmp_standard/mode/listinterfaces.pm",
"snmp_standard/mode/resources/",
"snmp_standard/mode/uptime.pm",
"network/fortinet/fortimail/snmp/"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"perl(SNMP)"
]
}

View File

@ -0,0 +1,89 @@
#
# Copyright 2023 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::fortimail::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'cpu', type => 0 }
];
$self->{maps_counters}->{cpu} = [
{ label => 'cpu-utilization', nlabel => 'cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_usage' } ],
output_template => 'Cpu usage is: %.2f%%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100 }
]
}
}
];
}
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_fmSysCpuUsage = '.1.3.6.1.4.1.12356.105.1.6.0';
my $snmp_result = $options{snmp}->get_leef(
oids => [ $oid_fmSysCpuUsage ],
nothing_quit => 1
);
$self->{cpu} = { cpu_usage => $snmp_result->{$oid_fmSysCpuUsage} };
}
1;
__END__
=head1 MODE
Check cpu usage.
=over 8
=item B<--warning-cpu-utilization>
Warning threshold in percent.
=item B<--critical-cpu-utilization>
Critical threshold in percent.
=back
=cut

View File

@ -0,0 +1,98 @@
#
# 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::fortimail::snmp::mode::disk;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'disk', type => 0, skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{disk} = [
{ label => 'log-usage-prct', nlabel => 'disk.log.space.usage.percentage', set => {
key_values => [ { name => 'log_prct_used' } ],
output_template => 'Log disk space used: %.2f %%',
perfdatas => [
{ template => '%.2f', min => 0, max => 100, unit => '%' }
]
}
},
{ label => 'mail-usage-prct', nlabel => 'disk.mail.space.usage.percentage', set => {
key_values => [ { name => 'mail_prct_used' } ],
output_template => 'Mail disk space 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_facSysLogDiskUsage = '.1.3.6.1.4.1.12356.105.1.8.0';
my $oid_facSysMailDiskUsage = '.1.3.6.1.4.1.12356.105.1.9.0';
my $result = $options{snmp}->get_leef(
oids => [ $oid_facSysLogDiskUsage, $oid_facSysMailDiskUsage ],
nothing_quit => 1
);
$self->{disk} = {
log_prct_used => $result->{$oid_facSysLogDiskUsage},
mail_prct_used => $result->{$oid_facSysMailDiskUsage}
}
}
1;
__END__
=head1 MODE
Check mail and log disk usage.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'mail-usage-prct', 'log-usage-prct' (%).
=back
=cut

View File

@ -0,0 +1,118 @@
#
# 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::fortimail::snmp::mode::ha;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use Digest::MD5 qw(md5_hex);
sub custom_status_output {
my ($self, %options) = @_;
return sprintf("high-availability status is '%s'", $self->{result_values}->{ha_status});
}
sub custom_status_calc {
my ($self, %options) = @_;
if (!defined($options{old_datas}->{$self->{instance} . '_ha_status'})) {
$self->{error_msg} = 'buffer creation';
return -2;
}
$self->{result_values}->{ha_status_last} = $options{old_datas}->{$self->{instance} . '_ha_status'};
$self->{result_values}->{ha_status} = $options{new_datas}->{$self->{instance} . '_ha_status'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{ label => 'ha-status', type => 2, critical_default => '%{ha_status} ne %{ha_status_last}', set => {
key_values => [ { name => 'ha_status' } ],
closure_custom_calc => \&custom_status_calc,
closure_custom_output => $self->can('custom_status_output'),
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, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});
return $self;
}
my $map_ha_status = {
0 => 'off', 1 => 'master', 2 => 'slave', 3 => 'configMaster', 4 => 'configSlave'
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_facHaCurrentStatus = '.1.3.6.1.4.1.12356.105.1.200.2.0';
my $result = $options{snmp}->get_leef(oids => [ $oid_facHaCurrentStatus ], nothing_quit => 1);
$self->{global} = {
ha_status => $map_ha_status->{ $result->{$oid_facHaCurrentStatus} }
};
$self->{cache_name} = 'fortinet_fortimail_' . $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'));
}
1;
__END__
=head1 MODE
Check high-availability status.
=over 8
=item B<--warning-ha-status>
Define the conditions to match for the status to be WARNING.
You can use the following variables: %{ha_status}, %{ha_status_last}
=item B<--critical-ha-status>
Define the conditions to match for the status to be CRITICAL (default: '%{ha_status} ne %{ha_status_last}').
You can use the following variables: %{ha_status}, %{ha_status_last}
=back
=cut

View File

@ -0,0 +1,211 @@
#
# 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::fortimail::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} = '^sensors$';
$self->{cb_hook1} = 'get_system_information';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
sensors => [
[ 'on', 'CRITICAL' ],
[ 'off', 'OK' ]
]
};
$self->{components_path} = 'network::fortinet::fortimail::snmp::mode::components';
$self->{components_module} = [ 'sensors' ];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});
return $self;
}
sub get_system_information {
my ($self, %options) = @_;
my $oid_fmlSysModel = '.1.3.6.1.4.1.12356.105.1.1.0';
my $oid_fmlSerial = '.1.3.6.1.4.1.12356.105.1.2.0';
my $oid_fmlSysVersion = '.1.3.6.1.4.1.12356.105.1.3.0';
my $oid_fmlAVVersion = '.1.3.6.1.4.1.12356.105.1.4.0';
my $result = $options{snmp}->get_leef(
oids => [ $oid_fmlSysModel, $oid_fmlSerial, $oid_fmlSysVersion, $oid_fmlAVVersion ]
);
$self->{output}->output_add(
long_msg => sprintf(
'[System: %s] [Serial: %s] [Firmware: %s] [Antivirus Version: %s]',
$result->{$oid_fmlSysModel},
$result->{$oid_fmlSerial},
defined($result->{$oid_fmlSysVersion}) ? $result->{$oid_fmlSysVersion} : 'unknown',
defined($result->{$oid_fmlAVVersion}) ? $result->{$oid_fmlAVVersion} : 'unknown'
)
);
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
1;
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'sensors'.
=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)
Can also exclude specific instance: --filter=sensors,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,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='sensors,WARNING,off'
=item B<--warning>
Set warning threshold for 'sensors' (syntax: type,regexp,threshold)
Example: --warning='sensors,.*,30'
=item B<--critical>
Set critical threshold for 'sensors' (syntax: type,regexp,threshold)
Example: --critical='sensors,.*,50'
=back
=cut
package network::fortinet::fortimail::snmp::mode::components::sensors;
use strict;
use warnings;
my %alarm_map = (
0 => 'off',
1 => 'on',
);
my $mapping = {
fgHwSensorEntName => { oid => '.1.3.6.1.4.1.12356.105.1.110.2.1.2' },
fgHwSensorEntValue => { oid => '.1.3.6.1.4.1.12356.105.1.110.2.1.3' },
fgHwSensorEntAlarmStatus => { oid => '.1.3.6.1.4.1.12356.105.1.110.2.1.4', map => \%alarm_map },
};
my $oid_fgHwSensorEntry = '.1.3.6.1.4.1.12356.105.1.110.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_fgHwSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking sensors");
$self->{components}->{sensors} = { name => 'sensors', total => 0, skip => 0 };
return if ($self->check_filter(section => 'sensors'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fgHwSensorEntry}})) {
next if ($oid !~ /^$mapping->{fgHwSensorEntAlarmStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fgHwSensorEntry}, instance => $instance);
my $name = centreon::plugins::misc::trim($result->{fgHwSensorEntName});
next if ($self->check_filter(section => 'sensors', instance => $instance, name => $name));
$self->{components}->{sensors}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"sensor '%s' alarm status is '%s' [instance: %s] [value: %s]",
$name, $result->{fgHwSensorEntAlarmStatus}, $instance,
defined($result->{fgHwSensorEntValue}) ? $result->{fgHwSensorEntValue} : '-'
)
);
my $exit = $self->get_severity(section => 'sensors', name => $name, value => $result->{fgHwSensorEntAlarmStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Sensor '%s' alarm status is '%s'", $name, $result->{fgHwSensorEntAlarmStatus})
);
}
next if (!defined($result->{fgHwSensorEntValue}));
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensors', instance => $instance, name => $name, value => $result->{fgHwSensorEntValue});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf("Sensor '%s' measure is %s", $name, $result->{fgHwSensorEntValue})
);
}
$self->{output}->perfdata_add(
nlabel => 'hardware.sensors.measure',
instances => $name,
value => $result->{fgHwSensorEntValue},
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,182 @@
#
# Copyright 2023 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::fortimail::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>
Define the conditions to match for the status to be WARNING.
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
=item B<--critical-status>
Define the conditions to match for the status to be CRITICAL (default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
You can use the following variables: %{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', 'deltaps', 'counter').
=item B<--units-cast>
Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', '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 interfaces').
=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>
Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
=item B<--oid-display>
efine the OID that will be used to name the interfaces (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

View File

@ -0,0 +1,121 @@
#
# 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::fortimail::snmp::mode::listqueues;
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 => {
'filter-name:s' => { name => 'filter_name' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
my $mapping = {
name => { oid => '.1.3.6.1.4.1.12356.105.1.103.2.1.2' }, # fmlMailQueueName
count => { oid => '.1.3.6.1.4.1.12356.105.1.103.2.1.3' }, # fmlMailQueueMailCount
size => { oid => '.1.3.6.1.4.1.12356.105.1.103.2.1.4' } # fmlMailQueueMailSize
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_table = '.1.3.6.1.4.1.12356.105.1.103.2';# fmlMailQueueStatisticsTable
my $snmp_result = $options{snmp}->get_table(oid => $oid_table);
my $results = {};
foreach (keys %$snmp_result) {
next if (!/^$mapping->{name}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{name} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{name} . "': no matching filter.");
next;
}
$results->{$instance}->{name} = lc($result->{name});
$results->{$instance}->{count} = $result->{count};
$results->{$instance}->{size} = $result->{size};
}
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 mail queues:'
);
$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 mail queues.
=over 8
=back
=cut

View File

@ -0,0 +1,86 @@
#
# 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::fortimail::snmp::mode::load;
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, skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{global} = [
{ label => 'load', nlabel => 'system.load.percentage', set => {
key_values => [ { name => 'system_load' } ],
output_template => 'system load: %.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_load = '.1.3.6.1.4.1.12356.105.1.30.0'; # systemLoad
my $snmp_result = $options{snmp}->get_leef(
oids => [ $oid_load ],
nothing_quit => 1
);
$self->{global} = { system_load => $snmp_result->{$oid_load} };
}
1;
__END__
=head1 MODE
Check system load.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'load' (%).
=back
=cut

View File

@ -0,0 +1,86 @@
#
# 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::fortimail::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.105.1.7.0';
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

View File

@ -0,0 +1,140 @@
#
# 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::fortimail::snmp::mode::queues;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub prefix_queue_output {
my ($self, %options) = @_;
return "Queue '" . $options{instance_value}->{display} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'queue', type => 1, cb_prefix_output => 'prefix_queue_output', message_multiple => 'All queues are ok' }
];
$self->{maps_counters}->{queue} = [
{ label => 'count', nlabel => 'queue.mails.count', set => {
key_values => [ { name => 'count' }, { name => 'display' } ],
output_template => 'mails: %s',
perfdatas => [
{ template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'size', nlabel => 'queue.mails.size.count', set => {
key_values => [ { name => 'size' }, { name => 'display' } ],
output_template => 'size: %s %s',
output_change_bytes => 1,
perfdatas => [
{ template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
}
];
}
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' }
});
return $self;
}
my $mapping = {
fmlMailQueueMailCount => { oid => '.1.3.6.1.4.1.12356.105.1.103.2.1.3' },
fmlMailQueueMailSize => { oid => '.1.3.6.1.4.1.12356.105.1.103.2.1.4' }
};
my $oid_fmlMailQueueEntry = '.1.3.6.1.4.1.12356.105.1.103.2.1';
my $oid_fmlMailQueueName = '.1.3.6.1.4.1.12356.105.1.103.2.1.2';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_fmlMailQueueName },
{ oid => $oid_fmlMailQueueEntry }
],
nothing_quit => 1
);
$self->{queue} = {};
foreach my $oid (keys %{$snmp_result->{$oid_fmlMailQueueName}}) {
next if ($oid !~ /^$oid_fmlMailQueueName\.(.*)/);
my $instance = $1;
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$snmp_result->{$oid_fmlMailQueueName}->{$oid} !~ /$self->{option_results}->{filter_name}/);
my $result = $options{snmp}->map_instance(
mapping => $mapping,
results => $snmp_result->{$oid_fmlMailQueueEntry},
instance => $instance
);
$self->{queue}->{$instance} = {
display => $snmp_result->{$oid_fmlMailQueueName}->{$oid},
count => $result->{'fmlMailQueueMailCount'},
size => $result->{'fmlMailQueueMailSize'} * 1024
};
}
if (scalar(keys %{$self->{queue}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No queue found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check queue statistics.
=over 8
=item B<--filter-name>
Filter queue name (can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'count', 'size'.
=back
=cut

View File

@ -0,0 +1,77 @@
#
# Copyright 2023 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::fortimail::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>
Warning threshold.
=item B<--critical-uptime>
Critical threshold.
=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

View File

@ -0,0 +1,57 @@
#
# 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::fortimail::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::fortimail::snmp::mode::cpu',
'disk' => 'network::fortinet::fortimail::snmp::mode::disk',
'ha' => 'network::fortinet::fortimail::snmp::mode::ha',
'hardware' => 'network::fortinet::fortimail::snmp::mode::hardware',
'interfaces' => 'network::fortinet::fortimail::snmp::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'load' => 'network::fortinet::fortimail::snmp::mode::load',
'memory' => 'network::fortinet::fortimail::snmp::mode::memory',
'queues' => 'network::fortinet::fortimail::snmp::mode::queues',
'list-queues' => 'network::fortinet::fortimail::snmp::mode::listqueues',
'uptime' => 'network::fortinet::fortimail::snmp::mode::uptime'
};
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check fortimail in SNMP.
=cut