List of usage examples for javax.management.openmbean CompositeDataSupport containsKey
public boolean containsKey(String key)
From source file:it.jnrpe.plugin.jmx.CCheckJMX.java
@Override protected Collection<Metric> gatherMetrics(ICommandLine cl) throws MetricGatheringException { Collection<Metric> metrics = new ArrayList<Metric>(super.gatherMetrics(cl)); if (this.getInfoData() == null || this.getVerbatim() >= 2) { String metricName = getCheckName(); if (this.getCheckData() instanceof Number) { metrics.add(//from w w w .j a v a 2 s . c o m MetricBuilder.forMetric(metricName).withMessage(metricName + " is {0}", this.getCheckData()) .withValue((Number) this.getCheckData()).build()); } else { metrics.add(MetricBuilder.forMetric(metricName) .withMessage(metricName + " is {0}", this.getCheckData()).withValue(0).build()); } LOG.debug(getContext(), "Created metric : " + metricName); } if (this.getInfoData() != null) { String metricName = getInfo_attribute(); if (this.getInfoData() instanceof CompositeDataSupport) { CompositeDataSupport data = (CompositeDataSupport) this.getInfoData(); CompositeType type = data.getCompositeType(); for (Iterator<String> it = type.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); if (data.containsKey(key) && !getCheckName().equals(metricName + "." + key)) { if (data.get(key) instanceof Number) { metrics.add(MetricBuilder.forMetric(metricName + "." + key) .withMessage(metricName + "." + key + " is {0}", data.get(key)) .withValue((Number) data.get(key)).build()); } else { metrics.add(MetricBuilder.forMetric(metricName + "." + key) .withMessage(metricName + "." + key + " is {0}", data.get(key)).withValue(0) .build()); } LOG.debug(getContext(), "Created metric : " + metricName + "." + key); } } } else { if (this.getInfoData() instanceof Number) { metrics.add(MetricBuilder.forMetric(metricName) .withMessage("info is {0}", this.getCheckData().toString()) .withValue((Number) this.getInfoData()).build()); } else { metrics.add(MetricBuilder.forMetric(metricName) .withMessage("info is {0}", this.getCheckData().toString()).withValue(0).build()); } LOG.debug(getContext(), "Created metric : " + "info"); } } return metrics; }