Debian Codegraph @

src/hardware/devices/polycom/rprm/snmp/mode/updates.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::updates;
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 => 'updates-status', type => 2, critical_default => '%{updates_status} =~ /failed/i',set => {
38 key_values => [ { name => 'updates_status' } ],
39 closure_custom_output => $self->can('custom_updates_status_output'),
40 closure_custom_perfdata => sub { return 0; },
41 closure_custom_threshold_check => \&catalog_status_threshold_ng
42 }
43 },
44 { label => 'updates-failed', nlabel => 'rprm.updates.failed.count', set => {
45 key_values => [ { name => 'updates_failed' } ],
46 output_template => 'Failed last 60m: %s',
47 perfdatas => [
48 { template => '%s', min => 0 }
49 ]
50 }
51 },
52 { label => 'updates-successed', nlabel => 'rprm.updates.successed.count', set => {
53 key_values => [ { name => 'updates_success' } ],
54 output_template => 'Successed last 60m: %s',
55 perfdatas => [
56 { template => '%s', min => 0 }
57 ]
58 }
59 }
60 ];
61 }
62
63 sub custom_updates_status_output {
64 my ($self, %options) = @_;
65
66 return sprintf('Current status: "%s"', $self->{result_values}->{updates_status});
67 }
68
69 sub prefix_global_output {
70 my ($self, %options) = @_;
71
72 return 'RPRM Updates 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_serviceSoftwareUpdateStatus = '.1.3.6.1.4.1.13885.102.1.2.3.1.0';
90 my $oid_serviceSoftwareUpdateFailuresLast60Mins = '.1.3.6.1.4.1.13885.102.1.2.3.2.0';
91 my $oid_serviceSoftwareUpdateSuccessLast60Mins = '.1.3.6.1.4.1.13885.102.1.2.3.3.0';
92
93 my %updates_status = ( 1 => 'disabled', 2 => 'ok', 3 => 'failed' );
94
95 my $result = $options{snmp}->get_leef(
96 oids => [
97 $oid_serviceSoftwareUpdateStatus,
98 $oid_serviceSoftwareUpdateFailuresLast60Mins,
99 $oid_serviceSoftwareUpdateSuccessLast60Mins
100 ],
101 nothing_quit => 1
102 );
103
104 $self->{global} = {
105 updates_status => $updates_status{$result->{$oid_serviceSoftwareUpdateStatus}},
106 updates_failed => $result->{$oid_serviceSoftwareUpdateFailuresLast60Mins},
107 updates_success => $result->{$oid_serviceSoftwareUpdateSuccessLast60Mins}
108 };
109 }
110
111 1;
112
113 __END__
114
115 =head1 MODE
116
117 Check Polycom RPRM updates jobs
118
119 =over 8
120
121 =item B<--warning-updates-status>
122
123 Custom Warning threshold of the updates state (default: none)
124 Syntax: --warning-updates-status='%{updates_status} =~ /clear/i'
125
126 =item B<--critical-updates-status>
127
128 Custom Critical threshold of the updates state
129 (default: '%{updates_status} =~ /failed/i' )
130 Syntax: --critical-updates-status='%{updates_status} =~ /failed/i'
131
132 =item B<--warning-* --critical-*>
133
134 Warning and Critical thresholds.
135 Possible values are: updates-failed, updates-successed
136
137 =back
138
139 =cut