use of org.netxms.client.snmp.MibTree in project netxms by netxms.
the class SnmpTest method testMibFileDownload.
public void testMibFileDownload() throws Exception {
final NXCSession session = connect(true);
Date ts = session.getMibFileTimestamp();
System.out.println("MIB file timestamp: " + ts.toString());
File f = session.downloadMibFile();
System.out.println("MIB file downloaded to: " + f.getPath() + " (size " + f.length() + " bytes)");
session.disconnect();
MibTree tree = new MibTree(f);
assertNotNull(tree.getRootObject());
MibObject[] objects = tree.getRootObject().getChildObjects();
assertNotNull(objects);
assertTrue(objects.length > 0);
for (int i = 0; i < objects.length; i++) System.out.println(objects[i].getObjectId().toString() + " " + objects[i].getName() + " " + objects[i].getFullName());
MibObject o = tree.findObject(SnmpObjectId.parseSnmpObjectId(".1.3.6.1.2.1.1.1"), true);
assertNotNull(o);
System.out.println("Found: " + o.getObjectId().toString() + " " + o.getName() + " " + o.getFullName());
o = tree.findObject(SnmpObjectId.parseSnmpObjectId(".1.3.6.1.100.100.100"), false);
assertNotNull(o);
System.out.println("Found: " + o.getObjectId().toString() + " " + o.getName() + " " + o.getFullName());
o = tree.findObject(SnmpObjectId.parseSnmpObjectId(".1.3.6.1.100.100.100"), true);
assertNull(o);
}
use of org.netxms.client.snmp.MibTree in project netxms by netxms.
the class MibCache method getMibTree.
/**
* @return the mibTree
*/
public static MibTree getMibTree() {
synchronized (MUTEX) {
if (mibTree != null)
return mibTree;
Location loc = Platform.getInstanceLocation();
if (loc != null) {
File targetDir;
try {
targetDir = new File(loc.getURL().toURI());
} catch (URISyntaxException e) {
targetDir = new File(loc.getURL().getPath());
}
// $NON-NLS-1$
File mibFile = new File(targetDir, "netxms.mib");
if (mibFile.exists()) {
try {
mibTree = new MibTree(mibFile);
} catch (Exception e) {
// $NON-NLS-1$
Activator.logError("Cannot load MIB file", e);
}
}
}
return (mibTree != null) ? mibTree : new MibTree();
}
}
Aggregations