Debian Codegraph @

src/network/paloalto/snmp/mode/panorama.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::paloalto::snmp::mode::panorama;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
28
29 sub custom_status_output {
30 my ($self, %options) = @_;
31
32 return "connection status is '" . $self->{result_values}->{status} . "'";
33 }
34
35 sub set_counters {
36 my ($self, %options) = @_;
37
38 $self->{maps_counters_type} = [
39 { name => 'pan', type => 1, cb_prefix_output => 'prefix_pan_output', message_multiple => 'All panorama connection statuses are ok', skipped_code => { -10 => 1 } },
40 ];
41
42 $self->{maps_counters}->{pan} = [
43 { label => 'status', threshold => 0, set => {
44 key_values => [ { name => 'status' }, { name => 'display' } ],
45 closure_custom_calc => \&catalog_status_calc,
46 closure_custom_output => $self->can('custom_status_output'),
47 closure_custom_perfdata => sub { return 0; },
48 closure_custom_threshold_check => \&catalog_status_threshold,
49 }
50 },
51 ];
52 }
53
54 sub prefix_pan_output {
55 my ($self, %options) = @_;
56
57 return "panorama '" . $options{instance_value}->{display} . "' ";
58 }
59
60 sub new {
61 my ($class, %options) = @_;
62 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
63 bless $self, $class;
64
65 $options{options}->add_options(arguments => {
66 'warning-status:s' => { name => 'warning_status', default => '' },
67 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /not-connected/i' },
68 });
69
70 return $self;
71 }
72
73 sub check_options {
74 my ($self, %options) = @_;
75 $self->SUPER::check_options(%options);
76
77 $self->change_macros(macros => ['warning_status', 'critical_status']);
78 }
79
80 sub manage_selection {
81 my ($self, %options) = @_;
82
83 my $oid_panMgmtPanoramaConnected = '.1.3.6.1.4.1.25461.2.1.2.4.1.0';
84 my $oid_panMgmtPanorama2Connected = '.1.3.6.1.4.1.25461.2.1.2.4.2.0';
85 my $snmp_result = $options{snmp}->get_leef(
86 oids => [$oid_panMgmtPanoramaConnected, $oid_panMgmtPanorama2Connected],
87 nothing_quit => 1
88 );
89
90 $self->{pan} = {
91 1 => {
92 display => 1,
93 status => $snmp_result->{$oid_panMgmtPanoramaConnected},
94 },
95 2 => {
96 display => 2,
97 status => $snmp_result->{$oid_panMgmtPanorama2Connected},
98 }
99 };
100 }
101
102 1;
103
104 __END__
105
106 =head1 MODE
107
108 Check panorama connection status.
109
110 =over 8
111
112 =item B<--warning-status>
113
114 Define the conditions to match for the status to be WARNING (default: '').
115 You can use the following variables: %{status}, %{display}
116
117 =item B<--critical-status>
118
119 Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /not-connected/i').
120 You can use the following variables: %{status}, %{display}
121
122 =back
123
124 =cut
125