+ Fix #537
This commit is contained in:
garnier-quentin 2016-12-28 16:02:18 +01:00
parent 1eb77c673e
commit f71d49f6e9
5 changed files with 515 additions and 0 deletions

View File

@ -0,0 +1,81 @@
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::sophos::es::snmp::mode::components::component;
use strict;
use warnings;
my %map_status = (0 => 'unknown', 1 => 'disabled', 2 => 'ok', 3 => 'warn', 4 => 'error');
my $mapping = {
sophosHwMemoryConsumption => { oid => '.1.3.6.1.4.1.2604.3.4', map => \%map_status, type => 'MemoryConsumption' },
sophosHwMemoryStatus => { oid => '.1.3.6.1.4.1.2604.3.5', map => \%map_status, type => 'Memory' },
sophosHwRaid => { oid => '.1.3.6.1.4.1.2604.3.6', map => \%map_status, type => 'Raid' },
sophosHwCpuStatus => { oid => '.1.3.6.1.4.1.2604.3.7', map => \%map_status, type => 'Cpu' },
sophosHwPowerSupplyLeft => { oid => '.1.3.6.1.4.1.2604.3.8', map => \%map_status, type => 'PowerSupplyLeft' },
sophosHwPowerSupplyRight => { oid => '.1.3.6.1.4.1.2604.3.9', map => \%map_status, type => 'PowerSupplyRight' },
sophosHwPowerSupplyFanLeft => { oid => '.1.3.6.1.4.1.2604.3.10', map => \%map_status, type => 'PowerSupplyFanLeft' },
sophosHwPowerSupplyFanRight => { oid => '.1.3.6.1.4.1.2604.3.11', map => \%map_status, type => 'PowerSupplyFanRight' },
sophosHwSystemFan => { oid => '.1.3.6.1.4.1.2604.3.12', map => \%map_status, type => 'SystemFan' },
sophosHwTemperature => { oid => '.1.3.6.1.4.1.2604.3.13', map => \%map_status, type => 'Temperature' },
sophosHwVoltage => { oid => '.1.3.6.1.4.1.2604.3.14', map => \%map_status, type => 'Voltage' },
sophosHwPowerSupplies => { oid => '.1.3.6.1.4.1.2604.3.16', map => \%map_status, type => 'PowerSupplies' },
};
my $oid_sophosHardware = '.1.3.6.1.4.1.2604.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sophosHardware };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking components");
$self->{components}->{component} = {name => 'components', total => 0, skip => 0};
return if ($self->check_filter(section => 'component'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sophosHardware});
if (scalar(keys %$result) == 0) {
$result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sophosHardware}, instance => '0');
return (scalar(keys %$result) == 0);
}
foreach (keys %{$mapping}) {
next if ($self->check_filter(section => 'component', instance => $mapping->{$_}->{type}));
$self->{components}->{component}->{total}++;
$self->{output}->output_add(long_msg => sprintf("component '%s' status is '%s' [instance: %s].",
$mapping->{$_}->{type}, $result->{$_},
$mapping->{$_}->{type}
));
my $exit = $self->get_severity(label => 'default', section => 'component', instance => $mapping->{$_}->{type}, value => $result->{$_});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("component '%s' status is '%s'",
$mapping->{$_}->{type}, $result->{$_}));
}
}
}
1;

View File

