-
-
Save centminmod/020eaf3d0d2785e301c0 to your computer and use it in GitHub Desktop.
Forked instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Monitor CentMinMod server using Monit | |
//About Monit | |
Monit is a helpful program that automatically monitors and manages server programs to ensure that they not only stay online consistently, but that the file size, checksum, or permissions are always correct. Additionally monit comes with a basic web interface through which all of the processes can be set up. This tutorial will cover the most basic setup and configuration. | |
//Install Monit on CentOS 6.5 | |
//STEP 1: Installation | |
//packages needed | |
yum install pam-devel | |
yum install openssl-devel | |
//STEP 2: Install Monit | |
cd /usr/local/src | |
wget http://mmonit.com/monit/dist/monit-5.8.tar.gz | |
tar -zxvf monit-5.8.tar.gz | |
cd monit-5.8 | |
./configure (If this fails, fix as necessary, then re-unpack the tar and try again) | |
make -j2 | |
make install | |
//STEP 3: Setup monitrc | |
cp monitrc /etc/ | |
vi /etc/monitrc | |
# Set the 'set daemon' line at the beginning to your preferred interval. | |
# At the end of monitrc add the following. | |
//nginx | |
check process nginx with pidfile /user/local/nginx/logs/nginx.pid | |
start program = "/etc/init.d/nginx start" | |
stop program = "/etc/init.d/nginx stop" | |
group nginx | |
//php-fpm | |
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid | |
group nginx | |
start program = "/etc/init.d/php-fpm start" | |
stop program = "/etc/init.d/php-fpm stop" | |
if failed host localhost port 80 protocol http | |
and request '/phpping' | |
with timeout 20 seconds for 5 cycles | |
then restart | |
## If the restarts attempts fail then alert. | |
if 3 restarts within 5 cycles then timeout | |
//MySql/MariaDB | |
check process mysql with pidfile /var/lib/mysql/server.yourdomain.com.pid | |
group nginx | |
start program = "/etc/init.d/mysql start" | |
stop program = "/etc/init.d/mysql stop" | |
if failed host localhost port 3306 protocol mysql then restart | |
if 5 restarts within 5 cycles then timeout | |
//STEP 4: setup the init.d file | |
cp contrib/rc.monit /etc/init.d/monit | |
chmod 755 /etc/init.d/monit | |
//You may need to fix the line inside the above file that's pointing at '/usr/bin/monit' to '/usr/local/bin/monit'. After this is in place you should have the 'service monit restart' command available. | |
//STEP 5: start Monit at boot | |
//edit vim '/etc/rc.d/rc.local' and add in the next line | |
/usr/local/bin/monit -c /etc/monitrc -p /var/run/monit.pid -l /var/log/monit.log | |
//STEP 6: Check | |
service monit status | |
//Optional - Enable email alert | |
cp monitrc /etc/ | |
vi /etc/monitrc | |
set mailserver localhost, # primary mailserver | |
set mail-format { from: [email protected] } | |
set alert [email protected] | |
//Optional - Enabling monitor status for online | |
cp monitrc /etc/ | |
vi /etc/monitrc | |
set httpd port 2812 and | |
use address YOURSERVER.com | |
allow monit:password //SET your own username and password | |
In case if you installed CSF firewall, Edit 'vi /etc/csf/csf.conf' and add the port 2812 in TCP_IN and TCP_OUT. then run 'csf -r' | |
Pushover API support: | |
http://mmonit.com/wiki/MMonit/Notification | |
Finish Up | |
Once you have configured all of the programs that you want to run, they will be automatically tracked and restarted should they turn off. | |
You can control the programs through both the web interface or the command line. | |
Once you have set up the configuration, check the syntax: | |
monit -t | |
After resolving any possible syntax errors, you can start running all of the monitored programs. | |
monit start all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment