monit

простой мониторинг

Задача

Задача

Решение

Решение

monit

Мониторинг

Процессы

Процессы

if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart

Сервисы

Сервисы

if failed url
  http://bill:1337@msft.com:81/?query
  and content == 'my.*regex' then alert
if failed icmp type echo count 5
  with timeout 15 seconds
  then alert
if failed port 80 proto http then alert
if failed port 443 type TCPSSL proto http
  then alert
if failed host cave.persia.ir port 4040
  send "Open, Sesame!\r\n"
  expect "Please enter the cave\r\n"
then restart

Файлы и папки

Файлы и папки

if changed checksum then exec "echo 123"
if failed checksum and 
 expect the sum 8f7f419955cefa0b33a2ba316cba3659
 then alert
if changed timestamp then exec 'apache.sh restart'
if size > 50 MB then exec 'logrotate'
if match 'Houston, we have a problem' then alert
check file su with path /bin/su
  if changed size then exec "ifconfig fxp0 down"

Файловые системы

Файловые системы

 check device rootfs with path /dev/hda1
  if space usage > 80% 5 times within 15 cycles 
     then alert 
     else if passed for 10 cycles then alert
  if space usage > 90% for 5 cycles then 
     exec '/try/to/free/the/space'
  if space usage > 99% then exec 'kill -9 1'

Удалённые файлы

if failed port 80 protocol http
  and request "/page.html"
  with checksum 350d6c0157a04c84012475bd87609db4
  then alert

Система

Система

if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 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

Действия

Действия

then alert
then stop
then restart
then exec 'true' as uid 1 gid 1
then unmonitor

Уведомления

CLI-интерфейс

monit summary
  The monit daemon 4.10.1 uptime: 10h 53m
  Process 'vpnc'                      running
  System 'pollux.cenkes.org'          running
monit status
monit reload
monit validate
monit restart apache
monit restart all

Веб-интерфейс

Недостатки

Преимущества

mmonit.com/monit/