Debian Codegraph @

src/hardware/devices/cisco/ces/restapi/mode/components/aic.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::aic;
22
23 use strict;
24 use warnings;
25
26 #<Connectors item="1">
27 # <Microphone item="1">
28 # <EcReferenceDelay item="1">0</EcReferenceDelay>
29 # </Microphone>
30 # <Microphone item="2">
31 # <EcReferenceDelay item="1">0</EcReferenceDelay>
32 # </Microphone>
33 #</Connectors>
34
35 sub check_aic {
36 my ($self, %options) = @_;
37
38 foreach (@{$options{entry}->{ $options{element} }}) {
39 my $instance = $options{element} . ':' . $_->{item};
40
41 my $ec_reference_delay = ref($_->{EcReferenceDelay}) eq 'HASH' ? $_->{EcReferenceDelay}->{content} : $_->{EcReferenceDelay};
42 next if (!defined($_->{ConnectionStatus}) && !defined($ec_reference_delay));
43
44 next if ($self->check_filter(section => 'aic', instance => $instance));
45 $self->{components}->{aic}->{total}++;
46
47 $self->{output}->output_add(
48 long_msg => sprintf(
49 "audio input connector '%s' connection status is '%s' [instance: %s, latency: %s ms]",
50 $instance,
51 defined($_->{ConnectionStatus}) ? $_->{ConnectionStatus} : 'n/a',
52 $instance,
53 defined($ec_reference_delay) ? $ec_reference_delay : '-'
54 )
55 );
56
57 if (defined($_->{ConnectionStatus})) {
58 my $exit = $self->get_severity(label => 'connection_status', section => 'aic.status', value => $_->{ConnectionStatus});
59 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
60 $self->{output}->output_add(
61 severity => $exit,
62 short_msg => sprintf("audio input connector '%s' connection status is '%s'", $instance, $_->{ConnectionStatus})
63 );
64 }
65 }
66
67 if (defined($ec_reference_delay)) {
68 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'aiclatency', instance => $instance, value => $ec_reference_delay);
69
70 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
71 $self->{output}->output_add(
72 severity => $exit,
73 short_msg => sprintf(
74 "audio input connector '%s' latency is %s ms",
75 $instance, $ec_reference_delay
76 )
77 );
78 }
79 $self->{output}->perfdata_add(
80 unit => 'ms',
81 nlabel => 'component.audio.input.connector.latency.milliseconds',
82 instances => [$options{element}, $_->{item}],
83 value => $ec_reference_delay,
84 warning => $warn,
85 critical => $crit
86 );
87 }
88 }
89 }
90
91 sub check {
92 my ($self) = @_;
93
94 $self->{output}->output_add(long_msg => 'checking audio input connectors');
95 $self->{components}->{aic} = { name => 'audio input connectors', total => 0, skip => 0 };
96 return if ($self->check_filter(section => 'aic'));
97
98 check_aic(
99 $self,
100 entry => $self->{results}->{Audio}->{Input}->{Connectors},
101 element => 'Microphone',
102 instance => 'item'
103 );
104 check_aic(
105 $self,
106 entry => $self->{results}->{Audio}->{Input}->{Connectors},
107 element => 'HDMI',
108 instance => 'item'
109 );
110 }
111
112 1;