Monit: Difference between revisions
From Bashlinux
Jump to navigationJump to search
Content deleted Content added
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
** Run Monit as daemon |
** Run Monit as daemon |
||
set daemon 120 |
set daemon 120 |
||
:* Send logs to /var/log/messages |
|||
set logfile syslog facility log_daemon |
set logfile syslog facility log_daemon |
||
:* Setup Monit Web Service with authentication from anywhere |
|||
set httpd port 2812 and |
set httpd port 2812 and |
||
allow user:password |
allow user:password |
||
:* Read configuration files for each service |
|||
include /etc/monit.d/* |
include /etc/monit.d/* |
||
* Open <tt>/etc/httpd/conf/httpd.conf</tt> and add the following lines: |
* Open <tt>/etc/httpd/conf/httpd.conf</tt> and add the following lines: |
||
| Line 62: | Line 62: | ||
=== How to setup and start M/Monit service === |
=== How to setup and start M/Monit service === |
||
==== Boot |
==== Boot from init.d ==== |
||
* Register the service to start on boot |
|||
chkconfig monit on |
chkconfig monit on |
||
| ⚫ | |||
| ⚫ | |||
service monit start |
service monit start |
||
| Line 72: | Line 71: | ||
* Append <tt>/etc/inittab</tt> to add: |
* Append <tt>/etc/inittab</tt> to add: |
||
mo:2345:respawn:/usr/bin/monit -Ic /etc/monit.conf |
mo:2345:respawn:/usr/bin/monit -Ic /etc/monit.conf |
||
| ⚫ | |||
| ⚫ | |||
init q |
init q |
||
Revision as of 03:27, 11 June 2015
How to install M/Monit from sources
- Download Monit tar file from tildeslash
wget http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz
- Unpack and install
tar zxvf monit-4.10.1.tar.gz cd monit-4.10.1 ./configure make make install
How to setup M/Monit
- Open /etc/monit.conf and set/uncomment this values:
- Run Monit as daemon
set daemon 120
- Send logs to /var/log/messages
set logfile syslog facility log_daemon
- Setup Monit Web Service with authentication from anywhere
set httpd port 2812 and allow user:password
- Read configuration files for each service
include /etc/monit.d/*
- Open /etc/httpd/conf/httpd.conf and add the following lines:
# Avoid Monit activity to be logged on Apache log SetEnvIf Request_URI "^/monit/token$" dontlog CustomLog logs/access_log common env=!dontlog
- Open port on iptables to watch monit on TCP port 2812
iptables -A INPUT -p tcp --dport 2812 -j ACCEPT
How to configure M/Monit services
Apache
File: /etc/monit.d/httpd.conf
check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/sbin/service httpd start"
stop program = "/sbin/service httpd stop"
if failed port host 127.0.0.1 port 80 protocol http
and request "/api/restaurant/id"
then restart
if 5 restarts within 5 cycles then timeout
MySQL
File: /etc/monit.d/mysqld.conf
check process mysql with pidfile /var/run/mysqld/mysqld.pid
group mysql
start program = "/sbin/service mysqld start"
stop program = "/sbin/service mysqld stop"
if failed host 127.0.0.1 port 3306 protocol mysql
then restart
if 5 restarts within 5 cycles then timeout
Actionqueue
File: /etc/monit.d/actionqueue.conf
check process actionqueue with pidfile /var/run/actionqueue.pid
group root
start program = "/sbin/service actionqueue start"
stop program = "/sbin/service actionqueue stop"
if failed host 127.0.0.1 port 8443
then restart
if 5 restarts within 5 cycles then timeout
How to setup and start M/Monit service
Boot from init.d
- Register the service to start on boot
chkconfig monit on
- Start service
service monit start
Respawnning with inittab
- Append /etc/inittab to add:
mo:2345:respawn:/usr/bin/monit -Ic /etc/monit.conf
- Start monit
init q