Debian Codegraph @

src/hardware/devices/polycom/rprm/snmp/mode/clusterstatus.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 hardware::devices::polycom::rprm::snmp::mode::clusterstatus;
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 set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'cluster-status', type => 2, critical_default => '%{cluster_status} =~ /outOfService/i', set => {
38 key_values => [ { name => 'cluster_status' } ],
39 output_template => 'Current status %s',
40 closure_custom_perfdata => sub { return 0; },
41 closure_custom_threshold_check => \&catalog_status_threshold_ng
42 }
43 },
44 { label => 'cluster-change-cause', type => 2, set => {
45 key_values => [ { name => 'cluster_change_cause' } ],
46 output_template => 'Last change cause: %s',
47 closure_custom_perfdata => sub { return 0; },
48 closure_custom_threshold_check => \&catalog_status_threshold_ng
49 }
50 }
51 ];
52 }
53
54 sub prefix_global_output {
55 my ($self, %options) = @_;
56
57 return 'RPRM HA Super Cluster: ';
58 }
59
60 sub new {
61 my ($class, %options) = @_;
62 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
63 bless $self, $class;
64
65 $options{options}->add_options(arguments => {
66 });
67
68 return $self;
69 }
70
71 sub manage_selection {
72 my ($self, %options) = @_;
73
74 my $oid_serviceHASuperClstrStatus = '.1.3.6.1.4.1.13885.102.1.2.16.1.0';
75 my $oid_serviceHAStatusChgReason = '.1.3.6.1.4.1.13885.102.1.2.16.2.0';
76
77 my %cluster_status = ( 1 => 'inService', 2 => 'busyOut', 3 => 'outOfService' );
78
79 my $result = $options{snmp}->get_leef(
80 oids => [
81 $oid_serviceHASuperClstrStatus,
82 $oid_serviceHAStatusChgReason
83 ],
84 nothing_quit => 1
85 );
86
87 $self->{global} = {
88 cluster_status => $cluster_status{$result->{$oid_serviceHASuperClstrStatus}},
89 cluster_change_cause => $result->{$oid_serviceHAStatusChgReason}
90 };
91 }
92
93 1;
94
95 __END__
96
97 =head1 MODE
98
99 Check Polycom HA SuperCluster status
100
101 =over 8
102
103 =item B<--warning-cluster-status>
104
105 Custom Warning threshold of the cluster state (default: none)
106 Syntax: --warning-cluster-status='%{cluster_status} =~ /busyOut/i'
107
108 =item B<--critical-cluster-status>
109
110 Custom Critical threshold of the cluster state
111 (default: '%{cluster_status} =~ /outOfService/i' )
112 Syntax: --critical-cluster-status='%{cluster_status} =~ /failed/i'
113
114 =item B<--warning-cluster-change-cause>
115
116 Custom Warning threshold of the cluster state change cause (default: none)
117 Syntax: --warning-cluster-change-cause='%{cluster_change_cause} =~ /manualFailover/i'
118
119 =item B<--critical-cluster-change-cause>
120
121 Custom Critical threshold of the cluster state change cause (default: none)
122 Syntax: --critical-cluster-change-cause='%{cluster_change_cause} =~ /manualFailover/i'
123
124 =back
125
126 =cut