Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device info #1

Closed
phen0 opened this issue Aug 3, 2021 · 15 comments
Closed

Device info #1

phen0 opened this issue Aug 3, 2021 · 15 comments

Comments

@phen0
Copy link

phen0 commented Aug 3, 2021

@w1tw0lf which info are you looking for? if you pull the device-info you'll get a huge json file with all device information.
just let me know maybe I can code something quickly.

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 3, 2021

@phen0

Managed to get most of the info that was missing.

Last one that I need is, clients per ap. The below gives info for all ap's
wifi0clients = sum(1 for _ in re.finditer(r'\b%s\b' % re.escape('wifi0'), str(clients)))

if I can add target_mac in the results it will be perfect. The target mac would be the associated ap mac address

Thank you so much for your help.

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 3, 2021

Something that I found that might work.

the api that is being used is /proxy/network/api/s/default/stat/sta

From searching the web for solution, found that you can use json to show what is needed. So if we can use the above api call to list all strings that has target_mac then we can count the 2.4ghz clients and 5ghz.

@phen0
Copy link
Author

phen0 commented Aug 3, 2021

@w1tw0lf guess you're right. I had a glance at the device json but there's not much information about clients but the stat/sta could provide this information. Let me check.

@phen0
Copy link
Author

phen0 commented Aug 3, 2021

I had a look at both json files clients and devices but I couldn't find any field named target_mac.
From what I've seen the list of clients provides:

                '_uptime_by_uap': 228,
                '_last_seen_by_uap': 1627996801,
                '_is_guest_by_uap': False,
                'ap_mac': '80:2a:a8:86:af:0b',
                'channel': 11,
                'radio': 'ng',
                'radio_name': 'wifi0',
                'essid': 'HomeNet',
                'bssid': '80:2a:a8:87:af:0b',
                'powersave_enabled': True,
                'is_11r': False,
                'user_group_id_computed': '5da4adc98823b95586e47e19',
                'ccq': 977,
                'rssi': 48,
                'noise': -113,
                'signal': -48,
                'tx_rate': 142476,
                'rx_rate': 1000,
                'tx_power': 30,
                'idletime': 0,
                'ip': '10.0.55.119',
                'dhcpend_time': 0,
                'satisfaction': 99,
                'anomalies': -1,
                'vlan': 0,
                'radio_proto': 'ng',
                'uptime': 320,
                'tx_bytes': 36144,
                'rx_bytes': 46767,
                'tx_packets': 109,
                'tx_retries': 82,
                'wifi_tx_attempts': 218,
                'rx_packets': 685,
                'bytes-r': 546,
                'tx_bytes-r': 313,
                'rx_bytes-r': 233,
                'authorized': True,
                'qos_policy_applied': True,
                'roam_count': 1,
                '_uptime_by_ugw': 2336143,
                '_last_seen_by_ugw': 1627996804,
                '_is_guest_by_ugw': False,
                'gw_mac': '74:ac:b9:ed:f1:73',
                'network': 'LAN',
                'network_id': '5da4adc98823b95586e47e18',
                '_uptime_by_usw': 2336143,
                '_last_seen_by_usw': 1627996804,
                '_is_guest_by_usw': False,
                'sw_mac': '74:ac:b9:ed:f1:73',
                'sw_depth': 0,
                'sw_port': 11,
                'wired_rate_mbps': 10000

So the AP mac is given and wifi channel but no mention of 2.4 or 5GHz.

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 3, 2021

under 'radio_name'
wifi0 = 2.4GHz
wifi1 = 5GHz

target_mac is specified in the unifi_ap.py and should match 'ap_mac'

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 3, 2021

wifi0 and wifi1 is wifi 5
ra0 and rai0 is wifi 6

where
ra0 = 2.4GHz
rai0 = 5GHz

Made some changes to unifi_ap.py for this
see line 16 to 25 that reflects in line 55 abd 56

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 4, 2021

Any luck ? Running into dead end from myside.

@phen0
Copy link
Author

phen0 commented Aug 4, 2021

sorry @w1tw0lf I need some spare time to look at. was busy today working but tomorrow I'll have a look at.

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 4, 2021

No stress @phen0 also had a busy day this side.

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 4, 2021

Think I might have found and easier way to pull this per ap...

if you look at /proxy/network/api/s/default/stat/device/"mac address ap"

user-num_sta come up 3 times, first 2 is the client on ap per station and the last one is the total clients per ap

we need to pull it from this section
[{"name":"wifi0","channel":5,"radio":"ng","ast_txto":null,"ast_cst":2,"ast_be_xmit":1050,"cu_total":31,"cu_self_rx":14,"cu_self_tx":16,"gain":3,"satisfaction":99,"state":"RUN","extchannel":0,"tx_power":17,"tx_packets":261,"tx_retries":82,"num_sta":12,"guest-num_sta":0,"user-num_sta":12},{"name":"wifi1","channel":40,"radio":"na","ast_txto":null,"ast_cst":null,"ast_be_xmit":844,"cu_total":3,"cu_self_rx":1,"cu_self_tx":2,"gain":4,"satisfaction":98,"state":"RUN","extchannel":-1,"tx_power":17,"tx_packets":563,"tx_retries":70,"num_sta":1,"guest-num_sta":0,"user-num_sta":1}]

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 4, 2021

Believe I might have fixed it....

Change this
wifi0clients = sum(1 for _ in re.finditer(r'\b%s\b' % re.escape('wifi0'), str(clients)))
wifi0clients = sum(1 for _ in re.finditer(r'\b%s\b' % re.escape('wifi1'), str(clients)))
to
wifi0clients = devs['radio_table_stats'][0]['user-num_sta']
wifi1clients = devs['radio_table_stats'][1]['user-num_sta']

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 4, 2021

Fixed.

@w1tw0lf w1tw0lf closed this as completed Aug 4, 2021
@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 4, 2021

Thank you @phen0 for willing to help. can't believe how easy it was actually.

@phen0
Copy link
Author

phen0 commented Aug 5, 2021

Hey @w1tw0lf,
this is even better. I wasn't aware which data will be sent as device status.....but looks great.
okay sorry that I couldn't help here but maybe next time ;-)

@w1tw0lf
Copy link
Owner

w1tw0lf commented Aug 5, 2021

No stress :)

was looking at this

wifi0score = devs['radio_table_stats'][0]['satisfaction']
wifi1score = devs['radio_table_stats'][1]['satisfaction']

And that is where I saw it.

PS: Playing around and seeing what info can be pulled from the switches 😄

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

No branches or pull requests

2 participants