View Full Version : Monitoring value returned from perl script
hi everyone,
i am new to zabbix (installed v1.0 a couple of weeks ago and upgraded to 1.1alpha4 last week).
i would like to be able to do the following: we have a perl script which checks a log file and then writes a value to another file which i was hoping zabbix would read and then trigger a response based on the value in the file (value could be something like 38 or 22 etc). however i cant get zabbix to access the value in the file (thought i could just cat the file). any ideas how i could get zabbix to do this..
so far i am very impressed with zabbix.
thanks.
john
PerroVerd
28-01-2005, 09:55
Hi
You can add extend the zabbix funcionality usinf UserParameter
http://www.zabbix.com/manual/v1.1/config_extend.php
In your case, a simple cat file | tail -n 1 will work.
Best regards
thanks for the quick reply.
i setup zabbix_agentd.conf with the following parameter
UserParameter=monitor[logging],cat /etc/zabbix/ServiceMonitoring/zabbix_ServiceMonitor | tail -n 1
which returns the value in zabbix_ServiceMonitor but when i setup zabbix items with monitor[logging] as zabbix agent, i get "Not supported by zabbix agent".
i currently use a UserParameter (on other servers) such as "ps aux | grep <process> | wc -l" to monitor particular processess which works but in the case of reading value contained in a file, zabbix does not want to use the value returned by "cat <file> | tail -n 1".
thanks
Are you sure the file always exists and is non empty? Also, have you tried to run both commands from zabbix command line? Can you post an output here?
am positive file exists and always contains a value (and nothing else but value).
sorry not sure what you mean when you say "run both commands from the zabbix command line". do you mean put the following in a key for item
cat /etc/zabbix/ServerMonitoring/zabbix_ServerMonitor | tail -n
as an agent (?)
sorry, am new to zabbix :)
thanks.
Sorry, I wasn't clear enough. Please, execute
cat /etc/zabbix/ServiceMonitoring/zabbix_ServiceMonitor | tail -n 1
I'd like to see what exactly it returns. By the way, does the item change status to Unsupported immediately or after a while?
[zabbix@test-tomcat-2 zabbix]$ cat /etc/zabbix/ServiceMonitoring/zabbix_ServiceMonitor | tail -n 1
100[zabbix@test-tomcat-2 zabbix]$
value is 100 at the moment.
doesnt change to Unsupported immediately, takes about 10 seconds
Add end-of-line to make it work.
sorry not 100% sure what you mean. do you mean add a \n to perl script so cat now looks like the following:
[zabbix@test-tomcat-2 ServiceMonitoring]$ cat /etc/zabbix/ServiceMonitoring/zabbix_ServiceMonitor
100
[zabbix@test-tomcat-2 ServiceMonitoring]$
have done this but the item is still showing as Unsupported, or do you mean something different.
thanks.
I meant \n, so you did everything right. Note that ZABBIX does not rechecks not supported parameters. You have to change status of the item manualy to 'Monitored'.
thanks alexei,
there must have been a problem with my zabbix_agentd.conf. replaced it and put in the UserParameter and now it works fine. thanks for all your help and thanks for the great software
john