PDA

View Full Version : External check script problem?


robroy83
04-10-2010, 17:52
Hi all.

I have two hardware NTP servers defined as hosts. I wrote a script which checks them using ntpdate, the script is run from Zabbix server. I use this script as an item of type "external check". When I define an item to monitor for a host in its "Key" field I write "check_ntp_zabbix.sh[{IPADDRESS}]" and in "Type" field "External check".

When I write the check_ntp_zabbix.sh script in such a way that it doesn't need a parameter the check is performed well by Zabbix. But I would like to make it a part of a template and to give IP address of external NTP server as a parameter (./check_ntp_zabbix.sh 10.0.0.1 for example). So i tried to use macros: "check_ntp_zabbix.sh[{IPADDRESS}]" but it doesn't work.

Could someone help?
How to use the script in a template and give an IP address as a parameter using macro?

Thank you very much,
R.

alixen
04-10-2010, 18:05
Hi,

Have you checked how Zabbix passes parameters to the script ?
It is documented there : http://www.zabbix.com/documentation/1.8/manual/config/items#external_checks

First parameter is always host name, you will get {IPADDRESS} in second one ($2).

Regards,
Alixen

robroy83
04-10-2010, 18:08
Yes, I know that I should use $2. But the problem here is how to make Zabbix to pass IP address of a host which is monitored in this $2 ?

Hi,

Have you checked how Zabbix passes parameters to the script ?
It is documented there : http://www.zabbix.com/documentation/1.8/manual/config/items#external_checks

First parameter is always host name, you will get {IPADDRESS} in second one ($2).

Regards,
Alixen

alixen
04-10-2010, 18:16
Yes, I know that I should use $2. But the problem here is how to make Zabbix to pass IP address of a host which is monitored in this $2 ?

Your syntax is correct:
check_ntp_zabbix.sh[{IPADDRESS}]

Are you sure that you have defined IP address in host configuration ?
Otherwise, you could add some debug logs to your script:
#! /bin/sh
LOG=/tmp/check_ntp_zabbix.log
echo "args:" $* >> $LOG
may help.

Regards,
Alixen