use of org.krupczak.xmp.XmpVar in project opennms by OpenNMS.
the class XmpDetector method detect.
@Override
public final DetectResults detect(DetectRequest request) {
final InetAddress address = request.getAddress();
XmpSession aSession;
XmpMessage aReply;
XmpVar[] vars, replyVars;
LOG.debug("XmpDetector: isServiceDetected starting to query " + address);
// try to establish session
aSession = new XmpSession(sockopts, address, xmpPort, xmpAuthenUser);
if (aSession.isClosed()) {
LOG.debug("XmpDetector: null session to " + address);
return new DetectResultsImpl(false);
}
LOG.debug("XmpDetector: isServiceDetected session established with " + address);
// query for core.sysName, core.sysDescr,
// core.sysUpTime, core.xmpdVersion
vars = new XmpVar[] { new XmpVar("core", "sysName", "", "", Xmp.SYNTAX_NULLSYNTAX), new XmpVar("core", "sysDescr", "", "", Xmp.SYNTAX_NULLSYNTAX), new XmpVar("core", "sysUpTime", "", "", Xmp.SYNTAX_NULLSYNTAX), new XmpVar("core", "xmpdVersion", "", "", Xmp.SYNTAX_NULLSYNTAX) };
if ((aReply = aSession.queryVars(vars)) == null) {
LOG.debug("XmpDetector: isServiceDetected no vars from " + address);
aSession.closeSession();
return new DetectResultsImpl(false);
}
aSession.closeSession();
// log what we retrieved
if ((replyVars = aReply.getMIBVars()) == null) {
LOG.debug("XmpDetector: isServiceDetected no replyVars for " + address);
return new DetectResultsImpl(false);
}
/* if replyVars == null */
LOG.debug("XmpDetector: isServiceDetected " + address + " reports " + replyVars[0].getValue() + "," + replyVars[1].getValue());
LOG.debug("XmpDetector: isServiceDetected true for " + address);
return new DetectResultsImpl(true);
}
Aggregations