summaryrefslogtreecommitdiffstats
path: root/src/Common/RequestHandlers/StatusRequestHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/RequestHandlers/StatusRequestHandler.cpp')
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.cpp52
1 files changed, 15 insertions, 37 deletions
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
index 989ce7c..25d2f23 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.cpp
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -18,30 +18,13 @@
*/
#include "StatusRequestHandler.h"
-#include <Net/Exception.h>
-#include "../SystemBackend.h"
-#include "../Logger.h"
-
-#include <boost/bind.hpp>
+#include "../SystemManager.h"
namespace Mad {
namespace Common {
namespace RequestHandlers {
-void StatusRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
- if(packet->getType() != "GetStatus") {
- Logger::log(Logger::ERROR, "Received an unexpected packet.");
-
- XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
-
- sendPacket(ret);
-
- signalFinished();
- return;
- }
-
+void StatusRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret) {
// TODO Require authentication
unsigned long uptime, idleTime;
@@ -50,8 +33,6 @@ void StatusRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packe
float loadAvg1, loadAvg5, loadAvg15;
- XmlPacket ret;
-
try {
SystemManager::get()->getUptimeInfo(&uptime, &idleTime);
SystemManager::get()->getMemoryInfo(&totalMem, &freeMem, &totalSwap, &freeSwap);
@@ -59,22 +40,19 @@ void StatusRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packe
}
catch(Net::Exception e) {}
- ret.setType("OK");
-
- 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);
-
- sendPacket(ret);
- signalFinished();
+ ret->setType("OK");
+
+ 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);
}
}