diff --git a/pom.xml b/pom.xml
index 83cd5dc..4e9e42a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -124,6 +124,12 @@
1.0.0-SNAPSHOT
+
+ com.loafle.overflow
+ crawler
+ 1.0.0-SNAPSHOT
+
+
diff --git a/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java b/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java
index 96601ad..49436ab 100644
--- a/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java
+++ b/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java
@@ -28,5 +28,7 @@ public interface InfraDAO extends JpaRepository {
@Query("SELECT DISTINCT i.target FROM INFRA i WHERE i.probe IN (:probeList)")
List findAllTargetByProbeList(@Param("probeList") List probeList);
+ Infra findByTarget(Target target);
+
// List findAllByProbe(List probeList);
}
\ No newline at end of file
diff --git a/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java b/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java
index 822bcd5..90ab10c 100644
--- a/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java
+++ b/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java
@@ -60,5 +60,9 @@ public class InfraService {
// return null;
}
+ public Infra readByTarget(Target target) {
+ return this.infraDAO.findByTarget(target);
+ }
+
}
diff --git a/src/main/java/com/loafle/overflow/module/meta/dao/MetaSensorItemKeyDAO.java b/src/main/java/com/loafle/overflow/module/meta/dao/MetaSensorItemKeyDAO.java
new file mode 100644
index 0000000..20aec33
--- /dev/null
+++ b/src/main/java/com/loafle/overflow/module/meta/dao/MetaSensorItemKeyDAO.java
@@ -0,0 +1,18 @@
+package com.loafle.overflow.module.meta.dao;
+
+import com.loafle.overflow.module.meta.model.MetaCrawler;
+import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by snoop on 17. 8. 29.
+ */
+@Repository
+public interface MetaSensorItemKeyDAO extends JpaRepository {
+
+// @Query("SELECT msik.item.id, msik.key from MetaSensorItemKey msik WHERE msik.crawler.id = (:metaCrawler.id)")
+ List findAllByCrawler(MetaCrawler metaCrawler);
+}
diff --git a/src/main/java/com/loafle/overflow/module/meta/model/MetaSensorItemKey.java b/src/main/java/com/loafle/overflow/module/meta/model/MetaSensorItemKey.java
new file mode 100644
index 0000000..d7d79f6
--- /dev/null
+++ b/src/main/java/com/loafle/overflow/module/meta/model/MetaSensorItemKey.java
@@ -0,0 +1,66 @@
+package com.loafle.overflow.module.meta.model;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * Created by snoop on 17. 8. 29.
+ */
+@Entity
+@Table(name = "META_SENSOR_ITEM_KEY", schema = "public")
+public class MetaSensorItemKey {
+ private long id;
+ private MetaSensorItem item;
+ private String key;
+ private MetaCrawler crawler;
+ private Date createDate;
+
+ @Id
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "ITEM_ID", nullable = false)
+ public MetaSensorItem getItem() {
+ return item;
+ }
+
+ public void setItem(MetaSensorItem item) {
+ this.item = item;
+ }
+
+ @Column(name = "KEY", nullable = true, length = 100)
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "CRAWLER_ID", nullable = false)
+ public MetaCrawler getCrawler() {
+ return crawler;
+ }
+
+ public void setCrawler(MetaCrawler crawler) {
+ this.crawler = crawler;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+}
diff --git a/src/main/java/com/loafle/overflow/module/meta/service/MetaSensorItemKeyService.java b/src/main/java/com/loafle/overflow/module/meta/service/MetaSensorItemKeyService.java
new file mode 100644
index 0000000..7db37d0
--- /dev/null
+++ b/src/main/java/com/loafle/overflow/module/meta/service/MetaSensorItemKeyService.java
@@ -0,0 +1,36 @@
+package com.loafle.overflow.module.meta.service;
+
+import com.loafle.overflow.module.meta.dao.MetaSensorItemKeyDAO;
+import com.loafle.overflow.module.meta.model.MetaCrawler;
+import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by snoop on 17. 8. 29.
+ */
+@Service
+public class MetaSensorItemKeyService {
+
+ @Autowired
+ private MetaSensorItemKeyDAO metaSensorItemKeyDAO;
+
+
+
+ public Map readAllByCrawler(MetaCrawler metaCrawler) {
+
+ Map resultMap = new HashMap<>();
+
+ List resultList = this.metaSensorItemKeyDAO.findAllByCrawler(metaCrawler);
+
+ for(MetaSensorItemKey oa : resultList) {
+ resultMap.put(oa.getItem().getId(), oa.getKey());
+ }
+
+ return resultMap;
+ }
+}
diff --git a/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java b/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java
index f4a8975..78badab 100644
--- a/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java
+++ b/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java
@@ -2,22 +2,30 @@ package com.loafle.overflow.module.sensor.service;
import com.loafle.overflow.commons.model.PageParams;
import com.loafle.overflow.commons.utils.PageUtil;
+import com.loafle.overflow.commons.utils.StringConvertor;
+import com.loafle.overflow.crawler.config.*;
import com.loafle.overflow.module.domain.model.Domain;
-import com.loafle.overflow.module.infra.model.Infra;
+import com.loafle.overflow.module.infra.model.*;
import com.loafle.overflow.module.infra.service.InfraService;
import com.loafle.overflow.module.meta.model.MetaSensorStatus;
+import com.loafle.overflow.module.meta.service.MetaSensorItemKeyService;
import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.probe.service.ProbeService;
import com.loafle.overflow.module.sensor.dao.SensorDAO;
import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem;
import com.loafle.overflow.module.target.model.Target;
+import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Created by insanity on 17. 6. 28.
@@ -37,6 +45,11 @@ public class SensorService {
@Autowired
private SensorItemService sensorItemService;
+ @Autowired
+ private MetaSensorItemKeyService metaSensorItemKeyService;
+
+ private Map mappingMap = null;
+
public Sensor regist(Sensor sensor) {
return this.sensorDAO.save(sensor);
}
@@ -96,4 +109,130 @@ public class SensorService {
return sensor;
}
+
+ public String generateSensorConfig(Sensor sensor) throws IOException {
+
+// Sensor dbSensor = this.sensorDAO.findOne(sensor.getId());
+ PageParams pageParams = new PageParams();
+ pageParams.setPageNo(0);
+ pageParams.setCountPerPage(Integer.MAX_VALUE);
+ pageParams.setSortCol("id");
+ pageParams.setSortDirection("descending");
+ Page dbItemList = this.sensorItemService.readAllBySensor(sensor, pageParams);
+
+ List sensorItems = dbItemList.getContent();
+
+ if(sensorItems.size() <= 0) {
+ return "";
+ }
+ Sensor dbSensor = sensorItems.get(0).getSensor();
+
+ Infra infra = this.infraService.readByTarget(dbSensor.getTarget());
+
+// InfraHost infraHost = this.getInfraHost(infra);
+
+ com.loafle.overflow.module.infra.model.InfraService infraService = (com.loafle.overflow.module.infra.model.InfraService)infra;
+
+ Config config = new Config();
+ config.setId(String.valueOf(sensor.getId()));
+
+ com.loafle.overflow.crawler.config.Target target = new com.loafle.overflow.crawler.config.Target();
+ Connection connection = new Connection();
+ connection.setIp(StringConvertor.intToIp(infraService.getHost().getIp()));
+ connection.setPort(String.valueOf(infraService.getPort()));
+ connection.setPortType(infraService.getPortType());
+ connection.setSsl(infraService.isTlsType());
+
+ target.setConnection(connection);
+
+ Map auth = new HashMap<>();
+ 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
+
+ target.setAuth(auth);
+
+ config.setTarget(target);
+
+ Schedule schedule = new Schedule();
+ schedule.setInterval("5"); // FIXME: Interval
+
+ config.setSchedule(schedule);
+
+ Crawler crawler = new Crawler();
+ crawler.setName(dbSensor.getCrawler().getName());
+ crawler.setContainer("java_proxy"); // FIXME: if
+
+ config.setCrawler(crawler);
+
+ if(this.mappingMap == null) {
+ this.mappingMap = this.metaSensorItemKeyService.readAllByCrawler(dbSensor.getCrawler());
+ }
+
+ Item item = new Item();
+ Keys keys = null;
+ List keysList = new ArrayList<>();
+ for(SensorItem sItem : sensorItems) {
+ keys = new Keys();
+// sItem.getItem().get
+ keys.setMetric(sItem.getItem().getKey());
+ keys.setKey(this.mappingMap.get(sItem.getItem().getId()));
+ keysList.add(keys);
+ }
+ item.setKeys(keysList);
+
+ QueryInfo queryInfo = new QueryInfo();
+ queryInfo.setQuery("show status");
+
+ item.setQueryInfo(queryInfo);
+
+ MappingInfo mappingInfo = new MappingInfo();
+ mappingInfo.setParseDirection("row");
+ mappingInfo.setValueColumn("Value");
+
+ List keyColumns = new ArrayList<>();
+ keyColumns.add("Variable_name");
+
+ mappingInfo.setKeyColumns(keyColumns);
+
+ item.setMappingInfo(mappingInfo);
+
+ List- itemList = new ArrayList<>();
+ itemList.add(item);
+
+ config.setItems(itemList);
+
+
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ return objectMapper.writeValueAsString(config);
+ }
+
+
+ private InfraHost getInfraHost(Infra infra) {
+
+ switch (infra.getInfraType().getId()) {
+ case 1:
+ InfraMachine infraMachine = (InfraMachine)infra;
+ break;
+ case 2:
+ InfraHost infraHost = (InfraHost)infra;
+ return infraHost;
+ case 3:
+ InfraOS infraOS = (InfraOS)infra;
+ break;
+ case 4:
+ InfraOSApplication infraOSApplication = (InfraOSApplication)infra;
+ break;
+ case 5:
+ InfraOSDaemon infraOSDaemon = (InfraOSDaemon)infra;
+ case 6:
+ InfraOSPort infraOSPort = (InfraOSPort)infra;
+ break;
+ case 7:
+ com.loafle.overflow.module.infra.model.InfraService infraOSService = (com.loafle.overflow.module.infra.model.InfraService)infra;
+ return infraOSService.getHost();
+ }
+ return null;
+ }
}
diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql
index 60cd16b..5253a44 100644
--- a/src/main/resources/init.sql
+++ b/src/main/resources/init.sql
@@ -501,6 +501,187 @@ INSERT INTO meta_sensor_item (id,create_date,"key",name,type_id) VALUES (
'94','2017-06-26 20:10','Performance.mysql.schema.users.lost','Performance_mysql_schema_users_lost','6');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_dump_status','11','5');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_load_status','11','6');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_resize_status','11','7');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_pages_data','11','8');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_bytes_data','11','9');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_pages_dirty','11','10');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_bytes_dirty','11','11');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_pages_flushed','11','12');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_pages_free','11','13');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_pages_misc','11','14');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_pages_total','11','15');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_read_ahead_rnd','11','16');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_read_ahead','11','17');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_read_ahead_evicted','11','18');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_read_requests','11','19');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_reads','11','20');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_wait_free','11','21');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_buffer_pool_write_requests','11','22');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_fsyncs','11','23');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_pending_fsyncs','11','24');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_pending_reads','11','25');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_pending_writes','11','26');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_read','11','27');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_reads','11','28');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_writes','11','29');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_data_written','11','30');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_dblwr_pages_written','11','31');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_dblwr_writes','11','32');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_log_waits','11','33');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_log_write_requests','11','34');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_log_writes','11','35');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_os_log_fsyncs','11','36');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_os_log_pending_fsyncs','11','37');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_os_log_pending_writes','11','38');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_os_log_written','11','39');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_page_size','11','40');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_pages_created','11','41');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_pages_read','11','42');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_pages_written','11','43');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_row_lock_current_waits','11','44');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_row_lock_time','11','45');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_row_lock_time_avg','11','46');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_row_lock_time_max','11','47');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_row_lock_waits','11','48');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_rows_deleted','11','49');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_rows_inserted','11','50');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_rows_read','11','51');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_rows_updated','11','52');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_num_open_files','11','53');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_truncated_status_writes','11','54');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Innodb_available_undo_logs','11','55');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connection_errors_accept','11','56');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connection_errors_internal','11','57');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connection_errors_max_connections','11','58');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connection_errors_peer_address','11','59');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connection_errors_select','11','60');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connection_errors_tcpwrap','11','61');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Connections','11','62');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Max_used_connections','11','63');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Max_used_connections_time','11','64');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_accounts_lost','11','65');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_cond_classes_lost','11','66');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_cond_instances_lost','11','67');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_digest_lost','11','68');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_file_classes_lost','11','69');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_file_handles_lost','11','70');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_file_instances_lost','11','71');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_hosts_lost','11','72');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_index_stat_lost','11','73');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_locker_lost','11','74');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_memory_classes_lost','11','75');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_metadata_lock_lost','11','76');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_mutex_classes_lost','11','77');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_mutex_instances_lost','11','78');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_nested_statement_lost','11','79');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_prepared_statements_lost','11','80');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_program_lost','11','81');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_rwlock_classes_lost','11','82');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_rwlock_instances_lost','11','83');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_session_connect_attrs_lost','11','84');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_socket_classes_lost','11','85');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_socket_instances_lost','11','86');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_stage_classes_lost','11','87');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_statement_classes_lost','11','88');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_table_handles_lost','11','89');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_table_instances_lost','11','90');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_table_lock_stat_lost','11','91');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_thread_classes_lost','11','92');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_thread_instances_lost','11','93');
+INSERT INTO meta_sensor_item_key (create_date,"key",crawler_id,item_id) VALUES (
+'2017-06-26 19:49','Performance_schema_users_lost','11','94');
+
INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES (
1,'2017-07-27 15:29:48.634',23,26);
diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java
index 33e174a..363fde0 100644
--- a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java
+++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java
@@ -3,6 +3,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.infra.model.Infra;
import com.loafle.overflow.module.probe.service.ProbeService;
+import com.loafle.overflow.module.target.model.Target;
import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
@@ -11,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.io.IOException;
+
/**
* Created by snoop on 17. 7. 27.
*/
@@ -71,6 +74,19 @@ public class InfraServiceTest {
// this.infraService.readAllTargetByProbeList()
}
+ @Test
+ public void readByTarget() throws IOException {
+ Target target = new Target();
+ target.setId(1);
+
+ Infra infra = this.infraService.readByTarget(target);
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ String json = objectMapper.writeValueAsString(infra);
+
+ System.out.println(json);
+ }
+
// @Test
// public void readAllByProbeList() throws IOException {
//
diff --git a/src/test/java/com/loafle/overflow/module/meta/service/MetaSensorItemKeyServiceTest.java b/src/test/java/com/loafle/overflow/module/meta/service/MetaSensorItemKeyServiceTest.java
new file mode 100644
index 0000000..af4067a
--- /dev/null
+++ b/src/test/java/com/loafle/overflow/module/meta/service/MetaSensorItemKeyServiceTest.java
@@ -0,0 +1,36 @@
+package com.loafle.overflow.module.meta.service;
+
+import com.loafle.overflow.module.meta.model.MetaCrawler;
+import com.loafle.overflow.spring.AppConfigTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.Map;
+
+/**
+ * Created by snoop on 17. 8. 29.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {AppConfigTest.class})
+public class MetaSensorItemKeyServiceTest {
+
+ @Autowired
+ private MetaSensorItemKeyService metaSensorItemKeyService;
+
+
+ @Test
+ public void readAllByCrawler() {
+ MetaCrawler metaCrawler = new MetaCrawler();
+ metaCrawler.setId((short)11);
+
+ Map resultMap = this.metaSensorItemKeyService.readAllByCrawler(metaCrawler);
+
+ Assert.assertNotEquals(resultMap.size(), 0);
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/loafle/overflow/module/sensor/service/SensorServiceTest.java b/src/test/java/com/loafle/overflow/module/sensor/service/SensorServiceTest.java
index 62a5c8e..4368424 100644
--- a/src/test/java/com/loafle/overflow/module/sensor/service/SensorServiceTest.java
+++ b/src/test/java/com/loafle/overflow/module/sensor/service/SensorServiceTest.java
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.io.IOException;
import java.util.Date;
/**
@@ -58,6 +59,17 @@ public class SensorServiceTest {
System.out.println(json);
}
+ @Test
+ public void generateSensorConfig() throws IOException {
+
+ Sensor sensor = new Sensor();
+ sensor.setId(3);
+ String result = this.sensorService.generateSensorConfig(sensor);
+
+ System.out.println(result);
+
+ }
+
// @Test
// public void readAllByTarget() throws Exception {
// Target target = new Target();