Debian Codegraph @

src/hardware/devices/polycom/rprm/snmp/mode/provisioning.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::provisioning;
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 => 'provisioning-status', type => 2, critical_default => '%{provisioning_status} =~ /failed/i', set => {
38 key_values => [ { name => 'provisioning_status' } ],
39 closure_custom_output => $self->can('custom_provisioning_status_output'),
40 closure_custom_perfdata => sub { return 0; },
41 closure_custom_threshold_check => \&catalog_status_threshold_ng
42 }
43 },
44 { label => 'provisioning-failed', nlabel => 'rprm.provisioning.failed.count', set => {
45 key_values => [ { name => 'provisioning_failed' } ],
46 output_template => 'Failed last 60m: %s',
47 perfdatas => [
48 { template => '%s', min => 0, unit => '' }
49 ]
50 }
51 },
52 { label => 'provisioning-success', nlabel => 'rprm.provisioning.success.count', set => {
53 key_values => [ { name => 'provisioning_success' } ],
54 output_template => 'Successed last 60m: %s',
55 perfdatas => [
56 { template => '%s', min => 0, unit => '' }
57 ]
58 }
59 }
60 ];
61 }
62
63 sub custom_provisioning_status_output {
64 my ($self, %options) = @_;
65
66 return sprintf('Current status: "%s"', $self->{result_values}->{provisioning_status});
67 }
68
69 sub prefix_global_output {
70 my ($self, %options) = @_;
71
72 return 'RPRM Provisioning jobs stats: ';
73 }
74
75 sub new {
76 my ($class, %options) = @_;
77 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
78 bless $self, $class;
79
80 $options{options}->add_options(arguments => {
81 });
82
83 return $self;
84 }
85
86 sub manage_selection {
87 my ($self, %options) = @_;
88
89 my $oid_serviceProvisioningStatus = '.1.3.6.1.4.1.13885.102.1.2.2.1.0';
90 my $oid_serviceProvisioningFailuresLast60Mins = '.1.3.6.1.4.1.13885.102.1.2.2.2.0';
91 my $oid_serviceProvisioningSuccessLast60Mins = '.1.3.6.1.4.1.13885.102.1.2.2.3.0';
92
93 my %provisioning_status = ( 0 => 'clear', 2 => 'in-progress', 3 => 'success', 4 => 'failed' );
94
95 my $result = $options{snmp}->get_leef(
96 oids => [
97 $oid_serviceProvisioningStatus,
98 $oid_serviceProvisioningFailuresLast60Mins,
99 $oid_serviceProvisioningSuccessLast60Mins
100 ],
101 nothing_quit => 1
102 );
103
104 $self->{global} = {
105 provisioning_status => $provisioning_status{$result->{$oid_serviceProvisioningStatus}},
106 provisioning_failed => $result->{$oid_serviceProvisioningFailuresLast60Mins},
107 provisioning_success => $result->{$oid_serviceProvisioningSuccessLast60Mins}
108 };
109 }
110
111 1;
112
113 __END__
114
115 =head1 MODE
116
117 Check Polycom RPRM provisioning jobs
118
119 =over 8
120
121 =item B<--warning-provisioning-status>
122
123 Custom Warning threshold of the provisioning state (default: none)
124 Syntax: --warning-provisioning-status='%{provisioning_status} =~ /clear/i'
125
126 =item B<--critical-provisioning-status>
127
128 Custom Critical threshold of the provisioning state
129 (default: '%{provisioning_status} =~ /failed/i' )
130 Syntax: --critical-provisioning-status='%{provisioning_status} =~ /failed/i'
131
132 =item B<--warning-* --critical-*>
133
134 Warning and Critical thresholds.
135 Possible values are: provisioning-failed, provisioning-success
136
137 =back
138
139 =cut