PDA

View Full Version : Monitoring value returned from perl script


johnl
28-01-2005, 09:49
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

johnl
28-01-2005, 10:24
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

Alexei
28-01-2005, 11:09
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?

johnl
28-01-2005, 11:32
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.

Alexei
28-01-2005, 13:04
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?

johnl
28-01-2005, 13:15
[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

Alexei
28-01-2005, 13:23
Add end-of-line to make it work.

johnl
28-01-2005, 14:22
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.

Alexei
01-02-2005, 15:04
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'.

johnl
01-02-2005, 16:46
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