| 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 network::evertz::AEA47721::snmp::mode::streamstatus; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); |
| 28 |
|
| 29 |
sub set_counters { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
$self->{maps_counters_type} = [ |
| 33 |
{ name => 'video', type => 1, cb_prefix_output => 'prefix_video_output', message_multiple => 'All videos are ok' }, |
| 34 |
{ name => 'audio', type => 1, cb_prefix_output => 'prefix_audio_output', message_multiple => 'All audios are ok' }, |
| 35 |
]; |
| 36 |
|
| 37 |
$self->{maps_counters}->{video} = [ |
| 38 |
{ label => 'video-status', threshold => 0, set => { |
| 39 |
key_values => [ { name => 'videoInputStatus' }, { name => 'display' } ], |
| 40 |
closure_custom_calc => $self->can('custom_status_calc'), |
| 41 |
closure_custom_calc_extra_options => { output_label => 'Status', name_status => 'videoInputStatus' }, |
| 42 |
closure_custom_output => $self->can('custom_status_output'), |
| 43 |
closure_custom_perfdata => sub { return 0; }, |
| 44 |
closure_custom_threshold_check => \&catalog_status_threshold, |
| 45 |
} |
| 46 |
}, |
| 47 |
]; |
| 48 |
$self->{maps_counters}->{audio} = [ |
| 49 |
{ label => 'audio-status', threshold => 0, set => { |
| 50 |
key_values => [ { name => 'videoInputGroupStatus' }, { name => 'display' } ], |
| 51 |
closure_custom_calc => $self->can('custom_status_calc'), |
| 52 |
closure_custom_calc_extra_options => { output_label => 'Status', name_status => 'videoInputGroupStatus' }, |
| 53 |
closure_custom_output => $self->can('custom_status_output'), |
| 54 |
closure_custom_perfdata => sub { return 0; }, |
| 55 |
closure_custom_threshold_check => \&catalog_status_threshold, |
| 56 |
} |
| 57 |
}, |
| 58 |
]; |
| 59 |
} |
| 60 |
|
| 61 |
sub custom_status_output { |
| 62 |
my ($self, %options) = @_; |
| 63 |
my $msg = $self->{result_values}->{output_label} . ' : ' . $self->{result_values}->{status}; |
| 64 |
|
| 65 |
return $msg; |
| 66 |
} |
| 67 |
|
| 68 |
sub custom_status_calc { |
| 69 |
my ($self, %options) = @_; |
| 70 |
|
| 71 |
$self->{result_values}->{output_label} = $options{extra_options}->{output_label}; |
| 72 |
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{name_status}}; |
| 73 |
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; |
| 74 |
return 0; |
| 75 |
} |
| 76 |
|
| 77 |
sub new { |
| 78 |
my ($class, %options) = @_; |
| 79 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 80 |
bless $self, $class; |
| 81 |
|
| 82 |
$options{options}->add_options(arguments => |
| 83 |
{ |
| 84 |
"warning-audio-status:s" => { name => 'warning_audio_status', default => '' }, |
| 85 |
"critical-audio-status:s" => { name => 'critical_audio_status', default => '%{status} =~ /loss/i' }, |
| 86 |
"warning-video-status:s" => { name => 'warning_video_status', default => '' }, |
| 87 |
"critical-video-status:s" => { name => 'critical_video_status', default => '%{status} =~ /loss|unknown/i' }, |
| 88 |
}); |
| 89 |
|
| 90 |
return $self; |
| 91 |
} |
| 92 |
|
| 93 |
sub check_options { |
| 94 |
my ($self, %options) = @_; |
| 95 |
$self->SUPER::check_options(%options); |
| 96 |
|
| 97 |
$self->change_macros(macros => ['warning_audio_status', 'critical_audio_status', 'warning_video_status', 'critical_video_status']); |
| 98 |
} |
| 99 |
|
| 100 |
sub prefix_video_output { |
| 101 |
my ($self, %options) = @_; |
| 102 |
|
| 103 |
return "Video '" . $options{instance_value}->{display} . "' "; |
| 104 |
} |
| 105 |
|
| 106 |
sub prefix_audio_output { |
| 107 |
my ($self, %options) = @_; |
| 108 |
|
| 109 |
return "Audio '" . $options{instance_value}->{display} . "' "; |
| 110 |
} |
| 111 |
|
| 112 |
my %map_video_input_status = (1 => 'loss', 2 => 'unknown', 3 => 'p270', 4 => 'n270', 5 => 'sdtiP270', |
| 113 |
6 => 'sdtiN270', 7 => 'std1080ix60', 8 => 'std1080ix5994', 9 => 'std1080ix50', 10 => 'std1035ix60', |
| 114 |
11 => 'std1035ix5994', 12 => 'std1080ix48', 13 => 'std1080ix4796', 14 => 'std1080px24', |
| 115 |
15 => 'std1080px2398', 16 => 'std1080px25', 17 => 'std1080px30', 18 => 'std1080px2997', |
| 116 |
19 => 'std720px60', 20 => 'std720px5994', |
| 117 |
); |
| 118 |
my %map_video_input_group_status = (1 => 'free', 2 => 'used', 3 => 'clean', 4 => 'loss'); |
| 119 |
|
| 120 |
my $mapping = { |
| 121 |
videoInputStatus => { oid => '.1.3.6.1.4.1.6827.10.138.4.1.1.1', map => \%map_video_input_status }, |
| 122 |
}; |
| 123 |
my $mapping2 = { |
| 124 |
videoInputGroupStatus => { oid => '.1.3.6.1.4.1.6827.10.138.4.2.1.2', map => \%map_video_input_group_status }, |
| 125 |
}; |
| 126 |
|
| 127 |
my $oid_monitorEntry = '.1.3.6.1.4.1.6827.10.138.4.1.1'; |
| 128 |
my $oid_audioMonitorEntry = '.1.3.6.1.4.1.6827.10.138.4.2.1'; |
| 129 |
|
| 130 |
sub manage_selection { |
| 131 |
my ($self, %options) = @_; |
| 132 |
|
| 133 |
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_monitorEntry }, |
| 134 |
{ oid => $oid_audioMonitorEntry }, |
| 135 |
], |
| 136 |
nothing_quit => 1); |
| 137 |
$self->{video} = {}; |
| 138 |
foreach my $oid (keys %{$snmp_result->{ $oid_monitorEntry }}) { |
| 139 |
next if ($oid !~ /^$mapping->{videoInputStatus}->{oid}\.(.*)$/); |
| 140 |
my $instance = $1; |
| 141 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{ $oid_monitorEntry }, instance => $instance); |
| 142 |
|
| 143 |
$self->{video}->{$instance} = { |
| 144 |
display => $instance, %$result |
| 145 |
}; |
| 146 |
} |
| 147 |
|
| 148 |
$self->{audio} = {}; |
| 149 |
foreach my $oid (keys %{$snmp_result->{ $oid_audioMonitorEntry }}) { |
| 150 |
next if ($oid !~ /^$mapping2->{videoInputGroupStatus}->{oid}\.(.*?)\.(.*?)$/); |
| 151 |
my ($audio_group_id, $instance) = ($1, $2); |
| 152 |
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{ $oid_audioMonitorEntry }, instance => $audio_group_id . '.' . $instance); |
| 153 |
|
| 154 |
$self->{audio}->{$audio_group_id . '.' . $instance} = { |
| 155 |
display => $instance . '.' . $audio_group_id, %$result |
| 156 |
}; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
1; |
| 161 |
|
| 162 |
__END__ |
| 163 |
|
| 164 |
=head1 MODE |
| 165 |
|
| 166 |
Check video/audio stream status. |
| 167 |
|
| 168 |
=over 8 |
| 169 |
|
| 170 |
=item B<--warning-audio-status> |
| 171 |
|
| 172 |
Set warning threshold for device status. |
| 173 |
You can use the following variables: %{status}, %{display} |
| 174 |
|
| 175 |
=item B<--critical-audio-status> |
| 176 |
|
| 177 |
Set critical threshold for device status (default: '%{status} =~ /loss/i'). |
| 178 |
You can use the following variables: %{status}, %{display} |
| 179 |
|
| 180 |
=item B<--warning-video-status> |
| 181 |
|
| 182 |
Set warning threshold for device connection status. |
| 183 |
You can use the following variables: %{status}, %{display} |
| 184 |
|
| 185 |
=item B<--critical-video-status> |
| 186 |
|
| 187 |
Set critical threshold for device connection status (default: '%{status} =~ /loss|unknown/i'). |
| 188 |
You can use the following variables: %{status}, %{display} |
| 189 |
|
| 190 |
=back |
| 191 |
|
| 192 |
=cut |