Ad Widget

Collapse

How to monitor if script was started/ended

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pioterus
    Junior Member
    • Jul 2020
    • 9

    #1

    How to monitor if script was started/ended

    Imagine the script run from crontab/windows task scheduler.

    How to monitor if this script was actually fired up and than ended? Please note, that this check cannot assume that the script itself will send such notification (using zabbix_sender) to Zabbix. Because of when it will not run it will not send any info.

    I need to check if it was actually run (possible reasons why it could fail: scheduler failure, permissions changed, script was renamed/deleted etc).

    One idea is to set value to some item in the script at the start and end and check if this item was actually set a value during the period of the scheduled run (at the beginning and end). If nothing would be changed then something went wrong. But it is a bit weird especially at the end, because I have to calculate when the script finishes. It is quite problematic.

    To use other words: I need a watchdog for this script but using Zabbix only.

    Any better ideas?

    Regards
    P.
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    Maybe something like zabbix sender and an item for start and end. If you expect the script to run hourly, a nodata trigger on the start item. If you expect the script to run in under 1 minute, the a difference between the two with a nodata() on the first item to not trigger if it's last update time stamp is UNDER 1 minute.

    Comment

    • pioterus
      Junior Member
      • Jul 2020
      • 9

      #3
      Yes, this is something I was thinking about. The problem is how to use nodata() in trigger properly: call it only when we expect the script should be running so we can expect data, but don't use it outside this period because then nodata() would obviously fire up the trigger.

      Comment

      • Singularity
        Member
        • Aug 2020
        • 81

        #4
        Since its a cronjob, you can output start time, end time, result, and errors(if any) to a txt file or json file or xml file and then read that file by creating an item-key logic in zabbix and finally pre-processing the text data you get by creating dependent items.

        Comment

        • isaqueprofeta
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Aug 2020
          • 154

          #5
          Look where your scheduling solution is sending the execution logs, or create a log output inside your script and write it to a file, then use Logfile monitoring in zabbix.

          Comment

          Working...