| | |

Monit diegimas

Diegiame monit (servisų monitoringui):

sudo apt-get install monit


Patikriname:

sudo nano /etc/default/monit

Surandame ir jei reikia keičiam eilutę: startup=0 į startup=1

Koreguojam konfigūraciją:

sudo nano /etc/monit/monitrc

įrašome tai (arba atkomentuojame eilutes):

set daemon 120
set logfile syslog facility log_daemon
set mailserver localhost # primary mailserve

( konfigūruojame, kam bus siunčiama ataskaitos )

set mailserver localhost
set mail-format { from: [email protected] }
set alert [email protected]

( konfigūruojame prievadą ir prieeigos teises (web interfeisas) )

set httpd port 2812 and
 use address localhost # only accept connection from localhost
 allow localhost # allow localhost to connect to the server and
 allow 192.168.1.0/255.255.255.0
 allow admin:monit # require user ‘admin' with password ‘monit'

( ir konfigūruojame kokiems servisams vykdysime monitoringą, pvz. )

#Self test
check system myserver.domain.com
    if loadavg (1min) > 4 then alert
    if loadavg (5min) > 3 then alert
    if memory usage > 75% then alert
    if cpu usage (user) > 70% then alert
    if cpu usage (system) > 30% then alert
    if cpu usage (wait) > 20% then alert

( kiti servisai )

#Proftpd   
#check process proftpd with pidfile /var/run/proftpd.pid
#   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

#FTP
#check process vsftpd matching "vsftpd"
# start program = "/etc/init.d/vsftpd start"
# stop program = "/etc/init.d/vsftpd stop"

#SSH
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 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout

#Ntpd
check process ntpd with pidfile /var/run/ntpd.pid
   start program = "/etc/init.d/ntp start"
   stop  program = "/etc/init.d/ntp stop"
   if failed host 127.0.0.1 port 123 type udp then restart
   if 5 restarts within 5 cycles then timeout   

#Munin-node   
check process munin with pidfile /var/run/munin/munin-node.pid
    start program = "/etc/init.d/munin-node start"
    stop program  = "/etc/init.d/munin-node stop"
    if 5 restarts within 5 cycles then timeout

#MySql
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    

#Apache
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 host www.domain.com port 80 protocol http
      and request "/server-status" then restart
   if cpu is greater than 60% for 2 cycles then alert
   if cpu > 80% for 5 cycles then restart
   if totalmem > 500 MB for 5 cycles then restart
   if children > 250 then restart
   if loadavg(5min) greater than 10 for 8 cycles then stop
   if 3 restarts within 5 cycles then timeout

# cron
check process cron with pidfile /var/run/crond.pid
group system
start program = "/etc/init.d/cron start"
stop  program = "/etc/init.d/cron stop"
if 5 restarts within 5 cycles then timeout
depends on cron_rc

check file cron_rc with path /etc/init.d/cron
group system
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
# PAPILDYTA: denyhosts
check process denyhosts with pidfile /var/run/denyhosts.pid
 start program = "/etc/init.d/denyhosts start"
 stop program = "/etc/init.d/denyhosts stop"
 if cpu > 90% for 2 cycles then alert
 if 5 restarts within 5 cycles then timeout

check file denyhosts.conf
 with path /etc/denyhosts.conf
 if changed checksum then alert

Atlikus koregavimus nepamirštame:

sudo /etc/init.d/monit restart

PASTABA:
1) Nepamirštame pavyzdžiuose pakeisti/prisitaikyti konfigūraciją pagal savo serverį/tinklą/IP.
2) dažnai Mysql veikia be pid filo, monit monitoringui atliekame:

sudo nano /etc/mysql/my.cnf
ir [mysqld] skyriuje įrašome:
pid-file = /var/run/mysqld/mysqld.pid

LinuxOS: Ubuntu/debian

Kviečiu įvertinti įrašą!
[Viso: 0 Vidurkis: 0]

Similar Posts

Parašykite komentarą

El. pašto adresas nebus skelbiamas.

Sauga: 41 − = 38