This commit is contained in:
qgarnier 2017-12-08 14:09:17 +01:00
parent d62ed5b3e4
commit 761de7e763
4 changed files with 362 additions and 1 deletions

View File

@ -0,0 +1,193 @@
#
# Copyright 2017 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::infoblox::snmp::mode::dhcpusage;
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, cb_prefix_output => 'prefix_global_output' },
{ name => 'dhcp', type => 1, cb_prefix_output => 'prefix_dhcp_output', message_multiple => 'All dhcp subnets are ok' },
];
my @map = (
['ibDhcpTotalNoOfDiscovers', 'discovers : %s', 'total-discovers'],
['ibDhcpTotalNoOfRequests', 'requests : %s', 'total-requests'],
['ibDhcpTotalNoOfReleases', 'releases : %s', 'total-releases'],
['ibDhcpTotalNoOfOffers', 'offers : %s', 'total-offers'],
['ibDhcpTotalNoOfAcks', 'acks : %s', 'total-acks'],
['ibDhcpTotalNoOfNacks', 'nacks : %s', 'total-nacks'],
['ibDhcpTotalNoOfDeclines', 'declines : %s', 'total-declines'],
['ibDhcpTotalNoOfInforms', 'informs : %s', 'total-informs'],
['ibDhcpTotalNoOfOthers', 'others : %s', 'total-others'],
);
$self->{maps_counters}->{global} = [];
for (my $i = 0; $i < scalar(@map); $i++) {
my $perf_label = $map[$i]->[2];
$perf_label =~ s/-/_/g;
push @{$self->{maps_counters}->{global}}, { label => $map[$i]->[2], set => {
key_values => [ { name => $map[$i]->[0], diff => 1 } ],
output_template => $map[$i]->[1],
perfdatas => [
{ label => $perf_label, value => $map[$i]->[0] . '_absolute', template => '%s', min => 0 },
],
}
};
}
$self->{maps_counters}->{dhcp} = [
{ label => 'subnet-used', set => {
key_values => [ { name => 'ibDHCPSubnetPercentUsed' }, { name => 'display' } ],
output_template => 'Used : %.2f %%',
perfdatas => [
{ label => 'subnet_used', value => 'iibDHCPSubnetPercentUsed_absolute', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
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 =>
{
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Total ";
}
sub prefix_dhcp_output {
my ($self, %options) = @_;
return "Subnet '" . $options{instance_value}->{display} . "' ";
}
my $mapping = {
ibDhcpTotalNoOfDiscovers => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.1' },
ibDhcpTotalNoOfRequests => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.2' },
ibDhcpTotalNoOfReleases => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.3' },
ibDhcpTotalNoOfOffers => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.4' },
ibDhcpTotalNoOfAcks => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.5' },
ibDhcpTotalNoOfNacks => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.6' },
ibDhcpTotalNoOfDeclines => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.7' },
ibDhcpTotalNoOfInforms => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.8' },
ibDhcpTotalNoOfOthers => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.3.9' },
};
my $mapping2 = {
ibDHCPSubnetNetworkAddress => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.1.1.1' },
ibDHCPSubnetNetworkMask => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.1.1.2' },
ibDHCPSubnetPercentUsed => { oid => '.1.3.6.1.4.1.7779.3.1.1.4.1.1.1.3' },
};
my $oid_ibDHCPStatistics = '.1.3.6.1.4.1.7779.3.1.1.4.1.3';
my $oid_ibDHCPSubnetEntry = '.1.3.6.1.4.1.7779.3.1.1.4.1.1.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_ibDHCPStatistics },
{ oid => $oid_ibDHCPSubnetEntry },
], nothing_quit => 1);
$self->{dhcp} = {};
foreach my $oid (keys %{$snmp_result->{$oid_ibDHCPSubnetEntry}}) {
next if ($oid !~ /^$mapping2->{ibDHCPSubnetNetworkAddress}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_ibDHCPSubnetEntry}, instance => $instance);
my $name = $result->{ibDHCPSubnetNetworkAddress} . '/' . $result->{ibDHCPSubnetNetworkMask};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{dhcp}->{$instance} = { display => $name,
%$result
};
}
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_ibDHCPStatistics}, instance => '0');
$self->{global} = { %$result };
$self->{cache_name} = "infoblox_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check dhcp usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='total-requests'
=item B<--filter-name>
Filter dhcp subnet name (can be a regexp).
=item B<--warning-*>
ibDhcpTotalNoOfDiscovers
Threshold warning.
Can be: 'total-discovers', 'total-requests', 'total-releases',
'total-offers', 'total-acks', 'total-nacks', 'total-declines',
'total-informs', 'total-others', 'subnet-used' (%).
=item B<--critical-*>
Threshold critical.
Can be: 'total-discovers', 'total-requests', 'total-releases',
'total-offers', 'total-acks', 'total-nacks', 'total-declines',
'total-informs', 'total-others', 'subnet-used' (%).
=back
=cut

