use of org.opennms.protocols.wmi.WmiParams in project opennms by OpenNMS.
the class WmiDetector method isServiceDetected.
@Override
public boolean isServiceDetected(final InetAddress address, final WmiAgentConfig agentConfig) {
WmiParams clientParams = null;
if (getWmiWqlStr().equals(DEFAULT_WMI_WQL)) {
// Create the check parameters holder.
clientParams = new WmiParams(WmiParams.WMI_OPERATION_INSTANCEOF, getCompVal(), getCompOp(), getWmiClass(), getWmiObject());
} else {
// Define the WQL Query.
clientParams = new WmiParams(WmiParams.WMI_OPERATION_WQL, getCompVal(), getCompOp(), getWmiWqlStr(), getWmiObject());
}
// Use WMI credentials from configuration files, and override values with the detector parameters if they exists.
if (getUsername() != null)
agentConfig.setUsername(getUsername());
if (getPassword() != null)
agentConfig.setPassword(getPassword());
if (getDomain() != null)
agentConfig.setDomain(getDomain());
if (getRetries() > 0)
agentConfig.setRetries(getRetries());
if (getTimeout() > 0)
agentConfig.setTimeout(getTimeout());
// Perform the operation specified in the parameters.
WmiResult result = isServer(address, agentConfig.getUsername(), agentConfig.getPassword(), agentConfig.getDomain(), getNamespace(), getMatchType(), agentConfig.getRetries(), agentConfig.getTimeout(), clientParams);
// Only fail on critical and unknown returns.
return (result != null && result.getResultCode() != WmiResult.RES_STATE_CRIT && result.getResultCode() != WmiResult.RES_STATE_UNKNOWN);
}
Aggregations