|
Apart from the table-related operations, the management applications is also required to handle the following situations.
Identify the table name, given the OID.
Identify the table index, given the OID.
To get table name we need a minimum of one column OID and the corresponding MIB file. The following piece of code uses the MibOperations class of the mibs package to identify the table name.
|
SnmpTarget target = new SnmpTarget(); // instantiate the SnmpTarget bean String oid = ("column OID"); // set the column OID target.setMibModules("MIB file Name"); // load the MIB
MibOperations mibops = target.getMibOperations(); SnmpOID rootoid = mibops.getSnmpOID(oid); MibNode node = mibops.getMibNode(rootoid);
MibNode tnode =node.getParent().getParent(); System.out.println("Table name is :"+tnode.getLabel()); |
The following piece of code gets the index of the table.
|
SnmpTarget target = new SnmpTarget(); // instantiate the SnmpTarget bean String oid = ("column OID"); // set the column OID target.setMibModules("MIB file Name"); // load the MIB
MibOperations mibops = target.getMibOperations(); SnmpOID rootoid = mibops.getSnmpOID(oid); MibNode node = mibops.getMibNode(rootoid);
Vector indices = null;
indices = node.getIndexes(target.getMibOperations()); if(indices !=null) { for(int i=0; i<indices.size();i++) { System.out.println("Table Index name is:"+indices.elementAt(i)); } } else { System.out.println("Invalid column OID"); } |
|