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.MetaSensorItemKey;
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.SensorItem;
import org.springframework.beans.factory.annotation.Autowired;
@ -51,15 +52,11 @@ public class GenerateUtil {
Map<String, Object> auth = new HashMap<>();
switch (metaCrawler.getId()) {
case 11: // mysql
{
if(metaCrawler.getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
auth.put("url", "jdbc:mysql://"+ StringConvertor.intToIp(infraService.getHost().getIp())+":"+String.valueOf(infraService.getPort()));
auth.put("id", "docker"); // FIXME: Auth Info
auth.put("pw", "qwer5795QWER"); // FIXME: Auth Info
}
break;
}
return auth;
}
@ -71,22 +68,17 @@ public class GenerateUtil {
String container = "";
switch (metaCrawler.getId()) {
case 1:
break;
case 2:
case 9:
case 10:
case 11:
case 13:
case 15:
if(metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|| metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|| metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
|| metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
|| metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
|| metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()) {
container = "java_proxy";
break;
default:
container = "java_proxy";
break;
}
else {
container = "network_proxy";
}
crawler.setContainer(container);
@ -99,10 +91,7 @@ public class GenerateUtil {
Connection connection = new Connection();
connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
switch (dbSensor.getCrawler().getId()) {
case 23:
{
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
connection.setPort("135");
connection.setPortType("tcp");
connection.setSsl(false);
@ -117,9 +106,6 @@ public class GenerateUtil {
target.setAuth(auth);
}
break;
}
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.InfraHost;
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.SensorItem;
import org.codehaus.jackson.map.ObjectMapper;
@ -49,11 +50,8 @@ public class InfraHostGenerator {
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
switch (dbSensor.getCrawler().getId()) {
case 23:
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, config);
default:
break;
}
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.module.infra.model.Infra;
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.SensorItem;
import org.codehaus.jackson.map.ObjectMapper;
@ -60,13 +61,8 @@ public class InfraServiceGenerator {
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
switch (dbSensor.getCrawler().getId()) {
case 11:
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, config);
// case 23:
// processWMI(sensorItems, keyMap, dbSensor, config);
default:
break;
}
ObjectMapper objectMapper = new ObjectMapper();

View File

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