patricegautier / unifiZabbix

Zabbix templates to monitor pretty much all Unifi devices
181 stars 36 forks source link

Script will not work in Zabbix #76

Closed DRK-Boll closed 1 year ago

DRK-Boll commented 1 year ago

Hi Patrice,

i want to install your Script to monitor our Unifi devices.

So i install everything in the readme:

sudo -u zabbix ssh -i yourUserName@oneOfYourUnifiDevicesIP --> This works fine sudo -u zabbix /usr/lib/zabbix/externalscripts/mca-dump-short.sh -d -u -i -t <UDMP|AP|SWITCH|CK> --> This works also

When i then in Zabbix i create a host, I have the following problem Preprocessing failed for: /usr/lib/zabbix/externalscripts/mca-dump-short.sh: Ungültige Option -- b.Usage /usr/lib/zabbix/ex...

  1. Result: /usr/lib/zabbix/externalscripts/mca-dump-short.sh: Ungültige Option -- b.Usage /usr/lib/zabbix/ex...
  2. Failed: cannot extract value from json by path "$.model_display": invalid object format, expected opening character '{' or '[' at: '/usr/lib/zabbix/externalscripts/mca-dump-short.sh: Ungültige Option -- b Usage /usr/lib/zabbix/externalscripts/mca-dump-short.sh -i privateKeyPath -p -u user -v -d tar

Can you help me please?

Thanks

DRK-Boll commented 1 year ago

So i try a little bit more.

In the Templates i remove the -b in the mca-dump mca-dump-short.sh["-d","{HOST.CONN}", "-u", "{$UNIFI_USER}", "-i", "{$UNIFI_SSH_PRIV_KEY_PATH}", "-t", "SWITCH", "-p", "{$UNIFI_SSHPASS_PASSWORD_PATH}", "-U", "{$UNIFI_VERBOSE_SSH}", "-o", "{$UNIFI_CHECK_TIMEOUT}","-b"]

Then it will work on our USW-Pro-48-PoE,.

On our US-16-150W it wont work. Do you know why?

kekko1485 commented 1 year ago

I also solved it by removing the -b from the mca-dump items of the templates but the script to my US-8 still wont work and go in timeout.

patricegautier commented 1 year ago

Apologies I hadn't committed the correct mac-dump script to the right spot.. Please update and let me know..

kekko1485 commented 1 year ago

It's all working for me. Thank you

DRK-Boll commented 1 year ago

For me its working too! Thanks

DRK-Boll commented 1 year ago

One question. I added the host with type Agent. But the agent is offline. Is it possible that it is online? Thanks

patricegautier commented 1 year ago

there's no zabbix agent on switches, so offline is right.. the script is using that connection info though, minus the port.

bding817 commented 1 year ago

Good Evening, I am working to get your tools implemented. I am having an issue where Zabbix wont run things correctly. When I run sudo -u zabbix /usr/lib/zabbix/externalscripts/mca-dump-short.sh -d 192.168.0.109 -u admini -i /usr/lib/zabbix/.ssh/zb_id_rsa -t SWITCH

I get the output of the JSON.

When zabbix runs things I get something like this for each host. I am using AP and SWITCH currently. The @@@@ comes when I remove the password path. 1330:20230113:220228.289 error reason for "Production Closet Switch:mca-dump-short.sh["-d","{HOST.CONN}", "-u", "{$UNIFI_USER}", "-i", "{$UNIFI_SSH_PRIV_KEY_PATH}", "-t", "SWITCH", "-p", "{$UNIFI_SSHPASS_PASSWORD_PATH}", "-U", "{$UNIFI_VERBOSE_SSH}", "-o", "{$UNIFI_CHECK_TIMEOUT}","-b"]" changed: Preprocessing failed for: { "at":"22:02:28", "r":"Error remote invoking mca-dump-short: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...

  1. Failed: Error This is what I get when I add the password path back.

    Failed: cannot extract value from json by path "$.sys_stats.mem_total": invalid object format, expected opening character '{' or '[' at: 'Password file not found '/var/lib/zabbix/password'' 1330:20230113:220626.282 item "Production Closet Switch:mem_used" became not supported: Preprocessing failed for: Password file not found '/var/lib/zabbix/password'

  2. Result: Password file not found '/var/lib/zabbix/password'
  3. Failed: cannot extract value from json by path "$.sys_stats.mem_used": invalid object format, expected opening character '{' or '[' at: 'Password file not found '/var/lib/zabbix/password'' 1330:20230113:220626.282 item "Production Closet Switch:model" became not supported: Preprocessing failed for: Password file not found '/var/lib/zabbix/password'
  4. Result: Password file not found '/var/lib/zabbix/password'
  5. Failed: cannot extract value from json by path "$.model_display": invalid object format, expected opening character '{' or '[' at: 'Password file not found '/var/lib/zabbix/password'' 1330:20230113:220626.282 item "Production Closet Switch:total_rx_bandwidth" became not supported: Preprocessing failed for: Password file not found '/var/lib/zabbix/password'
  6. Result: Password file not found '/var/lib/zabbix/password'
  7. Failed: cannot extract value from json by path "$.port_table[*].rx_bytes.sum()": invalid object format, expected opening character '{' or '[' at: 'Password file not found '/var/lib/zabbix/password'' 1330:20230113:220626.282 item "Production Closet Switch:total_tx_bandwidth" became not supported: Preprocessing failed for: Password file not found '/var/lib/zabbix/password'
  8. Result: Password file not found '/var/lib/zabbix/password'
  9. Failed: cannot extract value from json by path "$.port_table[*].tx_bytes.sum()": invalid object format, expected opening character '{' or '[' at: 'Password file not found '/var/lib/zabbix/password'' 1330:20230113:220626.282 item "Production Closet Switch:uptime" became not supported: Preprocessing failed for: Password file not found '/var/lib/zabbix/password'
  10. Result: Password file not found '/var/lib/zabbix/password'
  11. Failed: cannot extract value from json by path "$.uptime": invalid object format, expected opening character '{' or '[' at: 'Password file not found '/var/lib/zabbix/password'' 1332:20230113:220629.430 error reason for "Production Closet Switch:memory" changed: Cannot evaluate function: item "/Production Closet Switch/mem_used" is not supported at "last(//mem_used) / last(//mem_total)". 1332:20230113:220724.940 error reason for "Production Closet Switch:cpu_smooth" changed: Cannot evaluate function: item "/Production Closet Switch/cpu" is not supported at "avg(//cpu,{$UNIFI_SMOOTHING_PERIOD})".

    Any Help would be appreciated.

patricegautier commented 1 year ago

Couple of things:

• look in /tmp/mcaDumpShort.err, you should get a more complete error message. The '@@@@..' looks to me like ssh complaining about something

• from the zabbix server, are you able to ssh directly to the switch with that password?