Debian Codegraph @

src/network/barracuda/bma/snmp/mode/mails.pm

raw
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 network::barracuda::bma::snmp::mode::mails;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28
29 sub prefix_inbound_output {
30 my ($self, %options) = @_;
31
32 return 'Number of inbound mails ';
33 }
34
35 sub prefix_outbound_output {
36 my ($self, %options) = @_;
37
38 return 'Number of outbound mails ';
39 }
40
41 sub prefix_internal_output {
42 my ($self, %options) = @_;
43
44 return 'Number of internal mails ';
45 }
46
47 sub set_counters {
48 my ($self, %options) = @_;
49
50 $self->{maps_counters_type} = [
51 { name => 'inbound', type => 0, cb_prefix_output => 'prefix_inbound_output', skipped_code => { -10 => 1 } },
52 { name => 'outbound', type => 0, cb_prefix_output => 'prefix_outbound_output', skipped_code => { -10 => 1 } },
53 { name => 'internal', type => 0, cb_prefix_output => 'prefix_internal_output', skipped_code => { -10 => 1 } }
54 ];
55
56 foreach ('inbound', 'outbound', 'internal') {
57 $self->{maps_counters}->{$_} = [
58 { label => $_ . '-hourly', nlabel => 'mails.' . $_ . '.hourly.count', set => {
59 key_values => [ { name => $_ . 'EmailsHour' } ],
60 output_template => 'hourly: %s',
61 perfdatas => [
62 { template => '%s', min => 0 }
63 ]
64 }
65 },
66 { label => $_ . '-daily', nlabel => 'mails.' . $_ . '.daily.count', set => {
67 key_values => [ { name => $_ . 'EmailsDay' } ],
68 output_template => 'daily: %s',
69 perfdatas => [
70 { template => '%s', min => 0 }
71 ]
72 }
73 },
74 { label => $_ . '-total', nlabel => 'mails.' . $_ . '.total.count', set => {
75 key_values => [ { name => $_ . 'EmailsTotal', diff => 1 } ],
76 output_template => 'total: %s',
77 perfdatas => [
78 { template => '%s', min => 0 }
79 ]
80 }
81 }
82 ];
83 }
84 }
85
86
87 sub new {
88 my ($class, %options) = @_;
89 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
90 bless $self, $class;
91
92 $options{options}->add_options(arguments => {});
93
94 return $self;
95 }
96
97 my $mapping = {
98 inboundEmailsHour => { oid => '.1.3.6.1.4.1.20632.6.5.1' },
99 inboundEmailsDay => { oid => '.1.3.6.1.4.1.20632.6.5.2' },
100 inboundEmailsTotal => { oid => '.1.3.6.1.4.1.20632.6.5.3' },
101 internalEmailsHour => { oid => '.1.3.6.1.4.1.20632.6.5.4' },
102 internalEmailsDay => { oid => '.1.3.6.1.4.1.20632.6.5.5' },
103 internalEmailsTotal => { oid => '.1.3.6.1.4.1.20632.6.5.6' },
104 outboundEmailsHour => { oid => '.1.3.6.1.4.1.20632.6.5.7' },
105 outboundEmailsDay => { oid => '.1.3.6.1.4.1.20632.6.5.8' },
106 outboundEmailsTotal => { oid => '.1.3.6.1.4.1.20632.6.5.9' }
107 };
108
109 sub manage_selection {
110 my ($self, %options) = @_;
111
112 my $snmp_result = $options{snmp}->get_leef(
113 oids => [ map($_->{oid}, values(%$mapping)) ],
114 nothing_quit => 1
115 );
116 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result);
117 $self->{inbound} = $result;
118 $self->{outbound} = $result;
119 $self->{internal} = $result;
120
121 $self->{cache_name} = 'barracuda_bma_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
122 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
123 }
124
125 1;
126
127 __END__
128
129 =head1 MODE
130
131 Check e-mails.
132
133 =over 8
134
135 =item B<--warning-*> B<--critical-*>
136
137 Thresholds.
138 Can be: 'internal-hourly', 'internal-daily', 'internal-total',
139 'outbound-hourly', 'outbound-daily', 'outbound-total',
140 'inbound-hourly', 'inbound-daily', 'inbound-total'.
141
142 =back
143
144 =cut