zbx-sadman / unifi_proxy

Fast client-server version of UniFi Miner
45 stars 21 forks source link

zabbix-agentd requests #19

Closed alena-cv closed 6 years ago

alena-cv commented 6 years ago

How can I use the key to get values directly from the Zabbix agent? I’v tried to check value of “max client RX Rate” item, it’s seems to be in 10 times larger (300 Mbps instead of 30). I’v got the key from the Zabbix item in debug mode:

unifi.proxy[max,user,default,"[ap_mac=80:2a:a8:53:16:ee].rx_rate",,0] And put it to the zabbix-agent request:
> zabbix_agentd -t "unifi.proxy[median,user,default,ap_mac=80:2a:a8:53:16:ee.rx_rate,,0]" The answer is always “0”, and its seems to take this number from the end of request.

Please, explain me the correct way to make up unifi_proxy request. Thanks a lot!

zbx-sadman commented 6 years ago

Take max rx rate for all users on "default" site: zabbix_agentd -t 'unifi.proxy[max,user,default,rx_rate,,0]'

Take max rx rate for users on "default" site and connected to AP with specified MAC (use simple filter): zabbix_agentd -t 'unifi.proxy[max,user,default,"[ap_mac=00:27:22:0a:16:a7].rx_rate",,0]'

'0' is returned because no JSON key 'ap_mac=80:2a:a8:53:16:ee.rx_rate' was found and you use '0' as replacement value for NULL/ERROR (see last argument in the Zabbix key). It prevent Zabbix item to Unsupported state going.

If you want to get Mbps - you need multiply RAW value fetched from UniFi API's JSON key by .001. Refer to [{#SITEDESC}] UAP "{#NAME}" median client RX Rate discovery rule prototype in the Template UBNT UAP - UniFi Controller v5, for example.

alena-cv commented 6 years ago

Thanks for your answer! But it's still unclear for me, how can I get the result for max.rx_rate by specifically ap. If there is no key 'ap_mac=80:2a:a8:53:16:ee.rx_rate' how zabbix server gets the results?

2017-12-18 14:07 GMT+03:00 Grigory Prigodin notifications@github.com:

Take max rx rate for all users on "default" site: zabbix_agentd -t 'unifi.proxy[max,user,default,rx_rate,,0]'

Take max rx rate for users on "default" site and connected to AP with specified MAC (use simple filter): zabbix_agentd -t 'unifi.proxy[max,user,default, "[ap_mac=00:27:22:0a:16:a7].rx_rate",,0]'

'0' is returned because no JSON key 'ap_mac=80:2a:a8:53:16:ee.rx_rate' was found and you use '0' as replacement value for NULL/ERROR (see last argument in the Zabbix key). It prevent to put Zabbix item to Unsupported state.

If you want to get Mbps - you need multiply RAW value fetched from UniFi API's JSON key by .001. Refer to [{#SITEDESC}] UAP "{#NAME}" median client RX Rate discovery rule prototype in the Template UBNT UAP - UniFi Controller v5, for example.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zbx-sadman/unifi_proxy/issues/19#issuecomment-352395723, or mute the thread https://github.com/notifications/unsubscribe-auth/AQqf_5-g3gFNTzzwHN4fyIocntfY97_7ks5tBkeKgaJpZM4RFLNk .

zbx-sadman commented 6 years ago

UAP does not have rx_rate metric, we need to get it from user(s) which connected to specific AP. And we use filter condition (contained in nested square brackets inside Zabbix key option and explained in Wiki) to filter user records, which have JSON key ap_mac with value that equal to UAP's MAC and then Proxy/Miner stores all rx_rate JSON keys into script's internal memory structure. After that script can found max or calculate median value for you.