Ad Widget

Collapse

Schedule Maintenance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • navtek007
    Senior Member
    • May 2005
    • 100

    #1

    Schedule Maintenance

    Do you think that schedule maintenance would be coming in the next release? If not has anyone created a extension/script for zabbix to allow schedule maintenance so we dont get alerts and doesnt affect our SLA's.

    I have created the sql to stop monitoring all triggers (let me know if you want the code) for a specified host and created a cronjob to run at a specified time but this has its limits. if anyone has any other ideas on how best to implement this then that would be great.

    Thanks in advanced.
  • Nate Bell
    Senior Member
    • Feb 2005
    • 141

    #2
    My solution was to make a script that simply turns off every user's media. Run it once, they all turn off, run it again, they all turn back on. That way, you still have a log of the triggers going off if you want that data, and no one gets an alert.

    The downside to the script is if there are any users with media turned off, the script will turn them on with everything else. I could extend the script to keep track of which media was off in a temporary file, or I could just make sure I only have media defined that I want to be used (which is the solution I'm using).

    Here is my script if you would like it. It assumes you are using mysql and the database name is zabbix:
    Code:
    status=$(mysql -e 'select * from media;' zabbix | tail -n 1 | cut -f5)
    if [ "$status" -eq "0" ]; then
       echo Turning Zabbix Alerts OFF
       mysql -e 'update media set active = 1 where active  = 0;' zabbix
    fi
    
    if [ "$status" -eq "1" ]; then
       echo Turning Zabbix Alerts ON
       mysql -e 'update media set active = 0 where active  = 1;' zabbix
    fi

    Comment

    • navtek007
      Senior Member
      • May 2005
      • 100

      #3
      Thanks for the reply, however the triggers still causes the SLA to change..

      Any other ideas??

      Comment

      • Nate Bell
        Senior Member
        • Feb 2005
        • 141

        #4
        Well, you could modify the script to turn off every trigger, or every trigger for a specific host. But again, with this method any triggers already turned off will get turned back on with the rest of them.

        It seems like this would be a great addition to Zabbix, but I can't remember if Alexi is planning on including this in 1.1. Sadly, by PHP knowledge is lacking, so most of my tweaks to Zabbix are in the form of shell scripts.

        Nate

        Comment

        • navtek007
          Senior Member
          • May 2005
          • 100

          #5
          Dont worry I'm not the best at shell scripting.. I was thinking of doing something like this:

          1. Create a maintenance schedule page in zabbix similiar to the notification page.
          2. Create a page to link hosts to a maintenance schedule similiar to host/template linkage page
          3. Create a daemon that would query the maintenance table and turn off specified hosts triggers at the specified maintenance time.

          Ok easy said then done right!! 1 and 2 i'm ok about but I'm a little rusty on how I could do 3. Any ideas? Or maybe i'm taking the wrong angle on this one.

          Thanks.

          Comment

          • mary nancy
            Senior Member
            • Jul 2005
            • 125

            #6
            Hi

            I am interested in knowing the procedure to put one particular server in maitenance mode for a specific period. not all the servers.
            I hope to place this in maintenance mode through web console.
            Is it possible?????

            Regards
            Nancy

            Comment

            • navtek007
              Senior Member
              • May 2005
              • 100

              #7
              Hi Nancy,

              I put the following in place for schedule maintenance.

              1. Created a sql script that would turn off triggers for specific host groups.
              2. Created a sql script that would turn on triggers for specific host groups.
              3. Create a cron job to execute the specifed script at the specified time

              Basically what this allows me to do is turn off triggers during our system maintenance periods and also turn them off so our SLA's are not affected during the maintenance period.

              SQL Script:

              update triggers ,functions, items, hosts set triggers.status = 1
              where triggers.triggerid = functions.triggerid
              and items.itemid = functions.itemid
              and hosts.hostid = items.hostid
              and hosts.host like '%'
              and hosts.status=0;

              I hope this helps.

              Comment

              • crs9
                Member
                • Feb 2006
                • 35

                #8
                bash script vs sql script

                I'm very familiar with bash scripting, but never looked at mql scripting. Are they basically the same? Do you have to place the sql script anywhere specific and how do you execute it?

                Thanks

                Comment

                • navtek007
                  Senior Member
                  • May 2005
                  • 100

                  #9
                  Ok there are a couple of ways you could do this. I have just done the following:

                  1. Create a file called triggers_off.sh
                  2. copy the below script into the file
                  3. then add a cron job that executes your script according to your operational/maintenance schedules
                  4. to turn your triggers back on again just change the update command to set triggers.status = 1. Once again create another file (triggers_on.sh) with the same script in. Add a cron job to turn the triggers back on when maintenance is finished.

                  * Note that this sql script will only work in mysql 4.x

                  --------------------------------------

                  #!/bin/bash

                  USER=dbuser
                  PASSWD=dbpassword
                  DB=dbname


                  triggers="update triggers ,functions, items, hosts set triggers.status = 0
                  where triggers.triggerid = functions.triggerid
                  and items.itemid = functions.itemid
                  and hosts.hostid = items.hostid
                  and hosts.host like '%'
                  and hosts.status=0;"

                  echo $triggers | mysql -t -u $USER --password=$PASSWD --database=$DB > triggers_off.log

                  Comment

                  • ahahum
                    Member
                    • Jan 2009
                    • 79

                    #10
                    Great Idea

                    This seems like a great idea. I have a question though, will the alerts go off after the script is run and it detects if something goes down?

                    What I need is the ability to not be alerted overnight for certain triggers, but if they are still true at the start of business hours I need to know.

                    Does anyone else have this sort of setup?

                    Comment

                    • richlv
                      Senior Member
                      Zabbix Certified Trainer
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Oct 2005
                      • 3112

                      #11
                      btw, built-in maintenance support is already available in current trunk (that will become 1.8)
                      Zabbix 3.0 Network Monitoring book

                      Comment

                      • ahahum
                        Member
                        • Jan 2009
                        • 79

                        #12
                        Originally posted by richlv
                        btw, built-in maintenance support is already available in current trunk (that will become 1.8)
                        Yes, I am aware of that, but I have 4 more months to wait!

                        I'm trying to get something in place sooner so we can move off our old monitoring solution.

                        Comment

                        Working...