| 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::camera::hanwha::snmp::mode::components::service; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my $services = { |
| 27 |
'3.1.1.1' => 'alarmInput1', |
| 28 |
'3.1.2.1' => 'alarmInput2', |
| 29 |
'3.1.3.1' => 'alarmInput3', |
| 30 |
'3.1.4.1' => 'alarmInput4', |
| 31 |
'3.2.1.1' => 'relayOutput1', |
| 32 |
'3.2.2.1' => 'relayOutput2', |
| 33 |
'3.2.3.1' => 'relayOutput3', |
| 34 |
'3.2.4.1' => 'relayOutput4', |
| 35 |
'3.3.1' => 'motionDetection', |
| 36 |
'3.4.1' => 'videoAnalytics', |
| 37 |
'3.5.1' => 'faceDetection', |
| 38 |
'3.6.1' => 'networkDisconnection', |
| 39 |
'3.7.1' => 'tampering', |
| 40 |
'3.8.1' => 'audioDetection', |
| 41 |
'3.10.1' => 'defocus', |
| 42 |
'3.11.1' => 'fogDetection', |
| 43 |
'3.12.1' => 'soundClassification', |
| 44 |
'3.13.1' => 'shockDetection', |
| 45 |
'3.14.1' => 'temperatureDetection', |
| 46 |
}; |
| 47 |
my $oid_nwCam = '.1.3.6.1.4.1.36849.1.2'; |
| 48 |
|
| 49 |
sub load {} |
| 50 |
|
| 51 |
sub check { |
| 52 |
my ($self) = @_; |
| 53 |
|
| 54 |
$self->{output}->output_add(long_msg => "Checking services"); |
| 55 |
$self->{components}->{service} = { name => 'services', total => 0, skip => 0 }; |
| 56 |
return if ($self->check_filter(section => 'service')); |
| 57 |
|
| 58 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nwCam}})) { |
| 59 |
next if ($oid !~ /^$oid_nwCam\.(\d+)\.(.*?)\.0$/); |
| 60 |
my ($product_id, $service) = ($1, $2); |
| 61 |
next if (!defined($services->{$service})); |
| 62 |
|
| 63 |
my $instance = $services->{$service}; |
| 64 |
my $service_status = $self->{results}->{$oid_nwCam}->{$oid}; |
| 65 |
my $service_date = defined($self->{results}->{$oid_nwCam}->{$oid_nwCam . '.' . $product_id . '.' . $service . '.1'}) ? |
| 66 |
$self->{results}->{$oid_nwCam}->{$oid_nwCam . '.' . $product_id . '.' . $service . '.1'} : '-'; |
| 67 |
|
| 68 |
next if ($self->check_filter(section => 'service', instance => $instance)); |
| 69 |
|
| 70 |
$self->{components}->{service}->{total}++; |
| 71 |
$self->{output}->output_add(long_msg => sprintf("service '%s' status is '%s' [instance = %s] [date = %s]", |
| 72 |
$instance, $service_status, $instance, $service_date)); |
| 73 |
my $exit = $self->get_severity(section => 'service', instance => $instance, value => $service_status); |
| 74 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 75 |
$self->{output}->output_add(severity => $exit, |
| 76 |
short_msg => sprintf("service '%s' status is '%s'", $instance, $service_status)); |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
1; |