Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2017-09-08 14:42:51 +09:00
commit aba7d6b1c0
5 changed files with 109 additions and 86 deletions

View File

@ -8,6 +8,7 @@ import com.loafle.overflow.module.infra.model.InfraHost;
import com.loafle.overflow.module.meta.model.MetaCrawler; import com.loafle.overflow.module.meta.model.MetaCrawler;
import com.loafle.overflow.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.module.meta.service.MetaSensorItemKeyService; import com.loafle.overflow.module.meta.service.MetaSensorItemKeyService;
import com.loafle.overflow.module.meta.type.MetaCrawlerEnum;
import com.loafle.overflow.module.sensor.model.Sensor; import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem; import com.loafle.overflow.module.sensor.model.SensorItem;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -51,15 +52,11 @@ public class GenerateUtil {
Map<String, Object> auth = new HashMap<>(); Map<String, Object> auth = new HashMap<>();
switch (metaCrawler.getId()) { if(metaCrawler.getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
case 11: // mysql auth.put("url", "jdbc:mysql://"+ StringConvertor.intToIp(infraService.getHost().getIp())+":"+String.valueOf(infraService.getPort()));
{ auth.put("id", "docker"); // FIXME: Auth Info
auth.put("url", "jdbc:mysql://"+ StringConvertor.intToIp(infraService.getHost().getIp())+":"+String.valueOf(infraService.getPort())); auth.put("pw", "qwer5795QWER"); // FIXME: Auth Info
auth.put("id", "docker"); // FIXME: Auth Info }
auth.put("pw", "qwer5795QWER"); // FIXME: Auth Info
}
break;
}
return auth; return auth;
} }
@ -71,22 +68,17 @@ public class GenerateUtil {
String container = ""; String container = "";
switch (metaCrawler.getId()) { if(metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
case 1: || metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
break; || metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
case 2: || metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
case 9: || metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
case 10: || metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()) {
case 11: container = "java_proxy";
case 13: }
case 15: else {
container = "java_proxy"; container = "network_proxy";
break;
default:
container = "java_proxy";
break;
} }
crawler.setContainer(container); crawler.setContainer(container);
@ -99,28 +91,22 @@ public class GenerateUtil {
Connection connection = new Connection(); Connection connection = new Connection();
connection.setIp(StringConvertor.intToIp(infraHost.getIp())); connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
connection.setPort("135");
connection.setPortType("tcp");
connection.setSsl(false);
switch (dbSensor.getCrawler().getId()) { target.setConnection(connection);
case 23:
{
connection.setPort("135");
connection.setPortType("tcp");
connection.setSsl(false);
target.setConnection(connection); // FIXME: load crawler Auth Info
Map<String, Object> auth = new HashMap<>();
auth.put("id", "administrator");
auth.put("pw", "dbseogns18");
// FIXME: load crawler Auth Info target.setAuth(auth);
Map<String, Object> auth = new HashMap<>();
auth.put("id", "administrator");
auth.put("pw", "dbseogns18");
target.setAuth(auth);
}
break;
} }
return target; return target;
} }

View File

@ -6,6 +6,7 @@ import com.loafle.overflow.crawler.config.Schedule;
import com.loafle.overflow.module.infra.model.Infra; import com.loafle.overflow.module.infra.model.Infra;
import com.loafle.overflow.module.infra.model.InfraHost; import com.loafle.overflow.module.infra.model.InfraHost;
import com.loafle.overflow.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.module.meta.type.MetaCrawlerEnum;
import com.loafle.overflow.module.sensor.model.Sensor; import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem; import com.loafle.overflow.module.sensor.model.SensorItem;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
@ -49,11 +50,8 @@ public class InfraHostGenerator {
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler()); Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
switch (dbSensor.getCrawler().getId()) { if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
case 23: this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, config);
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, config);
default:
break;
} }
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();

View File

@ -7,6 +7,7 @@ import com.loafle.overflow.crawler.config.Crawler;
import com.loafle.overflow.crawler.config.Schedule; import com.loafle.overflow.crawler.config.Schedule;
import com.loafle.overflow.module.infra.model.Infra; import com.loafle.overflow.module.infra.model.Infra;
import com.loafle.overflow.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.module.meta.type.MetaCrawlerEnum;
import com.loafle.overflow.module.sensor.model.Sensor; import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem; import com.loafle.overflow.module.sensor.model.SensorItem;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
@ -60,13 +61,8 @@ public class InfraServiceGenerator {
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler()); Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
switch (dbSensor.getCrawler().getId()) { if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
case 11: this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, config);
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, config);
// case 23:
// processWMI(sensorItems, keyMap, dbSensor, config);
default:
break;
} }
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();

View File

@ -1,7 +1,6 @@
package com.loafle.overflow.module.generator.service; package com.loafle.overflow.module.generator.service;
import com.loafle.overflow.crawler.config.*; import com.loafle.overflow.crawler.config.*;
import com.loafle.overflow.module.meta.model.MetaCrawler;
import com.loafle.overflow.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.module.sensor.model.Sensor; import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem; import com.loafle.overflow.module.sensor.model.SensorItem;
@ -117,37 +116,37 @@ public class InfraServiceMysqlGenerator {
// return objectMapper.writeValueAsString(config); // return objectMapper.writeValueAsString(config);
} }
public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList, QueryInfo queryInfo, MappingInfo mappingInfo) { // public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList, QueryInfo queryInfo, MappingInfo mappingInfo) {
//
switch (metaCrawler.getId()) { // switch (metaCrawler.getId()) {
case 11: // mysql // case 11: // mysql
{ // {
String query = "show status where "; // String query = "show status where ";
// queryInfo.setQuery("show status where "); //// queryInfo.setQuery("show status where ");
//
Keys keys = null; // Keys keys = null;
for(int indexI = 0 ; indexI < keysList.size(); ++indexI) { // for(int indexI = 0 ; indexI < keysList.size(); ++indexI) {
keys = keysList.get(indexI); // keys = keysList.get(indexI);
query += "variable_name = '"; // query += "variable_name = '";
query += keys.getKey(); // query += keys.getKey();
query += "'"; // query += "'";
if(indexI + 1 < keysList.size()) { // if(indexI + 1 < keysList.size()) {
query += " or "; // query += " or ";
} // }
} // }
//
queryInfo.setQuery(query); // queryInfo.setQuery(query);
//
mappingInfo.setParseDirection("row"); // mappingInfo.setParseDirection("row");
mappingInfo.setValueColumn("Value"); // mappingInfo.setValueColumn("Value");
//
List<String> keyColumns = new ArrayList<>(); // List<String> keyColumns = new ArrayList<>();
keyColumns.add("Variable_name"); // keyColumns.add("Variable_name");
//
mappingInfo.setKeyColumns(keyColumns); // mappingInfo.setKeyColumns(keyColumns);
} // }
break; // break;
} // }
//
} // }
} }

View File

@ -0,0 +1,44 @@
package com.loafle.overflow.module.meta.type;
/**
* Created by snoop on 17. 9. 8.
*/
public enum MetaCrawlerEnum {
ACTIVEDIRECTORY_CRAWLER((short)1),
CASSANDRA_CRAWLER((short)2),
DHCP_CRAWLER((short)3),
DNS_CRAWLER((short)4),
FTP_CRAWLER((short)5),
HTTP_CRAWLER((short)6),
IMAP_CRAWLER((short)7),
LDAP_CRAWLER((short)8),
MONGODB_CRAWLER((short)9),
MSSQL_CRAWLER((short)10),
MYSQL_CRAWLER((short)11),
NETBIOS_CRAWLER((short)12),
ORACLE_CRAWLER((short)13),
POP_CRAWLER((short)14),
POSTGRESQL_CRAWLER((short)15),
REDIS_CRAWLER((short)16),
RMI_CRAWLER((short)17),
SMB_CRAWLER((short)18),
SMTP_CRAWLER((short)19),
SNMP_CRAWLER((short)20),
SSH_CRAWLER((short)21),
TELNET_CRAWLER((short)22),
WMI_CRAWLER((short)23),
UNKNOWN_CRAWLER((short)24);
private short value;
private MetaCrawlerEnum(short value) {
this.value = value;
}
public short getValue() {
return this.value;
}
}