From f85b6d5ab264910f272e69ce5997cebec54886ce Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 24 Feb 2009 22:03:34 +0100 Subject: Requests Status, DaemonStatus und UserList in XmlRequests umgewandelt --- src/Net/Packets/HostStatusPacket.cpp | 75 ------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 src/Net/Packets/HostStatusPacket.cpp (limited to 'src/Net/Packets/HostStatusPacket.cpp') diff --git a/src/Net/Packets/HostStatusPacket.cpp b/src/Net/Packets/HostStatusPacket.cpp deleted file mode 100644 index f998c2c..0000000 --- a/src/Net/Packets/HostStatusPacket.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * HostStatusPacket.cpp - * - * Copyright (C) 2008 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "HostStatusPacket.h" - -#include -#include -#include - - -namespace Mad { -namespace Net { -namespace Packets { - -HostStatusPacket::HostStatusPacket(Type type, uint16_t requestId, uint32_t uptime, uint32_t idleTime, - uint32_t totalMem, uint32_t freeMem, uint32_t totalSwap, uint32_t freeSwap, - uint32_t currentLoad, uint32_t nProcesses, float loadAvg1val, float loadAvg5val, float loadAvg15val) -: Packet(type, requestId), loadAvg1(loadAvg1val), loadAvg5(loadAvg5val), loadAvg15(loadAvg15val) -{ - char buf[20]; - std::snprintf(buf, sizeof(buf), "%.2f %.2f %.2f", loadAvg1, loadAvg5, loadAvg15); - - setLength(sizeof(CoreStatusData) + strlen(buf)); - coreStatusData = (CoreStatusData*)&rawData->data; - - coreStatusData->uptime = htonl(uptime); - coreStatusData->idleTime = htonl(idleTime); - - coreStatusData->totalMem = htonl(totalMem); - coreStatusData->freeMem = htonl(freeMem); - coreStatusData->totalSwap = htonl(totalSwap); - coreStatusData->freeSwap = htonl(freeSwap); - - coreStatusData->currentLoad = htonl(currentLoad); - coreStatusData->nProcesses = htonl(nProcesses); - - std::memcpy(coreStatusData->charData, buf, strlen(buf)); -} - -HostStatusPacket& HostStatusPacket::operator=(const Packet &p) { - Packet::operator=(p); - if(getLength() < sizeof(CoreStatusData)) - setLength(sizeof(CoreStatusData)); - coreStatusData = (CoreStatusData*)&rawData->data; - - parsePacket(); - - return *this; -} - -void HostStatusPacket::parsePacket() { - coreStatusData = (CoreStatusData*)&rawData->data; - - std::sscanf(std::string((char*)coreStatusData->charData, getLength()-sizeof(coreStatusData)).c_str(), "%f %f %f", &loadAvg1, &loadAvg5, &loadAvg15); -} - -} -} -} -- cgit v1.2.3