I'm really stuck on this one. Anyone who could offer me some guidance?I can't
believe I'm the only one who needs to trigger commands with snmp (I can't find
much of it searching the mailing list).
If scalar: Is it possible to set multiple values for one OID?
If table: Will setting multiple values/columns for one OID be handled as one
request by my handler?
I'm thinking perhaps tables is not the right structure for my commands as I
might have columns, but only 1 row anyway.
After taking a look at the code for getting values from the snmpset command it
seems like it is possible to send along more than one value:
netsnmp_variable_list* varlist = requests->requestvb;
while (varlist != NULL) {
netsnmp_vardata vardata = varlist->val;
u_char* text = vardata.string;
varlist = varlist->next_variable;
}
username@machine:~> snmpset -v2c -c private localhost 1.3.6.1.4.1.40850.2.5.0 s
testing
SNMPv2-SMI::enterprises.40850.2.5.0 = STRING: "testing"
However when I try to send more values along this way I get the following
error:
username@machine:~> snmpset -v2c -c private localhost 1.3.6.1.4.1.40850.2.5.0 s
testing s testing2
s: Needs value
username@machine:~> snmpset -v2c -c private localhost 1.3.6.1.4.1.40850.2.5.0 s
testing testing2
testing2: Needs type and value
username@machine:~> snmpset -v2c -c private localhost 1.3.6.1.4.1.40850.2.5.0 s
"testing" i 1234
i: Bad object type: 1
Sending this way works, but is actually 2 seperate requests and I cannot
trigger my command twice.
username@machine:~> snmpset -v2c -c private localhost 1.3.6.1.4.1.40850.2.5.0 s
"testing1234" 1.3.6.1.4.1.40850.2.5.0 s "testing5678"
SNMPv2-SMI::enterprises.40850.2.5.0 = STRING: "testing1234"
SNMPv2-SMI::enterprises.40850.2.5.0 = STRING: "testing5678"
If this OID was a command to run something on the device and could take two
command parameters. Triggering the command once for each of these command
parameters would be a mistake.
Even if I get to send with multiple values, there seems like no way to
distinguish them (between values of same type).
Also I need to trigger a command without any values, but that does not seem to
be possible.
username@machine:~> snmpset -v2c -c private localhost 1.3.6.1.4.1.40850.2.5.0
1.3.6.1.4.1.40850.2.5.0: Needs type and value
Anyway: Here is one radical thought. What about using snmpget to trigger a
command? At least when no parameters are sent it would be perfect and simple.
/Sverre
----- Original Message -----
Fra: "Sverre Moe" <sve...@spacetec.no>
Til: net-snmp-users@lists.sourceforge.net
Sendt: 23. november 2012 12:07:56
Emne: Table or Scalar Command for snmpset
If there is anyone active on this mailing list I hope they can answer me on
this question.
So down to business:
I need to know how I can set multiple parameter values with snmpset for my
commands?
I have implemented my commands as simple scalars, but lately I was thinking
perhaps I needed to implement them as tables since they can have multiple
parameters. When setting/triggering such a command with snmpset, the choice is
either no parameters, one parameter or multiple parameters.
Given the following example MIB for such a table. Lets say it is one of my
commands. Apparently write-only is no longer allowed in SMIv2, so I have used
not-accessible. These commands are not to be accessed by snmpget.
netSnmpHostsTable OBJECT-TYPE
SYNTAX SEQUENCE OF NetSnmpHostsEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"An example table that implements a wrapper around the
/etc/hosts file on a machine using the iterator helper API."
::= { meos 3 }
netSnmpHostsEntry OBJECT-TYPE
SYNTAX NetSnmpHostsEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A host name mapped to an ip address"
INDEX { netSnmpHostName }
::= { netSnmpHostsTable 1 }
NetSnmpHostsEntry ::= SEQUENCE {
netSnmpHostName OCTET STRING,
netSnmpHostAddressType OCTET STRING,
netSnmpHostAddress OCTET STRING
}
netSnmpHostName OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..64))
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A host name that exists in the /etc/hosts (unix) file."
::= { netSnmpHostsEntry 1 }
netSnmpHostAddressType OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..64))
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"The address type of then given host."
::= { netSnmpHostsEntry 2 }
netSnmpHostAddress OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..64))
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"The address of then given host."
::= { netSnmpHostsEntry 3 }
Calling with no parameters
snmpset netSnmpHostsTable.0
or calling with 3 parameters
snmpset netSnmpHostsTable.1 something netSnmpHostsTable.2 something else
netSnmpHostsTable.3 something more
Is that possible with snmpset? When setting multiple rows with snmpset will it
process it as one request or multiple requests?
CONFIDENTIALITY
This e-mail and any attachment contain KONGSBERG information which may be
proprietary, confidential or subject to export regulations, and is only meant
for the intended recipient(s). Any disclosure, copying, distribution or use is
prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in
error, please delete it immediately from your system and notify the sender
properly.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
CONFIDENTIALITY
This e-mail and any attachment contain KONGSBERG information which may be
proprietary, confidential or subject to export regulations, and is only meant
for the intended recipient(s). Any disclosure, copying, distribution or use is
prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in
error, please delete it immediately from your system and notify the sender
properly.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users