Ad Widget

Collapse

Trigger for detecting external scripts ( on proxy ) timeout ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pigi_102
    Member
    • Sep 2021
    • 35

    #1

    Trigger for detecting external scripts ( on proxy ) timeout ?

    Hi all,
    in my environment I have a Zabbix server that "asks" a Zabbix proxy to execute some external scripts to gather some information that could not be retrieved in other way.
    Everything is fine but there are situation where the script hangs and so the timeut mechanism "kill" it and I don't get data back to server.
    Also this is expected. It could happens and I'm aware of it.

    In some other particular situation the script does not complete as the service I'm checking for, for some reason does not answer for very long time ( days at least ).

    Obviously ( and as expected ) in both case I get, from the zabbix interface, an exclamation mark and a message stating "Timeout while executing a shell script."

    I would like to implement a trigger that, if I don't get data from the script after, say, a couple of hours, inform me of the situation.
    I've tried with nodata() but is not behaving as I thought it would.
    this is one of my test:
    nodata( /host/extcheck.sh,1200)=0
    I thought it would have mean:" If I don't get data for the last 1200 seconds the trigger fires" but is not ( and even changing from 0 to 1 the check does not works )

    How could I implement a trigger that fires if data is not received from an externalscript for a period of time ?

    Thanks in advance

    Pigi_102
  • Pigi_102
    Member
    • Sep 2021
    • 35

    #2
    The problem is that the data aren't already been sent ( one of the host is not answering to check since yesterday ).
    Should it be triggereed anyway or the data/time relationship is not in the historicals check but starts from when I've configured the trigger and from when the first check after configuring the trigger fails to gather data ?
    Thx

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #3
      I take it that your script is started by an item with "external check" type, right?
      Zabbix does not evaluate the script itself, but the item data.
      My guess is that, since you're are getting a "Timeout" error, your item might be getting unsupported before having no data, thus preventing the "nodata()" function from triggering.

      Comment

      • Pigi_102
        Member
        • Sep 2021
        • 35

        #4
        So there is no way, if an external script get killed from zabbix_proxy for a timeout, to interept this kind of events ?
        The script, when does not timeout, works correctly and I have a whole bunch of history results.

        I'm planning now on modify the script to trap the kill signal and echo a value for the return:

        Code:
        #!/bin/bash
        
        function cleanup()
        {
        echo 3
        rm -f $FILE
        }
        
        
        echo $$
        FILE=$( mktemp )
        echo $FILE
        trap cleanup EXIT
        sleep 60
        In this way I can intercept the return value and trigger on it.

        Sound like a plan ?

        Pigi

        Comment

        • Pigi_102
          Member
          • Sep 2021
          • 35

          #5
          Also this way does not work.
          It seems that, once the script has been killed by zabbix_proxy: task_manager it does not wait for a return so I can't intercept the "new" output.

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4807

            #6
            it should be nodata(/host/extcheck.sh,1200)=1
            Returns:
            1 - if no data received during the defined period of time
            0 - otherwise
            I don't really know why it did not work for you .. Did you wait enough? ...

            Comment

            Working...