summaryrefslogtreecommitdiffstats
path: root/src/Common/RequestHandlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/RequestHandlers')
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
index 95bdd30..7abcd7f 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.cpp
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -27,32 +27,43 @@ namespace RequestHandlers {
void StatusRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret) {
// TODO Require authentication
- unsigned long uptime, idleTime;
- unsigned long totalMem, freeMem, totalSwap, freeSwap;
- unsigned long currentLoad, nProcesses;
- float loadAvg1, loadAvg5, loadAvg15;
-
+ ret->setType("OK");
try {
+ unsigned long uptime, idleTime;
+
SystemManager::get()->getUptimeInfo(&uptime, &idleTime);
+
+ ret->add("uptime", uptime);
+ ret->add("idleTime", idleTime);
+ }
+ catch(Core::Exception e) {}
+
+ try {
+ unsigned long totalMem, freeMem, totalSwap, freeSwap;
+
SystemManager::get()->getMemoryInfo(&totalMem, &freeMem, &totalSwap, &freeSwap);
- SystemManager::get()->getLoadInfo(&currentLoad, &nProcesses, &loadAvg1, &loadAvg5, &loadAvg15);
+
+ ret->add("totalMem", totalMem);
+ ret->add("freeMem", freeMem);
+ ret->add("totalSwap", totalSwap);
+ ret->add("freeSwap", freeSwap);
}
catch(Core::Exception e) {}
- ret->setType("OK");
+ try {
+ unsigned long currentLoad, nProcesses;
+ float loadAvg1, loadAvg5, loadAvg15;
- ret->add("uptime", uptime);
- ret->add("idleTime", idleTime);
- ret->add("totalMem", totalMem);
- ret->add("freeMem", freeMem);
- ret->add("totalSwap", totalSwap);
- ret->add("freeSwap", freeSwap);
- ret->add("currentLoad", currentLoad);
- ret->add("nProcesses", nProcesses);
- ret->add("loadAvg1", loadAvg1);
- ret->add("loadAvg5", loadAvg5);
- ret->add("loadAvg15", loadAvg15);
+ SystemManager::get()->getLoadInfo(&currentLoad, &nProcesses, &loadAvg1, &loadAvg5, &loadAvg15);
+
+ ret->add("currentLoad", currentLoad);
+ ret->add("nProcesses", nProcesses);
+ ret->add("loadAvg1", loadAvg1);
+ ret->add("loadAvg5", loadAvg5);
+ ret->add("loadAvg15", loadAvg15);
+ }
+ catch(Core::Exception e) {}
}
}