ResultSet 처리

This commit is contained in:
jackdaw@loafle.com 2017-04-26 12:13:05 +09:00
parent ed726f368b
commit 0e74eb7dd9
5 changed files with 52 additions and 55 deletions

View File

@ -42,11 +42,10 @@ public class SQLCrawler extends Crawler {
for (Item item : config.getItems()) {
Query query = item.getQuery();
OFResultSet resultSet = OFResultSetRow.newInstance(item);
Map<String,Integer> meta = resultSet.getMeta();
rs = stmt.executeQuery((String)query.getQueryInfo().get("query"));
rs = stmt.executeQuery((String)item.getQueryInfo().getQuery());
while(rs.next()) {
List<String> row = new ArrayList<>(Arrays.asList(new String[meta.size()]));

View File

@ -22,22 +22,22 @@
},
"items" : [
{
"metrics" : [
"net.connection_count"
],
"query":
"keys" : [
{
"metric":"net.connection_count",
"key":"Connections"
}
],
"queryInfo" : {
"query":"show status where `variable_name` = 'Connections'",
"query":"show status where `variable_name` = 'Connections'"
},
"mappingInfo" : {
"parseDirection" : "row",
"valueColumn" : "Value",
"keyColumns" : [
"Variable_name"
]
},
"keys" : [
"Connections"
]
}
}
]

View File

@ -22,17 +22,14 @@
},
"items" : [
{
"metrics" : [
"net.connection_count"
],
"query": {
"queryInfo":{
"query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle'" ,
"parseDirection":"col"
},
"keys" : [
"connection_count"
]
{
"metric":"net.connection_count",
"key" : "connection_count"
}
],
"queryInfo":{
"query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle'"
}
}
]

View File

@ -22,18 +22,17 @@
},
"items" : [
{
"metrics" : [
"net.connection_count"
],
"query": {
"queryInfo" : {
"query": "select count(session_id) as connection_count from sys.dm_exec_connections where session_id = @@SPID",
"parseDirection" : "col"
},
"keys" : [
"connection_count"
]
}
}
{
"metric" :"net.connection_count",
"key" : "connection_count"
}
],
"queryInfo" : {
"query": "select count(session_id) as connection_count from sys.dm_exec_connections where session_id = @@SPID"
},
"mappingInfo" : {}
}
]
}

View File

@ -23,22 +23,24 @@
},
"items" : [
{
"metrics" : [
"object[$0].db[$1].datafile_size",
"object[$0].db[$1].logfile_size"
"keys" : [
{
"metric" : "object[$0].db[$1].datafile_size",
"key" : "Data File(s) Size (KB)"
},
{
"metric" : "object[$0].db[$1].logfile_size",
"key" : "Log File(s) Size (KB)"
}
],
"query": {
"queryInfo" : {
"query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'",
"query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'"
},
"mappingInfo" : {
"parseDirection" : "row",
"arrayColumns" : [ "object_name","instance_name"],
"keyColumns" : ["counter_name"],
"valueColumn" : "cntr_value"
},
"keys" : [
"Data File(s) Size (KB)",
"Log File(s) Size (KB)"
]
}
}
]