Discussion:
string as index of a table
sarath azad
2014-10-16 15:04:54 UTC
Permalink
Hello,

Could you please if it is advisable to use a string eg. name of item as a table index?
The table is yet to be defined, need defined and added to a MIB file.
The table will contain info of different items and our requirement is if we can get the info of a particular item by doing snmpget query passing the item name string as index.
I have tested it, it is feasible, but while giving the OID in snmpget, we needed to give the item name string index by dot separated ascii values of each character in the name.
eg. <OID of the table> .1.<column
no.>.5."65.66.67.68.69" where the item name is "ABCDE".

But from usage perspective it is not looking good that we need to manually calculate the ascii values of the characters in the item name and provide them in the snmpget query.
Is there any other way of doing this so that we can directly give the item name and not the ascii values?
Some thing like: <OID of the table> .1.<column
no.>.5."ABCD" or <OID of the table> .1.<column no.>.5."A.B.C.D"

thanks and regards
S Sarath
Niels Baggesen
2014-10-16 16:30:47 UTC
Permalink
Post by sarath azad
I have tested it, it is feasible, but while giving the OID in snmpget,
we needed to give the item name string index by dot separated ascii
values of each character in the name.
eg. <OID of the table> .1.<column
no.>.5."65.66.67.68.69" where the item name is "ABCDE".
I wonder where this is documented :-(

If you make sure that the shell passes the quotes to the command, you
can actually do it:

snmpwalk $host <OID of table>.1.<column>.\"ABCDE\"

If the index is an IMPLIED string (one without a length prefix) you must
use single quotes in stead of double quotes.

See the -OE option to snmpcmd(1)

/Niels
--
Niels Baggesen - @home - Århus - Denmark - ***@users.sourceforge.net
The purpose of computing is insight, not numbers --- R W Hamming
sarath azad
2014-10-17 14:38:15 UTC
Permalink
Hi Niels,

But using a query like: snmpwalk $host <OID of
table>.1.<column>.\"ABCDE\"
is not working also. Below are the test
results :

snmpget $host
<OID of table>.1.<column>.10."66.67.68.69.70.71.72.73.74.75"
<OID of
table>.1.<column>."BCDEFGHIJK" = INTEGER: 0
snmpget $host <OID of
table>.1.<column>.10.\"ABCDEFGHIJ\"
<OID of
table>.1.<column>.10."ABCDEFGHIJ": Unknown Object Identifier
(Index out of range: "ABCDEFGHIJ")
snmpget $host <OID of
table>.1.<column>.10.'ABCDEFGHIJ'
<OID of
table>.1.<column>.10.ABCDEFGHIJ: Unknown Object Identifier (Index out
of range: ABCDEFGHIJ )

Could you please help in resolving this?

Thanks and regards
S Sarath
Post by sarath azad
I have tested it, it is feasible, but while giving the OID in snmpget,
we needed to give the item name string index by dot separated ascii
values of each character in the name.
eg. <OID of the table> .1.<column
no.>.5."65.66.67.68.69" where the item name is "ABCDE".
I wonder where this is documented :-(

If you make sure that the shell passes the quotes to the command, you
can actually do it:

snmpwalk $host <OID of table>.1.<column>.\"ABCDE\"

If the index is an IMPLIED string (one without a length prefix) you must
use single quotes in stead of double quotes.

See the -OE option to snmpcmd(1)

/Niels
--
Niels Baggesen - @home - Århus - Denmark - ***@users.sourceforge.net
The purpose of computing is insight, not numbers --- R W Hamming
Fulko Hew
2014-10-17 14:52:38 UTC
Permalink
Post by sarath azad
Hi Niels,
But using a query like: snmpwalk $host <OID of
table>.1.<column>.\"ABCDE\"
snmpget $host <OID of
table>.1.<column>.10."66.67.68.69.70.71.72.73.74.75"
<OID of table>.1.<column>."BCDEFGHIJK" = INTEGER: 0
snmpget $host <OID of table>.1.<column>.10.\"ABCDEFGHIJ\"
<OID of table>.1.<column>.10."ABCDEFGHIJ": Unknown Object Identifier
(Index out of range: "ABCDEFGHIJ")
snmpget $host <OID of table>.1.<column>.10.'ABCDEFGHIJ'
<OID of table>.1.<column>.10.ABCDEFGHIJ: Unknown Object Identifier (Index
out of range: ABCDEFGHIJ )
Could you please help in resolving this?
You don't need to insert the length explicitly, it will be calculated and
inserted for you.
Try:

snmpget $host <OID of table>.1.<column>.\"ABCDEFGHIJ\"

Continue reading on narkive:
Loading...