2

I have monit running 24/7/365 and sending alerts to an e-mail address and text messages to a phone equally.

However I would now like to stop the phone text msgs at night so they don't wake me up.

I can't just silence my phone because we are on call for any relatives that might need us in an emergency.

I will figure out later how to get "unable to restart server" text messages at all times.

I have this in my monitrc file:

set alert [email protected]
set alert [email protected]

So I would like to turn off the vtext.com alert by adding something like the below (that works in the individual service "check process" files)

not every "* 23,0-6 * * *"

Any ideas on how to implement that?

Thanks, Ron

2
  • So if something goes down in the middle of the night you don't want to know about it?
    – joeqwerty
    Mar 24, 2014 at 16:39
  • monit has faithfully restarted anything that was unavailable or was maxed out for 5 minutes (for example) so the system has always kept running, even though some users probably were kicked off. I only want to be woken up if the website goes down and stays down (which has never happened). I can investigate any performance issues the next day based on what alerts came by e-mail. I like to get the phone text messages during the day in case I'm away from my computer.
    – Ron
    Mar 24, 2014 at 21:01

2 Answers 2

1

You can "unmonitor" the services outside of core operational hours.

I worked in an environment where the main systems only ran in production for part of the day. At the beginning of the business day, we would start the systems and Monit services via cron.

################################################################################
# Start any core services on this machine
################################################################################
0    6 * * 1-5 $BIN/monit -g servers start all

At the close of the day, we'd stop certain services and unmonitor other services.

################################################################################
# Shutdown Brazzers
################################################################################
01  15 * * 1-5 $BIN/monit unmonitor `/bin/hostname`
50  23 * * 0-5 $BIN/monit -g servers stop all
51  23 * * 0-5 $BIN/monit -g base  stop all
52  23 * * 0-5 $BIN/monit stop all

You could do the same with something like the following if you're not concerned about actually responding to the alerts:

monit unmonitor SERVICE_NAME

Of course, one could say that you're not monitoring effectively if you're getting too much noise. That takes a different approach, but what's the point in getting alerts if you're going to ignore them?

1
  • 1
    Thanks, for that detailed example, but I do not want to unmonitor anything. I just want it to UN-set the one alert to [email protected] for a period of time every day. FYI: This section of the doc tells how to temporarily turn off the monitoring of any "check" mmonit.com/monit/documentation/monit.html#service_poll_time but that is NOT what I want to do ... I want the monitoring to go on all the time so I have a continuous log and "faithful employee" :-)
    – Ron
    Mar 24, 2014 at 21:13
0

Monit itself does not have a facility by which you can tell it to stop sending alerts while still monitoring a service. The way I would solve the problem is by shifting to the email system the responsibility of determining whether I should be alerted. What I would do is:

  1. Create a mailbox that is the direct recipient of the alerts.

  2. Set a .forward which is a script that checks whether to forward the email to the final destination depending on what the time of day is.

ewwhite's solution works only for some rather narrow use-cases where the sysadmin who has set up monit is okay with Monit a) not sending alerts during a certain period of time and also b) not doing anything about the service that is sending alerts at undesirable times. Because that's what "unmonitor" means: yes, Monit will stop sending alerts but it will also stop doing anything about the service. If it dies during the night, Monit won't restart it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .