public static Properties getServiceProperties(final MonitoredService svc) { final InetAddress addr = InetAddressUtils.addr(svc.getIpAddr()); final boolean requireBrackets = addr != null && addr instanceof Inet6Address && !svc.getIpAddr().startsWith("["); final Properties properties = new Properties(); properties.put("ipaddr", requireBrackets ? "[" + svc.getIpAddr() + "]" : svc.getIpAddr()); properties.put("nodeid", svc.getNodeId()); properties.put("nodelabel", svc.getNodeLabel()); properties.put("svcname", svc.getSvcName()); return properties; } }
private String getBaseUrl(Map<String, Object> parameters, MonitoredService svc) { if(parameters.containsKey("base-url")) { String baseUrl = (String) parameters.get("base-url"); if(!baseUrl.contains("http")) { baseUrl = "http://" + baseUrl; } if(baseUrl.contains("${ipAddr}")) { baseUrl = BaseUrlUtils.replaceIpAddr(baseUrl, svc.getIpAddr()); } if(parameters.containsKey("port")) { String port = (String) parameters.get("port"); baseUrl = baseUrl + ":" + port; } return baseUrl; }else { return null; } }
private String enrichArguments(String args, MonitoredService svc, TimeoutTracker tracker, Map <String, Object> parameters) { String richArgs = args; richArgs = richArgs.replace("${timeout}", ((Long)tracker.getTimeoutInMillis()).toString()); richArgs = richArgs.replace("${timeoutsec}", ((Long)tracker.getTimeoutInSeconds()).toString()); richArgs = richArgs.replace("${retry}", ParameterMap.getKeyedString(parameters, "retry", ((Integer)DEFAULT_RETRY).toString())); richArgs = richArgs.replace("${ipaddr}", svc.getIpAddr()); richArgs = richArgs.replace("${nodeid}", ((Integer) svc.getNodeId()).toString()); richArgs = richArgs.replace("${nodelabel}", svc.getNodeLabel()); richArgs = richArgs.replace("${svcname}", svc.getSvcName()); return richArgs; }
@Override public Map<String, Object> getRuntimeAttributes(MonitoredService svc, Map<String, Object> parameters) { final Map<String, Object> attributes = new HashMap<>(); final PollStatus pollStatus = doPoll(svc.getNodeId(), svc.getIpAddr(), m_svcName); attributes.put("status", Integer.toString(pollStatus.getStatusCode())); attributes.put("reason", pollStatus.getReason()); return attributes; }
/** {@inheritDoc} */ @Override public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { int retries = ParameterMap.getKeyedInteger(parameters, "retry", PingConstants.DEFAULT_RETRIES); long timeout = ParameterMap.getKeyedLong(parameters, "timeout", PingConstants.DEFAULT_TIMEOUT); Long rtt = null; String phoneNumber = null; try { phoneNumber = phonebook.getTargetForAddress(svc.getIpAddr()); } catch (final PhonebookException e) { LOG.warn("Unable to get phonebook target for {}", svc.getIpAddr(), e); } if (phoneNumber != null) { try { rtt = SmsPinger.ping(phoneNumber, timeout, retries); } catch (final Exception e) { LOG.warn("Unable to ping phone number: {}", phoneNumber, e); } } if (rtt != null) { return PollStatus.available(rtt.doubleValue()); } else { return PollStatus.unavailable(); } } }
@Override public PollStatus poll(MonitoredService monSvc, Map<String, Object> parameters) { if (parameters.containsKey("status")) { final int statusCode = getKeyedInteger(parameters, "status", PollStatus.SERVICE_UNKNOWN); final String reason = getKeyedString(parameters, "reason", null); return PollStatus.get(statusCode, reason); } synchronized (m_network) { return doPoll(monSvc.getNodeId(), monSvc.getIpAddr(), m_svcName); } }
case "ipAddr": case "ipAddress": sb.append(svc.getIpAddr()); break; case "nodeId":
/** {@inheritDoc} */ @Override public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { PollStatus status = null; try { final MailTransportParameters mailParms = MailTransportParameters.get(parameters); try { if ("${ipaddr}".equals(mailParms.getReadTestHost())) { mailParms.setReadTestHost(svc.getIpAddr()); } } catch (final IllegalStateException ise) { //just ignore, don't have to have a both a read and send test configured } try { if ("${ipaddr}".equals(mailParms.getSendTestHost())) { mailParms.setSendTestHost(svc.getIpAddr()); } } catch (final IllegalStateException ise) { //just ignore, don't have to have a both a read and send test configured } parseJavaMailProperties(mailParms); status = doMailTest(mailParms); } catch (final IllegalStateException ise) { //ignore this because we don't have to have both a send and read } catch (final Throwable e) { LOG.error("An error occurred while polling.", e); status = PollStatus.down("Exception from mailer: " + e.getLocalizedMessage()); } return status; }
@Override public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { return PassiveStatusKeeper.getInstance().getStatus(svc.getNodeLabel(), svc.getIpAddr(), svc.getSvcName()); }
log.warn("No transactions were configured for host {}", svc.getIpAddr()); return PollStatus.unavailable("No transactions were configured for host " + svc.getIpAddr()); session.setRecipient(m_phonebook.getTargetForAddress(svc.getIpAddr())); log.warn("Unable to locate recpient phone number for IP address {}", svc.getIpAddr(), e); return PollStatus.unavailable("Unable to find phone number for IP address " + svc.getIpAddr()); } catch (SequenceException e) { log.warn("Unable to parse sequence configuration for host {}", svc.getIpAddr(), e); return PollStatus.unavailable("unable to read sequence configuration"); } catch (Throwable e) {
private void applyThresholds(String rrdPath, MonitoredService service, String dsName, Map<String, Number> entries) { try { if (m_thresholdingSet == null) { RrdRepository repository = new RrdRepository(); repository.setRrdBaseDir(new File(rrdPath)); m_thresholdingSet = new LatencyThresholdingSet(service.getNodeId(), service.getIpAddr(), service.getSvcName(), service.getNodeLocation(), repository, m_resourceStorageDao); } LinkedHashMap<String, Double> attributes = new LinkedHashMap<String, Double>(); for (String ds : entries.keySet()) { Number sampleValue = entries.get(ds); if (sampleValue == null) { attributes.put(ds, Double.NaN); } else { attributes.put(ds, sampleValue.doubleValue()); } } if (m_thresholdingSet.isNodeInOutage()) { LOG.info("applyThresholds: the threshold processing will be skipped because the service {} is on a scheduled outage.", service); } else if (m_thresholdingSet.hasThresholds(attributes)) { List<Event> events = m_thresholdingSet.applyThresholds(dsName, attributes); if (events.size() > 0) { ThresholdingEventProxy proxy = new ThresholdingEventProxy(); proxy.add(events); proxy.sendAllEvents(); } } } catch(Throwable e) { LOG.error("Failed to threshold on {} for {} because of an exception", service, dsName, e); } }
LOG.info("Using address {} from node '{}':'{}' as proxy for service '{}' on interface {}", proxyAddress, proxyNodeFS, proxyNodeFI, svc.getSvcName(), svc.getIpAddr()); return proxyAddress; LOG.info("Using address {} from node with DBID {} as proxy for service '{}' on interface {}", proxyAddress, proxyNodeId, svc.getSvcName(), svc.getIpAddr()); return proxyAddress; LOG.info("Using address {} (user-specified) as proxy for service '{}' on interface {}", proxyAddress, svc.getSvcName(), svc.getIpAddr()); return proxyAddress; LOG.error("Unable to determine proxy address for service '{}' on interface '{}'. The poll will be unable to proceed.", svc.getSvcName(), svc.getIpAddr()); return null;
m_bsfManager.declareBean("ip_addr",svc.getIpAddr(),String.class); m_bsfManager.declareBean("node_id",svc.getNodeId(),int.class ); m_bsfManager.declareBean("node_label", svc.getNodeLabel(), String.class);
private void persistLatencySamples(MonitoredService service, Map<String, Number> entries, File rrdRepositoryRoot, String rrdBaseName) { RrdRepository repository = new RrdRepository(); repository.setStep(m_pollerConfig.getStep(m_pkg)); repository.setRraList(m_pollerConfig.getRRAList(m_pkg)); repository.setHeartBeat(repository.getStep() * HEARTBEAT_STEP_MULTIPLIER); repository.setRrdBaseDir(rrdRepositoryRoot); // When making calls directly to RrdUtils#createRrd() and RrdUtils#updateRrd(), // the behavior was as follows: // 1) All samples get written to response/${ipAddr}/${rrdBaseName}.rrd // This happens whether or not storeByGroup is enabled. // 2) If multiple entries are present, the DSs are created in the same order that they // appear in the map LatencyCollectionResource latencyResource = new LatencyCollectionResource(service.getSvcName(), service.getIpAddr(), service.getNodeLocation()); for (final Entry<String, Number> entry : entries.entrySet()) { final String ds = entry.getKey(); final Number value = entry.getValue() != null ? entry.getValue() : Double.NaN; LatencyCollectionAttributeType latencyType = new LatencyCollectionAttributeType(rrdBaseName, ds); latencyResource.addAttribute(new LatencyCollectionAttribute(latencyResource, latencyType, ds, value.doubleValue())); } ServiceParameters params = new ServiceParameters(Collections.emptyMap()); CollectionSetVisitor persister = m_persisterFactory.createPersister(params, repository, false, true, true); SingleResourceCollectionSet collectionSet = new SingleResourceCollectionSet(latencyResource, new Date()); collectionSet.setStatus(CollectionStatus.SUCCEEDED); collectionSet.visit(persister); }
LOG.debug("Service {} on interface {} is down, but continuing to gather latency data", svc.getSvcName(), svc.getIpAddr()); serviceStatus = PollStatus.unavailable("the failure ping count (" + failurePingCount + ") was reached"); } else {
serviceStatus = PollStatus.unavailable("Selenium page sequence attempt on:" + svc.getIpAddr() + " failed : selenium-test compilation error " + e.getMessage()); String reason = "Selenium sequence failed: CompilationFailedException" + e.getMessage(); SeleniumMonitor.LOG.debug(reason); PollStatus.unavailable(reason); } catch (IOException e) { serviceStatus = PollStatus.unavailable("Selenium page sequence attempt on " + svc.getIpAddr() + " failed: IOException occurred, failed to find selenium-test: " + seleniumTestFilename); String reason = "Selenium sequence failed: IOException: " + e.getMessage(); SeleniumMonitor.LOG.debug(reason); PollStatus.unavailable(reason); } catch (Exception e) { serviceStatus = PollStatus.unavailable("Selenium page sequence attempt on " + svc.getIpAddr() + " failed:\n" + e.getMessage()); String reason = "Selenium sequence failed: Exception: " + e.getMessage(); SeleniumMonitor.LOG.debug(reason);
/** {@inheritDoc} */ @Override public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); for(timeoutTracker.reset(); timeoutTracker.shouldRetry(); timeoutTracker.nextAttempt()) { try { timeoutTracker.startAttempt(); if (svc.getAddress().isReachable(timeoutTracker.getSoTimeout())) { return PollStatus.available(timeoutTracker.elapsedTimeInMillis()); } } catch (IOException e) { LOG.debug("Unable to contact {}", svc.getIpAddr(), e); } } String reason = svc+" failed to respond"; LOG.debug(reason); return PollStatus.unavailable(reason); }
List<CIMObject> cimObjects = null; try { cimObjects = vmwareViJavaAccess.queryCimObjects(hostSystem, "CIM_NumericSensor", svc.getIpAddr()); } catch (Exception e) { logger.warn("Error retrieving CIM values from host system '{}'", vmwareManagedObjectId, e.getMessage());
LOG.debug("{}: Creating new AMI-Connection: {}:{}, {}/{}", svc.getSvcName(), svc.getIpAddr(), amiConfig.getPort(), amiConfig.getUsername(), amiConfig.getPassword()); ManagerConnectionFactory factory = new ManagerConnectionFactory(svc.getIpAddr(), amiConfig.getPort().orElse(null), amiConfig.getUsername().orElse(null), amiConfig.getPassword().orElse(null)); ManagerConnection managerConnection; if(amiConfig.getUseTls().orElse(false))
expect(svc.getIpAddr()).andReturn("127.0.0.1").atLeastOnce(); expect(svc.getSvcName()).andReturn("ICMP").atLeastOnce(); expect(svc.getNodeLocation()).andReturn(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID).atLeastOnce();