Ad Widget

Collapse

External check script problem?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robroy83
    Junior Member
    • Sep 2010
    • 3

    #1

    External check script problem?

    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
    Senior Member
    • Apr 2006
    • 474

    #2
    Hi,

    Have you checked how Zabbix passes parameters to the script ?
    It is documented there : http://www.zabbix.com/documentation/...xternal_checks

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

    Regards,
    Alixen
    http://www.alixen.fr/zabbix.html

    Comment

    • robroy83
      Junior Member
      • Sep 2010
      • 3

      #3
      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 ?

      Originally posted by alixen
      Hi,

      Have you checked how Zabbix passes parameters to the script ?
      It is documented there : http://www.zabbix.com/documentation/...xternal_checks

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

      Regards,
      Alixen

      Comment

      • alixen
        Senior Member
        • Apr 2006
        • 474

        #4
        Originally posted by robroy83
        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:
        Code:
        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:
        Code:
        #! /bin/sh
        LOG=/tmp/check_ntp_zabbix.log
        echo "args:" $* >> $LOG
        may help.

        Regards,
        Alixen
        http://www.alixen.fr/zabbix.html

        Comment

        Working...