With the integrated monitoring daemon, you can perform email notification, automatic recovery, etc., and monitoring above the set threshold. -Http response, process, port monitoring Example) Apache, MySQL, SSL, Postfix, fluentd ・ CPU, memory, load average, disk capacity, etc.
$ sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ sudo yum -y install monit
$ rpm -ql monit
/etc/logrotate.d/monit
/etc/monit.d
/etc/monit.d/logging
/etc/monitrc
/usr/bin/monit
/usr/lib/systemd/system/monit.service
/usr/share/doc/monit-5.14
/usr/share/doc/monit-5.14/COPYING
/usr/share/doc/monit-5.14/README
/usr/share/man/man1/monit.1.gz
/var/log/monit.log
$ sudo cp -av /etc/monitrc{,.bk}
`/etc/monitrc' -> `/etc/monitrc.bak'
// -a Copy with permissions as much as possible
// -v Show file name before copying
// {,.bk}With a technique called brace deployment.Copy with file name bk
$ vi /etc/monitrc
…
set daemon 30 //The default check interval is 30 seconds, so change it arbitrarily.
…
include /etc/monit.d/*.conf // .Edit to read only conf
set httpd port 2812 and #Web interface port(Default:2812)
allow localhost #IP to allow access(localhost)
allow XXX.XXX.XXX.XXX/XX #IP to allow access(Any IP)
allow admin:monit #Management console user='admin' password='monit'
#Comment out because SSL is not used below
#with ssl { # enable SSL/TLS and set path to server certificate
# pemfile: /etc/ssl/certs/monit.pem
#}
$ vi /etc/monit.d/XXXX.conf //Create new for each setting
$ mv /etc/monit.d/logging /etc/monit.d/logging.conf //Rename log configuration file
The following is the main configuration file.
/etc/monitrc
backup:/etc/monitrc.bk
Include and read the following individual configuration file.
/etc/monit.d/*.conf
/etc/monit.d/test.conf
//Monitoring process settings
check process test matching "test"
//Startup settings
start program "/usr/local/test/bin/start_test.sh"
//Stop setting
stop program "/usr/local/test/bin/stop_test.sh"
//If there is no process, restart
if does not exist then restart
//Notify slack *
if does not exist then exec "/usr/local/test/bin/slacknotice.sh"
//If you do not wake up after restarting 5 times during 5 monitoring, stop
if 5 restarts within 5 cycles then unmonitor
Don't forget to give execute permission to the executing shell.
$ chmod +x
Slack notification reference site: https://cloudpack.media/10085
echo "0 */1 * * * /usr/bin/monit monitor all" >> /var/spool/cron/root
https://hogem.hatenablog.com/entry/20090723/1248358467
Start command
$ systemctl start monit
Automatically starts when the OS starts
$ systemctl enable monit
Stop command
$ systemctl stop monit
status
$ monit status
Reload when setting is changed (Important !!)
$ monit reload
Test command when changing settings
$ monit -t
Know the monitoring status
$ monit summary
When monit is skipped (when Not monitored)
$ monit monitor all
Command list
$ monit -h
IP: IP of monit server
PORT: PORT set in ⑤'
http://XXX.XXX.XXX.XXX:2812/
The following sites were described in detail. https://inokara.hateblo.jp/category/monit
Recommended Posts