use of org.opennms.netmgt.config.datacollection.MibObj in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDao method processObjectList.
/**
* Takes a list of MibObj objects iterates over them
* creating corresponding MibObject objects and adding them to the supplied
* MibObject list.
* @param groupName TODO
* @param groupIfType TODO
* @param objectList
* List of MibObject objects parsed from
* 'datacollection-config.xml'
* @param mibObjectList
* List of MibObject objects currently being built
*/
private void processObjectList(final String groupName, final String groupIfType, final List<MibObj> objectList, final List<MibObject> mibObjectList) {
for (final MibObj mibObj : objectList) {
// Create a MibObject from the XML MibObj
final MibObject aMibObject = new MibObject();
aMibObject.setGroupName(groupName);
aMibObject.setGroupIfType(groupIfType);
aMibObject.setOid(mibObj.getOid());
aMibObject.setAlias(mibObj.getAlias());
aMibObject.setType(mibObj.getType());
aMibObject.setInstance(mibObj.getInstance());
aMibObject.setMaxval(mibObj.getMaxval());
aMibObject.setMinval(mibObj.getMinval());
final ResourceType resourceType = getConfiguredResourceTypes().get(mibObj.getInstance());
if (resourceType != null) {
aMibObject.setResourceType(resourceType);
}
// Add the MIB object provided it isn't already in the list
if (!mibObjectList.contains(aMibObject)) {
mibObjectList.add(aMibObject);
}
}
}
use of org.opennms.netmgt.config.datacollection.MibObj in project opennms by OpenNMS.
the class DataCollectionConfigFile method doVisit.
private void doVisit(Group group, DataCollectionVisitor visitor) {
visitor.visitGroup(group);
// mibObj
for (Iterator<MibObj> it = group.getMibObjs().iterator(); it.hasNext(); ) {
MibObj mibObj = it.next();
doVisit(mibObj, visitor);
}
// subGroups
for (Iterator<String> it = group.getIncludeGroups().iterator(); it.hasNext(); ) {
String subGroup = it.next();
doVisitSubGroup(subGroup, visitor);
}
visitor.completeGroup(group);
}
use of org.opennms.netmgt.config.datacollection.MibObj in project opennms by OpenNMS.
the class JsmiMibParser method getDataCollection.
/* (non-Javadoc)
* @see org.opennms.features.vaadin.mibcompiler.api.MibParser#getDataCollection()
*/
@Override
public DatacollectionGroup getDataCollection() {
if (module == null) {
return null;
}
LOG.info("Generating data collection configuration for {}", module.getId());
DatacollectionGroup dcGroup = new DatacollectionGroup();
dcGroup.setName(module.getId());
NameCutter cutter = new NameCutter();
try {
for (SmiVariable v : module.getVariables()) {
String groupName = getGroupName(v);
String resourceType = getResourceType(v);
Group group = getGroup(dcGroup, groupName, resourceType);
// FIXME what if it is not a primitive type, like in ENTITY-SENSOR-MIB ?
String typeName = getMetricType(v.getType().getPrimitiveType());
if (typeName != null) {
// RRDtool/JRobin DS size restriction.
String alias = cutter.trimByCamelCase(v.getId(), 19);
MibObj mibObj = new MibObj();
mibObj.setOid('.' + v.getOidStr());
mibObj.setInstance(resourceType == null ? "0" : resourceType);
mibObj.setAlias(alias);
mibObj.setType(typeName);
group.addMibObj(mibObj);
if (typeName.equals("string") && resourceType != null) {
for (ResourceType rs : dcGroup.getResourceTypes()) {
if (rs.getName().equals(resourceType) && rs.getResourceLabel().equals("${index}")) {
rs.setResourceLabel("${" + v.getId() + "} (${index})");
}
}
}
}
}
} catch (Throwable e) {
String errors = e.getMessage();
if (errors == null || errors.trim().equals(""))
errors = "An unknown error accured when generating data collection objects from the MIB " + module.getId();
LOG.error("Data Collection parsing error: {}", errors, e);
errorHandler.addError(errors);
return null;
}
return dcGroup;
}
Aggregations