| 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::cyberoam::snmp::mode::components::service; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my $map_v17_status = { |
| 27 |
1 => 'untouched', 2 => 'stopped', 3 => 'initializing', 4 => 'running', 5 => 'exiting', |
| 28 |
6 => 'dead', 7 => 'unregistered' |
| 29 |
}; |
| 30 |
my $map_v18_status = { |
| 31 |
0 => 'untouched', 1 => 'stopped', 2 => 'initializing', 3 => 'running', |
| 32 |
4 => 'exiting', 5 => 'dead', 6 => 'frozen', 7 => 'unregistered' |
| 33 |
}; |
| 34 |
|
| 35 |
my $mapping = { |
| 36 |
pop3Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.1', map => $map_v17_status, type => 'pop3' }, |
| 37 |
imap4Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.2', map => $map_v17_status, type => 'imap4' }, |
| 38 |
smtpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.3', map => $map_v17_status, type => 'smtp' }, |
| 39 |
ftpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.4', map => $map_v17_status, type => 'ftp' }, |
| 40 |
httpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.5', map => $map_v17_status, type => 'http' }, |
| 41 |
avService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.6', map => $map_v17_status, type => 'av' }, |
| 42 |
asService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.7', map => $map_v17_status, type => 'as' }, |
| 43 |
dnsService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.8', map => $map_v17_status, type => 'dns' }, |
| 44 |
haService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.9', map => $map_v17_status, type => 'ha' }, |
| 45 |
idpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.10', map => $map_v17_status, type => 'idp' }, |
| 46 |
apacheService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.11', map => $map_v17_status, type => 'apache' }, |
| 47 |
ntpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.12', map => $map_v17_status, type => 'ntp' }, |
| 48 |
tomcatService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.13', map => $map_v17_status, type => 'tomcat' }, |
| 49 |
sslvpnService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.14', map => $map_v17_status, type => 'sslvpn' }, |
| 50 |
DataBaseService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.15', map => $map_v17_status, type => 'database' }, |
| 51 |
networkService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.16', map => $map_v17_status, type => 'network' }, |
| 52 |
garnerService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.17', map => $map_v17_status, type => 'garner' }, |
| 53 |
droutingService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.18', map => $map_v17_status, type => 'drouting' }, |
| 54 |
sshdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.19', map => $map_v17_status, type => 'sshd' }, |
| 55 |
dgdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.20', map => $map_v17_status, type => 'dgd' }, |
| 56 |
|
| 57 |
sfosPoP3Service => { oid => '.1.3.6.1.4.1.2604.5.1.3.1', map => $map_v18_status, type => 'pop3' }, |
| 58 |
sfosImap4Service => { oid => '.1.3.6.1.4.1.2604.5.1.3.2', map => $map_v18_status, type => 'imap4' }, |
| 59 |
sfosSmtpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.3', map => $map_v18_status, type => 'smtp' }, |
| 60 |
sfosFtpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.4', map => $map_v18_status, type => 'ftp' }, |
| 61 |
sfosHttpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.5', map => $map_v18_status, type => 'http' }, |
| 62 |
sfosAVService => { oid => '.1.3.6.1.4.1.2604.5.1.3.6', map => $map_v18_status, type => 'av' }, |
| 63 |
sfosASService => { oid => '.1.3.6.1.4.1.2604.5.1.3.7', map => $map_v18_status, type => 'as' }, |
| 64 |
sfosDNSService => { oid => '.1.3.6.1.4.1.2604.5.1.3.8', map => $map_v18_status, type => 'dns' }, |
| 65 |
sfosHAService => { oid => '.1.3.6.1.4.1.2604.5.1.3.9', map => $map_v18_status, type => 'ha' }, |
| 66 |
sfosIPSService => { oid => '.1.3.6.1.4.1.2604.5.1.3.10', map => $map_v18_status, type => 'ips' }, |
| 67 |
sfosApacheService => { oid => '.1.3.6.1.4.1.2604.5.1.3.11', map => $map_v18_status, type => 'apache' }, |
| 68 |
sfosNtpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.12', map => $map_v18_status, type => 'ntp' }, |
| 69 |
sfosTomcatService => { oid => '.1.3.6.1.4.1.2604.5.1.3.13', map => $map_v18_status, type => 'tomcat' }, |
| 70 |
sfosSSLVpnService => { oid => '.1.3.6.1.4.1.2604.5.1.3.14', map => $map_v18_status, type => 'sslvpn' }, |
| 71 |
sfosIPSecVpnService => { oid => '.1.3.6.1.4.1.2604.5.1.3.15', map => $map_v18_status, type => 'ipsecvpn' }, |
| 72 |
sfosDatabaseservice => { oid => '.1.3.6.1.4.1.2604.5.1.3.16', map => $map_v18_status, type => 'database' }, |
| 73 |
sfosNetworkService => { oid => '.1.3.6.1.4.1.2604.5.1.3.17', map => $map_v18_status, type => 'network' }, |
| 74 |
sfosGarnerService => { oid => '.1.3.6.1.4.1.2604.5.1.3.18', map => $map_v18_status, type => 'garner' }, |
| 75 |
sfosDroutingService => { oid => '.1.3.6.1.4.1.2604.5.1.3.19', map => $map_v18_status, type => 'drouting' }, |
| 76 |
sfosSSHdService => { oid => '.1.3.6.1.4.1.2604.5.1.3.20', map => $map_v18_status, type => 'sshd' }, |
| 77 |
sfosDgdService => { oid => '.1.3.6.1.4.1.2604.5.1.3.21', map => $map_v18_status, type => 'dgd' } |
| 78 |
}; |
| 79 |
my $oid_serviceStats = '.1.3.6.1.4.1.21067.2.1.2.10'; |
| 80 |
my $oid_sfosXGServiceStatus = '.1.3.6.1.4.1.2604.5.1.3'; |
| 81 |
|
| 82 |
sub load { |
| 83 |
my ($self) = @_; |
| 84 |
|
| 85 |
push @{$self->{request}}, { oid => $oid_serviceStats }, { oid => $oid_sfosXGServiceStatus }; |
| 86 |
} |
| 87 |
|
| 88 |
sub check { |
| 89 |
my ($self) = @_; |
| 90 |
|
| 91 |
$self->{output}->output_add(long_msg => "checking services"); |
| 92 |
$self->{components}->{service} = {name => 'services', total => 0, skip => 0}; |
| 93 |
return if ($self->check_filter(section => 'service')); |
| 94 |
|
| 95 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0); |
| 96 |
|
| 97 |
foreach (keys %$mapping) { |
| 98 |
next if (!defined($result->{$_})); |
| 99 |
next if ($self->check_filter(section => 'service', instance => $mapping->{$_}->{type})); |
| 100 |
|
| 101 |
$self->{components}->{service}->{total}++; |
| 102 |
|
| 103 |
$self->{output}->output_add( |
| 104 |
long_msg => sprintf( |
| 105 |
"service '%s' status is '%s' [instance: %s].", |
| 106 |
$mapping->{$_}->{type}, $result->{$_}, |
| 107 |
$mapping->{$_}->{type} |
| 108 |
) |
| 109 |
); |
| 110 |
my $exit = $self->get_severity(label => 'default', section => 'service', instance => $mapping->{$_}->{type}, value => $result->{$_}); |
| 111 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 112 |
$self->{output}->output_add( |
| 113 |
severity => $exit, |
| 114 |
short_msg => sprintf( |
| 115 |
"service '%s' status is '%s'", |
| 116 |
$mapping->{$_}->{type}, |
| 117 |
$result->{$_} |
| 118 |
) |
| 119 |
); |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
1; |