/* (non-Javadoc) * @see org.opennms.features.vaadin.mibcompiler.api.MibParser#getDataCollection() */ public DatacollectionGroup getDataCollection() { if (module == null) { return null; } LogUtils.infof(this, "Generating data collection configuration for %s", 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); String typeName = getMetricType(v.getType().getPrimitiveType()); if (typeName != null) { String alias = cutter.trimByCamelCase(v.getId(), 19); // RRDtool/JRobin DS size restriction. 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.getResourceTypeCollection()) { 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(); LogUtils.errorf(this, e, "Data Collection parsing error: %s", errors); errorHandler.addError(errors); return null; } return dcGroup; }
@Parameters public static Collection<Object[]> data() throws ParseException { final MibObj obj = new MibObj(); obj.setAlias("cyPMSerialPortNum"); obj.setInstance("cyPMSerialPortNum"); obj.setOid(".1.3.6.1.4.1.2925.4.5.2.1.1"); obj.setType("string"); obj.setMaxval("4294967295"); obj.setMinval("0"); return Arrays.asList( new Object[][] { { obj, "<mibObj oid=\".1.3.6.1.4.1.2925.4.5.2.1.1\" instance=\"cyPMSerialPortNum\" alias=\"cyPMSerialPortNum\" type=\"string\" maxval=\"4294967295\" minval=\"0\" />", "target/classes/xsds/datacollection-config.xsd" } }); }