@ -0,0 +1,108 @@
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::sophos::es::snmp::mode::components::system;
use strict;
use warnings;
my %map_status = (0 => 'unknown', 1 => 'disabled', 2 => 'ok', 3 => 'warn', 4 => 'error');
my $mapping = {
seaClusterStatus => { oid => '.1.3.6.1.4.1.2604.2.1.1.1', map => \%map_status, type => 'Cluster' },
seaNodeStatus => { oid => '.1.3.6.1.4.1.2604.2.1.1.2', map => \%map_status, type => 'Node' },
seaRebootStatus => { oid => '.1.3.6.1.4.1.2604.2.1.1.3', map => \%map_status, type => 'Reboot' },
seaStatusMailConnections => { oid => '.1.3.6.1.4.1.2604.2.1.1.4', map => \%map_status, type => 'MailConnections' },
seaStatusMailDiskUsage => { oid => '.1.3.6.1.4.1.2604.2.1.1.5', map => \%map_status, type => 'MailDiskUsage' },
seaStatusMailDiskUsageQuarantine => { oid => '.1.3.6.1.4.1.2604.2.1.1.6', map => \%map_status, type => 'MailDiskUsageQuarantine' },
seaStatusMailLdapSync => { oid => '.1.3.6.1.4.1.2604.2.1.1.7', map => \%map_status, type => 'MailLdapSync' },
seaStatusDeliveryQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.8', map => \%map_status, type => 'DeliveryQueue' },
seaStatusIncomingQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.9', map => \%map_status, type => 'IncomingQueue' },
seaStatusMailTLSError => { oid => '.1.3.6.1.4.1.2604.2.1.1.10', map => \%map_status, type => 'MailTLSError' },
seaStatusSoftwareConfigBackup => { oid => '.1.3.6.1.4.1.2604.2.1.1.11', map => \%map_status, type => 'ConfigBackup' },
seaStatusSoftwareLogfileBackup => { oid => '.1.3.6.1.4.1.2604.2.1.1.12', map => \%map_status, type => 'LogfileBackup' },
seaStatusSoftwareQuarantineBackup => { oid => '.1.3.6.1.4.1.2604.2.1.1.13', map => \%map_status, type => 'QuarantineBackup' },
seaStatusSoftwareClusterConnect => { oid => '.1.3.6.1.4.1.2604.2.1.1.14', map => \%map_status, type => 'ClusterConnect' },
seaStatusSoftwareClusterSync => { oid => '.1.3.6.1.4.1.2604.2.1.1.15', map => \%map_status, type => 'ClusterSync' },
seaStatusSoftwareProcessHealth => { oid => '.1.3.6.1.4.1.2604.2.1.1.16', map => \%map_status, type => 'ProcessHealth' },
seaStatusSoftwareQuarantineSummary => { oid => '.1.3.6.1.4.1.2604.2.1.1.17', map => \%map_status, type => 'QuarantineSummary' },
seaStatusSoftwareSystemLoad => { oid => '.1.3.6.1.4.1.2604.2.1.1.18', map => \%map_status, type => 'SystemLoad' },
seaStatusSoftwareUpdateConnection => { oid => '.1.3.6.1.4.1.2604.2.1.1.19', map => \%map_status, type => 'UpdateConnection' },
seaStatusSoftwareUpdateDataInstall => { oid => '.1.3.6.1.4.1.2604.2.1.1.20', map => \%map_status, type => 'UpdateDataInstall' },
seaStatusSoftwareUpdatePendingreboot => { oid => '.1.3.6.1.4.1.2604.2.1.1.21', map => \%map_status, type => 'UpdatePendingreboot' },
seaStatusSoftwareUpgradeAvailable => { oid => '.1.3.6.1.4.1.2604.2.1.1.22', map => \%map_status, type => 'UpgradeAvailable' },
seaStatusSoftwareUpgradeConnection => { oid => '.1.3.6.1.4.1.2604.2.1.1.23', map => \%map_status, type => 'UpgradeConnection' },
seaStatusSoftwareUpgradeDownload => { oid => '.1.3.6.1.4.1.2604.2.1.1.24', map => \%map_status, type => 'UpgradeDownload' },
seaStatusSoftwareUpgradeInstall => { oid => '.1.3.6.1.4.1.2604.2.1.1.25', map => \%map_status, type => 'UpgradeInstall' },
seaStatusSystemCertificate => { oid => '.1.3.6.1.4.1.2604.2.1.1.26', map => \%map_status, type => 'Certificate' },
seaStatusSystemLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.27', map => \%map_status, type => 'License' },
seaStatusSystemCrossWired => { oid => '.1.3.6.1.4.1.2604.2.1.1.28', map => \%map_status, type => 'CrossWired' },
seaStatusSystemSpxTrialLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.29', map => \%map_status, type => 'SpxTrialLicense' },
seaStatusSpxQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.30', map => \%map_status, type => 'SpxQueue' },
seaStatusSpxFailureQueue => { oid => '.1.3.6.1.4.1.2604.2.1.1.31', map => \%map_status, type => 'SpxFailureQueue' },
seaStatusSpxEncryption => { oid => '.1.3.6.1.4.1.2604.2.1.1.32', map => \%map_status, type => 'SpxEncryption' },
seaStatusSystemSandboxLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.33', map => \%map_status, type => 'SandboxLicense' },
seaStatusSoftwareSyslogProcess => { oid => '.1.3.6.1.4.1.2604.2.1.1.34', map => \%map_status, type => 'SyslogProcess' },
seaStatusSoftwareSyslogConnection => { oid => '.1.3.6.1.4.1.2604.2.1.1.35', map => \%map_status, type => 'SyslogConnection' },
seaStatusSoftwareCloned => { oid => '.1.3.6.1.4.1.2604.2.1.1.36', map => \%map_status, type => 'Cloned' },
seaStatusMailException => { oid => '.1.3.6.1.4.1.2604.2.1.1.37', map => \%map_status, type => 'MailException' },
seaStatusMailShostError => { oid => '.1.3.6.1.4.1.2604.2.1.1.38', map => \%map_status, type => 'MailShostError' },
seaStatusSystemTrialLicense => { oid => '.1.3.6.1.4.1.2604.2.1.1.39', map => \%map_status, type => 'TrialLicense' },
};
my $oid_sophosSysEmail = '.1.3.6.1.4.1.2604.2.1.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sophosSysEmail };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking system");
$self->{components}->{system} = {name => 'system', total => 0, skip => 0};
return if ($self->check_filter(section => 'system'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sophosSysEmail});
if (scalar(keys %$result) == 0) {
$result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sophosSysEmail}, instance => '0');
return (scalar(keys %$result) == 0);
}
foreach (keys %{$mapping}) {
next if ($self->check_filter(section => 'system', instance => $mapping->{$_}->{type}));
$self->{components}->{system}->{total}++;
$self->{output}->output_add(long_msg => sprintf("system '%s' status is '%s' [instance: %s].",
$mapping->{$_}->{type}, $result->{$_},
$mapping->{$_}->{type}
));
my $exit = $self->get_severity(label => 'default', section => 'system', instance => $mapping->{$_}->{type}, value => $result->{$_});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("system '%s' status is '%s'",
$mapping->{$_}->{type}, $result->{$_}));
}
}
}
1;

