Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Catalog pertinent device info available from hostifi #11

Open
dzygmundfelt opened this issue Jan 30, 2022 · 8 comments
Open

Catalog pertinent device info available from hostifi #11

dzygmundfelt opened this issue Jan 30, 2022 · 8 comments
Assignees

Comments

@dzygmundfelt
Copy link

  • How can we pull stuff from hostifi?
  • Can we automate grabbing this data? Might be a good thing to do during builds, might be a good thing to do regularly and save with the rest of our data.
@multilectical multilectical self-assigned this Feb 21, 2022
@multilectical
Copy link

Taking this on and keeping some notes here:

@multilectical
Copy link

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.

@dzygmundfelt
Copy link
Author

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.

@dzygmundfelt
Copy link
Author

Also want to reference https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php, which is some more good documentation.

@multilectical
Copy link

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/

@allanxgomez
Copy link

allanxgomez commented Jul 12, 2022

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

@hawc2
Copy link

hawc2 commented Aug 8, 2022

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants