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()) { for (Item item : config.getItems()) {
Query query = item.getQuery();
OFResultSet resultSet = OFResultSetRow.newInstance(item); OFResultSet resultSet = OFResultSetRow.newInstance(item);
Map<String,Integer> meta = resultSet.getMeta(); Map<String,Integer> meta = resultSet.getMeta();
rs = stmt.executeQuery((String)query.getQueryInfo().get("query")); rs = stmt.executeQuery((String)item.getQueryInfo().getQuery());
while(rs.next()) { while(rs.next()) {
List<String> row = new ArrayList<>(Arrays.asList(new String[meta.size()])); List<String> row = new ArrayList<>(Arrays.asList(new String[meta.size()]));

View File

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

View File

@ -22,18 +22,15 @@
}, },
"items" : [ "items" : [
{ {
"metrics" : [ "keys" : [
"net.connection_count" {
], "metric":"net.connection_count",
"query": { "key" : "connection_count"
"queryInfo":{
"query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle'" ,
"parseDirection":"col"
},
"keys" : [
"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" : [ "items" : [
{ {
"metrics" : [ "keys" : [
"net.connection_count" {
], "metric" :"net.connection_count",
"query": { "key" : "connection_count"
"queryInfo" : {
"query": "select count(session_id) as connection_count from sys.dm_exec_connections where session_id = @@SPID",
"parseDirection" : "col"
},
"keys" : [
"connection_count"
]
} }
],
"queryInfo" : {
"query": "select count(session_id) as connection_count from sys.dm_exec_connections where session_id = @@SPID"
},
"mappingInfo" : {}
} }
] ]
} }

View File

@ -23,23 +23,25 @@
}, },
"items" : [ "items" : [
{ {
"metrics" : [ "keys" : [
"object[$0].db[$1].datafile_size", {
"object[$0].db[$1].logfile_size" "metric" : "object[$0].db[$1].datafile_size",
], "key" : "Data 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'", "metric" : "object[$0].db[$1].logfile_size",
"parseDirection" : "row", "key" : "Log File(s) Size (KB)"
"arrayColumns" : [ "object_name","instance_name"],
"keyColumns" : ["counter_name"],
"valueColumn" : "cntr_value"
},
"keys" : [
"Data File(s) Size (KB)",
"Log File(s) Size (KB)"
]
} }
],
"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'"
},
"mappingInfo" : {
"parseDirection" : "row",
"arrayColumns" : [ "object_name","instance_name"],
"keyColumns" : ["counter_name"],
"valueColumn" : "cntr_value"
}
} }
] ]
} }