| 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 apps::inin::mediaserver::snmp::mode::audioengineusage; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub set_counters { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{maps_counters_type} = [ |
| 32 |
{ name => 'engine', type => 1, cb_prefix_output => 'prefix_engine_output', message_multiple => 'All audio engines are ok' } |
| 33 |
]; |
| 34 |
|
| 35 |
$self->{maps_counters}->{engine} = [ |
| 36 |
{ label => 'avg-load', set => { |
| 37 |
key_values => [ { name => 'i3MsAudioEngineAverageLoad' }, { name => 'display' } ], |
| 38 |
output_template => 'Average Load : %s', |
| 39 |
perfdatas => [ |
| 40 |
{ label => 'load_avg', value => 'i3MsAudioEngineAverageLoad', template => '%s', |
| 41 |
min => 0, label_extra_instance => 1, instance_use => 'display' }, |
| 42 |
], |
| 43 |
} |
| 44 |
}, |
| 45 |
{ label => 'elem-count', set => { |
| 46 |
key_values => [ { name => 'i3MsAudioEngineElementCount' }, { name => 'display' } ], |
| 47 |
output_template => 'Total active graph elements : %s', |
| 48 |
perfdatas => [ |
| 49 |
{ label => 'elem_count', value => 'i3MsAudioEngineElementCount', template => '%s', |
| 50 |
min => 0, label_extra_instance => 1, instance_use => 'display' }, |
| 51 |
], |
| 52 |
} |
| 53 |
}, |
| 54 |
]; |
| 55 |
} |
| 56 |
|
| 57 |
sub new { |
| 58 |
my ($class, %options) = @_; |
| 59 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 60 |
bless $self, $class; |
| 61 |
|
| 62 |
$options{options}->add_options(arguments => |
| 63 |
{ |
| 64 |
"filter-location:s" => { name => 'filter_location' }, |
| 65 |
}); |
| 66 |
|
| 67 |
return $self; |
| 68 |
} |
| 69 |
|
| 70 |
sub prefix_engine_output { |
| 71 |
my ($self, %options) = @_; |
| 72 |
|
| 73 |
return "Audio Engine '" . $options{instance_value}->{display} . "' "; |
| 74 |
} |
| 75 |
|
| 76 |
my $mapping = { |
| 77 |
i3MsAudioEngineLocation => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.4' }, |
| 78 |
i3MsAudioEngineAverageLoad => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.6' }, |
| 79 |
i3MsAudioEngineElementCount => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.8' }, |
| 80 |
}; |
| 81 |
|
| 82 |
my $oid_i3MsAudioEngineInfoTableEntry = '.1.3.6.1.4.1.2793.8227.2.1.1'; |
| 83 |
|
| 84 |
sub manage_selection { |
| 85 |
my ($self, %options) = @_; |
| 86 |
|
| 87 |
$self->{engine} = {}; |
| 88 |
my $snmp_result = $options{snmp}->get_table(oid => $oid_i3MsAudioEngineInfoTableEntry, |
| 89 |
nothing_quit => 1); |
| 90 |
|
| 91 |
|
| 92 |
foreach my $oid (keys %{$snmp_result}) { |
| 93 |
next if ($oid !~ /^$mapping->{i3MsAudioEngineLocation}->{oid}\.(.*)$/); |
| 94 |
my $instance = $1; |
| 95 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 96 |
|
| 97 |
if (defined($self->{option_results}->{filter_location}) && $self->{option_results}->{filter_location} ne '' && |
| 98 |
$result->{i3MsAudioEngineLocation} !~ /$self->{option_results}->{filter_location}/) { |
| 99 |
$self->{output}->output_add(long_msg => "skipping '" . $result->{i3MsAudioEngineLocation} . "': no matching filter.", debug => 1); |
| 100 |
next; |
| 101 |
} |
| 102 |
|
| 103 |
$self->{engine}->{$instance} = { display => $result->{i3MsAudioEngineLocation}, |
| 104 |
%$result |
| 105 |
}; |
| 106 |
} |
| 107 |
|
| 108 |
if (scalar(keys %{$self->{engine}}) <= 0) { |
| 109 |
$self->{output}->add_option_msg(short_msg => "No audio engine found."); |
| 110 |
$self->{output}->option_exit(); |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
1; |
| 115 |
|
| 116 |
__END__ |
| 117 |
|
| 118 |
=head1 MODE |
| 119 |
|
| 120 |
Check audio engine usage. |
| 121 |
|
| 122 |
=over 8 |
| 123 |
|
| 124 |
=item B<--filter-counters> |
| 125 |
|
| 126 |
Only display some counters (regexp can be used). |
| 127 |
Example: --filter-counters='^elem-count$' |
| 128 |
|
| 129 |
=item B<--filter-location> |
| 130 |
|
| 131 |
Filter location name (can be a regexp). |
| 132 |
|
| 133 |
=item B<--warning-*> |
| 134 |
|
| 135 |
Warning threshold. |
| 136 |
Can be: 'elem-count', 'avg-load'. |
| 137 |
|
| 138 |
=item B<--critical-*> |
| 139 |
|
| 140 |
Critical threshold. |
| 141 |
Can be: 'elem-count', 'avg-load'. |
| 142 |
|
| 143 |
=back |
| 144 |
|
| 145 |
=cut |