[SNMP4J] Strings are printed in hexadecimal

Enrique J. Garcia Diaz egdiaz at gmail.com
Sat Aug 30 14:55:47 CEST 2008


Hello everybody!

I am implementing a program that recover information of a snmp agent. To get
that, I am using SNMP4J. I have some problems when I want to recover a
table. Now, the problem is the values that are String I only get this values
in hexadecimal format.

I put the code and if somebody see something wrong, I`ll appreciate the
suggestion to improve it!!

TableUtil util = new TableUtils (snmp, new DefaultPDUFactory); //snmp is an
object of the class Snmp
List list = utils.getTable (target, arr, lowerIndex, upperIndex); //target
is an object of the class CommunityTarget

// arr is an OID[]
for (int i = 0; i < list.size; i++)
{
  TableEvent e = (TableEvent) list.get(i);
  int ifIndex = ((e.getColumns())[0].getVariable().toInt());
  String ifDescr = ((e.getColumns())[1].getVariable().toString());
  ...

  System.out.println ("ifIndex = " + ifIndex);
  System.out.println ("ifDescr = " + ifDescr);
}

In this case (table ifTable of RFC1213 MIB) the value returned is...

ifIndex = 0
ifDescr =
4d:53:20:54:43:50:20:4c:6f:6f:70:62:61:63:6b:20:69:6e:74:65:72:66:61:63:65:00
(rather than MS TCP Loopback interface)

I have the same problem with all the variables that are String.

Thanks in advanced,
Kike



More information about the SNMP4J mailing list