View File

@ -31,7 +31,7 @@ sub set_counters {
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'dns', type => 1, cb_prefix_output => 'prefix_dns_output', message_multiple => 'All dns zones are ok' }
{ name => 'dns', type => 1, cb_prefix_output => 'prefix_dns_output', message_multiple => 'All dns zones are ok' },
];
$self->{maps_counters}->{global} = [

View File

@ -0,0 +1,166 @@
#
# Copyright 2017 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::infoblox::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 => [
['unknown', 'OK'],
['working', 'OK'],
['inactive', 'OK'],
['warning', 'WARNING'],
['failed', 'CRITICAL'],
],
};
$self->{components_path} = 'network::infoblox::snmp::mode::components';
$self->{components_module} = ['service'];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
1;
=head1 MODE
Check physical service status.
=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,fan1
=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,OK,warning'
=back
=cut
package network::infoblox::snmp::mode::components::service;
use strict;
use warnings;
my %map_service_status = (
1 => 'working', 2 => 'warning',
3 => 'failed', 4 => 'inactive', 5 => 'unknown',
);
my %map_service_name = (
1 => 'dhcp', 2 => 'dns', 3 => 'ntp', 4 => 'tftp', 5 => 'http-file-dist',
6 => 'ftp', 7 => 'bloxtools-move', 8 => 'bloxtools', 9 => 'node-status',
10 => 'disk-usage', 11 => 'enet-lan', 12 => 'enet-lan2', 13 => 'enet-ha',
14 => 'enet-mgmt', 15 => 'lcd', 16 => 'memory', 17 => 'replication', 18 => 'db-object',
19 => 'raid-summary', 20 => 'raid-disk1', 21 => 'raid-disk2', 22 => 'raid-disk3',
23 => 'raid-disk4', 24 => 'raid-disk5', 25 => 'raid-disk6', 26 => 'raid-disk7',
27 => 'raid-disk8', 28 => 'fan1', 29 => 'fan2', 30 => 'fan3', 31 => 'fan4',
32 => 'fan5', 33 => 'fan6', 34 => 'fan7', 35 => 'fan8', 36 => 'power-supply1',
37 => 'power-supply2', 38 => 'ntp-sync', 39 => 'cpu1-temp', 40 => 'cpu2-temp',
41 => 'sys-temp', 42 => 'raid-battery', 43 => 'cpu-usage', 44 => 'ospf',
45 => 'bgp', 46 => 'mgm-service', 47 => 'subgrid-conn', 48 => 'network-capacity',
49 => 'reporting', 50 => 'dns-cache-acceleration', 51 => 'ospf6',
52 => 'swap-usage', 53 => 'discovery-consolidator', 54 => 'discovery-collector',
55 => 'discovery-capacity', 56 => 'threat-protection', 57 => 'cloud-api',
58 => 'threat-analytics', 59 => 'taxii', 60 => 'bfd', 61 => 'outbound',
);
my $mapping = {
ibNodeServiceName => { oid => '.1.3.6.1.4.1.7779.3.1.1.2.1.10.1.1', map => \%map_service_name },
ibNodeServiceStatus => { oid => '.1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2', map => \%map_service_status },
};
my $oid_ibMemberNodeServiceStatusEntry = '.1.3.6.1.4.1.7779.3.1.1.2.1.10.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_ibMemberNodeServiceStatusEntry, end => $mapping->{ibNodeServiceStatus}->{oid} };
}
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'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ibMemberNodeServiceStatusEntry}})) {
next if ($oid !~ /^$mapping->{ibNodeServiceName}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ibMemberNodeServiceStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'service', instance => $result->{ibNodeServiceName}));
$self->{components}->{service}->{total}++;
$self->{output}->output_add(long_msg => sprintf("service '%s' status is '%s' [instance = %s]",
$result->{ibNodeServiceName}, $result->{ibNodeServiceStatus}, $result->{ibNodeServiceName}));
my $exit = $self->get_severity(section => 'default', instance => $result->{ibNodeServiceName}, value => $result->{ibNodeServiceStatus});
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'", $result->{ibNodeServiceName}, $result->{ibNodeServiceStatus}));
}
}
}
1;

View File

@ -32,10 +32,12 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::infoblox::snmp::mode::cpu',
'dhcp-usage' => 'network::infoblox::snmp::mode::dhcpusage',
'dns-usage' => 'network::infoblox::snmp::mode::dnsusage',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::infoblox::snmp::mode::memory',
'services' => 'network::infoblox::snmp::mode::services',
);
return $self;