Monitorizare server cu Monit

monitaptitude install monit
modificam monit.rc (păstrați doar ce aveți/va interesează - spre ex. doar nginx sau apache, nu ambele):
cp /etc/monit/monitrc /etc/monit/monitrc_orig
 cat /dev/null > /etc/monit/monitrc
 vi /etc/monit/monitrc
set daemon  60
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: adresata@domeniu.ro }
set alert adresata@domeniu.ro
set httpd port 2812 and 
   SSL DISABLE 
   allow admin:test 

check process pro-ftpd with pidfile "/var/run/proftpd.pid"
        group ftp
        start program = "/etc/init.d/proftpd start"
        stop program  = "/etc/init.d/proftpd stop"
        if failed port 21 protocol ftp then restart
        if 5 restarts within 5 cycles then timeout
        depends on mysql

check process pure-ftpd with pidfile "/var/run/pure-ftpd/pure-ftpd.pid"
        group ftp
        start program = "/etc/init.d/pure-ftpd-mysql start"
        stop program  = "/etc/init.d/pure-ftpd-mysql stop"
        if failed port 21 protocol ftp then restart
        if 5 restarts within 5 cycles then timeout
        depends on mysql
check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/ssh start"
   stop program  "/etc/init.d/ssh stop"
   if failed port 2222 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout

check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"
   if failed host 127.0.0.1 port 3306 then restart
   if 5 restarts within 5 cycles then timeout
   if cpu usage is greater than 60 percent for 2 cycles then alert
   if cpu usage > 98% for 5 cycles then restart
   if 2 restarts within 3 cycles then timeout
   if 5 restarts within 5 cycles then timeout

check process apache with pidfile /var/run/apache2.pid
   group www
   start program = "/etc/init.d/apache2 start"
   stop program  = "/etc/init.d/apache2 stop"
   if failed port 80 protocol http then restart
   if cpu is greater than 60% for 2 cycles then alert
   if cpu > 80% for 5 cycles then restart
   if children > 512 then restart
   if loadavg(5min) greater than 10 for 8 cycles then stop
   if 3 restarts within 5 cycles then timeout

check process postfix with pidfile /var/spool/postfix/pid/master.pid
   group mail
   start program = "/etc/init.d/postfix start"
   stop program = "/etc/init.d/postfix stop"
   if failed port 25 protocol smtp then restart if 5 restarts within 5 cycles then timeout

check process named with pidfile /var/run/named/named.pid
 start program = "/etc/init.d/bind9 start"
 stop program = "/etc/init.d/bind9 stop"
 if failed host 193.192.42.4 port 53 type tcp protocol dns then restart
 if failed host 193.192.42.4 port 53 type udp protocol dns then restart
 if 5 restarts within 5 cycles then timeout

check process php5-fpm with pidfile /var/run/php5-fpm.pid
 group php
 start program = "/etc/init.d/php5-fpm start"
 stop program  = "/etc/init.d/php5-fpm stop"
 if failed unixsocket /var/run/php5-fpm.sock then restart
 if 3 restarts within 5 cycles then timeout

check process spamd with pidfile /var/run/spamd.pid
 group mail
 start program = "/etc/init.d/spamassassin start"
 stop  program = "/etc/init.d/spamassassin stop"
 if 5 restarts within 5 cycles then timeout
 if cpu usage > 99% for 5 cycles then alert
 if mem usage > 99% for 5 cycles then alert

check process fail2ban with pidfile /var/run/fail2ban/fail2ban.pid
 group security
 start program "/etc/init.d/fail2ban start"
 stop program "/etc/init.d/fail2ban stop"
 if 5 restarts within 5 cycles then timeout

check process nginx with pidfile /var/run/nginx.pid
 start program = "/etc/init.d/nginx start"
 stop program = "/etc/init.d/nginx stop"
 group www-data
  if children > 250 then restart
  if loadavg(5min) greater than 10 for 8 cycles then stop
  if failed host localhost port 80
      protocol HTTP request "/monit/token" then restart
  if 3 restarts within 3 cycles then alert
  if 3 restarts within 5 cycles then timeout



Monitorizare server cu monit

verificați sa aveți aceasi cale ca și mine la toate

introduceți în ispconfig la firewall la tcp si portul 2812

pornim monit dacă nu sunt erori

/etc/init.d/monit syntax
/etc/init.d/monit start

și deschidem:

https://www.domeniultau.net:2812/

 

 

Ultimele știri monitorizare:

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Zi cu cuvintele tale...