View Full Version : Schedule Maintenance
navtek007
16-10-2005, 22:43
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
17-10-2005, 19:27
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:
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
navtek007
18-10-2005, 01:31
Thanks for the reply, however the triggers still causes the SLA to change..
Any other ideas??
Nate Bell
18-10-2005, 17:00
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
navtek007
18-10-2005, 22:10
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.
mary nancy
21-04-2006, 00:25
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
navtek007
21-04-2006, 01:15
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.
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
navtek007
22-04-2006, 06:34
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
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?
btw, built-in maintenance support is already available in current trunk (that will become 1.8)
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.