This commit is contained in:
garnier-quentin 2019-06-13 17:39:06 +02:00
parent f6a9795d10
commit b4f2585702
1 changed files with 23 additions and 10 deletions

View File

@ -48,10 +48,11 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"role:s" => { name => 'role', default => 'primary' },
});
$options{options}->add_options(arguments => {
'role:s' => { name => 'role', default => 'primary' },
'filter-vrid:s' => { name => 'filter_vrid' },
});
return $self;
}
@ -73,18 +74,26 @@ sub run {
my $oid_cHsrpGrpStandbyState = ".1.3.6.1.4.1.9.9.106.1.2.1.1.15"; # HSRP Oper Status
my $oid_cHsrpGrpEntryRowStatus = ".1.3.6.1.4.1.9.9.106.1.2.1.1.17"; # HSRP Admin Status
my $results = $self->{snmp}->get_multiple_table(oids => [
{ oid => $oid_cHsrpGrpStandbyState },
{ oid => $oid_cHsrpGrpEntryRowStatus },
],
nothing_quit => 1);
my $results = $self->{snmp}->get_multiple_table(oids =>
[
{ oid => $oid_cHsrpGrpStandbyState },
{ oid => $oid_cHsrpGrpEntryRowStatus },
],
nothing_quit => 1
);
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("Router is in its expected state : '%s'", $self->{option_results}->{role}));
foreach my $oid (keys %{$results->{$oid_cHsrpGrpStandbyState}}) {
$oid =~ /(\d+\.\d+)$/;
my $vrid = $1;
if (defined($self->{option_results}->{filter_vrid}) && $self->{option_results}->{filter_vrid} ne '' &&
$vrid !~ /$self->{option_results}->{filter_vrid}/) {
$self->{output}->output_add(long_msg => "skipping vrid '" . $vrid . "': no matching filter.", debug => 1);
next;
}
my $operState = $results->{$oid_cHsrpGrpEntryRowStatus}->{$oid_cHsrpGrpEntryRowStatus . "." . $vrid};
my $adminState = $results->{$oid_cHsrpGrpStandbyState}->{$oid};
@ -121,6 +130,10 @@ Check Cisco HSRP (CISCO-HSRP-MIB). Trigger a critical if not in the expected sta
=over 8
=item B<--filter-vrid>
Filter VRID (can be a regexp).
=item B<--role>
If role is 'primary', an error if HSRPs are 'standby' states.