JMX Config generate Test
This commit is contained in:
parent
4994ef7421
commit
42529545ce
|
@ -60,7 +60,8 @@ public class GenerateUtil {
|
|||
|| metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()) {
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
container = "java_proxy";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.loafle.overflow.module.auth.model.AuthCrawler;
|
|||
import com.loafle.overflow.module.auth.service.AuthCrawlerService;
|
||||
import com.loafle.overflow.module.infra.model.Infra;
|
||||
import com.loafle.overflow.module.infra.model.InfraService;
|
||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.module.meta.type.MetaCrawlerEnum;
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
|
@ -32,6 +33,9 @@ public class InfraServiceGenerator {
|
|||
@Autowired
|
||||
private InfraServiceMysqlGenerator infraServiceMysqlGenerator;
|
||||
|
||||
@Autowired
|
||||
private InfraServiceJMXGenerator infraServiceJMXGenerator;
|
||||
|
||||
@Autowired
|
||||
private AuthCrawlerService authCrawlerService;
|
||||
|
||||
|
@ -62,6 +66,8 @@ public class InfraServiceGenerator {
|
|||
|
||||
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, config);
|
||||
} else if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, config);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
@ -94,6 +100,10 @@ public class InfraServiceGenerator {
|
|||
auth.put("url", "jdbc:mysql://"+ StringConvertor.intToIp(infraService.getHost().getIp())+":"+String.valueOf(infraService.getPort()));
|
||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
} else if (sensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
connection.setPort("9840");
|
||||
}
|
||||
|
||||
target.setAuth(auth);
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
package com.loafle.overflow.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.crawler.config.*;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.module.sensor.model.SensorItem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 9. 11.
|
||||
*/
|
||||
@Service("InfraServiceJMXGenerator")
|
||||
public class InfraServiceJMXGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws IOException {
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
Item item = null;
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
Map<String, Object> extendMap = new HashMap<>();
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
|
||||
for (Map.Entry<String, List<MetaSensorItemKey>> elms : metricMap.entrySet()) {
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
buffer.setLength(0);
|
||||
|
||||
buffer.append(elms.getKey());
|
||||
|
||||
for (int idx = 0; idx < elms.getValue().size(); idx++) {
|
||||
tempItemKey = elms.getValue().get(idx);
|
||||
|
||||
buffer.append(tempItemKey.getKey());
|
||||
|
||||
keys = new Keys();
|
||||
keys.setKey(tempItemKey.getKey());
|
||||
keys.setMetric(tempItemKey.getItem().getKey());
|
||||
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
List<String> aliases = null;
|
||||
List<String> arrayCol = null;
|
||||
|
||||
if (json != null && json.length() > 0) {
|
||||
HashMap<String, Object> optionMap;
|
||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("aliases");
|
||||
|
||||
if (obj != null) {
|
||||
aliases = (List<String>)obj;
|
||||
}
|
||||
|
||||
obj = optionMap.get("arrayColumns");
|
||||
if (obj != null) {
|
||||
arrayCol = (List<String>)obj;
|
||||
}
|
||||
}
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(tempItemKey.getFroms());
|
||||
queryInfo.setExtend(extendMap);
|
||||
|
||||
extendMap.put("aliases", aliases);
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setArrayColumns(arrayCol);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
itemList.add(item);
|
||||
}
|
||||
config.setItems(itemList);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -791,37 +791,37 @@ INSERT INTO meta_sensor_item_key (create_date,"key",froms,option_json,crawler_id
|
|||
'2017-06-26 19:49','FreeSpace','Win32_LogicalDisk','{"arrayColumns": ["Caption"],"appends": ["Caption"]}','23','106');
|
||||
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','maxThreads','*Catalina:type=ThreadPool,*','{"arrayColumns" : [ "ThreadPool" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','107');
|
||||
'2017-06-26 19:49','maxThreads','*Catalina:type=ThreadPool,*','{"arrayColumns" : [ "ThreadPool" ], "aliases":[{"key":"Catalina:type","index":0}] } ','17','107');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','currentThreadCount','*Catalina:type=ThreadPool,*','{"arrayColumns" : [ "ThreadPool" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','108');
|
||||
'2017-06-26 19:49','currentThreadCount','*Catalina:type=ThreadPool,*','{"arrayColumns" : [ "ThreadPool" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','108');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','currentThreadsBusy','*Catalina:type=ThreadPool,*','{"arrayColumns" : [ "ThreadPool" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','109');
|
||||
'2017-06-26 19:49','currentThreadsBusy','*Catalina:type=ThreadPool,*','{"arrayColumns" : [ "ThreadPool" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','109');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','bytesSent','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','110');
|
||||
'2017-06-26 19:49','bytesSent','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','110');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','bytesReceived','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','111');
|
||||
'2017-06-26 19:49','bytesReceived','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','111');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','errorCount','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','112');
|
||||
'2017-06-26 19:49','errorCount','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','112');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','requestCount','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','113');
|
||||
'2017-06-26 19:49','requestCount','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','113');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','maxTime','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','114');
|
||||
'2017-06-26 19:49','maxTime','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','114');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','processingTime','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','115');
|
||||
'2017-06-26 19:49','processingTime','*Catalina:type=GlobalRequestProcessor,*','{"arrayColumns" : [ "GlobalRequestProcessor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','115');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','processingTime','*Catalina:j2eeType=Servlet,*','{"arrayColumns" : [ "Servlet" ]}, {"aliases:[{"key":"Catalina:j2eeType","index":0}]"}','17','116');
|
||||
'2017-06-26 19:49','processingTime','*Catalina:j2eeType=Servlet,*','{"arrayColumns" : [ "Servlet" ], "aliases":[{"key":"Catalina:j2eeType","index":0}]}','17','116');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','errorCount','*Catalina:j2eeType=Servlet,*','{"arrayColumns" : [ "Servlet" ]}, {"aliases:[{"key":"Catalina:j2eeType","index":0}]"}','17','117');
|
||||
'2017-06-26 19:49','errorCount','*Catalina:j2eeType=Servlet,*','{"arrayColumns" : [ "Servlet" ], "aliases":[{"key":"Catalina:j2eeType","index":0}]}','17','117');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','requestCount','*Catalina:j2eeType=Servlet,*','{"arrayColumns" : [ "Servlet" ]}, {"aliases:[{"key":"Catalina:j2eeType","index":0}]"}','17','118');
|
||||
'2017-06-26 19:49','requestCount','*Catalina:j2eeType=Servlet,*','{"arrayColumns" : [ "Servlet" ], "aliases":[{"key":"Catalina:j2eeType","index":0}]}','17','118');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','accessCount','*Catalina:type=StringCache,*','{"arrayColumns" : [ "StringCache" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','119');
|
||||
'2017-06-26 19:49','accessCount','*Catalina:type=StringCache,*','{"arrayColumns" : [ "StringCache" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','119');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','hitCount','*Catalina:type=StringCache,*','{"arrayColumns" : [ "StringCache" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','120');
|
||||
'2017-06-26 19:49','hitCount','*Catalina:type=StringCache,*','{"arrayColumns" : [ "StringCache" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','120');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','jspCount','*Catalina:type=JspMonitor,*','{"arrayColumns" : [ "JspMonitor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','121');
|
||||
'2017-06-26 19:49','jspCount','*Catalina:type=JspMonitor,*','{"arrayColumns" : [ "JspMonitor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','121');
|
||||
INSERT INTO meta_sensor_item_key (create_date,"key","froms",option_json,crawler_id,item_id) VALUES (
|
||||
'2017-06-26 19:49','jspReloadCount','*Catalina:type=JspMonitor,*','{"arrayColumns" : [ "JspMonitor" ]}, {"aliases:[{"key":"Catalina:type","index":0}]"} ','17','122');
|
||||
'2017-06-26 19:49','jspReloadCount','*Catalina:type=JspMonitor,*','{"arrayColumns" : [ "JspMonitor" ], "aliases":[{"key":"Catalina:type","index":0}]} ','17','122');
|
||||
|
||||
INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES (
|
||||
1,'2017-07-27 15:29:48.634',23,26);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class SensorServiceTest {
|
|||
public void generateSensorConfig() throws IOException {
|
||||
|
||||
Sensor sensor = new Sensor();
|
||||
sensor.setId(3);
|
||||
sensor.setId(5);
|
||||
String result = this.sensorService.generateSensorConfig(sensor);
|
||||
|
||||
System.out.println(result);
|
||||
|
|
Loading…
Reference in New Issue
Block a user