Ad Widget

Collapse

External scripts and arguments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geostant
    Member
    • Feb 2015
    • 32

    #1

    External scripts and arguments

    Hey,

    I've a python script that I've wrote and would like Zabbix item to use it as a test.

    The script return result that I would like to use for the trigger.

    The script SSH a sever and return a number, very simple.

    However the script need host, username and password for the SSH
    and I would like to pass it with arguments from the zabbix host so that the script will be a template and not static.

    So,
    1. Is there an option to run external script test ? (I know that in Nagios it's possible as we already do it)

    2. How do I pass arguments to my Python script from Zabbix ?

    3. How do I return arguments from my script to Zabbix ?


    Thanks
  • geostant
    Member
    • Feb 2015
    • 32

    #2
    I've managed to find the "External Check" option,
    so I've set it up with a shell script that actually run my python (as I'm not sure that file.py can be executed directly by zabbix).

    I've set the key as script[host,user,pass]
    where at this stage I don't use macro data as just typed in the actual host and credentials instead of the args above.

    At this stage, nothing really happen.
    I can't find where zabbix (proxy in my case) write execution logs (/var/log/zabbix/zabbix_proxy.log doesn't contain any info about it).

    Any help would be appreciated.


    P.S.
    I've made sure that /etc/zabbix/zabbix_proxy.conf
    have a proper set of folder for external scripts and that it's not commented out (#)

    I've uploaded the script file and the .sh file to my externalscript folder and gave it CHMOD 4755

    Comment

    • geostant
      Member
      • Feb 2015
      • 32

      #3
      Another progress, but still now go...
      I'm now able to run my bash script that call my python script
      I pass arguments to my bash script that pass them on to my python.

      The result of manual run is OK and give the result that I expect,
      it's now only an issue of setting up my zabbix external check on the item that I'm not able to get properly.

      This is the KEY that I've set : script_lic_check[192.168.1.1,some_user,some_password]

      Comment

      • geostant
        Member
        • Feb 2015
        • 32

        #4
        I've tried now to set a simple shell script that only echo to a temp file the current time and date, just to make sure that it's not an issue with my python.

        Still now go, it's not even executing that simple shell script.
        Something is wrong for sure.

        Comment

        • Firm
          Senior Member
          • Dec 2009
          • 342

          #5
          Check zabbix_server.log for any errors regarding script run. May be there's no enough permissions to run script under zabbix user.

          Comment

          • nmz
            Member
            • Jan 2016
            • 69

            #6
            Solved?

            Does you solved this issue? I also faced with such as situation. I have no idea what to do. My script is located in zabbix server let's say (192.168.10.200) and I would like to get data from 192.168.10.202. When I setup item I just get result from 192.168.10.200.

            Waiting reply....

            Thanks

            Comment

            • geostant
              Member
              • Feb 2015
              • 32

              #7
              Hey,

              Yes I figured it out eventually.

              I've used PARAMIKO Python library which allow you to run linux command on the target SSH machine.

              Check it out :

              Comment

              Working...