提交 c57c4315 authored 作者: blu's avatar blu

feature: report status

上级 d8d018d0
...@@ -1285,30 +1285,37 @@ public: ...@@ -1285,30 +1285,37 @@ public:
ret["time"] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count(); ret["time"] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
ret["msg"] = "ok"; ret["msg"] = "ok";
ret["data"] = json(); ret["data"] = json();
json detail, summary;
string sn = req.get_param_value("sn"); string sn = req.get_param_value("sn");
try { try {
if(!sn.empty()) { if(!sn.empty() && sn != "all") {
if(this->peerData["ipcStatus"].count(sn) != 0){ if(this->peerData["ipcStatus"].count(sn) != 0){
json j; json j;
j[sn] = this->peerData["ipcStatus"][sn]; j[sn] = this->peerData["ipcStatus"][sn];
ret["data"] = j; detail = j;
}else{ }else{
ret["msg"] = "ipc not found"; ret["msg"] = "ipc not found";
ret["code"] = 1; ret["code"] = 1;
} }
}else if(sn == "all"){
detail = this->peerData["ipcStatus"];
}else{ }else{
ret["data"] = this->peerData["ipcStatus"]; // nop
} }
ret["data"]["detail"] = detail;
// get a copy to build summary // get a copy to build summary
json ipcsData = this->peerData["ipcStatus"]; json ipcsData = this->peerData["ipcStatus"];
int numIpcTotal = ipcsData.size();
int numIpcOnline = 0;
for(auto &[k,v]: ipcsData.items()){ for(auto &[k,v]: ipcsData.items()){
json diff = json::diff(v["expected"], v["current"]);
for(auto &[k,v]: this->peerData["modulecls"].items()){ if(diff.size() != 0) {
summary["problematic"].push_back(k);
}else{
summary["ok"].push_back(k);
} }
} }
ret["data"]["summary"] = summary;
} }
catch(exception &e) { catch(exception &e) {
ret["code"] = -1; ret["code"] = -1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论