From ac3873a6ca83b0dd654c784e0fd43656b92efca3 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 26 Apr 2017 12:38:58 +0900 Subject: [PATCH] sdf --- .../overflow/crawler/jmx/JmxCrawler.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java b/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java index d1afe57..aea9cda 100644 --- a/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java +++ b/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java @@ -36,19 +36,21 @@ public class JmxCrawler extends Crawler{ private MBeanReceiver receiver; private List whiteObjectNameList = new ArrayList<>(); private List> keys = new ArrayList<>(); + private List metrics = new ArrayList<>(); private Map re = new HashMap(); @Override public Object getInternal(Config config) throws Exception { - MBeanReceiver m = new MBeanReceiver() { - @Override - public void recordBean(String domain, LinkedList attrKeys, String attrName, String attrType, String attrDescription, Object value) { - re.put(attrName, value.toString()); - } - }; + MBeanReceiver m = (domain, attrKeys, attrName, attrType, attrDescription, value) -> re.put(attrName, value.toString()); +// MBeanReceiver m = new MBeanReceiver() { +// @Override +// public void recordBean(String domain, LinkedList attrKeys, String attrName, String attrType, String attrDescription, Object value) { +// re.put(attrName, value.toString()); +// } +// }; // "service:jmx:rmi:///jndi/rmi://192.168.1.103:9840/jmxrmi"; String hostIp = config.getTarget().getConnection().getIp(); String port = config.getTarget().getConnection().getPort(); @@ -60,6 +62,7 @@ public class JmxCrawler extends Crawler{ for (Item item : config.getItems()) { List querys = item.getQueries(); + this.metrics = item.getMetrics(); for (Query q : querys) { this.whiteObjectNameList.add(q.getQuery()); this.keys.add(q.getKeys()); @@ -70,12 +73,15 @@ public class JmxCrawler extends Crawler{ this.doCrawler(); Map result = new LinkedHashMap<>(); + int idx = 0; for (List ks : this.keys) { for (String k : ks) { for (String key : re.keySet()) { if (k.equals(key)) { - result.put(key, re.get(key)); + String metricKey = this.metrics.get(idx); + result.put(metricKey, re.get(key)); + idx++; } } }