Nagios::Plugin::JUNOS: send_query: Support fallback to JUNOS::Device::command.
This commit is contained in:
parent
2700d4d4c8
commit
0d4f3dab1a
|
@ -390,7 +390,7 @@ sub send_query
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $query = shift;
|
my $query = shift;
|
||||||
my $queryargs = shift;
|
my $queryargs = shift || {};
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
my $err;
|
my $err;
|
||||||
|
@ -399,10 +399,15 @@ sub send_query
|
||||||
. join(", ", map { "$_ => $queryargs->{$_}" } keys %$queryargs)
|
. join(", ", map { "$_ => $queryargs->{$_}" } keys %$queryargs)
|
||||||
. " to router.");
|
. " to router.");
|
||||||
|
|
||||||
if (ref $queryargs) {
|
if (scalar(keys %$queryargs)) {
|
||||||
$res = $self->{'junos'}->$query(%$queryargs);
|
$res = $self->{'junos'}->$query(%$queryargs);
|
||||||
} else {
|
} else {
|
||||||
$res = $self->{'junos'}->$query();
|
eval {
|
||||||
|
$res = $self->{'junos'}->$query();
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$res = $self->{'junos'}->command($query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ref $res) {
|
if (! ref $res) {
|
||||||
|
|
Loading…
Reference in a new issue