Open dzygmundfelt opened 2 years ago
Taking this on and keeping some notes here:
Quick update on a couple things I tried yesterday:
node-unifi didn't work well because of what seemed to be missing modules, but after installing and researching has to do with webpack not playing nicely with some modules. Errors like the one below for http, https, util and other modules.
Module not found: Error: Can't resolve 'util' in '/home/onion/www/PCW_map/node_modules/tough-cookie/lib'
Same with https://github.com/oddbit/unifi-js
Also, I'm new to typescript and was constantly breaking typed things. Need a few free days sometimes to familiarize myself on that front. But I started a non ts gatsby project and same issues.
So will pick this up again once I have a bit of time. But my plan from here on out is to look closer at API calls I see here:
Possibly just copy those into a react component or experiment with the API calls in there.
@dzygmundfelt you mentioned you wanted to look into that last night. Please update if you get anywhere.
Also useful for sussing the API:
The first link was super helpful, and I'm querying Unifi via http calls in Postman. The call to this endpoint
stat/report/{interval}.{type}
with json body like
{
"attrs": ["bytes", "wan-tx_bytes", "wan-rx_bytes", "wlan_bytes", "num_sta", "lan-num_sta", "wlan-num_sta", "time", "rx_bytes", "tx_bytes"]
}
seems to be how we can get time-chunked reports of network activity. You can also pass start and end times to that call. Hitting this endpoint
/api/s/default/stat/sysinfo
brought back some interesting stuff about data retention times
"data_retention_days": 365,
"data_retention_time_in_hours_for_5minutes_scale": 168,
"data_retention_time_in_hours_for_hourly_scale": 720,
"data_retention_time_in_hours_for_daily_scale": 4320,
"data_retention_time_in_hours_for_monthly_scale": 8760,
"data_retention_time_in_hours_for_others": 8760,
that could clue us in to how often we'd want to grab these reports.
More broadly, I think we ought to decide on a couple of stats that we want to collect so that we can automate pulling them. Also this ticket is in the map project, but I feel like lately we've been talking more about collecting Unifi Controller stats as a separate thing.
Also want to reference https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php, which is some more good documentation.
ahh that's great. Just wanted to mention I think I realized just after commenting, the libraries I failed at getting working seem to work in node but not in the browser. In gatsby there's a file usually used for generating pages that runs on build and run node. gatsby-node.js in the root dir : https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/
Some possible API tidbits for consideration (and totally up for debate) from Allan:
data pulls
monthly
raw counts of unique client (MAC addresses) per month
repeat clients? ie long term reliance on Mesh
event promotion days? see the bumps from engagement
Bandwidth
consumption? Peak times?
weekly
uptime for APs
disconnect counts
isolation count
other error counts/some QoS data
Leases renewed?
have to think about this, not sure
Just noting two key files for this project:
1) the api browser tool: https://apibrowser.phillycommunitywireless.org/
2) this sample code for api calls: https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php