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