Debian Codegraph @

src/network/stonesoft/snmp/mode/clusterstate.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::stonesoft::snmp::mode::clusterstate;
22
23 use base qw(centreon::plugins::templates::counter);
24 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
25
26 use strict;
27 use warnings;
28
29 sub custom_status_output {
30 my ($self, %options) = @_;
31
32 return sprintf(
33 "Node status is '%s' [Member id: %s]",
34 $self->{result_values}->{node_status},
35 $self->{result_values}->{node_member_id}
36 );
37 }
38
39 sub set_counters {
40 my ($self, %options) = @_;
41
42 $self->{maps_counters_type} = [
43 { name => 'global', type => 0 }
44 ];
45
46 $self->{maps_counters}->{global} = [
47 {
48 label => 'status',
49 type => 2,
50 unknown_default => '%{node_status} =~ /unknown/i',
51 warning_default => '%{node_status} =~ /lockedOnline/i',
52 critical_default => '%{node_status} =~ /^(?:offline|goingOffline|lockedOffline|goingLockedOffline|standby|goingStandby)$/i',
53 set => {
54 key_values => [ { name => 'node_status' }, { name => 'node_member_id' } ],
55 closure_custom_output => $self->can('custom_status_output'),
56 closure_custom_perfdata => sub { return 0; },
57 closure_custom_threshold_check => \&catalog_status_threshold_ng
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
71 return $self;
72 }
73
74 my $map_oper_state = {
75 0 => 'unknown',
76 1 => 'online',
77 2 => 'goingOnline',
78 3 => 'lockedOnline',
79 4 => 'goingLockedOnline',
80 5 => 'offline',
81 6 => 'goingOffline',
82 7 => 'lockedOffline',
83 8 => 'goingLockedOffline',
84 9 => 'standby',
85 10 => 'goingStandby'
86 };
87
88 sub manage_selection {
89 my ($self, %options) = @_;
90
91 my $oid_nodeMemberId = '.1.3.6.1.4.1.1369.6.1.1.2.0';
92 my $oid_nodeOperState = '.1.3.6.1.4.1.1369.6.1.1.3.0';
93 my $snmp_result = $options{snmp}->get_leef(oids => [$oid_nodeMemberId, $oid_nodeOperState], nothing_quit => 1);
94 $self->{global} = {
95 node_status => $map_oper_state->{ $snmp_result->{$oid_nodeOperState} },
96 node_member_id => $snmp_result->{$oid_nodeMemberId}
97 };
98 }
99
100 1;
101
102 __END__
103
104 =head1 MODE
105
106 Check status of clustered node.
107
108 =over 8
109
110 =item B<--unknown-status>
111
112 Define the conditions to match for the status to be UNKNOWN (default: '%{node_status} =~ /unknown/i').
113 You can use the following variables: %{node_status}, %{node_member_id}.
114
115 =item B<--warning-status>
116
117 Define the conditions to match for the status to be WARNING (default: '%{node_status} =~ /lockedOnline/i').
118 You can use the following variables: %{node_status}, %{node_member_id}.
119
120 =item B<--critical-status>
121
122 Define the conditions to match for the status to be CRITICAL (default: '%{node_status} =~ /^(?:offline|goingOffline|lockedOffline|goingLockedOffline|standby|goingStandby)$/i').
123 You can use the following variables: %{node_status}, %{node_member_id}.
124
125 =back
126
127 =cut
128