Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@eksiscloud
eksiscloud / apache2
Last active April 22, 2020 17:20
Monit: Apache2 (backend of Varnish)
#Apache2
check process apache with pidfile /var/run/apache2/apache2.pid
group www
start program = "/usr/sbin/service apache2 start"
stop program = "/usr/sbin/service apache2 stop"
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 2 GB for 5 cycles then restart
if children > 250 then restart
@eksiscloud
eksiscloud / mysql
Created April 22, 2020 17:22
Monit: MariaDB and MySQL
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group database
group mysql
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart
if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart
if 5 restarts with 5 cycles then timeout
depend mysql_bin
depend mysql_rc
@eksiscloud
eksiscloud / php-fpm
Last active April 22, 2020 17:57
Monit: PHP-FPM
# PHP-FPM
check process php7.3-fpm with pidfile /var/run/php/php7.3-fpm.pid
start program = "/usr/sbin/service php7.3-fpm start" with timeout 60 seconds
stop program = "/usr/sbin/service php7.3-fpm stop"
if failed unixsocket /var/run/php/php7.3-fpm.sock then restart
if 2 restarts within 2 cycles then timeout
@eksiscloud
eksiscloud / redis
Created April 22, 2020 18:01
Monit: Redis
# Redis
check host redis.host with address 127.0.0.1
if failed port 6379 protocol redis then alert
check process redis-server with pidfile "/var/run/redis/redis-server.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if failed host 127.0.0.1 port 6379 then restart
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
@eksiscloud
eksiscloud / fail2ban
Created April 22, 2020 18:12
Monit: Fail2ban
Fail2ban
check process fail2ban with pidfile /var/run/fail2ban/fail2ban.pid
group services
start program = "/etc/init.d/fail2ban force-start"
stop program = "/etc/init.d/fail2ban stop || :"
if failed unixsocket /var/run/fail2ban/fail2ban.sock then restart
if 5 restarts within 5 cycles then timeout
check file fail2ban_log with path /var/log/fail2ban.log
if match "ERROR|WARNING" then alert
@eksiscloud
eksiscloud / postfix
Created April 22, 2020 18:14
Monit: Postfix
# Postfix
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 host YOUR-RELAY-HOST port 587
type tcp protocol smtp using tls
with timeout 15 seconds
then alert
if 3 restarts within 5 cycles then timeout
@eksiscloud
eksiscloud / cron
Created April 22, 2020 18:21
Monit: Cron
check process crond with pidfile /var/run/crond.pid
group system
group crond
start program = "/etc/init.d/cron start"
stop program = "/etc/init.d/cron stop"
if 5 restarts with 5 cycles then timeout
depend cron_bin
depend cron_rc
depend cron_spool
@eksiscloud
eksiscloud / host
Created April 22, 2020 18:31
Monit: Virtual host/domain
### eksis.one
check host eksis.one with address www.eksis.one
# ICMP check
if failed icmp type echo
for 2 times within 2 cycles
then alert
# HTTPS check
if failed port 443 type tcpSSL protocol http
@eksiscloud
eksiscloud / hitch
Created April 22, 2020 18:52
Monit: Hitch
# Hitch
check process hitch with pidfile /var/run/hitch.pid
start program = "/usr/bin/systemctl start hitch" with timeout 30 seconds
stop program = "/usr/bin/systemctl stop hitch"
if failed host 127.0.0.1 port 443 type tcpSSL protocol http
and request /index.html with timeout 5 seconds for 2 times within 2 cycles
then restart
if 2 restarts within 2 cycles then timeout
@eksiscloud
eksiscloud / www.conf
Last active May 2, 2020 07:59
PHP-FPM: pm-pools for 8GB/4CPU VPS where is 20 - 5000 users per day
; DigitalOcean 4 CPU, 8 GB RAM
; PHP7.3-FPM
; If all pools hit in with full power there isn't enough RAM, I reckon.
;
; static
; Wordpress, 2000 - 5000 users per day
[www]
user = www-data
group = www-data
listen = /run/php/php7.3-fpm.sock