Ref #714 : WIP infoblox

This commit is contained in:
qgarnier 2017-12-08 11:53:22 +01:00
parent 7e89b55bbe
commit d62ed5b3e4
4 changed files with 461 additions and 0 deletions

View File

@ -0,0 +1,92 @@
#
# 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::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
];
$self->{maps_counters}->{global} = [
{ label => 'usage', set => {
key_values => [ { name => 'cpu' } ],
output_template => 'CPU Usage : %.2f %%',
perfdatas => [
{ label => 'cpu_usage', value => 'cpu_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_ibSystemMonitorCpuUsage = '.1.3.6.1.4.1.7779.3.1.1.2.1.8.1.1.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
$oid_ibSystemMonitorCpuUsage
], nothing_quit => 1);
$self->{global} = { cpu => $snmp_result->{$oid_ibSystemMonitorCpuUsage} };
}
1;
__END__
=head1 MODE
Check CPU usage.
=over 8
=item B<--warning-usage>
Threshold warning.
=item B<--critical-usage>
Threshold critical.
=back
=cut

View File

@ -0,0 +1,209 @@
#
# 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::dnsusage;
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 => 'dns', type => 1, cb_prefix_output => 'prefix_dns_output', message_multiple => 'All dns zones are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total-query-rate', set => {
key_values => [ { name => 'ibDnsQueryRate' } ],
output_template => 'Total query rate : %s',
perfdatas => [
{ label => 'total_query_rate', value => 'ibDnsQueryRate_absolute', template => '%s',
min => 0 },
],
}
},
{ label => 'total-hit-ratio', set => {
key_values => [ { name => 'ibDnsHitRatio' } ],
output_template => 'Total hit ratio : %.2f %%',
perfdatas => [
{ label => 'total_hit_ratio', value => 'ibDnsHitRatio_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
];
$self->{maps_counters}->{dns} = [
{ label => 'success-count', set => {
key_values => [ { name => 'ibBindZoneSuccess', diff => 1 }, { name => 'display' } ],
output_template => 'Success responses : %s',
perfdatas => [
{ label => 'success_count', value => 'ibBindZoneSuccess_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'referral-count', set => {
key_values => [ { name => 'ibBindZoneReferral', diff => 1 }, { name => 'display' } ],
output_template => 'Referrals : %s',
perfdatas => [
{ label => 'referral_count', value => 'ibBindZoneReferral_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'nxrrset-count', set => {
key_values => [ { name => 'ibBindZoneNxRRset', diff => 1 }, { name => 'display' } ],
output_template => 'Non-existent record : %s',
perfdatas => [
{ label => 'nxrrset_count', value => 'ibBindZoneNxRRset_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'failure-count', set => {
key_values => [ { name => 'ibBindZoneFailure', diff => 1 }, { name => 'display' } ],
output_template => 'Failed queries : %s',
perfdatas => [
{ label => 'failure_count', value => 'ibBindZoneFailure_absolute', template => '%s',
min => 0, 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_dns_output {
my ($self, %options) = @_;
return "Zone '" . $options{instance_value}->{display} . "' ";
}
my $mapping = {
ibBindZoneName => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.1.1.1' },
ibBindZoneSuccess => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.1.1.2' },
ibBindZoneReferral => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.1.1.3' },
ibBindZoneNxRRset => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.1.1.4' },
ibBindZoneFailure => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.1.1.7' },
};
my $mapping2 = {
ibDnsHitRatio => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.5' },
ibDnsQueryRate => { oid => '.1.3.6.1.4.1.7779.3.1.1.3.1.6' },
};
my $oid_ibZoneStatisticsEntry = '.1.3.6.1.4.1.7779.3.1.1.3.1.1.1';
my $oid_ibDnsModule = '.1.3.6.1.4.1.7779.3.1.1.3.1';
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
$self->{dns} = {};
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_ibZoneStatisticsEntry },
{ oid => $oid_ibDnsModule, start => $mapping2->{ibDnsHitRatio}->{oid} },
], nothing_quit => 1);
foreach my $oid (keys %{$snmp_result->{$oid_ibZoneStatisticsEntry}}) {
next if ($oid !~ /^$mapping->{ibBindZoneName}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_ibZoneStatisticsEntry}, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{ibBindZoneName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{ibBindZoneName} . "': no matching filter.", debug => 1);
next;
}
$self->{dns}->{$instance} = { display => $result->{ibBindZoneName},
%$result
};
}
if (scalar(keys %{$self->{dns}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No dns zone found.");
$self->{output}->option_exit();
}
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_ibDnsModule}, 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 dns usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^success-coun$'
=item B<--filter-name>
Filter dns zone name (can be a regexp).
=item B<--warning-*>
Threshold warning.
Can be: 'total-query-rate', 'total-hit-ratio', 'success-count', 'referral-count', 'nxrrset-count',
'failure-count'.
=item B<--critical-*>
Threshold critical.
Can be: 'total-query-rate', 'total-hit-ratio', 'success-count', 'referral-count', 'nxrrset-count',
'failure-count'.
=back
=cut

View File

@ -0,0 +1,108 @@
#
# 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::memory;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'memory', type => 0 },
];
$self->{maps_counters}->{memory} = [
{ label => 'mem-usage', set => {
key_values => [ { name => 'ram_used' } ],
output_template => 'Memory Used: %.2f%%',
perfdatas => [
{ label => 'memory_used', value => 'ram_used_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'swap-usage', set => {
key_values => [ { name => 'swap_used' } ],
output_template => 'Swap Used: %.2f%%',
perfdatas => [
{ label => 'swap_used', value => 'swap_used_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_ibSystemMonitorMemUsage = '.1.3.6.1.4.1.7779.3.1.1.2.1.8.2.1.0';
my $oid_ibSystemMonitorSwapUsage = '.1.3.6.1.4.1.7779.3.1.1.2.1.8.3.1.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
$oid_ibSystemMonitorMemUsage, $oid_ibSystemMonitorSwapUsage,
], nothing_quit => 1);
$self->{memory} = {
ram_used => $snmp_result->{$oid_ibSystemMonitorMemUsage},
swap_used => $snmp_result->{$oid_ibSystemMonitorSwapUsage},
};
}
1;
__END__
=head1 MODE
Check memory usage.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'mem-usage' (%), 'swap-usage' (%).
=item B<--critical-*>
Threshold critical.
Can be: 'mem-usage' (%), 'swap-usage' (%).
=back
=cut

View File

@ -0,0 +1,52 @@
#
# 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::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} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::infoblox::snmp::mode::cpu',
'dns-usage' => 'network::infoblox::snmp::mode::dnsusage',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::infoblox::snmp::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Infoblox equipments in SNMP.
=cut