summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/SystemBackendPosix/SystemBackendPosix.cpp18
-rw-r--r--src/modules/SystemBackendPosix/SystemBackendPosix.h6
-rw-r--r--src/modules/SystemBackendProc/SystemBackendProc.cpp22
-rw-r--r--src/modules/SystemBackendProc/SystemBackendProc.h6
4 files changed, 24 insertions, 28 deletions
diff --git a/src/modules/SystemBackendPosix/SystemBackendPosix.cpp b/src/modules/SystemBackendPosix/SystemBackendPosix.cpp
index a215c86..35e6c4f 100644
--- a/src/modules/SystemBackendPosix/SystemBackendPosix.cpp
+++ b/src/modules/SystemBackendPosix/SystemBackendPosix.cpp
@@ -29,12 +29,12 @@ namespace Modules {
boost::shared_ptr<SystemBackendPosix> SystemBackendPosix::backend;
-bool SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) {
+void SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) throw(Net::Exception) {
Net::ThreadManager::get()->detach();
FILE *pipe = popen("/bin/df -P -k", "r");
if(!pipe)
- return false;
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
char buffer[1024];
std::string output;
@@ -47,7 +47,7 @@ bool SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *f
pclose(pipe);
if(!fsInfo)
- return true;
+ return;
fsInfo->clear();
@@ -75,19 +75,21 @@ bool SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *f
delete [] mountedOn;
}
- return true;
+ return;
}
-bool SystemBackendPosix::shutdown() {
+void SystemBackendPosix::shutdown() throw(Net::Exception) {
Net::ThreadManager::get()->detach();
- return (system("/sbin/halt") == 0);
+ if(system("/sbin/halt") != 0)
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
}
-bool SystemBackendPosix::reboot() {
+void SystemBackendPosix::reboot() throw(Net::Exception) {
Net::ThreadManager::get()->detach();
- return (system("/sbin/reboot") == 0);
+ if(system("/sbin/reboot") != 0)
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
}
}
diff --git a/src/modules/SystemBackendPosix/SystemBackendPosix.h b/src/modules/SystemBackendPosix/SystemBackendPosix.h
index 2ec026d..3cdb43c 100644
--- a/src/modules/SystemBackendPosix/SystemBackendPosix.h
+++ b/src/modules/SystemBackendPosix/SystemBackendPosix.h
@@ -38,10 +38,10 @@ class SystemBackendPosix : public Common::SystemBackend {
static boost::shared_ptr<SystemBackendPosix> backend;
protected:
- virtual bool getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo);
+ virtual void getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) throw(Net::Exception);
- virtual bool shutdown();
- virtual bool reboot();
+ virtual void shutdown() throw(Net::Exception);
+ virtual void reboot() throw(Net::Exception);
public:
~SystemBackendPosix();
diff --git a/src/modules/SystemBackendProc/SystemBackendProc.cpp b/src/modules/SystemBackendProc/SystemBackendProc.cpp
index 1888227..ab074b2 100644
--- a/src/modules/SystemBackendProc/SystemBackendProc.cpp
+++ b/src/modules/SystemBackendProc/SystemBackendProc.cpp
@@ -29,18 +29,18 @@ namespace Modules {
boost::shared_ptr<SystemBackendProc> SystemBackendProc::backend;
-bool SystemBackendProc::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) {
+void SystemBackendProc::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Net::Exception) {
Net::ThreadManager::get()->detach();
uptimeFile.seekg(0, std::ios::beg);
if(!uptimeFile.good())
- return false;
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
float f;
uptimeFile >> f;
if(!uptimeFile.good())
- return false;
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
if(uptime)
*uptime = (unsigned long)f;
@@ -48,11 +48,9 @@ bool SystemBackendProc::getUptimeInfo(unsigned long *uptime, unsigned long *idle
uptimeFile >> f;
if(uptimeFile.good() && idleTime)
*idleTime = (unsigned long)f;
-
- return true;
}
-bool SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) {
+void SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Net::Exception) {
Net::ThreadManager::get()->detach();
if(totalMem)
@@ -67,7 +65,7 @@ bool SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *fr
meminfoFile.seekg(0, std::ios::beg);
if(!meminfoFile.good())
- return false;
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
while(!meminfoFile.eof() && meminfoFile.good()) {
std::string line;
@@ -92,11 +90,9 @@ bool SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *fr
if((!totalMem || *totalMem) && (!freeMem || *freeMem) && (!totalSwap || *totalSwap) && (!freeSwap || *freeSwap))
break;
}
-
- return true;
}
-bool SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) {
+void SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Net::Exception) {
Net::ThreadManager::get()->detach();
unsigned long currentLoadValue = 0, nProcessesValue = 0;
@@ -105,13 +101,13 @@ bool SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *n
loadFile.seekg(0, std::ios::beg);
if(!loadFile.good())
- return false;
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
std::string line;
std::getline(loadFile, line);
if(line.empty())
- return false;
+ throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
std::sscanf(line.c_str(), "%f %f %f %lu/%lu", &loadAvg1Value, &loadAvg5Value, &loadAvg15Value, &currentLoadValue, &nProcessesValue);
@@ -129,8 +125,6 @@ bool SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *n
if(loadAvg15)
*loadAvg15 = loadAvg15Value;
-
- return true;
}
}
diff --git a/src/modules/SystemBackendProc/SystemBackendProc.h b/src/modules/SystemBackendProc/SystemBackendProc.h
index 9b36df4..eb2f8a6 100644
--- a/src/modules/SystemBackendProc/SystemBackendProc.h
+++ b/src/modules/SystemBackendProc/SystemBackendProc.h
@@ -39,9 +39,9 @@ class SystemBackendProc : public Common::SystemBackend, boost::noncopyable {
SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {}
protected:
- virtual bool getUptimeInfo(unsigned long *uptime, unsigned long *idleTime);
- virtual bool getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap);
- virtual bool getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15);
+ virtual void getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Net::Exception);
+ virtual void getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Net::Exception);
+ virtual void getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Net::Exception);
public:
static void registerBackend() {