+ Fix #550
This commit is contained in:
parent
1b129b785f
commit
1eb77c673e
|
@ -0,0 +1,88 @@
|
||||||
|
#
|
||||||
|
# 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::cyberoam::snmp::mode::components::service;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my %map_status = (
|
||||||
|
1 => 'untouched', 2 => 'stopped', 3 => 'initializing', 4 => 'running', 5 => 'exiting',
|
||||||
|
6 => 'dead', 7 => 'unregistered',
|
||||||
|
);
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
pop3Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.1', map => \%map_status, type => 'pop3' },
|
||||||
|
imap4Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.2', map => \%map_status, type => 'imap4' },
|
||||||
|
smtpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.3', map => \%map_status, type => 'smtp' },
|
||||||
|
ftpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.4', map => \%map_status, type => 'ftp' },
|
||||||
|
httpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.5', map => \%map_status, type => 'http' },
|
||||||
|
avService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.6', map => \%map_status, type => 'av' },
|
||||||
|
asService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.7', map => \%map_status, type => 'as' },
|
||||||
|
dnsService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.8', map => \%map_status, type => 'dns' },
|
||||||
|
haService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.9', map => \%map_status, type => 'ha' },
|
||||||
|
idpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.10', map => \%map_status, type => 'idp' },
|
||||||
|
apacheService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.11', map => \%map_status, type => 'apache' },
|
||||||
|
ntpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.12', map => \%map_status, type => 'ntp' },
|
||||||
|
tomcatService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.13', map => \%map_status, type => 'tomcat' },
|
||||||
|
sslvpnService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.14', map => \%map_status, type => 'sslvpn' },
|
||||||
|
DataBaseService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.15', map => \%map_status, type => 'database' },
|
||||||
|
networkService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.16', map => \%map_status, type => 'network' },
|
||||||
|
garnerService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.17', map => \%map_status, type => 'garner' },
|
||||||
|
droutingService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.18', map => \%map_status, type => 'drouting' },
|
||||||
|
sshdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.19', map => \%map_status, type => 'sshd' },
|
||||||
|
dgdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.20', map => \%map_status, type => 'dgd' },
|
||||||
|
};
|
||||||
|
my $oid_serviceStats = '.1.3.6.1.4.1.21067.2.1.2.10';
|
||||||
|
|
||||||
|
sub load {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
push @{$self->{request}}, { oid => $oid_serviceStats };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => "checking services");
|
||||||
|
$self->{components}->{service} = {name => 'services', total => 0, skip => 0};
|
||||||
|
return if ($self->check_filter(section => 'service'));
|
||||||
|
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_serviceStats}, instance => '0');
|
||||||
|
|
||||||
|
foreach (keys %{$mapping}) {
|
||||||
|
next if ($self->check_filter(section => 'service', instance => $mapping->{$_}->{type}));
|
||||||
|
|
||||||
|
$self->{components}->{service}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => sprintf("service '%s' status is '%s' [instance: %s].",
|
||||||
|
$mapping->{$_}->{type}, $result->{$_},
|
||||||
|
$mapping->{$_}->{type}
|
||||||
|
));
|
||||||
|
my $exit = $self->get_severity(label => 'default', section => 'service', 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("service '%s' status is '%s'",
|
||||||
|
$mapping->{$_}->{type}, $result->{$_}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -33,6 +33,14 @@ sub set_counters {
|
||||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' },
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' },
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'live-users', set => {
|
||||||
|
key_values => [ { name => 'live_users' } ],
|
||||||
|
output_template => 'live users = %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'live_users', value => 'live_users_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
{ label => 'http-hits', set => {
|
{ label => 'http-hits', set => {
|
||||||
key_values => [ { name => 'http_hits', diff => 1 } ],
|
key_values => [ { name => 'http_hits', diff => 1 } ],
|
||||||
output_template => 'http hits = %s',
|
output_template => 'http hits = %s',
|
||||||
|
@ -40,7 +48,7 @@ sub set_counters {
|
||||||
{ label => 'http_hits', value => 'http_hits_absolute', template => '%s', min => 0 },
|
{ label => 'http_hits', value => 'http_hits_absolute', template => '%s', min => 0 },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'ftp-hits', set => {
|
{ label => 'ftp-hits', set => {
|
||||||
key_values => [ { name => 'ftp_hits', diff => 1 } ],
|
key_values => [ { name => 'ftp_hits', diff => 1 } ],
|
||||||
output_template => 'ftp hits = %s',
|
output_template => 'ftp hits = %s',
|
||||||
|
@ -103,18 +111,20 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_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_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_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_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 $oid_smtpHits = '.1.3.6.1.4.1.21067.2.1.2.9.3.0';
|
||||||
my $result = $options{snmp}->get_leef(oids => [$oid_httpHits, $oid_ftpHits, $oid_pop3Hits,
|
my $result = $options{snmp}->get_leef(oids => [$oid_liveUsers, $oid_httpHits, $oid_ftpHits, $oid_pop3Hits,
|
||||||
$oid_imapHits, $oid_smtpHits], nothing_quit => 1);
|
$oid_imapHits, $oid_smtpHits], nothing_quit => 1);
|
||||||
|
|
||||||
$self->{cache_name} = "cyberoam_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
$self->{cache_name} = "cyberoam_" . $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'));
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
|
|
||||||
$self->{global} = { http_hits => $result->{$oid_httpHits},
|
$self->{global} = { live_users => $result->{$oid_liveUsers},
|
||||||
|
http_hits => $result->{$oid_httpHits},
|
||||||
ftp_hits => $result->{$oid_ftpHits},
|
ftp_hits => $result->{$oid_ftpHits},
|
||||||
pop3_hits => $result->{$oid_pop3Hits},
|
pop3_hits => $result->{$oid_pop3Hits},
|
||||||
imap_hits => $result->{$oid_imapHits},
|
imap_hits => $result->{$oid_imapHits},
|
||||||
|
@ -139,12 +149,12 @@ Example: --filter-counters='http-hits'
|
||||||
=item B<--warning-*>
|
=item B<--warning-*>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
Can be: http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits.
|
Can be: live-users, http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits.
|
||||||
|
|
||||||
=item B<--critical-*>
|
=item B<--critical-*>
|
||||||
|
|
||||||
Threshold critical.
|
Threshold critical.
|
||||||
Can be: http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits.
|
Can be: live-users, http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
#
|
||||||
|
# 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::cyberoam::snmp::mode::services;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::hardware);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub set_system {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{regexp_threshold_overload_check_section_option} = '^(service)$';
|
||||||
|
|
||||||
|
$self->{cb_hook2} = 'snmp_execute';
|
||||||
|
|
||||||
|
$self->{thresholds} = {
|
||||||
|
default => [
|
||||||
|
['untouched', 'OK'],
|
||||||
|
['stopped', 'CRITICAL'],
|
||||||
|
['initializing', 'OK'],
|
||||||
|
['running', 'OK'],
|
||||||
|
['exiting', 'CRITICAL'],
|
||||||
|
['dead', 'CRITICAL'],
|
||||||
|
['unregistered', 'OK'],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{components_path} = 'network::cyberoam::snmp::mode::components';
|
||||||
|
$self->{components_module} = ['service'];
|
||||||
|
}
|
||||||
|
|
||||||
|
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 services.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--component>
|
||||||
|
|
||||||
|
Which component to check (Default: '.*').
|
||||||
|
Can be: 'service'.
|
||||||
|
|
||||||
|
=item B<--filter>
|
||||||
|
|
||||||
|
Exclude some parts (comma seperated list)
|
||||||
|
Can also exclude specific instance: --filter=service,pop
|
||||||
|
|
||||||
|
=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='service,imap4,OK,stopped'
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -36,6 +36,7 @@ sub new {
|
||||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||||
'memory' => 'network::cyberoam::snmp::mode::memory',
|
'memory' => 'network::cyberoam::snmp::mode::memory',
|
||||||
'requests' => 'network::cyberoam::snmp::mode::requests',
|
'requests' => 'network::cyberoam::snmp::mode::requests',
|
||||||
|
'services' => 'network::cyberoam::snmp::mode::services',
|
||||||
'storage' => 'network::cyberoam::snmp::mode::storage',
|
'storage' => 'network::cyberoam::snmp::mode::storage',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue