| 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::sophos::es::snmp::mode::components::system; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_status = (0 => 'unknown', 1 => 'disabled', 2 => 'ok', 3 => 'warn', 4 => 'error'); |
| 27 |
|
| 28 |
my $mapping = { |
| 29 |
seaClusterStatus => { oid => '.1.3.6.1.4.1.2604.2.1.1.1', map => \%map_status, type => 'Cluster' }, |
| 30 |
seaNodeStatus => { oid => '.1.3.6.1.4.1.2604.2.1.1.2', map => \%map_status, type => 'Node' }, |
| 31 |
seaRebootStatus => { oid => '.1.3.6.1.4.1.2604.2.1.1.3', map => \%map_status, type => 'Reboot' }, |
| 32 |
seaStatusMailConnections => { oid => '.1.3.6.1.4.1.2604.2.1.1.4', map => \%map_status, type => 'MailConnections' }, |
| 33 |
seaStatusMailDiskUsage => { oid => '.1.3.6.1.4.1.2604.2.1.1.5', map => \%map_status, type => 'MailDiskUsage' }, |
| 34 |
seaStatusMailDiskUsageQuarantine => { oid => '.1.3.6.1.4.1.2604.2.1.1.6', map => \%map_status, type => 'MailDiskUsageQuarantine' }, |
| 35 |
seaStatusMailLdapSync => { oid => '.1.3.6.1.4.1.2604.2.1.1.7', map => \%map_status, type => 'MailLdapSync' }, |
| 36 |
seaStatusDeliveryQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.8', map => \%map_status, type => 'DeliveryQueue' }, |
| 37 |
seaStatusIncomingQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.9', map => \%map_status, type => 'IncomingQueue' }, |
| 38 |
seaStatusMailTLSError => { oid => '.1.3.6.1.4.1.2604.2.1.1.10', map => \%map_status, type => 'MailTLSError' }, |
| 39 |
seaStatusSoftwareConfigBackup => { oid => '.1.3.6.1.4.1.2604.2.1.1.11', map => \%map_status, type => 'ConfigBackup' }, |
| 40 |
seaStatusSoftwareLogfileBackup => { oid => '.1.3.6.1.4.1.2604.2.1.1.12', map => \%map_status, type => 'LogfileBackup' }, |
| 41 |
seaStatusSoftwareQuarantineBackup => { oid => '.1.3.6.1.4.1.2604.2.1.1.13', map => \%map_status, type => 'QuarantineBackup' }, |
| 42 |
seaStatusSoftwareClusterConnect => { oid => '.1.3.6.1.4.1.2604.2.1.1.14', map => \%map_status, type => 'ClusterConnect' }, |
| 43 |
seaStatusSoftwareClusterSync => { oid => '.1.3.6.1.4.1.2604.2.1.1.15', map => \%map_status, type => 'ClusterSync' }, |
| 44 |
seaStatusSoftwareProcessHealth => { oid => '.1.3.6.1.4.1.2604.2.1.1.16', map => \%map_status, type => 'ProcessHealth' }, |
| 45 |
seaStatusSoftwareQuarantineSummary => { oid => '.1.3.6.1.4.1.2604.2.1.1.17', map => \%map_status, type => 'QuarantineSummary' }, |
| 46 |
seaStatusSoftwareSystemLoad => { oid => '.1.3.6.1.4.1.2604.2.1.1.18', map => \%map_status, type => 'SystemLoad' }, |
| 47 |
seaStatusSoftwareUpdateConnection => { oid => '.1.3.6.1.4.1.2604.2.1.1.19', map => \%map_status, type => 'UpdateConnection' }, |
| 48 |
seaStatusSoftwareUpdateDataInstall => { oid => '.1.3.6.1.4.1.2604.2.1.1.20', map => \%map_status, type => 'UpdateDataInstall' }, |
| 49 |
seaStatusSoftwareUpdatePendingreboot => { oid => '.1.3.6.1.4.1.2604.2.1.1.21', map => \%map_status, type => 'UpdatePendingreboot' }, |
| 50 |
seaStatusSoftwareUpgradeAvailable => { oid => '.1.3.6.1.4.1.2604.2.1.1.22', map => \%map_status, type => 'UpgradeAvailable' }, |
| 51 |
seaStatusSoftwareUpgradeConnection => { oid => '.1.3.6.1.4.1.2604.2.1.1.23', map => \%map_status, type => 'UpgradeConnection' }, |
| 52 |
seaStatusSoftwareUpgradeDownload => { oid => '.1.3.6.1.4.1.2604.2.1.1.24', map => \%map_status, type => 'UpgradeDownload' }, |
| 53 |
seaStatusSoftwareUpgradeInstall => { oid => '.1.3.6.1.4.1.2604.2.1.1.25', map => \%map_status, type => 'UpgradeInstall' }, |
| 54 |
seaStatusSystemCertificate => { oid => '.1.3.6.1.4.1.2604.2.1.1.26', map => \%map_status, type => 'Certificate' }, |
| 55 |
seaStatusSystemLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.27', map => \%map_status, type => 'License' }, |
| 56 |
seaStatusSystemCrossWired => { oid => '.1.3.6.1.4.1.2604.2.1.1.28', map => \%map_status, type => 'CrossWired' }, |
| 57 |
seaStatusSystemSpxTrialLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.29', map => \%map_status, type => 'SpxTrialLicense' }, |
| 58 |
seaStatusSpxQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.30', map => \%map_status, type => 'SpxQueue' }, |
| 59 |
seaStatusSpxFailureQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.31', map => \%map_status, type => 'SpxFailureQueue' }, |
| 60 |
seaStatusSpxEncryption => { oid => '.1.3.6.1.4.1.2604.2.1.1.32', map => \%map_status, type => 'SpxEncryption' }, |
| 61 |
seaStatusSystemSandboxLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.33', map => \%map_status, type => 'SandboxLicense' }, |
| 62 |
seaStatusSoftwareSyslogProcess => { oid => '.1.3.6.1.4.1.2604.2.1.1.34', map => \%map_status, type => 'SyslogProcess' }, |
| 63 |
seaStatusSoftwareSyslogConnection => { oid => '.1.3.6.1.4.1.2604.2.1.1.35', map => \%map_status, type => 'SyslogConnection' }, |
| 64 |
seaStatusSoftwareCloned => { oid => '.1.3.6.1.4.1.2604.2.1.1.36', map => \%map_status, type => 'Cloned' }, |
| 65 |
seaStatusMailException => { oid => '.1.3.6.1.4.1.2604.2.1.1.37', map => \%map_status, type => 'MailException' }, |
| 66 |
seaStatusMailShostError => { oid => '.1.3.6.1.4.1.2604.2.1.1.38', map => \%map_status, type => 'MailShostError' }, |
| 67 |
seaStatusSystemTrialLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.39', map => \%map_status, type => 'TrialLicense' }, |
| 68 |
}; |
| 69 |
my $oid_sophosSysEmail = '.1.3.6.1.4.1.2604.2.1.1'; |
| 70 |
|
| 71 |
sub load { |
| 72 |
my ($self) = @_; |
| 73 |
|
| 74 |
push @{$self->{request}}, { oid => $oid_sophosSysEmail }; |
| 75 |
} |
| 76 |
|
| 77 |
sub check { |
| 78 |
my ($self) = @_; |
| 79 |
|
| 80 |
$self->{output}->output_add(long_msg => "Checking system"); |
| 81 |
$self->{components}->{system} = {name => 'system', total => 0, skip => 0}; |
| 82 |
return if ($self->check_filter(section => 'system')); |
| 83 |
|
| 84 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sophosSysEmail}); |
| 85 |
if (scalar(keys %$result) == 0) { |
| 86 |
$result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sophosSysEmail}, instance => '0'); |
| 87 |
return (scalar(keys %$result) == 0); |
| 88 |
} |
| 89 |
|
| 90 |
foreach (keys %{$mapping}) { |
| 91 |
next if ($self->check_filter(section => 'system', instance => $mapping->{$_}->{type})); |
| 92 |
|
| 93 |
$self->{components}->{system}->{total}++; |
| 94 |
|
| 95 |
$self->{output}->output_add(long_msg => sprintf("system '%s' status is '%s' [instance: %s].", |
| 96 |
$mapping->{$_}->{type}, $result->{$_}, |
| 97 |
$mapping->{$_}->{type} |
| 98 |
)); |
| 99 |
my $exit = $self->get_severity(label => 'default', section => 'system', instance => $mapping->{$_}->{type}, value => $result->{$_}); |
| 100 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 101 |
$self->{output}->output_add(severity => $exit, |
| 102 |
short_msg => sprintf("system '%s' status is '%s'", |
| 103 |
$mapping->{$_}->{type}, $result->{$_})); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
1; |