summaryrefslogtreecommitdiffstats
path: root/src/modules/SystemBackendProc/SystemBackendProc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/SystemBackendProc/SystemBackendProc.cpp')
-rw-r--r--src/modules/SystemBackendProc/SystemBackendProc.cpp22
1 files changed, 8 insertions, 14 deletions
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;
}
}