Debian Codegraph @

src/network/evertz/DA6HDL7700/snmp/mode/videostatus.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 network::evertz::DA6HDL7700::snmp::mode::videostatus;
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 ];
35
36 $self->{maps_counters}->{video} = [
37 { label => 'video-status', threshold => 0, set => {
38 key_values => [ { name => 'videoLocked' }, { name => 'detectedVideoStandard' }, { name => 'display' } ],
39 closure_custom_calc => $self->can('custom_status_calc'),
40 closure_custom_output => $self->can('custom_status_output'),
41 closure_custom_perfdata => sub { return 0; },
42 closure_custom_threshold_check => \&catalog_status_threshold,
43 }
44 },
45 ];
46 }
47
48 sub custom_status_output {
49 my ($self, %options) = @_;
50 my $msg = 'is : ' . $self->{result_values}->{video_locked};
51
52 return $msg;
53 }
54
55 sub custom_status_calc {
56 my ($self, %options) = @_;
57
58 $self->{result_values}->{video_locked} = $options{new_datas}->{$self->{instance} . '_videoLocked'};
59 $self->{result_values}->{detected_video_standard} = $options{new_datas}->{$self->{instance} . '_detectedVideoStandard'};
60 $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
61 return 0;
62 }
63
64 sub new {
65 my ($class, %options) = @_;
66 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
67 bless $self, $class;
68
69 $options{options}->add_options(arguments =>
70 {
71 "warning-video-status:s" => { name => 'warning_video_status', default => '' },
72 "critical-video-status:s" => { name => 'critical_video_status', default => '%{video_locked} =~ /notLocked/i' },
73 });
74
75 return $self;
76 }
77
78 sub check_options {
79 my ($self, %options) = @_;
80 $self->SUPER::check_options(%options);
81
82 $self->change_macros(macros => ['warning_video_status', 'critical_video_status']);
83 }
84
85 sub prefix_video_output {
86 my ($self, %options) = @_;
87
88 return "Video '" . $options{instance_value}->{display} . "' ";
89 }
90
91 my %map_video_standard = (1 => 'vs15G', 2 => 'vs540M', 3 => 'vs360M',
92 4 => 'vs270M', 5 => 'vs177M', 6 => 'vs143', 7 => 'none'
93 );
94 my %map_video_locked = (1 => 'locked', 2 => 'notlocked');
95
96 my $mapping = {
97 videoLocked => { oid => '.1.3.6.1.4.1.6827.10.131.4.1.1.1', map => \%map_video_locked },
98 detectedVideoStandard => { oid => '.1.3.6.1.4.1.6827.10.131.4.1.1.2', map => \%map_video_standard },
99 };
100
101 my $oid_videoMonitorEntry = '.1.3.6.1.4.1.6827.10.131.4.1.1';
102
103 sub manage_selection {
104 my ($self, %options) = @_;
105
106 my $snmp_result = $options{snmp}->get_table(oid => $oid_videoMonitorEntry,
107 nothing_quit => 1);
108 $self->{video} = {};
109 foreach my $oid (keys %$snmp_result) {
110 next if ($oid !~ /^$mapping->{videoLocked}->{oid}\.(.*)$/);
111 my $instance = $1;
112 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
113
114 $self->{video}->{$instance} = {
115 display => $instance, %$result
116 };
117 }
118 }
119
120 1;
121
122 __END__
123
124 =head1 MODE
125
126 Check video stream status.
127
128 =over 8
129
130 =item B<--warning-video-status>
131
132 Set warning threshold for device connection status.
133 You can use the following variables: %{video_locked}, %{display}
134
135 =item B<--critical-video-status>
136
137 Set critical threshold for device connection status (default: '%{video_locked} =~ /notLocked/i').
138 You can use the following variables: %{video_locked}, %{display}
139
140 =back
141
142 =cut