zbx-sadman / unifi_miner

UniFi Miner helps deliver data from UniFi Controller to Zabbix
66 stars 11 forks source link

Number of users per WLAN #6

Closed mausampaio closed 7 years ago

mausampaio commented 7 years ago

Hello,

I would like to get the amount of users logged into a UAP over WLAN.

Is there any way to get this information?

Thank you!

zbx-sadman commented 7 years ago

Yes, you can get it, but not so simply.

UniFi controller does not have "wlan_name" or similar field in user object record.

But object uap have vap_table nested array (virtual AP, one per WLAN on UAP), that have wlanconf_id and num_sta fields. You must summarize num_sta field's values for all vap_table objects (on all Site's UAPs) that have wlanconf_id of required WLAN.

So, at first you must take wlanconf_id of some WLAN: ./unifi_miner.pl -a get -o wlan -s default -k [name=myWlanName]._id At second you must use this wlanconf_id to filter vap_table objects, and sum num_sta fields: ./unifi_miner.pl -a sum -o uap -s default -k vap_table.[wlanconf_id=myWLANID].num_sta

And, i think, that both of _unifiminer.pl calls can be joined: ./unifi_miner.pl -a sum -o uap -s default -k vap_table.[wlanconf_id=@./unifi_miner.pl -a get -o wlan -s default -k [name=myWlan]._id@].num_sta (replace @ sign to backquote mark, Github just eat it in message).

If you use Zabbix - just add new prototype to "UniFi WLANs discovery" rule: _unifi.proxy[sum,uap,{#SITENAME},\"vap_table.[wlanconf_id={#ID}].numsta\"]

Unfortunately, i can't test it, because does not have UniFi equipments at home. Try, and tell about result.

mausampaio commented 7 years ago

Very good! It worked perfectly, thank you very much.

I also tried using the -m parameter to return from a specific UAP and it worked perfectly.

Thank you for your great work, I'll help whenever i can.