Ad Widget

Collapse

Key to using scripts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tokind
    Member
    • May 2007
    • 47

    #1

    Key to using scripts?

    I added nslookup as a script in my Zabbix 1.6.2 "Configuration --> Scripts". I want to use this to monitor connectivity and routing with queries to various root servers.

    In 1.0 versions of Zabbix I would do things like this with zabbix_agentd running on the Zabbix server, and bash or php scripts to return useful results. This Scripts functionality, new to me, seems to promise the ability to execute system applications and scripts without having to run zabbix_agentd.

    'Can't figure out how though. When I add the hosts (root servers) I want to query, and go to set up Items, I cannot figure out how to add the script as an action. I intuit that icmpping calls the script /usr/bin/ping and returns an integer result, but how can I get the same sort of functionality with nslookup?
  • Calimero
    Senior Member
    • Nov 2006
    • 481

    #2
    Scripts defined in "Config > Scripts" serve another purpose actually.

    Those scripts are run "on demand" from the GUI. I'm not familiar with that feature and so far the only possibility to run scripts seems to be from the maps: click on one of the Host and then the "Tools" section of the menu will show available scripts.

    Anyway, what you're probably looking for are External Scripts.
    1. Create directory /etc/zabbix/externalscripts
    2. Drop you test script in that directory. Make sure user zabbix has execution permissions (eg: chmod 0755 check1.sh)
    3. Edit zabbix_server.conf and set 'ExternalScripts=/etc/zabbix/externalscripts'
    4. Go to one of your hosts, add new Item
    5. Choose type External Check
    6. Keyname is the name of you script with brackets (empty brackets if your script needs no extra parameters). eg: check1.sh[] or check1.sh[average]


    check1.sh will always receive at least one argument ($1) : IP address or DNS name of the monitored host. Parameters given in the brackets are given as $2 $3 ... though it seems the comma is not considered a separator as in UserParameters (use space)

    Comment

    • georgew
      Member
      • Mar 2008
      • 50

      #3
      That seems easy enough.

      I set this up and it seems to be happy, but it is not running my script.

      My key is set like this:
      dBm[]

      It should be giving a integer result. How do I make it run the script and grab that result?

      The permissions are set to 755 on the script, and the directory it is in, so there should be no permissions problems...


      George
      Last edited by georgew; 12-05-2009, 22:06.

      Comment

      • Calimero
        Senior Member
        • Nov 2006
        • 481

        #4
        Originally posted by georgew
        I set this up and it seems to be happy, but it is not running my script.

        My key is set like this:
        dBm[]

        It should be giving a integer result. How do I make it run the script and grab that result?

        The permissions are set to 755 on the script, and the directory it is in, so there should be no permissions problems...
        Quick thoughts:
        * Are the permissions OK for all path components ? (ed: /etc , /etc/zabbix, /etc/zabbix/externalscripts ...) ?
        * Is you file really named "dBm" ? Script name is of course case-sensitive and must include whatever extension you gave it (dbm.sh[] if you script is called dbm.sh ...) ?
        * What if you run zabbix_server with debug level logging ?

        Comment

        • georgew
          Member
          • Mar 2008
          • 50

          #5
          I'm not sure what I did, but it eventually started working. But yeah, the name, permissions, and all were good.

          I think I was making too many changes in the config, and the first time I figured out how to implement the script correctly, I forgot to select external check, but when I deleted the item and tried again for the 17th time, it just worked...

          Comment

          Working...