/** * Clones an Attrib object. Makes a deep copy! * * @param input * @return */ public static Attrib clone(Attrib input) { Attrib output = new Attrib(); output.setAlias(input.getAlias()); output.setMaxval(input.getMaxval()); output.setMinval(input.getMinval()); output.setName(input.getName()); output.setType(input.getType()); return output; }
/** * Converts this {@link org.opennms.netmgt.config.collectd.jmx.CompMember} to an {@link org.opennms.netmgt.config.collectd.jmx.Attrib}. * This is basically to use most of the APIs which have already been written for Attrib. * * @return The converted CompMember as an Attrib. */ public Attrib toAttrib() { Attrib attrib = new Attrib(); attrib.setAlias(_alias); attrib.setMaxval(_maxval); attrib.setMinval(_minval); attrib.setType(_type); attrib.setName(_name); return attrib; }
@Override public void apply(Attrib input) { // The mbean "PooledDataSource" has already a "0numFailChecDfltUsr" alias. Therefore the // JmxConfiggenerator created a "NAME_CRASH"-alias. We manually overwrite the value here to a valid one if ("0numFailedCheckinsDfltUsr_NAME_CRASH_AS_19_CHAR_VALUE".equals(input.getAlias()) && "numFailedCheckinsDefaultUser".equals(input.getName())) { input.setAlias("1numFailChecDfltUsr"); } } });
private Attrib createAttr(MBeanAttributeInfo jmxMBeanAttributeInfo) { Attrib xmlJmxAttribute = new Attrib(); xmlJmxAttribute.setType(AttributeType.GAUGE); xmlJmxAttribute.setName(jmxMBeanAttributeInfo.getName()); String alias = nameCutter.trimByDictionary(jmxMBeanAttributeInfo.getName()); alias = createAndRegisterUniqueAlias(alias); xmlJmxAttribute.setAlias(alias); return xmlJmxAttribute; }
private Collection<Report> generateAttributeReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); for (Attrib attrib : mbean.getAttribList()) { final String title = String.format("%s[%s]", mbean.getObjectname().toString() , attrib.getName()); final String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + attrib.getAlias() + "." + ATTRIBUTEREPORT; Report report = new Report(reportId, title, title, "verticalLabel"); report.addGraph(new Graph(attrib.getAlias(), attrib.getName(), attrib.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); reports.add(report); Colors.resetColor(); } return reports; }
if (attr.getType().isNumeric()) { JMXDataSource ds = new JMXDataSource(); ds.setName(attr.getAlias()); ds.setType(attr.getType()); dsList.put(objectName + "|" + attr.getName(), ds); } else { LOG.warn("buildDataSourceList: Data type '{}' not supported. Only integer-type data may be stored in RRD. MBean object '{}' will not be mapped to RRD data source.", attr.getType(), attr.getAlias());
protected void validate(Attrib attrib, ValidationResult validationResult) { validateInternal(attributeNameValidator, attrib, attrib.getAlias(), validationResult); validateInternal(attributeLengthValidator, attrib, attrib.getAlias(), validationResult); validateInternal(attributeUniqueNameValidator, attrib, attrib.getAlias(), validationResult); } }
private Attrib createAttr(MBeanAttributeInfo jmxMBeanAttributeInfo) { Attrib xmlJmxAttribute = new Attrib(); xmlJmxAttribute.setType(AttributeType.GAUGE); xmlJmxAttribute.setName(jmxMBeanAttributeInfo.getName()); String alias = nameCutter.trimByDictionary(jmxMBeanAttributeInfo.getName()); alias = createAndRegisterUniqueAlias(alias); xmlJmxAttribute.setAlias(alias); return xmlJmxAttribute; }
private Collection<Report> generateAttributeReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); for (Attrib attrib : mbean.getAttribList()) { final String title = String.format("%s[%s]", mbean.getObjectname().toString() , attrib.getName()); final String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + attrib.getAlias() + "." + ATTRIBUTEREPORT; Report report = new Report(reportId, title, title, "verticalLabel"); report.addGraph(new Graph(attrib.getAlias(), attrib.getName(), attrib.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); reports.add(report); Colors.resetColor(); } return reports; }
public DetectMBeansJob(JmxConfigGeneratorUI ui, ServiceConfig config) { this.ui = Objects.requireNonNull(ui); this.config = Objects.requireNonNull(config); filterMap.put(Mbean.class, (Consumer<Mbean>) input -> { // The default PooledDataSource name is "com.mchange.v2.c3p0.PooledDataSource[1hge1gv9a1li8lwdjzwyop|290e7d09]". // We remove the weired part at the end if (input.getName().contains("com.mchange.v2.c3p0.PooledDataSource")) { input.setName("com.mchange.v2.c3p0.PooledDataSource"); } }); filterMap.put(Attrib.class, (Consumer<Attrib>) input -> { // The mbean "PooledDataSource" has already a "0numFailChecDfltUsr" alias. Therefore the // JmxConfiggenerator created a "NAME_CRASH"-alias. We manually overwrite the value here to a valid one if ("0numFailedCheckinsDfltUsr_NAME_CRASH_AS_19_CHAR_VALUE".equals(input.getAlias()) && "numFailedCheckinsDefaultUser".equals(input.getName())) { input.setAlias("1numFailChecDfltUsr"); } }); }
/** * Extracts all Attribute and Composite Attribute Names * from the given MBean. * * @param bean The MBean to extract attributes from. * @return An unmodifiable list of Attribute/Composite Attribute Names. */ private List<String> extractAttributeNames(Mbean bean) { List<String> attributes = new ArrayList<>(); for (Attrib eachAttrib : bean.getAttribList()) { attributes.add(eachAttrib.getName()); } for (CompAttrib eachCompAttrib : bean.getCompAttribList()) { attributes.add(eachCompAttrib.getName()); } return Collections.unmodifiableList(attributes); }
if (attr.getType().isNumeric()) { JMXDataSource ds = new JMXDataSource(); ds.setName(attr.getAlias()); ds.setType(attr.getType()); dsList.put(objectName + "|" + attr.getName(), ds); } else { LOG.warn("buildDataSourceList: Data type '{}' not supported. Only integer-type data may be stored in RRD. MBean object '{}' will not be mapped to RRD data source.", attr.getType(), attr.getAlias());
protected void validate(Attrib attrib, ValidationResult validationResult) { validateInternal(attributeNameValidator, attrib, attrib.getAlias(), validationResult); validateInternal(attributeLengthValidator, attrib, attrib.getAlias(), validationResult); validateInternal(attributeUniqueNameValidator, attrib, attrib.getAlias(), validationResult); } }
/** * Clones an Attrib object. Makes a deep copy! * * @param input * @return */ public static Attrib clone(Attrib input) { Attrib output = new Attrib(); output.setAlias(input.getAlias()); output.setMaxval(input.getMaxval()); output.setMinval(input.getMinval()); output.setName(input.getName()); output.setType(input.getType()); return output; }
public static Map<String, List<Attrib>> getAttributeMap(JmxCollection collection, String aSysoid, String anAddress) { final Map<String, List<Attrib>> attributeMap = new HashMap<String, List<Attrib>>(); if (aSysoid == null) { LOG.debug("getMibObjectList: aSysoid parameter is NULL..."); return attributeMap; } if (collection == null) { return attributeMap; } for(Mbean mbean : collection.getMbeans()) { // Make sure to create a new ArrayList because we add to it below List<Attrib> list = new ArrayList<Attrib>(mbean.getAttribList()); for(CompAttrib compAttrib : mbean.getCompAttribList()) { for (CompMember compMember : compAttrib.getCompMemberList()) { Attrib attribWrapper = new Attrib(); attribWrapper.setName(compAttrib.getName() + "|" + compMember.getName()); attribWrapper.setAlias(compMember.getAlias()); attribWrapper.setType(compMember.getType()); list.add(attribWrapper); } } attributeMap.put(mbean.getObjectname(), list); } return attributeMap; }
private Collection<Report> generateMbeanReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); if (!mbean.getAttribList().isEmpty()) { String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + MBEANREPORT; Report report = new Report(reportId, mbean.getName(), mbean.getName(), "verticalLabel"); for (Attrib attrib : mbean.getAttribList()) { report.addGraph(new Graph(attrib.getAlias(), attrib.getName(), attrib.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); } reports.add(report); Colors.resetColor(); } return reports; }
public Attrib getAttrib() { for (Attrib eachAttrib : getMbean().getAttribList()) { if (Objects.equals(getCollectedAttribute().getName(), eachAttrib.getName())) { return eachAttrib; } } return null; }
@Override public Map<Object, String> getNamesMap() { Map<Object, String> objectToNameMap = new HashMap<>(); for (Mbean bean : selectionManager.getSelectedMbeans()) { for (Attrib att : selectionManager.getSelectedAttributes(bean)) { objectToNameMap.put(att, att.getAlias()); } for (CompAttrib compAttrib : selectionManager.getSelectedCompositeAttributes(bean)) { for (CompMember compMember : selectionManager.getSelectedCompositeMembers(compAttrib)) { objectToNameMap.put(compMember, compMember.getAlias()); } } } return Collections.unmodifiableMap(objectToNameMap); } }
private Collection<Report> generateMbeanReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); if (!mbean.getAttribList().isEmpty()) { String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + MBEANREPORT; Report report = new Report(reportId, mbean.getName(), mbean.getName(), "verticalLabel"); for (Attrib attrib : mbean.getAttribList()) { report.addGraph(new Graph(attrib.getAlias(), attrib.getName(), attrib.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); } reports.add(report); Colors.resetColor(); } return reports; }