enhance dynamic command

This commit is contained in:
qgarnier 2017-11-07 18:00:07 +01:00
parent 9fa98de88b
commit d4fe4d846b
2 changed files with 10 additions and 9 deletions

View File

@ -570,10 +570,11 @@ sub set {
# Get last value
next if ($oid !~ /(.*)\.(\d+)([\.\s]*)$/);
my $value = $options{oids}->{$oid};
my $value = $options{oids}->{$oid}->{value};
my $type = $options{oids}->{$oid}->{type};
my ($oid, $instance) = ($1, $2);
push @$vars, [$oid, $instance, $value];
push @$vars, [$oid, $instance, $value, $type];
}
$self->{session}->set($vars);

View File

@ -86,10 +86,10 @@ sub create_command {
my ($self, %options) = @_;
my $oids2set = {};
$oids2set->{$oid_nsExtendStatus . '.' . $options{instance}} = 4;
$oids2set->{$oid_nsExtendArgs . '.' . $options{instance}} = $self->{option_results}->{args};
$oids2set->{$oid_nsExtendCommand . '.' . $options{instance}} = $self->{option_results}->{command};
$oids2set->{$oid_nsExtendExecType . '.' . $options{instance}} = defined($self->{option_results}->{shell}) ? 2 : 1;
$oids2set->{$oid_nsExtendStatus . '.' . $options{instance}} = { value => 4, type => 'INTEGER' };
$oids2set->{$oid_nsExtendArgs . '.' . $options{instance}} = { value => $self->{option_results}->{args}, type => 'OCTETSTR' };
$oids2set->{$oid_nsExtendCommand . '.' . $options{instance}} = { value => $self->{option_results}->{command}, type => 'OCTETSTR' };
$oids2set->{$oid_nsExtendExecType . '.' . $options{instance}} = { value => (defined($self->{option_results}->{shell}) ? 2 : 1), type => 'INTEGER' };
$self->{snmp}->set(oids => $oids2set);
}
@ -106,15 +106,15 @@ sub update_command {
my $oids2set = {};
if (!defined($options{result}->{$oid_nsExtendCommand . '.' . $options{instance}}) ||
$options{result}->{$oid_nsExtendCommand . '.' . $options{instance}} ne $self->{option_results}->{command}) {
$oids2set->{$oid_nsExtendCommand . '.' . $options{instance}} = $self->{option_results}->{command};
$oids2set->{$oid_nsExtendCommand . '.' . $options{instance}} = { value => $self->{option_results}->{command}, type => 'OCTETSTR' };
}
if (!defined($options{result}->{$oid_nsExtendArgs . '.' . $options{instance}}) ||
$options{result}->{$oid_nsExtendArgs . '.' . $options{instance}} ne $self->{option_results}->{args}) {
$oids2set->{$oid_nsExtendArgs . '.' . $options{instance}} = $self->{option_results}->{args};
$oids2set->{$oid_nsExtendArgs . '.' . $options{instance}} = { value => $self->{option_results}->{args}, type => 'OCTETSTR' };
}
if (!defined($options{result}->{$oid_nsExtendExecType . '.' . $options{instance}}) ||
$options{result}->{$oid_nsExtendExecType . '.' . $options{instance}} ne $shell) {
$oids2set->{$oid_nsExtendExecType . '.' . $options{instance}} = $shell;
$oids2set->{$oid_nsExtendExecType . '.' . $options{instance}} = { value => $shell, type => 'INTEGER' };
}
if (scalar(keys %$oids2set) > 0) {