| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package apps::lotus::snmp::mode::mailstate; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub new { |
| 29 |
my ($class, %options) = @_; |
| 30 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 31 |
bless $self, $class; |
| 32 |
|
| 33 |
$options{options}->add_options(arguments => |
| 34 |
{ |
| 35 |
"warning-waiting:s" => { name => 'warning_waiting', }, |
| 36 |
"critical-waiting:s" => { name => 'critical_waiting', }, |
| 37 |
"warning-dead:s" => { name => 'warning_dead', }, |
| 38 |
"critical-dead:s" => { name => 'critical_dead', }, |
| 39 |
}); |
| 40 |
|
| 41 |
return $self; |
| 42 |
} |
| 43 |
|
| 44 |
sub check_options { |
| 45 |
my ($self, %options) = @_; |
| 46 |
$self->SUPER::init(%options); |
| 47 |
|
| 48 |
if (($self->{perfdata}->threshold_validate(label => 'warning-waiting', value => $self->{option_results}->{warning_waiting})) == 0) { |
| 49 |
$self->{output}->add_option_msg(short_msg => "Wrong warning-waiting threshold '" . $self->{option_results}->{warning_waiting} . "'."); |
| 50 |
$self->{output}->option_exit(); |
| 51 |
} |
| 52 |
if (($self->{perfdata}->threshold_validate(label => 'critical-waiting', value => $self->{option_results}->{critical_waiting})) == 0) { |
| 53 |
$self->{output}->add_option_msg(short_msg => "Wrong critical-waiting threshold '" . $self->{option_results}->{critical_waiting} . "'."); |
| 54 |
$self->{output}->option_exit(); |
| 55 |
} |
| 56 |
if (($self->{perfdata}->threshold_validate(label => 'warning-dead', value => $self->{option_results}->{warning_dead})) == 0) { |
| 57 |
$self->{output}->add_option_msg(short_msg => "Wrong warning-dead threshold '" . $self->{option_results}->{warning_dead} . "'."); |
| 58 |
$self->{output}->option_exit(); |
| 59 |
} |
| 60 |
if (($self->{perfdata}->threshold_validate(label => 'critical-dead', value => $self->{option_results}->{critical_dead})) == 0) { |
| 61 |
$self->{output}->add_option_msg(short_msg => "Wrong critical-dead threshold '" . $self->{option_results}->{critical_dead} . "'."); |
| 62 |
$self->{output}->option_exit(); |
| 63 |
} |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
sub run { |
| 68 |
my ($self, %options) = @_; |
| 69 |
$self->{snmp} = $options{snmp}; |
| 70 |
|
| 71 |
my $oid_lnDeadMail = '.1.3.6.1.4.1.334.72.1.1.4.1.0'; |
| 72 |
# my $oid_DeliveredMail = '.1.3.6.1.4.1.334.72.1.1.4.2.0'; |
| 73 |
# my $oid_TransferredMail = '.1.3.6.1.4.1.334.72.1.1.4.5.0'; |
| 74 |
my $oid_lnWaitingMail = '.1.3.6.1.4.1.334.72.1.1.4.6.0'; |
| 75 |
|
| 76 |
my $results = $self->{snmp}->get_leef(oids => [$oid_lnDeadMail, $oid_lnWaitingMail], nothing_quit => 1); |
| 77 |
# my $delivered = $self->{snmp}->get_leef(oid => $oid_DeliveredMail, nothing_quit => 1); |
| 78 |
# my $transferred = $self->{snmp}->get_leef(oid => $oid_TransferredMail, nothing_quit => 1); |
| 79 |
|
| 80 |
my $exit1 = $self->{perfdata}->threshold_check(value => $results->{$oid_lnDeadMail}, |
| 81 |
threshold => [ { label => 'critical-dead', 'exit_litteral' => 'critical' }, { label => 'warning-dead', exit_litteral => 'warning' } ]); |
| 82 |
my $exit2 = $self->{perfdata}->threshold_check(value => $results->{$oid_lnWaitingMail}, |
| 83 |
threshold => [ { label => 'critical-waiting', 'exit_litteral' => 'critical' }, { label => 'warning-waiting', exit_litteral => 'warning' } ]); |
| 84 |
my $exit_code = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); |
| 85 |
|
| 86 |
|
| 87 |
$self->{output}->output_add(severity => $exit_code, |
| 88 |
short_msg => sprintf("Number of dead mail: %d Number of waiting mail: %d", $results->{$oid_lnDeadMail}, $results->{$oid_lnWaitingMail})); |
| 89 |
$self->{output}->perfdata_add(label => 'dead', unit => 'mail', |
| 90 |
value => $results->{$oid_lnDeadMail}, |
| 91 |
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-dead'), |
| 92 |
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-dead'), |
| 93 |
); |
| 94 |
$self->{output}->perfdata_add(label => 'waiting', unit => 'mail', |
| 95 |
value => $results->{$oid_lnWaitingMail}, |
| 96 |
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-waiting'), |
| 97 |
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-waiting'), |
| 98 |
); |
| 99 |
$self->{output}->display(); |
| 100 |
$self->{output}->exit(); |
| 101 |
} |
| 102 |
|
| 103 |
1; |
| 104 |
|
| 105 |
__END__ |
| 106 |
|
| 107 |
=head1 MODE |
| 108 |
|
| 109 |
Check the number of dead and wainting mail on the lotus server (NOTES-MIB.mib) |
| 110 |
|
| 111 |
=over 8 |
| 112 |
|
| 113 |
=item B<--warning-dead> |
| 114 |
|
| 115 |
Warning threshold in percent. |
| 116 |
|
| 117 |
=item B<--critical-dead> |
| 118 |
|
| 119 |
Critical threshold in percent. |
| 120 |
|
| 121 |
=item B<--warning-waiting> |
| 122 |
|
| 123 |
Warning threshold in percent. |
| 124 |
|
| 125 |
=item B<--critical-waiting> |
| 126 |
|
| 127 |
Critical threshold in percent. |
| 128 |
|
| 129 |
=back |
| 130 |
|
| 131 |
=cut |