diff --git a/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java b/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java index d243c90..e93c75c 100644 --- a/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java +++ b/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java @@ -25,7 +25,7 @@ public class WMICrawlerWindows extends WMICrawlerOS { String query = ""; Item cItem = null; - Query cQuery = null; + // int idxMetric = 0; @@ -37,8 +37,7 @@ public class WMICrawlerWindows extends WMICrawlerOS { cItem = config.getItems().get(cIndexI); - cQuery = cItem.getQuery(); - query = (String)cQuery.getQueryInfo().get("query"); + query = (String)cItem.getQueryInfo().get("query"); wmiconnect = connectServer(config); @@ -89,7 +88,7 @@ public class WMICrawlerWindows extends WMICrawlerOS { List row = null; - List columns = (List)citem.getQuery().getQueryInfo().get("arrayColumns"); + List columns = (List)citem.getQueryInfo().get("arrayColumns"); while (enumVariant.hasMoreElements()) { @@ -98,8 +97,8 @@ public class WMICrawlerWindows extends WMICrawlerOS { vItem = enumVariant.nextElement(); item = vItem.toDispatch(); - for( int indexI = 0; indexI < citem.getQuery().getKeys().size(); ++indexI) { - vValue = Dispatch.call(item, citem.getQuery().getKeys().get(indexI)); + for( int indexI = 0; indexI < citem.getKeys().size(); ++indexI) { + vValue = Dispatch.call(item, citem.getKeys().get(indexI)); value = vValue.toString(); vValue.safeRelease(); row.add(value); @@ -126,43 +125,6 @@ public class WMICrawlerWindows extends WMICrawlerOS { return ofResultSet; } - protected void getMultiValue(EnumVariant enumVariant,Query cQuery, Map resultMap) { - - Variant vItem = null; - Dispatch item = null; - - String indexColumn = (String)cQuery.getQueryInfo().get("indexColumn"); - - Variant vValue = null; - Variant vColumn = null; - String value = null; - String columnStr = null; - - - - while (enumVariant.hasMoreElements()) { - - vItem = enumVariant.nextElement(); - item = vItem.toDispatch(); - - vColumn = Dispatch.call(item, indexColumn); - columnStr = vColumn.toString(); - vColumn.safeRelease(); - - for( int indexI = 0; indexI < cQuery.getKeys().size(); ++indexI) { - - vValue = Dispatch.call(item, cQuery.getKeys().get(indexI)); - value = vValue.toString(); - - vValue.safeRelease(); - } - - vItem.safeRelease(); - item.safeRelease(); - } - - } - protected void getMultiValue(EnumVariant enumVariant, Query cQuery, Item cItem, int idxMetric, Map resultMap) { Variant vItem = null; diff --git a/src/test/resources/config/example.json b/src/test/resources/config/example.json index d0e7ef3..20ba905 100644 --- a/src/test/resources/config/example.json +++ b/src/test/resources/config/example.json @@ -15,47 +15,41 @@ "interval" : "10" }, "crawler" : { - "name":"redis_protocol_crawler", - "container":"network_crawler" + "name":"wmi_crawler", + "container":"java_proxy" }, "items" : [ - { "metrics": [ "cpu[$0].usage.system", "cpu[$0].usage.idle", "cpu[$0].usage.user" ], - "query": - { - "queryInfo": { - "query":"select PercentProcessorTime, PercentIdleTime, PercentUserTime,Name from Win32_PerfFormattedData_PerfOS_Processor", - "parseDirection" : "col", - "arrayColumns":["Name"] - }, - "keys":["PercentProcessorTime","PercentIdleTime", "PercentUserTime"] - } - + "queryInfo": { + "query":"select PercentProcessorTime, PercentIdleTime, PercentUserTime,Name from Win32_PerfFormattedData_PerfOS_Processor", + "parseDirection" : "col", + "arrayColumns":["Name"] + }, + "keys":["PercentProcessorTime","PercentIdleTime", "PercentUserTime"] } - ,{ + ,{ "metrics": [ "cpu.usage.system", "cpu.usage.idle", "cpu.usage.user" ], - "query": - { - "queryInfo": { - "query":"select PercentProcessorTime, PercentIdleTime, PercentUserTime,Name from Win32_PerfFormattedData_PerfOS_Processor where Name='_Total'", - "parseDirection" : "col" - }, - "keys":["PercentProcessorTime","PercentIdleTime", "PercentUserTime"] - } + "queryInfo": { + "query":"select PercentProcessorTime, PercentIdleTime, PercentUserTime,Name from Win32_PerfFormattedData_PerfOS_Processor where Name='_Total'", + "parseDirection" : "col" + + }, + "keys":["PercentProcessorTime","PercentIdleTime", "PercentUserTime"] + } - ] + ] } \ No newline at end of file