4 #include <Poco/JSON/Object.h>
5 #include <Poco/JSON/Array.h>
6 #include <Poco/JSON/JSON.h>
7 #include <Poco/JSON/Stringifier.h>
8 #include <Poco/JSON/Parser.h>
9 #include <Poco/JSON/JSONException.h>
10 #include <Poco/Dynamic/Var.h>
23 :
cpu(0.0),
iowait(0.0), vramUsed(0), vramUsedPercent(0.0), rramUsed(0), rramUsedPercent(0.0),
24 diskUsed(0), diskUsedPercent(0.0),
processes(0), processesPercent(0.0),
threads(0), threadsPercent(0.0), loadAverage(0.0)
29 :
cpu(0.0),
iowait(0.0), vramUsed(0), vramUsedPercent(0.0), rramUsed(0), rramUsedPercent(0.0),
30 diskUsed(0), diskUsedPercent(0.0),
processes(0), processesPercent(0.0),
threads(0), threadsPercent(0.0), loadAverage(0.0)
36 :
cpu(0.0),
iowait(0.0), vramUsed(0), vramUsedPercent(0.0), rramUsed(0), rramUsedPercent(0.0),
37 diskUsed(0), diskUsedPercent(0.0),
processes(0), processesPercent(0.0),
threads(0), threadsPercent(0.0), loadAverage(0.0)
39 (*this) = std::forward<ResourceUsage>(rhs);
67 cpu = std::move(rhs.cpu);
68 iowait = std::move(rhs.iowait);
77 threads = std::move(rhs.threads);
120 std::ostringstream ostr;
121 ostr << resourceUsage.
cpu << delimiter
122 << resourceUsage.
iowait << delimiter
139 resourceUsage.
clear();
140 std::string str(rhs);
141 std::replace(str.begin(), str.end(),
delimiter,
' ');
142 std::stringstream istr(str);
143 std::istream_iterator<std::string> iit(istr);
144 std::istream_iterator<std::string> eos;
147 std::istringstream(*iit) >> resourceUsage.
cpu;
150 std::istringstream(*iit) >> resourceUsage.
iowait;
168 std::istringstream(*iit) >> resourceUsage.
loadAverage;
173 :
inherited(), resourceUsage(resourceUsage_)
178 :
inherited(), resourceUsage(resourceUsage_)
189 Poco::JSON::Object::Ptr
pObj =
new Poco::JSON::Object();
203 std::stringstream ostr;
204 Poco::JSON::Stringifier::stringify(pObj, ostr);
207 catch(Poco::Exception& e)
213 catch(std::exception& e)
228 Poco::JSON::Parser parser;
229 Poco::Dynamic::Var res = parser.parse(json);
230 Poco::JSON::Object::Ptr
pObj = res.extract<Poco::JSON::Object::Ptr>();
234 resourceUsage.
cpu = convertVarToNumeric<double>(tmp, 0.0);
237 resourceUsage.
iowait = convertVarToNumeric<double>(tmp, 0.0);
252 resourceUsage.
threadsPercent = convertVarToNumeric<double>(tmp, 0.0);
255 resourceUsage.
loadAverage = convertVarToNumeric<double>(tmp, 0.0);
258 catch(Poco::JSON::JSONException& e)
264 catch(Poco::Exception& e)
270 catch(std::exception& e)
281 resourceUsage.
clear();