Switch port discovery not working anymore since last update
hellojoe88 opened this issue · 13 comments
I imported the newest template + script into my zabbix. The switch_discovery is not working anymore now:
docker exec zabbix-docker-compose-zabbix-server-1 /usr/lib/zabbix/externalscripts/mca-dump-short.sh -d 172.18.62.72 -u admin -i /var/lib/zabbix/ssh_keys/zb_id_rsa -t SWITCH_DISCOVERY /usr/lib/zabbix/externalscripts/mca-dump-short.sh: line 382: jqProgram: unbound variable
Did I do something wrong or was I too brave to try to newest update? ;)
Sorry for the bad syntax before. I exectued:
docker exec zabbix-docker-compose-zabbix-server-1 /usr/lib/zabbix/externalscripts/mca-dump-short.sh -d 172.18.62.72 -u admin -i /var/lib/zabbix/ssh_keys/zb_id_rsa -t SWITCH_DISCOVERY
and got as an error message
/usr/lib/zabbix/externalscripts/mca-dump-short.sh: line 382: jqProgram: unbound variable
I'm getting the same error on switch discoveries.
The first part of /tmp/mcaDumpShort.err is:
{ "at":"14:20:43", "r":"jq --indent 0 del (.port_table[]?.mac_table) returned status 4; parse error: Invalid numeric literal at line 1, column 4; JQ input was ssh -o PubkeyAccepted KeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-rsa -o ConnectTimeout=5 -o StrictHostKeyChecking
=accept-new -i /home/zabbix/.ssh/zabbix/zb_id_rsa tomf@192.168.0.252 mca-dump{
Seems you hit the same issue as me, I am currently using zabbix 6 (6.0.13 to be exact)
I have a udm pro se/usw 8 poe/usw 48poe and some aps. the data is polled correctly but for the switches namely usw 8 poe/usw 48poe I am seeing the same error "line 382: jqProgram: unbound variable"
further analysis performed :
running this command to get verbose data whilst tailing the mca log in tmp
"sudo -u zabbix /usr/lib/zabbix/externalscripts/mca-dump-short.sh -d 192.168.1.5 -u ubnt -i /home/zabbix/.ssh/zb_id_rsa -t SWITCH_DISCOVERY -v"
"r":"jq --indent 0 del (.port_table[]?.mac_table) returned status 4; parse error: Invalid numeric literal at line 1, column 4;
note that the data is being polled by the first part of the script as I can see the data in the log, this looks like a jq parsing issue
I would also like to give a huge thanks to the maintainer of this project :-)
FWIW, I'm using Zabbix 6.2.7 on Ubuntu 22.04
I see the same thing for ALL my switches when sent the SWITCH_DISCOVERY request
I notice the last change "typo" may have something to do with this, but I'm scratching my head, as I do not see a clear cause.
I am suspecting its the architecture field @RainCaster if i may ask is your string for architecture "armv71" ?
I'm using x64 machines, but that's not it.
The real issue may be that there is no global declaration of "jqProgram". It is declared in "startSwitchDiscovery()" which makes it a local to that subroutine. So it is not visible to "invokeMcaDump()" where the line we are seeing errors out.
It looks like that was it. My test scripts now run properly. Let me see if Zabbix will now collect all the unifi stats.
if possible let me know the changes so i test them out as well
Try these two fixes:
On line 149 of mca-dump-short.sh, delete the word "declare" Leave the rest of the line "jqProgram=..." there please.
Add a new line at the top, right after the line that starts "declare HE_RSA_SSH_KEY_OPTIONS="
That line should say "declare jqProgram"
I'm still having other issues, because I deleted my old records & templates and the new ones are having a few problems.
hmm strange although its working for my 3 switches tailing the log still outputs the error.
will monitor and post tomorrow if everything remains fine.
many thanks @RainCaster
That jqProgram handling was clearly incorrect sorry about that.. That last commit addresses that. please file a separate issue for the other problems you guys are mentioning..
sorry guys - make that the last few commits, I am committing way too fast here
Thanks for reacting so fast. It now works for me again.