inovex / zax

Zabbix frontend for Android
http://inovex.github.io/zax/
GNU General Public License v3.0
66 stars 32 forks source link

Perl Script returning errors? #38

Open JohnnySSH opened 10 years ago

JohnnySSH commented 10 years ago

Hi,

I'm trying to run the perl script on FreeBSD 10 but it keeps on throwing up errors:

Use of uninitialized value in split at /usr/local/etc/zabbix22/scripts/pubnub.pl line 27. Use of uninitialized value $ARGV[1] in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44.

Perl version is: 5.16.3_11

I also have all the necessary Perl packages installed and have been following this guide:

http://inovex.github.io/zax/#howto_push

Though my Zabbix version is 2.2 but that shouldn't matter..... I think.

Can anyone help?

Thanks

JohnnySSH commented 10 years ago

Somehow the script managed to run from Zabbix however, is the log supposed to look like this:


$VAR1 = []; $VAR1 = []; $VAR1 = {}; http://pubsub.pubnub.com/[URL]/0/zabbixmobile/0/{"triggerid": , "message": "","status": ""}


Checking Pubnub user panel there seems to be no activity at all??

Seems like something isn't right.

JohnnySSH commented 10 years ago

I managed to debug as much as I could so far and it seems that some needed Perl modules were missing:

www/p5-libwww devel/p5-Data-Dumper www/p5-Any-URI-Escape devel/p5-File-Flock

Not sure if the last port was the correct one so did a CPAN install for it:

perl -MCPAN -e'install "File::Flock"'

At least the /tmp/pubnub.log file is populating with data now :-)

However, nothing is being sent to Pubnub. These are the errors observed in the logs:

Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44.

I think it would be great to include all necessary Perl modules on the Howto Page:

http://inovex.github.io/zax/#howto_push

Also perhaps a quick guide for Pubnub's web UI as it's anything but user friendly!

jimsmith commented 10 years ago

Maybe this should be closed. Works for me and I'm a user is tested this on a plain vanilla Linux centos and aws linux ami and works. Initally some credentials in the naming and ordering could be improved but works for me.

JohnnySSH commented 10 years ago

@jimsmith FreeBSD is a different OS to Linux and built with different library patches etc..... so what works on Linux may not necessarily work on FreeBSD unless correctly patched or hacked out.

I think I have got the above to a workable state however, it definitely needs looking at as it's highly unstable. Lot's of Pubnub connection errors. In addition ZAX clients inside the network simply are not able to connect to Pubnub at all and through debugging all I'm getting is "Error" or "Timeout".

I'll dig through my logs and see if there's anything substantial to post and report back if I find anything.

JohnnySSH commented 10 years ago

Ok so here is the log from Zabbix server:

Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value $key in hash element at /usr/local/etc/zabbix22/scripts/pubnub.pl line 34. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in concatenation (.) or string at /usr/local/etc/zabbix22/scripts/pubnub.pl line 40. Use of uninitialized value in print at /usr/local/etc/zabbix22/scripts/pubnub.pl line 44.

aikar commented 9 years ago

I wrote a PHP script to replace it, find it here: https://gist.github.com/aikar/e2b58ca22d1c84537111

No dependencies required other than PHP.

Gomez commented 9 years ago

@aikar You sure the php script works? I get this errors:

PHP Notice:  Undefined variable: body in /usr/lib/zabbix/alertscripts/pubnub.php on line 15
PHP Warning:  implode(): Invalid arguments passed in /usr/lib/zabbix/alertscripts/pubnub.php on line 15
PHP Warning:  Missing argument 2 for http_post(), called in /usr/lib/zabbix/alertscripts/pubnub.php on line 17 and defined in /usr/lib/zabbix/alertscripts/pubnub.php on line 33
PHP Notice:  Undefined variable: data in /usr/lib/zabbix/alertscripts/pubnub.php on line 34
PHP Notice:  Undefined variable: data in /usr/lib/zabbix/alertscripts/pubnub.php on line 44
PHP Warning:  file_get_contents() expects parameter 1 to be a valid path, array given in /usr/lib/zabbix/alertscripts/pubnub.php on line 44
PHP Notice:  Undefined variable: http_response_header in /usr/lib/zabbix/alertscripts/pubnub.php on line 46
aikar commented 9 years ago

Oops, I missed a line I had in mine (I made tweaks to it after the original gist and then just pieced in the updates and missed it it seems)

above the line 15 $body = array_splice($argv, 3);

Check the gist link for update.

ottok commented 7 years ago

I have the same errors. Running Ubuntu 14.04 and Zabbix server 3.2:

/usr/lib/zabbix/alertscripts$ ./pubnub.pl 
flock() on closed filehandle $log at ./pubnub.pl line 26.
print() on closed filehandle $log at ./pubnub.pl line 31.
Use of uninitialized value in split at ./pubnub.pl line 34.
print() on closed filehandle $log at ./pubnub.pl line 39.
Use of uninitialized value $ARGV[1] in concatenation (.) or string at ./pubnub.pl line 54.
Use of uninitialized value in concatenation (.) or string at ./pubnub.pl line 54.
Use of uninitialized value in concatenation (.) or string at ./pubnub.pl line 54.
print() on closed filehandle $log at ./pubnub.pl line 58.
print() on closed filehandle $log at ./pubnub.pl line 59.
print() on closed filehandle $log at ./pubnub.pl line 60.
flock() on closed filehandle $pushlog at ./pubnub.pl line 68.
Use of uninitialized value in concatenation (.) or string at ./pubnub.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./pubnub.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./pubnub.pl line 69.
print() on closed filehandle $pushlog at ./pubnub.pl line 69.

I have not succeeded in setting up ZAX with PubNub yet. Can anybody help? Is the docs at http://inovex.github.io/zax/#howto_push compatible with Zabbix 3? Is some update like for Zabbkit at https://www.zabbix.com/forum/showthread.php?t=41967&page=8 needed?

ottok commented 7 years ago

It seems the errors above don't matter as my ZAX perl script suddently started working correctly. The solution was to add the parameters described at https://www.zabbix.com/documentation/3.0/manual/introduction/whatsnew300#custom_parameter_support_for_alert_scripts and then waiting for some 30 minutes or so.

Looking at my admin.pubnub.com account the app I created (and used the public and private keys from) says there are no devices and no messages have been relayed, but still it works.