Debian Codegraph @

src/network/cisco/umbrella/snmp/mode/connectivity.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::cisco::umbrella::snmp::mode::connectivity;
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_ng);
28
29 sub custom_status_output {
30 my ($self, %options) = @_;
31
32 return uc($self->{result_values}->{display}) . " health: " . $self->{result_values}->{status};
33 }
34
35 sub set_counters {
36 my ($self, %options) = @_;
37
38 $self->{maps_counters_type} = [
39 { name => 'dns', type => 0 },
40 { name => 'localdns', type => 0 },
41 { name => 'cloud', type => 0 },
42 { name => 'ad', type => 0 }
43 ];
44
45 foreach ('dns', 'localdns', 'cloud', 'ad') {
46 $self->{maps_counters}->{$_} = [
47 {
48 label => $_ . '-status', type => 2,
49 critical_default => '%{status} =~ /red/' ,
50 warning_default => '%{status} =~ /yellow/',
51 unknown_default => '%{status} !~ /(green|yellow|red|white)/',
52 set => {
53 key_values => [ { name => 'status' }, { name => 'display' }],
54 closure_custom_output => $self->can('custom_status_output'),
55 closure_custom_perfdata => sub { return 0; },
56 closure_custom_threshold_check => \&catalog_status_threshold_ng
57 }
58 }
59 ];
60 }
61 }
62
63 sub new {
64 my ($class, %options) = @_;
65 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
66 bless $self, $class;
67
68 $options{options}->add_options(arguments => { });
69
70 return $self;
71 }
72
73 sub manage_selection {
74 my ($self, %options) = @_;
75
76 my $oid_dns = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.3.100.110.115.1';
77 my $oid_localdns = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.8.108.111.99.97.108.100.110.115.1';
78 my $oid_cloud = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.5.99.108.111.117.100.1';
79 my $oid_ad = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.2.97.100.1';
80
81 my $result = $options{snmp}->get_leef(
82 oids => [ $oid_dns, $oid_localdns, $oid_cloud, $oid_ad ],
83 nothing_quit => 1
84 );
85
86 foreach my $umbrella_component ('dns', 'localdns', 'cloud', 'ad') {
87 my $status_output = $result->{eval("\$oid_" . "$umbrella_component")};
88 if ($status_output =~ /\((.*?)\)/){
89 my $status = $1;
90 $self->{$umbrella_component} = {
91 display => $umbrella_component,
92 status => $status
93 };
94 }
95 }
96
97 }
98
99 1;
100
101 __END__
102
103 =head1 MODE
104
105 Check connectivity between Umbrella server and DNS, local DNS, Umbrella dashboard (cloud) and AD connectors.
106
107 =over 8
108
109 =item B<--warning-*>
110
111 Define the conditions to match for the status to be WARNING. (default: '%{status} =~ /yellow/').
112 Can be: 'dns-status', 'localdns-status', 'cloud-status', 'ad-status'.
113
114 Can use special variables like: %{status}, %{display}
115
116 =item B<--critical-*>
117
118 Define the conditions to match for the status to be CRITICAL. (default: %{status} =~ /red/).
119 Can be: 'dns-status', 'localdns-status', 'cloud-status', 'ad-status'.
120
121 Can use special variables like: %{status}, %{display}
122
123 =back
124
125 =cut