Nagios::Plugin::JUNOS: send_query: Support fallback to JUNOS::Device::command.

This commit is contained in:
Sebastian Harl 2012-01-03 11:56:14 +01:00
parent 2700d4d4c8
commit 0d4f3dab1a

View file

@ -390,7 +390,7 @@ sub send_query
{
my $self = shift;
my $query = shift;
my $queryargs = shift;
my $queryargs = shift || {};
my $res;
my $err;
@ -399,10 +399,15 @@ sub send_query
. join(", ", map { "$_ => $queryargs->{$_}" } keys %$queryargs)
. " to router.");
if (ref $queryargs) {
if (scalar(keys %$queryargs)) {
$res = $self->{'junos'}->$query(%$queryargs);
} else {
$res = $self->{'junos'}->$query();
eval {
$res = $self->{'junos'}->$query();
};
if ($@) {
$res = $self->{'junos'}->command($query);
}
}
if (! ref $res) {