Ad Widget

Collapse

Having zabbix watch for a job completion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whitetr6
    Junior Member
    • Apr 2011
    • 12

    #1

    Having zabbix watch for a job completion

    I'm trying to figure out the best way to accomplish this. Our development team runs a number of nightly "jobs", mostly shell scripts, that do various things - backup databases, upload new code, etc. We need Zabbix to watch for completion of these jobs and alert if something fails.

    I've thought about just having the job shell script write a file "success" or "fail", and have Zabbix look for that. I've also considered reading from an event log, or a database table. We can implement whatever method would be easiest for Zabbix to monitor.

    Any suggestions are much appreciated.
    Thank you
  • jamesNJ
    Senior Member
    • Jun 2015
    • 103

    #2
    Look at the zabbix_send utility. I think you can use that with an active check to have your scripts send status to zabbix directly. You might have to construct something like a master script that dispatches your jobs and then sends success/fail to zabbix as the jobs complete or fail.

    Comment

    • akbar415
      Senior Member
      • May 2015
      • 119

      #3
      Originally posted by whitetr6
      I'm trying to figure out the best way to accomplish this. Our development team runs a number of nightly "jobs", mostly shell scripts, that do various things - backup databases, upload new code, etc. We need Zabbix to watch for completion of these jobs and alert if something fails.

      I've thought about just having the job shell script write a file "success" or "fail", and have Zabbix look for that. I've also considered reading from an event log, or a database table. We can implement whatever method would be easiest for Zabbix to monitor.

      Any suggestions are much appreciated.
      Thank you
      I do something like that.

      I make two check's.

      First I include in the script two thing
      a) Create a log file with word OK, if sucess, or FAIL.
      b)
      Code:
      echo $[ 1 + $[ RANDOM % 1000 ]] >> log_file
      This is to be shure that every log file created by the script have a singular checksum. This way if the script don't run (eg: problem with cron) I will know.


      Second I created the follow in Zabbix

      Check checksum vfs.file.cksum[log_file]
      Check Word in log file vfs.file.regmatch[log_file,Status = OK]

      And now, the trigger.

      Code:
      {hostname:vfs.file.cksum[log_file].change()}=0
      or
      {hostname:vfs.file.regmatch[log_file,Status = OK].last()}=0
      If the checksum don't change or if the regex Status=OK was not finded on the log, zabbix will alert me.

      Comment

      • jamesNJ
        Senior Member
        • Jun 2015
        • 103

        #4
        akbar415, is there some way to synchronize an action like that on a daily basis?

        Let's say for instance that I run scrip to change a file once per day at 1am, and then want to check that the file changed sometime after (like 2am), and send an alert if it hasn't changed.

        I would like to run a job once very early in the morning, and then sometime after check this and alert if the file was not properly updated.

        I think maybe I may need to have the item update hourly, and then execute a trigger if there was not change and hour was equal to the hour I expected it to change.

        Thanks

        Comment

        • akbar415
          Senior Member
          • May 2015
          • 119

          #5
          Originally posted by jamesNJ
          akbar415, is there some way to synchronize an action like that on a daily basis?

          Let's say for instance that I run scrip to change a file once per day at 1am, and then want to check that the file changed sometime after (like 2am), and send an alert if it hasn't changed.

          I would like to run a job once very early in the morning, and then sometime after check this and alert if the file was not properly updated.

          I think maybe I may need to have the item update hourly, and then execute a trigger if there was not change and hour was equal to the hour I expected it to change.

          Thanks

          Option 1 = Use Flexible intervals on item configuration to only update values of this item in the time you want.
          Option 2 = In the trigger expression put something like "Current time = N", so the trigger will only be fired in the hour you want

          Comment

          Working...