@Transient @XmlTransient public boolean isAvailable() { if (m_status != null) { return m_status.isAvailable(); } return true; }
private boolean logicalStatusChanged(final OnmsLocationSpecificStatus currentStatus, final OnmsLocationSpecificStatus newStatus) { return currentStatus != null || (!newStatus.getPollResult().isAvailable()); }
private boolean logicalStatusChanged(final OnmsLocationSpecificStatus currentStatus, final OnmsLocationSpecificStatus newStatus) { return currentStatus != null || (!newStatus.getPollResult().isAvailable()); }
/** * <p>calculateStatus</p> * * @param pollStatuses a {@link java.util.Collection} object. * @return a {@link org.opennms.web.svclayer.support.DefaultDistributedStatusService.Severity} object. */ public Severity calculateStatus(Collection<PollStatus> pollStatuses) { int goodStatuses = 0; int badStatuses = 0; for (PollStatus pollStatus : pollStatuses) { if (pollStatus.isAvailable()) { goodStatuses++; } else if (!pollStatus.isUnknown()) { badStatuses++; } } if (goodStatuses == 0 && badStatuses == 0) { return Severity.INDETERMINATE; } else if (goodStatuses > 0 && badStatuses == 0) { return Severity.NORMAL; } else { return Severity.CRITICAL; } }
/** * <p>calculateStatus</p> * * @param pollStatuses a {@link java.util.Collection} object. * @return a {@link org.opennms.web.svclayer.support.DefaultDistributedStatusService.Severity} object. */ public Severity calculateStatus(Collection<PollStatus> pollStatuses) { int goodStatuses = 0; int badStatuses = 0; for (PollStatus pollStatus : pollStatuses) { if (pollStatus.isAvailable()) { goodStatuses++; } else if (!pollStatus.isUnknown()) { badStatuses++; } } if (goodStatuses == 0 && badStatuses == 0) { return Severity.INDETERMINATE; } else if (goodStatuses > 0 && badStatuses == 0) { return Severity.NORMAL; } else { return Severity.CRITICAL; } }
private String getResponseText(PollStatus status) { if (status.isAvailable()) { Double responseTime = status.getResponseTime(); if (responseTime != null && responseTime >= 0) { return responseTime + "ms"; } else { return ""; } } else { return status.getReason(); } }
private String getResponseText(PollStatus status) { if (status.isAvailable()) { Double responseTime = status.getResponseTime(); if (responseTime != null && responseTime >= 0) { return responseTime + "ms"; } else { return ""; } } else { return status.getReason(); } }
/** * TODO: Use the enum for these string values */ private String getStyleForPollResult(PollStatus status) { if (status.isAvailable()) { return "Normal"; } else if (status.isUnresponsive()) { return "Warning"; } else if (status.isUnknown()) { return "Indeterminate"; } else { return "Critical"; } }
@Override public PollStatus handlePollResult(MonitoredService svc, Map<String, Object> parameters, PollStatus status) { if ("true".equals(ParameterMap.getKeyedString(parameters, "invert-status", "false"))) { if (status.isAvailable()) { return PollStatus.unavailable("This is an inverted service and the underlying service has started responding"); } else { return PollStatus.available(); } } return status; } }
/** * TODO: Use the enum for these string values */ private String getStyleForPollResult(PollStatus status) { if (status.isAvailable()) { return "Normal"; } else if (status.isUnresponsive()) { return "Warning"; } else if (status.isUnknown()) { return "Indeterminate"; } else { return "Critical"; } }
@Override public void reportSingleScan(final ScanReport report) { if (report == null) { throw new IllegalArgumentException("ScanReport cannot be null"); } LOG.info("Scan report complete: {}", report); m_scanReportDao.save(report); if (report.getPollResults().stream().allMatch(a -> { return a.getPollStatus().isAvailable(); } )) { // If all polls returned 'available' then send the success event sendSuccessfulScanReportEvent(report.getId(), report.getLocation()); } else { // Otherwise send the unsuccessful event int total = 0; int failed = 0; final StringBuilder failedPollResults = new StringBuilder(); for (ScanReportPollResult result : report.getPollResults()) { total++; if (!result.getPollStatus().isAvailable()) { failed++; failedPollResults.append(String.format(FAILED_POLL_RESULT_MESSAGE_FORMAT, result.getNodeLabel(), result.getIpAddress(), result.getServiceName(), result.getPollStatus().getReason())); } } StringBuffer finalMessage = new StringBuffer(); finalMessage.append(String.format(FAILURE_SUMMARY_MESSAGE_FORMAT, failed, total)); finalMessage.append("<ul>"); finalMessage.append(failedPollResults); finalMessage.append("</ul>"); sendUnsuccessfulScanReportEvent(report.getId(), report.getLocation(), finalMessage.toString()); } }
@Override public void reportSingleScan(final ScanReport report) { if (report == null) { throw new IllegalArgumentException("ScanReport cannot be null"); } LOG.info("Scan report complete: {}", report); m_scanReportDao.save(report); if (report.getPollResults().stream().allMatch(a -> { return a.getPollStatus().isAvailable(); } )) { // If all polls returned 'available' then send the success event sendSuccessfulScanReportEvent(report.getId(), report.getLocation()); } else { // Otherwise send the unsuccessful event int total = 0; int failed = 0; final StringBuilder failedPollResults = new StringBuilder(); for (ScanReportPollResult result : report.getPollResults()) { total++; if (!result.getPollStatus().isAvailable()) { failed++; failedPollResults.append(String.format(FAILED_POLL_RESULT_MESSAGE_FORMAT, result.getNodeLabel(), result.getIpAddress(), result.getServiceName(), result.getPollStatus().getReason())); } } StringBuffer finalMessage = new StringBuffer(); finalMessage.append(String.format(FAILURE_SUMMARY_MESSAGE_FORMAT, failed, total)); finalMessage.append("<ul>"); finalMessage.append(failedPollResults); finalMessage.append("</ul>"); sendUnsuccessfulScanReportEvent(report.getId(), report.getLocation(), finalMessage.toString()); } }
for (tracker.reset(); tracker.shouldRetry() && !ps.isAvailable(); tracker.nextAttempt()) { try { ps = ssh.poll(tracker); if (regex != null && ps.isAvailable()) { String response = ssh.getServerBanner(); m_isAvailable = result.isAvailable();
private void sendRegainedOrLostServiceEvent(final OnmsLocationSpecificStatus newStatus, final PollStatus pollResult) { final String uei = pollResult.isAvailable() ? EventConstants.REMOTE_NODE_REGAINED_SERVICE_UEI : EventConstants.REMOTE_NODE_LOST_SERVICE_UEI; final EventBuilder builder = createEventBuilder(newStatus.getLocationMonitor(), uei) .setMonitoredService(newStatus.getMonitoredService()); if (!pollResult.isAvailable() && pollResult.getReason() != null) { builder.addParam(EventConstants.PARM_LOSTSERVICE_REASON, pollResult.getReason()); } m_eventIpcManager.sendNow(builder.getEvent()); }
status = sendTestMessage(mailParms); if (status.isAvailable()) { LOG.debug("doMailTest: send test successful."); status = readTestMessage(mailParms); if (status.isAvailable()) { status.setResponseTime(Double.valueOf(String.valueOf(System.currentTimeMillis() - beginPoll)));
private void sendRegainedOrLostServiceEvent(final OnmsLocationSpecificStatus newStatus, final PollStatus pollResult) { final String uei = pollResult.isAvailable() ? EventConstants.REMOTE_NODE_REGAINED_SERVICE_UEI : EventConstants.REMOTE_NODE_LOST_SERVICE_UEI; final EventBuilder builder = createEventBuilder(newStatus.getLocationMonitor(), uei) .setMonitoredService(newStatus.getMonitoredService()); if (!pollResult.isAvailable() && pollResult.getReason() != null) { builder.addParam(EventConstants.PARM_LOSTSERVICE_REASON, pollResult.getReason()); } m_eventIpcManager.sendNow(builder.getEvent()); }
public void testSshBad() throws Exception { Date start = new Date(); ssh.setAddress(bad); assertFalse(ssh.poll(tt).isAvailable()); Date end = new Date(); // give it 2.5 seconds to time out assertTrue(end.getTime() - start.getTime() < 2500); }
for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt() ) { HttpClientWrapper clientWrapper = null; try {
public void testSshGood() throws Exception { ssh.setAddress(good); assertTrue("SSH poll against " + GOOD_HOST + " failed", ssh.poll(tt).isAvailable()); }
TimeoutTracker tracker = new TimeoutTracker(parameters, DEFAULT_SEQUENCE_RETRY, DEFAULT_TIMEOUT); for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt()) { String seleniumTestFilename = getGroovyFilename( parameters ); try {