Search in sources :

Example 6 with XmpVar

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);
}
Also used : XmpVar(org.krupczak.xmp.XmpVar) XmpSession(org.krupczak.xmp.XmpSession) XmpMessage(org.krupczak.xmp.XmpMessage) DetectResultsImpl(org.opennms.netmgt.provision.support.DetectResultsImpl) InetAddress(java.net.InetAddress)

Aggregations

XmpVar (org.krupczak.xmp.XmpVar)6 XmpMessage (org.krupczak.xmp.XmpMessage)5 XmpSession (org.krupczak.xmp.XmpSession)2 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)2 InetAddress (java.net.InetAddress)1 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)1 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)1 GenericTypeResource (org.opennms.netmgt.collection.support.builder.GenericTypeResource)1 InterfaceLevelResource (org.opennms.netmgt.collection.support.builder.InterfaceLevelResource)1 Resource (org.opennms.netmgt.collection.support.builder.Resource)1 Group (org.opennms.netmgt.config.xmpDataCollection.Group)1 MibObj (org.opennms.netmgt.config.xmpDataCollection.MibObj)1 XmpCollection (org.opennms.netmgt.config.xmpDataCollection.XmpCollection)1 XmpAgentConfig (org.opennms.netmgt.protocols.xmp.config.XmpAgentConfig)1 DetectResultsImpl (org.opennms.netmgt.provision.support.DetectResultsImpl)1