@Override public Map<String, Object> getRuntimeAttributes(MonitoredService svc, Map<String, Object> parameters) { try { SnmpPeerFactory.init(); } catch (IOException e) { LOG.error("SnmpPeerFactory initialization failed.", e); } return ImmutableMap.of("agent", SnmpPeerFactory.getInstance().getAgentConfig(svc.getAddress(), svc.getNodeLocation())); }
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); } }
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); }
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();
.withLocation(service.getNodeLocation()) .withSystemId(systemId) .withServiceAttributes(attributes) request.setNodeId(service.getNodeId()); request.setNodeLabel(service.getNodeLabel()); request.setNodeLocation(service.getNodeLocation()); request.setTimeToLiveMs(ttlInMs); request.addAttributes(attributes);