I am just starting to learn monit. On its man page I found this:
The behavior of Monit is controlled by command-line options and a run control file, ~/.monitrc, the syntax of which we describe in a later section. Command-line options override .monitrc declarations.
And when I created my .monitrc file with the following content and test it, it showed errors and I changed it and it is fine now:
➜ brt_client git:(master) ✗ monit -t
/home/jgu/.monitrc:2: Warning: Program does not exist: 'echo'
➜ brt_client git:(master) ✗ vim ~/.monitrc
➜ brt_client git:(master) ✗ vim ~/.monitrc
➜ brt_client git:(master) ✗ monit -t
➜ brt_client git:(master) ✗
but when I do service monit restart, I got this:
➜ brt_client git:(master) ✗ service monit restart
* Stopping daemon monitor monit [ OK ]
* Starting daemon monitor monit empty config, please edit /etc/monit/monitrc.
So I checked the code in /etc/init.d/monit and found this:
CONFIG="/etc/monit/monitrc"
monit_check_config () {
# Check for emtpy config.
if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]
then
echo "empty config, please edit $CONFIG."
exit 0
fi
}
So if I am not wrong, this program does not take -c or other flags. And I checked the log in /var/log/monit.log, it did not show that I restarted it. Of course, according to the script, it just exited with 0(why it is exiting with 0?).
So I checked the file, turns out I do not have the access to read /etc/monit/monitrc. So get sudo privilege for moinit and tried again. It is fine.
So now comes the actual question:
I did not find anything related to "~/.monitrc" in /etc/monit/monitrc, like "include ~/.monitrc", only include the directory in conf.d, how does monit know to load .monitrc in home directory? (By magic?)
And let's say I logged out and my college login to my computer with his account, does that mean my configuration will not work for him at all?
But that monit reload should have happened right? (if it does not get reloaded, then my ~/.monitrc should still be functioning)