Added averages and so on to DeviceTimePoint.

This commit is contained in:
stephb9959
2022-03-26 11:07:15 -07:00
parent 87d108055e
commit 4ef98b3cba
4 changed files with 161 additions and 0 deletions

View File

@@ -314,6 +314,30 @@ components:
type: array
items:
$ref: '#/components/schemas/TIDstat_entry'
tx_bytes_bw:
type: number
rx_bytes_bw:
type: number
tx_packets_bw:
type: number
rx_packets_bw:
type: number
tx_failed_pct:
type: number
tx_retries_pct:
type: number
tx_duration_pct:
type: number
AveragePoint:
type: object
properties:
min:
type: number
max:
type: number
avg:
type: number
SSIDTimePoint:
type: object
@@ -330,6 +354,27 @@ components:
type: array
items:
$ref: '#/components/schemas/UETimePoint'
tx_bytes_bw:
type:
$ref: '#/components/schemas/AveragePoint'
rx_bytes_bw:
type:
$ref: '#/components/schemas/AveragePoint'
tx_packets_bw:
type:
$ref: '#/components/schemas/AveragePoint'
rx_packets_bw:
type:
$ref: '#/components/schemas/AveragePoint'
tx_failed_pct:
type:
$ref: '#/components/schemas/AveragePoint'
tx_retries_pct:
type:
$ref: '#/components/schemas/AveragePoint'
tx_duration_pct:
type:
$ref: '#/components/schemas/AveragePoint'
APTimePoint:
type: object
@@ -364,6 +409,22 @@ components:
tx_packets:
type: integer
format: int64
tx_bytes_bw:
type: number
rx_bytes_bw:
type: number
rx_dropped_pct:
type: number
tx_dropped_pct:
type: number
rx_packets_bw:
type: number
tx_packets_bw:
type: number
rx_errors_pct:
type: number
tx_errors_pct:
type: number
RadioTimePoint:
type: object
@@ -398,6 +459,14 @@ components:
noise:
type: integer
format: int64
active_pct:
type: number
busy_pct:
type: number
receive_pct:
type: number
transmit_pct:
type: number
DeviceTimePoint:
type: object

View File

