-
Notifications
You must be signed in to change notification settings - Fork 6
/
monitrc
124 lines (103 loc) · 3.83 KB
/
monitrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
set daemon 30
with start delay 120
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server
# # Nginx
# check process nginx with pidfile /var/run/nginx.pid
# start program = "/etc/init.d/nginx start"
# stop program = "/etc/init.d/nginx stop"
# if cpu is greater than 40% for 2 cycles then alert
# if cpu > 60% for 5 cycles then restart
# if 10 restarts within 10 cycles then timeout
# if failed host 127.0.0.1 port 443 protocol https and
# status = 401
# then restart
# OpenVPN
check process vpn-network with pidfile /var/run/openvpn/server.pid
start program = "/etc/init.d/openvpn start server"
stop program = "/etc/init.d/openvpn stop server"
check host tap0 with address 10.8.0.1
start program = "/etc/init.d/openvpn start server"
stop program = "/etc/init.d/openvpn stop server"
if failed
icmp type echo count 5 with timeout 15 seconds
then restart
check process vpn-network-udp with pidfile /var/run/openvpn/server-udp.pid
start program = "/etc/init.d/openvpn start server-udp"
stop program = "/etc/init.d/openvpn stop server-udp"
check host tap1 with address 10.9.0.1
start program = "/etc/init.d/openvpn start server-udp"
stop program = "/etc/init.d/openvpn stop server-udp"
if failed
icmp type echo count 5 with timeout 15 seconds
then restart
# DROPBEAR
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/dropbear start"
stop program "/etc/init.d/dropbear stop"
if failed port 80 protocol dropbear then restart
# if 5 restarts within 5 cycles then timeout
# OpenSSH
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
# # stunnel
# check process stunnel4 with pidfile /var/run/stunnel4.pid
# start program = "/etc/init.d/stunnel4 start" with timeout 20 seconds
# stop program = "/etc/init.d/stunnel4 stop"
# if failed host 127.0.0.1 port 993 with timeout 20 seconds then restart
# if 3 restarts within 5 cycles then unmonitor
# dnsmasq
check process dnsmasq with pidfile /var/run/dnsmasq/dnsmasq.pid
start program = "/etc/init.d/dnsmasq start" with timeout 60 seconds
stop program = "/etc/init.d/dnsmasq stop"
if failed
host 127.0.0.1
port 53 use type udp
protocol dns
with timeout 60 seconds
then restart
if 3 restarts within 5 cycles then timeout
depends on dnsmasq-bin
depends on dnsmasq-hosts
check file dnsmasq-bin with path /usr/sbin/dnsmasq
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
check file dnsmasq-hosts with path /etc/hosts
if changed timestamp then restart
# # Tinyproxy
# check process tinyproxy with pidfile /var/run/tinyproxy/tinyproxy.pid
# start program "/etc/init.d/tinyproxy restart"
# stop program "/etc/init.d/tinyproxy stop"
# if failed host 127.0.0.1 port 8888 type tcp then restart
# # if 5 restarts within 5 cycles then timeout
# sslh
check process sslh with pidfile /var/run/sslh/sslh.pid
start program "/etc/init.d/sslh start"
stop program "/etc/init.d/sslh stop"
if failed host 128.199.74.12 port 443 type tcp then restart
# if 5 restarts within 5 cycles then timeout
# Configuration Credits
# --
# dnsmasq
# https://www.the-hawkes.de/monitor-your-raspberrypi-with-monit.html
#
# nginx
# https://gist.github.com/franck/1415908
#
# OpenVPN
# http://grimore.org/unix/monit/openvpn
#
# stunnel
# http://www.peter.ca/article11.11.html
#
# Tinyproxy
# http://grimore.org/unix/monit/tinyproxy