zbx-sadman / unifi_proxy

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

Zabbix Agent 3.2.10 Crashes #18

Closed zdsimpso closed 6 years ago

zdsimpso commented 6 years ago

I am running Zabbix-agent 3.2.10. I've compiled the zbx_unifi_Zabbix_3_2/unifi.c without error and the Zabbix agent loads it.

I can pull the unifi.alive value without issue, but the agent crashes when I try to pull a unifi.proxy value. zabbix_agentd -t "unifi.alive" unifi.alive [u|1]

zabbix_agentd -t "unifi.proxy[discovery,wlan]" zabbix_agentd [18571]: ERROR: Got signal [signal:11(SIGSEGV),reason:1,refaddr:(nil)]. Crashing ... zabbix_agentd [18571]: ERROR: ====== Fatal information: ====== zabbix_agentd [18571]: ERROR: Program counter: (nil)

<OUTPUT TRUNCATED>

zabbix_agentd [18571]: ERROR: ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] zabbix_agentd [18571]: ERROR: ================================ zabbix_agentd [18571]: ERROR: Please consider attaching a disassembly listing to your bug report. zabbix_agentd [18571]: ERROR: This listing can be produced with, e.g., objdump -DSswx zabbix_agentd. zabbix_agentd [18571]: ERROR: ================================

zbx-sadman commented 6 years ago

What OS you use?

zdsimpso commented 6 years ago

I'm on Debian 9.3

zbx-sadman commented 6 years ago

Ough... I still sit on Wheezy and test all on this release.

I'll try to install latest Debian on virtual machine when i will have some free time.

zbx-sadman commented 6 years ago

I've see no problem:

root@debian9:/usr/local/lib/zabbix# zabbix_agentd -t "unifi.alive"
unifi.alive                                   [u|1]

root@debian9:/usr/local/lib/zabbix# zabbix_agentd -t "unifi.proxy[discovery,wlan]"
unifi.proxy[discovery,wlan]                   [s|{"data":[{"{#SITENAME}":"default",  ...
"{#ISGUEST}":"1","{#ID}":"56a070ad9932e99b10769b7d","{#SITEDESC}":"South"}]}]

root@debian9:/usr/local/lib/zabbix# uname -a
Linux debian9 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3 (2017-12-03) x86_64 GNU/Linux

root@debian9:/usr/local/sbin# zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 3.2.10
Revision 74337 7 November 2017, compilation time: Dec 14 2017 04:52:52

Copyright (C) 2017 Zabbix SIA
zdsimpso commented 6 years ago

Herm. I just created a new stretch system, with base utils and ssh-server, and it's still crashing on me.

added the Zabbix 3.2 repo package apt-get install zabbix-agent unzip apt-get install build-essential apt-get source zabbix-agent cd /tmp unzip unifi_proxy-master.zip cd /zabbix-3.2.10 ./configure cd src/modules cp -R /tmp/unifi_proxy-master/src/modules/zbx_unifi_Zabbix_3_2 ./unifi cd unifi make mkdir -p /usr/lib/zabbix/modules/ cp unifi.so /usr/lib/zabbix/modules cp /tmp/unifi_proxy-master/usr/local/lib/zabbix/unifi.conf /usr/lib/zabbix/modules chown zabbix:zabbix /usr/lib/zabbix/modules/* cp /tmp/unifi_proxy-master/etc/zabbix/zbx_unifi.conf /etc/zabbix/zabbix_agentd.d/ vim /etc/zabbix/zabbix_agentd.d/zbx_unifi.conf <<Update module path to /usr/lib/zabbix/modules>> vim /usr/lib/zabbix/modules/unifi.conf <> /etc/init.d/zabbix-agent restart

cd /tmp/unifi_proxy-master/src gcc unifi_proxy_get.c -o unifi_proxy_get ./unifi_proxy_get 10.0.5.16 8448 "discovery,uap" {"data":[{"{#SITEDESC}": <>

zabbix_agentd -t "unifi.alive" unifi.alive [u|1]

zabbix_agentd -t "unifi.proxy[discovery,wlan]" zabbix_agentd [19761]: ERROR: Got signal [signal:11(SIGSEGV),reason:1,refaddr:(nil)]. Crashing ... zabbix_agentd [19761]: ERROR: ====== Fatal information: ====== zabbix_agentd [19761]: ERROR: Program counter: (nil) zabbix_agentd [19761]: ERROR: === Registers: === <>

zbx-sadman commented 6 years ago

May be something going wrong when precompiled agent package is used...

I just download as always full sources from Zabbix site (not from repo), compile agent only and install it. All other steps are close to yours.

I see that you make discovery for UAPs via CLI utility, but trying discover WLANs via zabbix_agentd .

zbx-sadman commented 6 years ago

I've found that precompiled agent crashing when _zbx_tcpconnect() called by my module. On agentd which compiled from sources no this problem seen.

At this time i can't understand what is wrong.

zbx-sadman commented 6 years ago

So, the result of my investigation: i need to rewrite module code to make it more independent of Zabbix internal functions, because in https://support.zabbix.com/browse/ZBX-12900 (similar case) i've found the answer of Zabbix developers: "In your code you are using Zabbix functions, their behaviour may change without any prior notice. Closing as Won't Fix."

May be i'll done it in a week. Workaround is self-compiled agent.

zbx-sadman commented 6 years ago

@zdsimpso , you can try updated loadable module - i rewrited and tested via zabbix_agentd -t following:

At this time i haven't Zabbix 3.0/3.1 releases in my system and i leave corresponding code unchanged.

zdsimpso commented 6 years ago

Thanks!!

3.2.10 module appears to be working just fine now.

Tried it out on my 3.4.4 system and it appears to be working there as well.