@@ -40,6 +40,22 @@ namespace OpenWifi {
return false;
}
template <typename X, typename M> double Average( X T, const std::vector<M> &Values ) {
double result = 0.0;
if(!Values.empty()) {
double sum = 0.0;
for(const auto &v:Values) {
sum += (v.*T);
}
result = sum / (double) Values.size();
}
return result;
}
void AP::UpdateStats(const std::shared_ptr<nlohmann::json> &State) {
DI_.states++;
DI_.connected =true;
@@ -238,10 +254,39 @@ namespace OpenWifi {
association.tx_packets_bw = safe_div( association.tx_packets , time_lapse );
association.rx_packets_bw = safe_div( association.rx_packets , time_lapse );
}
association.tx_failed_pct = safe_pct( association.tx_failed, association.tx_packets);
association.tx_retries_pct = safe_pct( association.tx_retries, association.tx_packets);
association.tx_duration_pct = safe_pct( association.tx_duration, time_lapse );
ssid.tx_failed_pct.max = std::max(ssid.tx_failed_pct.max, association.tx_failed_pct);
ssid.tx_failed_pct.min = std::max(ssid.tx_failed_pct.min, association.tx_failed_pct);
ssid.tx_retries_pct.max = std::max(ssid.tx_retries_pct.max, association.tx_retries_pct);
ssid.tx_retries_pct.min = std::max(ssid.tx_retries_pct.min, association.tx_retries_pct);
ssid.tx_duration_pct.max = std::max(ssid.tx_duration_pct.max, association.tx_duration_pct);
ssid.tx_duration_pct.min = std::max(ssid.tx_duration_pct.min, association.tx_duration_pct);
ssid.tx_bytes_bw.max = std::max(ssid.tx_bytes_bw.max, association.tx_bytes_bw);
ssid.tx_bytes_bw.min = std::max(ssid.tx_bytes_bw.min, association.tx_bytes_bw);
ssid.rx_bytes_bw.max = std::max(ssid.rx_bytes_bw.max, association.rx_bytes_bw);
ssid.rx_bytes_bw.min = std::max(ssid.rx_bytes_bw.min, association.rx_bytes_bw);
ssid.tx_packets_bw.max = std::max(ssid.tx_packets_bw.max, association.tx_packets_bw);
ssid.tx_packets_bw.min = std::max(ssid.tx_packets_bw.min, association.tx_packets_bw);
ssid.rx_packets_bw.max = std::max(ssid.rx_packets_bw.max, association.rx_packets_bw);
ssid.rx_packets_bw.min = std::max(ssid.rx_packets_bw.min, association.rx_packets_bw);
}
ssid.tx_bytes_bw.avg = Average(&AnalyticsObjects::UETimePoint::tx_bytes_bw,ssid.associations);
ssid.rx_bytes_bw.avg = Average(&AnalyticsObjects::UETimePoint::rx_bytes_bw,ssid.associations);
ssid.tx_packets_bw.avg = Average(&AnalyticsObjects::UETimePoint::tx_packets_bw,ssid.associations);
ssid.rx_packets_bw.avg = Average(&AnalyticsObjects::UETimePoint::rx_packets_bw,ssid.associations);
ssid.tx_failed_pct.avg = Average(&AnalyticsObjects::UETimePoint::tx_failed_pct,ssid.associations);
ssid.tx_retries_pct.avg = Average(&AnalyticsObjects::UETimePoint::tx_retries_pct,ssid.associations);
ssid.tx_duration_pct.avg = Average(&AnalyticsObjects::UETimePoint::tx_duration_pct,ssid.associations);
}
if (got_connection && got_health) {

View File

@@ -317,12 +317,37 @@ namespace OpenWifi::AnalyticsObjects {
return false;
}
void AveragePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"min",min);
field_to_json(Obj,"max",max);
field_to_json(Obj,"avg",avg);
}
bool AveragePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"min",min);
field_from_json(Obj,"max",max);
field_from_json(Obj,"avg",avg);
return true;
} catch(...) {
}
return false;
}
void SSIDTimePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"bssid",bssid);
field_to_json(Obj,"mode",mode);
field_to_json(Obj,"ssid",ssid);
field_to_json(Obj,"band",band);
field_to_json(Obj,"associations",associations);
field_to_json(Obj,"tx_bytes_bw",tx_bytes_bw);
field_to_json(Obj,"rx_bytes_bw",rx_bytes_bw);
field_to_json(Obj,"tx_packets_bw",tx_packets_bw);
field_to_json(Obj,"rx_packets_bw",rx_packets_bw);
field_to_json(Obj,"tx_failed_pct",tx_failed_pct);
field_to_json(Obj,"tx_retries_pct",tx_retries_pct);
field_to_json(Obj,"tx_duration_pct",tx_duration_pct);
}
bool SSIDTimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -332,6 +357,13 @@ namespace OpenWifi::AnalyticsObjects {
field_from_json(Obj,"ssid",ssid);
field_from_json(Obj,"band",band);
field_from_json(Obj,"associations",associations);
field_from_json(Obj,"tx_bytes_bw",tx_bytes_bw);
field_from_json(Obj,"rx_bytes_bw",rx_bytes_bw);
field_from_json(Obj,"tx_packets_bw",tx_packets_bw);
field_from_json(Obj,"rx_packets_bw",rx_packets_bw);
field_from_json(Obj,"tx_failed_pct",tx_failed_pct);
field_from_json(Obj,"tx_retries_pct",tx_retries_pct);
field_from_json(Obj,"tx_duration_pct",tx_duration_pct);
return true;
} catch(...) {

View File

@@ -109,6 +109,14 @@ namespace OpenWifi {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct AveragePoint {
double min = 0.0,
max = 0.0,
avg = 0.0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct UETimePoint {
std::string station;
int64_t rssi = 0;
@@ -171,6 +179,13 @@ namespace OpenWifi {
ssid;
uint64_t band=0;
std::vector<UETimePoint> associations;
AveragePoint tx_bytes_bw,
rx_bytes_bw,
tx_packets_bw,
rx_packets_bw,
tx_failed_pct,
tx_retries_pct,
tx_duration_pct;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);