diff --git a/centreon/plugins/snmp.pm b/centreon/plugins/snmp.pm index 786481d9d..7e42f2b50 100644 --- a/centreon/plugins/snmp.pm +++ b/centreon/plugins/snmp.pm @@ -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); diff --git a/snmp_standard/mode/dynamiccommand.pm b/snmp_standard/mode/dynamiccommand.pm index be9b70b2a..9169dd2a6 100644 --- a/snmp_standard/mode/dynamiccommand.pm +++ b/snmp_standard/mode/dynamiccommand.pm @@ -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) {