View File

@ -0,0 +1,102 @@
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::sophos::es::snmp::mode::health;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(system|component)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['unknown', 'OK'],
['disabled', 'OK'],
['ok', 'OK'],
['warn', 'WARNING'],
['error', 'CRITICAL'],
],
};
$self->{components_path} = 'network::sophos::es::snmp::mode::components';
$self->{components_module} = ['component', 'system'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check health status.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'component', 'system'.
=item B<--filter>
Exclude some parts (comma seperated list)
Can also exclude specific instance: --filter=system,MailDiskUsage
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='component,UNKNOWN,unknown'
=back
=cut

View File

@ -0,0 +1,175 @@
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::sophos::es::snmp::mode::message;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'sea_msg', type => 1, cb_prefix_output => 'prefix_seamsg_output', message_multiple => 'All messages are ok' },
];
$self->{maps_counters}->{global} = [
{ label => 'queue', set => {
key_values => [ { name => 'queue' } ],
output_template => 'Current Queue : %s',
perfdatas => [
{ label => 'queue', value => 'queue_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'total-msg-in', set => {
key_values => [ { name => 'total_in', diff => 1 } ],
output_template => 'Total Message In : %.2f/s', per_second => 1,
perfdatas => [
{ label => 'total_msg_in', value => 'total_in_per_second', template => '%.2f',
unit => '/s', min => 0 },
],
}
},
{ label => 'total-msg-out', set => {
key_values => [ { name => 'total_out', diff => 1 } ],
output_template => 'Total Message Out : %.2f/s', per_second => 1,
perfdatas => [
{ label => 'total_msg_out', value => 'total_out_per_second', template => '%.2f',
unit => '/s', min => 0 },
],
}
},
];
$self->{maps_counters}->{sea_msg} = [
{ label => 'msg-in', set => {
key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ],
output_template => 'In : %.2f/s', per_second => 1,
perfdatas => [
{ label => 'msg_in', value => 'in_per_second', template => '%.2f',
unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'msg-out', set => {
key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ],
output_template => 'Out : %.2f/s', per_second => 1,
perfdatas => [
{ label => 'msg_out', value => 'out_per_second', template => '%.2f',
unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_seamsg_output {
my ($self, %options) = @_;
return "Message '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
my $mapping = {
counterType => { oid => '.1.3.6.1.4.1.2604.1.1.1.4.1.2' },
counterInbound => { oid => '.1.3.6.1.4.1.2604.1.1.1.4.1.3' },
counterOutbound => { oid => '.1.3.6.1.4.1.2604.1.1.1.4.1.4' },
};
my $oid_sophosStatisticsEmail = '.1.3.6.1.4.1.2604.1.1.1';
my $oid_seaStatisticsQueuedMessages = '.1.3.6.1.4.1.2604.1.1.1.5';
sub manage_selection {
my ($self, %options) = @_;
my $oid_liveUsers = '.1.3.6.1.4.1.21067.2.1.2.6.0';
my $oid_httpHits = '.1.3.6.1.4.1.21067.2.1.2.7.0';
my $oid_ftpHits = '.1.3.6.1.4.1.21067.2.1.2.8.0';
my $oid_pop3Hits = '.1.3.6.1.4.1.21067.2.1.2.9.1.0';
my $oid_imapHits = '.1.3.6.1.4.1.21067.2.1.2.9.2.0';
my $oid_smtpHits = '.1.3.6.1.4.1.21067.2.1.2.9.3.0';
my $results = $options{snmp}->get_table(oid => $oid_sophosStatisticsEmail, nothing_quit => 1);
$self->{cache_name} = "sophos_es_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
$self->{global} = { total_in => 0, total_out => 0 };
$self->{global}->{queue} = defined($results->{$oid_seaStatisticsQueuedMessages}) ? $results->{$oid_seaStatisticsQueuedMessages} : undef;
$self->{sea_msg} = {};
foreach my $oid (keys %$results) {
next if ($oid !~ /^$mapping->{counterType}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
$self->{sea_msg}->{lc($result->{counterType})} = { display => lc($result->{counterType}),
in => $result->{counterInbound}, out => $result->{counterOutbound}
};
$self->{global}->{total_in} += $result->{counterInbound};
$self->{global}->{total_out} += $result->{counterOutbound};
}
}
1;
__END__
=head1 MODE
Check message statistics.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='queue'
=item B<--warning-*>
Threshold warning.
=item B<--critical-*>
Threshold critical.
Can be: queue, total-in, total-out, msg-in, msg-out.
=back
=cut

View File

@ -0,0 +1,49 @@
#
# Copyright 2016 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::sophos::es::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
'health' => 'network::sophos::es::snmp::mode::health',
'message' => 'network::sophos::es::snmp::mode::message',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Sophos Email Security appliance (also virtual) in SNMP.
=cut