fix config
This commit is contained in:
parent
eb8436f4f1
commit
e00e49b429
@ -3,7 +3,7 @@ package com.loafle.overflow.crawler.mongo;
|
|||||||
import com.loafle.overflow.crawler.Crawler;
|
import com.loafle.overflow.crawler.Crawler;
|
||||||
import com.loafle.overflow.crawler.config.Config;
|
import com.loafle.overflow.crawler.config.Config;
|
||||||
import com.loafle.overflow.crawler.config.Item;
|
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.OFResultSet;
|
||||||
import com.loafle.overflow.crawler.result.OFResultSetCol;
|
import com.loafle.overflow.crawler.result.OFResultSetCol;
|
||||||
import com.mongodb.MongoClient;
|
import com.mongodb.MongoClient;
|
||||||
@ -49,17 +49,18 @@ public class MongoCrawler extends Crawler {
|
|||||||
|
|
||||||
row = new ArrayList<>();
|
row = new ArrayList<>();
|
||||||
|
|
||||||
ofResultSet = new OFResultSetCol(item);
|
ofResultSet = OFResultSet.newInstance(item);
|
||||||
|
|
||||||
|
Map<String,Integer> metaMap = ofResultSet.getMeta();
|
||||||
|
|
||||||
dataBaseName = (String)item.getQueryInfo().get("dataBaseName");
|
dataBaseName = item.getQueryInfo().getExtend().get("dataBaseName");
|
||||||
statusCommand = (String)item.getQueryInfo().get("statusCommand");
|
statusCommand = item.getQueryInfo().getExtend().get("statusCommand");
|
||||||
|
|
||||||
MongoDatabase database = mongoClient.getDatabase(dataBaseName);
|
MongoDatabase database = mongoClient.getDatabase(dataBaseName);
|
||||||
Document serverStatus = database.runCommand(new Document(statusCommand, 1));
|
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>();
|
// Map<String,Object> resultMap = new HashMap<String, Object>();
|
||||||
// for (Map.Entry<String, Object> set : serverStatus.entrySet()){
|
// 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"));
|
// Map<String, String> re = (Map<String, String>) resultMap.get(query.getQueryInfo().get("query"));
|
||||||
|
|
||||||
for (int index =0 ; index < item.getKeys().size() ; ++index) {
|
for( String key : metaMap.keySet()) {
|
||||||
row.add(String.valueOf(re.get(item.getKeys().get(index))));
|
row.add(String.valueOf(re.get(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ofResultSet.addRow(row);
|
ofResultSet.addRow(row);
|
||||||
|
@ -20,27 +20,24 @@
|
|||||||
},
|
},
|
||||||
"items" : [
|
"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" : [
|
"keys" : [
|
||||||
"bits",
|
{"metric":"memory.usage.bits", "key":"bits"},
|
||||||
"resident",
|
{"metric":"memory.usage.rss", "key":"resident"},
|
||||||
"virtual",
|
{"metric":"memory.usage.vmem", "key":"virtual"},
|
||||||
"supported",
|
{"metric":"memory.usage.supported", "key":"supported"},
|
||||||
"mapped",
|
{"metric":"memory.usage.mapped", "key":"mapped"},
|
||||||
"mappedWithJournal"
|
{"metric":"memory.usage.mappedWithJournal", "key":"mappedWithJournal"}
|
||||||
]
|
],
|
||||||
|
"queryInfo" : {
|
||||||
|
"query": "mem",
|
||||||
|
"extend" : {
|
||||||
|
"dataBaseName":"admin",
|
||||||
|
"statusCommand": "serverStatus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mappingInfo" : {
|
||||||
|
"parseDirection" : "col"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user