Skip to content

Instantly share code, notes, and snippets.

@IcaroBichir
Last active March 2, 2016 01:11
Show Gist options
  • Save IcaroBichir/40ac8e4477aaf3892afe to your computer and use it in GitHub Desktop.
Save IcaroBichir/40ac8e4477aaf3892afe to your computer and use it in GitHub Desktop.
Monit configuration for check nginx and tomcat on CentOS servers and send alerts to AWS SES.
set daemon 30
set logfile syslog
set idfile /var/.monit.id
####### MAIL CONF ######
set mailserver email-smtp.us-east-1.amazonaws.com port 465
username "***************"
password "***************"
using SSLV3 with timeout 30 seconds
set mail-format { from: noreply@yourdomain.com
subject: $SERVICE -- Proccess ID $EVENT
message: Alert from $HOST
Incident date and time: $DATE
$SERVICE service - (Process ID $EVENT) - $ACTION action was made
Event description: $DESCRIPTION.
Regards,
Monit
}
set alert sysadmin_alert@yourdomain.com
####### MONIT UI ######
set httpd
port 2812
use address 0.0.0.0
allow 127.0.0.1
## If you use UI, set user and passwd with md5
## allow md5 /etc/httpd/htpasswd
####### SERVICES ######
check system $HOST
if loadavg (5min) > 3 then alert
if loadavg (15min) > 1 then alert
if memory usage > 80% for 2 cycles then alert
if swap usage > 20% for 4 cycles then alert
if cpu usage (user) > 80% for 2 cycles then alert
if cpu usage (system) > 20% for 2 cycles then alert
if cpu usage (wait) > 80% for 2 cycles then alert
if cpu usage > 200% for 4 cycles then alert
## nginx
check process nginx
with pidfile /usr/local/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed host 127.0.0.1 port 80 then alert
## tomcat
check host 127.0.0.1 with address 127.0.0.1
start program = "/etc/init.d/tomcat start"
stop program = "/etc/init.d/tomcat stop"
if failed port 8080 then alert
if failed port 8080 for 5 cycles then restart
###### CHECK HOSTS #####
check host icarobichir with address icarobichir.com.br
if failed port 80 protocol http with timeout 30 seconds then alert
## Includes
include /etc/monit.d/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment