From bf561f8226e97f4ace4f04bddf198175e91ee7f0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 18 Jun 2009 18:16:40 +0200 Subject: StatusRequestHandler: Nur verf?gbare Daten ?bermitteln --- .../RequestHandlers/StatusRequestHandler.cpp | 47 +++++++++++++--------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'src/Common') 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 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(¤tLoad, &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(¤tLoad, &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) {} } } -- cgit v1.2.3