mirror of
https://github.com/Telecominfraproject/wlan-cloud-analytics.git
synced 2026-01-27 10:22:33 +00:00
Adding uptime and memory.
This commit is contained in:
@@ -216,6 +216,11 @@ components:
|
||||
format: int64
|
||||
locale:
|
||||
type: string
|
||||
memory:
|
||||
type: number
|
||||
uptime:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
DeviceInfoList:
|
||||
type: object
|
||||
|
||||
@@ -21,7 +21,22 @@ namespace OpenWifi {
|
||||
// find radios first to get associations.
|
||||
try {
|
||||
|
||||
DI_.lastState = (*State)["unit"]["localtime"];
|
||||
if(State->contains("unit")) {
|
||||
auto unit = (*State)["unit"];
|
||||
GetJSON("localtime", unit, DI_.lastState, (uint64_t) 0);
|
||||
GetJSON("uptime", unit, DI_.uptime, (uint64_t) 0);
|
||||
if(unit.contains("memory")) {
|
||||
auto memory = unit["memory"];
|
||||
uint64_t free_mem, total_mem;
|
||||
GetJSON("free", memory, free_mem, (uint64_t) 0);
|
||||
GetJSON("total", memory, total_mem, (uint64_t) 0);
|
||||
if(total_mem) {
|
||||
DI_.memory = ((double) (total_mem - free_mem) / (double)total_mem) * 100.0;
|
||||
} else {
|
||||
DI_.memory = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::map<uint, uint> radio_band;
|
||||
if(State->contains("radios") && (*State)["radios"].is_array()) {
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenWifi {
|
||||
|
||||
class UE {
|
||||
public:
|
||||
UE(uint64_t Station):
|
||||
explicit UE(uint64_t Station):
|
||||
Station_(Station) {
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ namespace OpenWifi::AnalyticsObjects {
|
||||
field_to_json(Obj,"health",health);
|
||||
field_to_json(Obj,"lastHealth",lastHealth);
|
||||
field_to_json(Obj,"locale",locale);
|
||||
field_to_json(Obj,"uptime",uptime);
|
||||
field_to_json(Obj,"memory",memory);
|
||||
}
|
||||
|
||||
bool DeviceInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -104,6 +106,8 @@ namespace OpenWifi::AnalyticsObjects {
|
||||
field_from_json(Obj,"health",health);
|
||||
field_from_json(Obj,"lastHealth",lastHealth);
|
||||
field_from_json(Obj,"locale",locale);
|
||||
field_from_json(Obj,"uptime",uptime);
|
||||
field_from_json(Obj,"memory",memory);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ namespace OpenWifi {
|
||||
uint64_t health;
|
||||
uint64_t lastHealth;
|
||||
std::string locale;
|
||||
uint64_t uptime;
|
||||
double memory;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
@@ -280,6 +280,11 @@ namespace OpenWifi::RESTAPI_utils {
|
||||
S = Obj->get(Field).toString();
|
||||
}
|
||||
|
||||
inline void field_from_json(Poco::JSON::Object::Ptr Obj, const char *Field, double & V) {
|
||||
if(Obj->has(Field))
|
||||
V = Obj->get(Field);
|
||||
}
|
||||
|
||||
inline void field_from_json(Poco::JSON::Object::Ptr Obj, const char *Field, uint64_t &V) {
|
||||
if(Obj->has(Field))
|
||||
V = Obj->get(Field);
|
||||
|
||||
Reference in New Issue
Block a user