public boolean hasThresholds() { return m_thresholdingSet.hasThresholds(); }
public boolean isNodeInOutage() { return m_thresholdingSet.isNodeInOutage(); }
/** * Force reload thresholds configuration, and merge threshold states */ public void reload() { m_thresholdingSet.reinitialize(); }
/** {@inheritDoc} */ public List<Event> applyThresholds(CollectionResource resource, Map<String, CollectionAttribute> attributesMap, Date collectionTimestamp) { if (!isCollectionEnabled(resource)) { LOG.debug("applyThresholds: Ignoring resource {} because data collection is disabled for this resource.", resource); return new LinkedList<>(); } CollectionResourceWrapper resourceWrapper = new CollectionResourceWrapper( collectionTimestamp, m_nodeId, m_hostAddress, m_serviceName, m_repository, resource, attributesMap, m_resourceStorageDao); resourceWrapper.setCounterReset(counterReset); return applyThresholds(resourceWrapper, attributesMap); }
/** * Static method create must be used to create new ThresholdingVisitor instance. * Is static because successful creation depends on thresholding-enabled parameter. * * @param nodeId a int. * @param hostAddress a {@link java.lang.String} object. * @param serviceName a {@link java.lang.String} object. * @param repo a {@link org.opennms.netmgt.rrd.RrdRepository} object. * @param svcParams a {@link org.opennms.netmgt.collection.api.ServiceParameters} object. * @return a {@link org.opennms.netmgt.threshd.ThresholdingVisitor} object. * @throws ThresholdInitializationException */ public static ThresholdingVisitor create(int nodeId, String hostAddress, String serviceName, RrdRepository repo, ServiceParameters svcParams, ResourceStorageDao resourceStorageDao) throws ThresholdInitializationException { String enabled = ParameterMap.getKeyedString(svcParams.getParameters(), "thresholding-enabled", null); if (enabled != null && !"true".equals(enabled)) { LOG.info("create: Thresholds processing is not enabled. Check thresholding-enabled param on collectd package"); return null; } CollectorThresholdingSet thresholdingSet = new CollectorThresholdingSet(nodeId, hostAddress, serviceName, repo, svcParams, resourceStorageDao); if (!thresholdingSet.hasThresholds()) { LOG.warn("create: the ipaddress/service {}/{} on node {} has no configured thresholds.", hostAddress, serviceName, nodeId); } return new ThresholdingVisitor(thresholdingSet); }
/** * <p>hasThresholds</p> * * @param attribute a {@link org.opennms.netmgt.collection.api.CollectionAttribute} object. * @return a boolean. */ public boolean hasThresholds(CollectionAttribute attribute) { CollectionResource resource = attribute.getResource(); if (!isCollectionEnabled(attribute.getResource())) return false; if (resource instanceof AliasedResource && !storeByIfAlias) return false; return hasThresholds(resource.getResourceTypeName(), attribute.getName()); }
public void setCounterReset(boolean counterReset) { m_thresholdingSet.setCounterReset(counterReset); }
public void reloadScheduledOutages() throws ThresholdInitializationException { m_thresholdingSet.updateScheduledOutages(); }
/** * Apply threshold for specific resource (and required attributes). * Send thresholds events (if exists). */ @Override public void completeResource(CollectionResource resource) { List<Event> eventList = m_thresholdingSet.applyThresholds(resource, m_attributesMap, m_collectionTimestamp); ThresholdingEventProxy proxy = ThresholdingEventProxyFactory.getFactory().getProxy(); proxy.add(eventList); proxy.sendAllEvents(); }
/** * Add/Update required attributes for thresholds on m_attributeMap. * This is used because {@link CollectionResource} does not have direct reference to their attributes. * (The way to get attribute is against {@link AttributeGroup} object contained on {@link CollectionResource} * implementations). */ @Override public void visitAttribute(CollectionAttribute attribute) { if (m_thresholdingSet.hasThresholds(attribute)) { String name = attribute.getName(); m_attributesMap.put(name, attribute); LOG.debug("visitAttribute: storing value {} for attribute named {}", attribute.getNumericValue() != null ? attribute.getNumericValue() : attribute.getStringValue(), name); } }