enh(plugin)apps-protocol-ospf-snmp metricsv2 (#2525)

This commit is contained in:
itoussies 2021-01-19 11:37:30 +01:00 committed by GitHub
parent e52a438bba
commit 865bdda89d
2 changed files with 22 additions and 31 deletions

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
@ -58,6 +58,12 @@ sub custom_change_calc {
return 0;
}
sub prefix_nb_output {
my ($self, %options) = @_;
return "Neighbor '" . $options{instance_value}->{NbrIpAddr} . "/" . $options{instance_value}->{NbrRtrId} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
@ -67,13 +73,12 @@ sub set_counters {
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
{ label => 'total', nlabel => 'neighbors.total.count',set => {
key_values => [ { name => 'total' } ],
output_template => 'Total neighbors : %s',
perfdatas => [
{ label => 'total', value => 'total', template => '%s',
min => 0 },
],
{ label => 'total', template => '%s', min => 0 }
]
}
},
{ label => 'total-change', threshold => 0, set => {
@ -81,17 +86,21 @@ sub set_counters {
closure_custom_calc => $self->can('custom_change_calc'),
closure_custom_output => $self->can('custom_change_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
closure_custom_threshold_check => \&catalog_status_threshold_ng,
}
},
];
$self->{maps_counters}->{nb} = [
{ label => 'status', threshold => 0, set => {
{
label => 'status',
type => 2,
critical_default => '%{NbrState} =~ /down/i',
set => {
key_values => [ { name => 'NbrIpAddr' }, { name => 'NbrRtrId' }, { name => 'NbrState' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
closure_custom_threshold_check => \&catalog_status_threshold_ng,
}
},
];
@ -102,30 +111,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{NbrState} =~ /down/i' },
"warning-total-change:s" => { name => 'warning_total_change', default => '' },
"critical-total-change:s" => { name => 'critical_total_change', default => '' },
$options{options}->add_options(arguments => {
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status', 'warning_total_change', 'critical_total_change']);
}
sub prefix_nb_output {
my ($self, %options) = @_;
return "Neighbor '" . $options{instance_value}->{NbrIpAddr} . "/" . $options{instance_value}->{NbrRtrId} . "' ";
}
my %map_state = (
1 => 'down',
2 => 'attempt',

View File

@ -30,9 +30,9 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'neighbor' => 'apps::protocols::ospf::snmp::mode::neighbor',
);
$self->{modes} = {
'neighbor' => 'apps::protocols::ospf::snmp::mode::neighbor'
};
return $self;
}