anapsix / zabbix-haproxy

HAProxy Zabbix Discovery and Template
170 stars 77 forks source link

Cache not updating #20

Closed Phil57 closed 8 years ago

Phil57 commented 8 years ago

I'm having a mistery with haproxy_stats.sh

If I run haproxy_stats.sh manually un a shell, the cache is updating correctly. I can choose a value under or above 1 minute.

If Zabbix queries the script, the cache never updates itself. It happens both with Zabbix and manually with zabbix_get.

Note: I am not using haproxy_discovery.sh nor I'm using haproxy_zbx_template.xml I have directly put a key like "haproxy.stats[mySuperBackend BACKEND status]" in Zabbix I am getting goods values, the only thing is the cache not updating I'm using Zabbix 2.4.X and Ubuntu 14.04

Is there something I'm doing wrong ?

noamik commented 8 years ago

Have you tried running zabbix_get / zabbix_agent manually?

Like so: zabbix_get -s zabbix-agent-ip -p zabbix-agent-port -k item-key ex.: zabbix_get -s 192.168.1.2 -p 10050 -k agent.ping zabbix_agentd [-c config-file] -t item-key

Phil57 commented 8 years ago

Yes with zabbix_get it doesn't update either

zabbix_get -s 1.2.3.4 -p 10050 -k "haproxy.stats[mySuperBackend BACKEND status]"

But I get my value, so the script runs.

noamik commented 8 years ago

You will have to debug for yourself from there. Most likely reason is access rights. When you tried manually you most likely didn't execute the script as zabbix user. Make sure zabbix user is even allowed to write that file.

anapsix commented 8 years ago

What @noamik said - make sure cache file can be read and written to by Zabbix user. Delete the file altogether before running it via sudo -u zabbix zabbix_get... See if file appears after that, if not, check cache destination directory permissions

Phil57 commented 8 years ago

I got it working I don't know how, and after a reboot it's broken again. I'll let you know at the end how it goes

Phil57 commented 8 years ago

Ok, I found what's going wrong. I had CACHE_STATS_EXPIRATION:-0,5 so less than a minutes and it doesn't like the comma.

Is there any possibility to specify a cache of less than a minute, let's say 30s? Seems that find do not have an option that alows that.

noamik commented 8 years ago

You could try this: http://superuser.com/questions/300246/linux-command-to-find-files-changed-in-last-n-seconds

You'd need to modify the script to use mtime instead of mmin ... Edit: Or on linux try one of the other proposed solutions ...

Phil57 commented 8 years ago

It's working with -mmin 0.5. But only on Ubuntu 16.04, not 14.04 boxes. Oh well ....

Thank you for your help.

anapsix commented 8 years ago

@Phil57 you should be able to use -mtime to avoid decimals