Debian Codegraph @

src/hardware/devices/cisco/ces/restapi/mode/components.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::cisco::ces::restapi::mode::components;
22
23 use base qw(centreon::plugins::templates::hardware);
24
25 use strict;
26 use warnings;
27
28 sub set_system {
29 my ($self, %options) = @_;
30
31 $self->{regexp_threshold_numeric_check_section_option} = '^(?:aiclatency|aocdelay)$';
32
33 $self->{cb_hook2} = 'execute_custom';
34
35 $self->{thresholds} = {
36 connection_status => [
37 ['NotConnected', 'OK'],
38 ['Connected', 'OK'],
39 ['Unknown', 'UNKNOWN']
40 ],
41 connected => [
42 ['True', 'OK'],
43 ['False', 'WARNING'],
44 ['Unknown', 'UNKNOWN']
45 ],
46 temperature => [
47 ['n/a', 'OK'],
48 ['Normal', 'OK'],
49 ['.*', 'CRITICAL']
50 ],
51 software_status => [
52 ['None', 'OK'],
53 ['InProgress', 'OK'],
54 ['InstallationFailed', 'CRITICAL'],
55 ['Failed', 'CRITICAL'],
56 ['Succeeded', 'OK']
57 ],
58 software_urgency => [
59 ['n/a', 'OK'],
60 ['Low', 'OK'],
61 ['Medium', 'OK'],
62 ['Critical', 'CRITICAL']
63 ],
64 signal_state => [
65 ['OK', 'OK'],
66 ['Unsupported', 'WARNING'],
67 ['Unknown', 'UNKNOWN']
68 ],
69 format_status => [
70 ['Ok', 'OK'],
71 ['OutOfRange', 'WARNING'],
72 ['NotFound', 'OK'],
73 ['Error', 'CRITICAL'],
74 ['Interlaced', 'OK'],
75 ['Unknown', 'UNKNOWN']
76 ],
77 webex => [
78 ['Disabled', 'OK'],
79 ['Stopped', 'OK'],
80 ['Error', 'CRITICAL'],
81 ['Registered', 'OK'],
82 ['Registering', 'OK']
83 ],
84 st_status => [
85 ['Inactive', 'WARNING'],
86 ['Active', 'OK']
87 ],
88 st_availability => [
89 ['Unavailable', 'WARNING'],
90 ['Available', 'OK'],
91 ['Off', 'OK']
92 ]
93 };
94
95 $self->{components_exec_load} = 0;
96
97 $self->{components_path} = 'hardware::devices::cisco::ces::restapi::mode::components';
98 $self->{components_module} = [
99 'ad', 'aic', 'aoc', 'camera', 'st', 'software', 'temperature', 'vic',
100 'vis', 'voc', 'webex'
101 ];
102 }
103
104 sub new {
105 my ($class, %options) = @_;
106 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
107 bless $self, $class;
108
109 $options{options}->add_options(arguments => {});
110
111 return $self;
112 }
113
114 sub execute_custom {
115 my ($self, %options) = @_;
116
117 $self->{results} = $options{custom}->request_api(
118 url_path => '/status.xml',
119 ForceArray => ['Microphone', 'HDMI', 'Line', 'InternalSpeaker', 'Camera', 'Connector', 'Source']
120 );
121
122 my $system_version = 'unknown';
123 $system_version = $self->{results}->{version} if (defined($self->{results}->{version}));
124
125 $self->{output}->output_add(long_msg => 'firmware version: ' . $system_version);
126 }
127
128 1;
129
130 =head1 MODE
131
132 Check components.
133
134 =over 8
135
136 =item B<--component>
137
138 Which component to check (default: '.*').
139 Can be: 'ad' (audio device), 'aic' (audio input connectors), 'aoc' (audio output connectors),
140 'camera', 'st' (speakerTrack), 'software', 'temperature', 'vic' (video input connectors),
141 'vis' (video input source), 'voc', (video output connectors), 'webex'.
142
143 =item B<--filter>
144
145 Exclude some parts (comma separated list)
146 You can also exclude items from specific instances: --filter='aic,Microphone.1'
147
148 =item B<--no-component>
149
150 Define the expected status if no components are found (default: critical).
151
152 =item B<--threshold-overload>
153
154 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
155 Example: --threshold-overload='ad.status,CRITICAL,NotConnected'
156
157 =item B<--warning>
158
159 Set warning threshold for 'temperature', 'fan', 'psu' (syntax: type,regexp,threshold)
160 Example: --warning='aiclatency,.*,20'
161
162 =item B<--critical>
163
164 Set critical threshold for 'temperature', 'fan', 'psu' (syntax: type,regexp,threshold)
165 Example: --critical='aiclatency,.*,50'
166
167 =back
168
169 =cut