mirror of
https://github.com/Telecominfraproject/wlan-cloud-analytics.git
synced 2026-01-27 02:22:21 +00:00
Initial commit
This commit is contained in:
@@ -6,12 +6,95 @@
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
/*
|
||||
|
||||
{"interfaces":[
|
||||
{ "clients":
|
||||
[{ "ipv4_addresses":["10.2.0.1"],
|
||||
"ipv6_addresses":["fe80:0:0:0:a8a2:caff:fe45:bc6b"],
|
||||
"mac":"e2:63:da:86:64:8e",
|
||||
"ports":["eth1"]}],
|
||||
"counters":
|
||||
{"collisions":0,"multicast":762813,"rx_bytes":181910484,"rx_dropped":0,"rx_errors":0,"rx_packets":1076144,"tx_bytes":2749349,"tx_dropped":0,"tx_errors":0,"tx_packets":12941},
|
||||
"dns_servers":["10.2.0.1"],
|
||||
"ipv4":{"addresses":["10.2.177.154/16"],
|
||||
"dhcp_server":"10.2.0.1","leasetime":86400},
|
||||
"location":"/interfaces/0",
|
||||
"name":"up0v0",
|
||||
"uptime":130177},
|
||||
{"counters":
|
||||
{"collisions":0,"multicast":0,"rx_bytes":0,"rx_dropped":0,"rx_errors":0,"rx_packets":0,"tx_bytes":1032226,"tx_dropped":0,"tx_errors":0,"tx_packets":4881},
|
||||
"ipv4":{"addresses":["192.168.1.1/24"]},
|
||||
"location":"/interfaces/1",
|
||||
"name":"down1v0",
|
||||
"ssids":[
|
||||
{ "bssid":"04:f8:f8:fc:3b:04",
|
||||
"iface":"wlan0",
|
||||
"location":"/interfaces/1/ssids/0",
|
||||
"mode":"ap",
|
||||
"phy":"soc/1b700000.pci/pci0001:00/0001:00:00.0/0001:01:00.0",
|
||||
"radio":{"$ref":"#/radios/0"},
|
||||
"ssid":"OpenWifi"},
|
||||
{ "bssid":"04:f8:f8:fc:3b:03",
|
||||
"iface":"wlan1",
|
||||
"location":"/interfaces/1/ssids/0",
|
||||
"mode":"ap",
|
||||
"phy":"soc/1b900000.pci/pci0002:00/0002:00:00.0/0002:01:00.0",
|
||||
"radio":{"$ref":"#/radios/1"},"ssid":"OpenWifi"}],
|
||||
"uptime":130177}],
|
||||
"link-state":{"downstream":{"eth1":{"carrier":0}},"upstream":{"eth0":{"carrier":1,"duplex":"full","speed":1000}}},"radios":[{"active_ms":130162935,"busy_ms":5320005,"channel":100,"channel_width":"80","noise":-103,"phy":"soc/1b700000.pci/pci0001:00/0001:00:00.0/0001:01:00.0","receive_ms":4466633,"transmit_ms":450846,"tx_power":24},{"active_ms":130169276,"busy_ms":21844515,"channel":6,"channel_width":"20","noise":-96,"phy":"soc/1b900000.pci/pci0002:00/0002:00:00.0/0002:01:00.0","receive_ms":18929929,"transmit_ms":421807,"tx_power":30}],"unit":{"load":[0.039063,0.02295,0.001465],"localtime":1647363036,"memory":{"buffered":6762496,"cached":17711104,"free":99299328,"total":217239552},"uptime":130207},"version":1}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void AP::UpdateStats(const std::shared_ptr<nlohmann::json> &State) {
|
||||
DI_.states++;
|
||||
DI_.connected =true;
|
||||
DI_.lastPing = DI_.lastState = OpenWifi::Now();
|
||||
std::cout << "Stats update for MAC: " << Utils::IntToSerialNumber(mac_) << std::endl;
|
||||
std::cout << *State << std::endl;
|
||||
// std::cout << *State << std::endl;
|
||||
|
||||
// find radios first to get associations.
|
||||
try {
|
||||
auto radios = (*State)["radios"];
|
||||
uint radio_index=0;
|
||||
std::map<uint,uint> radio_band;
|
||||
for(const auto &radio:radios) {
|
||||
if(radio.contains("channel")) {
|
||||
radio_band[radio_index++] = radio["channel"] <= 16 ? 2 : 5;
|
||||
}
|
||||
}
|
||||
|
||||
// now that we know the radio bands, look for associations
|
||||
auto interfaces = (*State)["interfaces"];
|
||||
DI_.associations_2g = DI_.associations_5g = DI_.associations_6g = 0;
|
||||
for(const auto &interface:interfaces) {
|
||||
if(interface.contains("ssids")) {
|
||||
auto ssids = interface["ssids"];
|
||||
for (const auto &ssid: ssids) {
|
||||
auto radio = ssid["radio"]["$ref"];
|
||||
auto radio_parts = Poco::StringTokenizer(radio, "/");
|
||||
auto radio_location = std::atoi(radio_parts[2].c_str());
|
||||
if (ssid.contains("associations")) {
|
||||
auto associations = ssid["associations"];
|
||||
auto the_radio = radio_band.find(radio_location)->second;
|
||||
if(the_radio==2)
|
||||
DI_.associations_2g += associations.size();
|
||||
else if(the_radio==5)
|
||||
DI_.associations_5g += associations.size();
|
||||
else if(the_radio==6)
|
||||
DI_.associations_6g += associations.size();
|
||||
for(const auto &association:associations) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << "Stats update for MAC: " << Utils::IntToSerialNumber(mac_) << std::endl;
|
||||
std::cout << "2G:" << DI_.associations_2g << " 5G" << DI_.associations_5g << " 6G:" << DI_.associations_6g << std::endl;
|
||||
} catch (...) {
|
||||
std::cout << "Could not parse stats for " << Utils::IntToSerialNumber(mac_) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
1166
stats_sample/bridge2_stats.json
Normal file
1166
stats_sample/bridge2_stats.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user