fix config

This commit is contained in:
snoop 2017-04-26 12:19:22 +09:00
parent eb8436f4f1
commit e00e49b429
2 changed files with 25 additions and 27 deletions

View File

@ -3,7 +3,7 @@ package com.loafle.overflow.crawler.mongo;
import com.loafle.overflow.crawler.Crawler;
import com.loafle.overflow.crawler.config.Config;
import com.loafle.overflow.crawler.config.Item;
import com.loafle.overflow.crawler.config.Query;
import com.loafle.overflow.crawler.result.OFResultSet;
import com.loafle.overflow.crawler.result.OFResultSetCol;
import com.mongodb.MongoClient;
@ -49,17 +49,18 @@ public class MongoCrawler extends Crawler {
row = new ArrayList<>();
ofResultSet = new OFResultSetCol(item);
ofResultSet = OFResultSet.newInstance(item);
Map<String,Integer> metaMap = ofResultSet.getMeta();
dataBaseName = (String)item.getQueryInfo().get("dataBaseName");
statusCommand = (String)item.getQueryInfo().get("statusCommand");
dataBaseName = item.getQueryInfo().getExtend().get("dataBaseName");
statusCommand = item.getQueryInfo().getExtend().get("statusCommand");
MongoDatabase database = mongoClient.getDatabase(dataBaseName);
Document serverStatus = database.runCommand(new Document(statusCommand, 1));
Map<String, String> re = (Map<String, String>)serverStatus.get(item.getQueryInfo().get("query"));
Map<String, String> re = (Map<String, String>)serverStatus.get(item.getQueryInfo().getQuery());
// Map<String,Object> resultMap = new HashMap<String, Object>();
// for (Map.Entry<String, Object> set : serverStatus.entrySet()){
@ -70,8 +71,8 @@ public class MongoCrawler extends Crawler {
// Map<String, String> re = (Map<String, String>) resultMap.get(query.getQueryInfo().get("query"));
for (int index =0 ; index < item.getKeys().size() ; ++index) {
row.add(String.valueOf(re.get(item.getKeys().get(index))));
for( String key : metaMap.keySet()) {
row.add(String.valueOf(re.get(key)));
}
ofResultSet.addRow(row);

View File

@ -20,27 +20,24 @@
},
"items" : [
{
"metrics" : [
"memory.usage.bits",
"memory.usage.rss",
"memory.usage.vmem",
"memory.usage.supported",
"memory.usage.mapped",
"memory.usage.mappedWithJournal"
],
"queryInfo": {
"query":"mem",
"dataBaseName":"admin",
"statusCommand":"serverStatus"
},
"keys" : [
"bits",
"resident",
"virtual",
"supported",
"mapped",
"mappedWithJournal"
]
{"metric":"memory.usage.bits", "key":"bits"},
{"metric":"memory.usage.rss", "key":"resident"},
{"metric":"memory.usage.vmem", "key":"virtual"},
{"metric":"memory.usage.supported", "key":"supported"},
{"metric":"memory.usage.mapped", "key":"mapped"},
{"metric":"memory.usage.mappedWithJournal", "key":"mappedWithJournal"}
],
"queryInfo" : {
"query": "mem",
"extend" : {
"dataBaseName":"admin",
"statusCommand": "serverStatus"
}
},
"mappingInfo" : {
"parseDirection" : "col"
}
}
]
}