Ad Widget

Collapse

Long Running UserParameter Script Techniques

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pottmi
    Junior Member
    • Oct 2010
    • 4

    #1

    Long Running UserParameter Script Techniques

    Zabbix Crew,

    I understand that long running scripts in UserParameters cause problems with Zabbix and are discouraged.

    I am interested in doing some checks that could take as long as 1/2 hour.

    A) One of the suggested ways to deal with that is to use a cron job to run the long running script, and use a short running task to pickup the net result of the long running script. I don't like this option because I want to use Zabbix to initiate the check so that I can use Zabbix to disable the check.

    B) Another one of the suggestions is to zapcat library to push data into Zabbix. This is only a slightly better option because it still requires a cron job to initiate the check.

    Here are my questions:
    1) Are there other options to deal with long running checks?

    2) What happens to Zabbix when it does a long running check?
    (all other checks queued?, crash?, watch dog timer timeout?).

    3) Is this recognized as a weakness in Zabbix and is likely to change? Or is it just part of the Zabbix is inherently designed and like to never change?

    4) Are there other monitoring systems that do gracefully handle long running user created tests?

    --
    Michael
  • alixen
    Senior Member
    • Apr 2006
    • 474

    #2
    Hi,

    Originally posted by pottmi
    1) Are there other options to deal with long running checks?
    You could start the job via UserParameter and let it run in background.
    Your job can send its result later with zabbix_sender.

    Originally posted by pottmi
    2) What happens to Zabbix when it does a long running check?
    (all other checks queued?, crash?, watch dog timer timeout?).
    A timeout happens.
    Zabbix doesn't accept a timeout greater than 30s.

    Originally posted by pottmi
    3) Is this recognized as a weakness in Zabbix and is likely to change? Or is it just part of the Zabbix is inherently designed and like to never change?
    Not being a Zabbix developer, I can't answer to your questions.
    As a user, I also think that it is a weakness.
    Another weakness is that a the script called by UserParameter can only return a single value.
    I have some scripts that compute several parameters at once and I need to play some tricks to get around this limitation.

    Originally posted by pottmi
    4) Are there other monitoring systems that do gracefully handle long running user created tests?
    Don't know

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

    Comment

    • nelsonab
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2006
      • 1233

      #3
      You might want to look into a hybrid of sorts. You will need to divide your check into two pieces, the first interfaces with Zabbix (I'll call this the Zabbix Check) and the second interfaces with whatever you want to check (I'll call this the process check).

      The Zabbix check is called by the Zabbix agent and the first thing it does is to see if the process check has been run wihtin a specified window. If it has it will then pull the data needed from a local data cache and report that back to Zabbix.

      If the process check has been run outside the acceptable window the Zabbix portion will check to see if the process check is running and has not crashed (one way to do this is to have the process check output a timestamp at regular intervals to a file, and then check to see if there is a timestamp within an appropriate window.). If the process check has crashed, ensure the pid of the process check does not exist and restart. If the Zabbix portion detects no process check (normal process check termination) it will then spawn a new process check and then terminate leaving the process check running in the background.

      This is a high level, but hopefully this gives you an idea of how to accomplish this.

      Scripting is where the fun is! :-D
      RHCE, author of zbxapi
      Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
      Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

      Comment

      • trikke
        Senior Member
        • Aug 2007
        • 140

        #4
        Hi,

        an other idea would be to run the script with system.run[...,nowait]. Let the script put his output in a logfile and have zabbix monitor the Logfile!

        Greets
        Patrick

        Comment

        Working...