# yum install --enablerepo=epel monit
# cp /etc/monitrc /etc/monitrc.default
# vi /etc/monitrc
#set daemon 30
set daemon 60
# with start delay 240
set pidfile /var/run/monit.pid
set statefile /var/.monit.state
set ssl options {
verify: disable
}
【書式】 SET <SSL|TLS> [OPTIONS] { VERSION: <AUTO|SSLV2|SSLV3|TLSV1|TLSV11|TLSV12|TLSV13> VERIFY: <ENABLE|DISABLE> SELFSIGNED: <ALLOW|REJECT> CIPHERS: <string> PEMFILE: <path> CLIENTPEMFILE: <path> CACERTIFICATEFILE: <path> CACERTIFICATEPATH: <path> } |
SSLオプションステートメントは、Monit経由で行われるすべてのSSL / TLS接続にグローバルに適用されます。SSLオプションは、ローカルチェック、メールサーバー設定、またはmmonitステートメントでも設定でき、グローバル設定を上書きまたは拡張します。 グローバルSSLオプションを設定するには、次のステートメントを.monitrcファイルの先頭近くに配置します。 |
set mailserver localhost
with timeout 10 seconds
【書式】 SET MAILSERVER <hostname|ip-address> [PORT number] [USERNAME string] [PASSWORD string] [using SSL [with options {...}] [CERTIFICATE CHECKSUM [MD5|SHA1] <hash>], ... [with TIMEOUT X SECONDS] [using HOSTNAME hostname] |
set mail-format {
from: Monit Support <monit@example.jp>
reply-to: support@example.jp
subject: $SERVICE $EVENT at $DATE
message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
}
【書式】 set mail-format { from: Monit Support <monit@foo.bar> reply-to: support@domain.com subject: $SERVICE $EVENT at $DATE message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION. Yours sincerely, monit } |
【書式】 SET ALERT mail-address [[NOT]{event, ...}] [REMINDER cycles] |
set alert support@example.jp
【例】 check host myhost with address 1.2.3.4 if failed port 3306 protocol mysql then alert if failed port 80 protocol http then alert alert foo@baz # Local service alert |
set alert support@example.jp only on { timeout, nonexist }
set alert support@example.jp but not on { instance }
Event: | Failure state: | Success state: |
---|---|---|
action | "Action failed" | "Action done" |
checksum | "Checksum failed" | "Checksum succeeded" |
bytein | "Download bytes exceeded" | "Download bytes ok" |
byteout | "Upload bytes exceeded" | "Upload bytes ok" |
connection | "Connection failed" | "Connection succeeded" |
content | "Content failed", | "Content succeeded" |
data | "Data access error" | "Data access succeeded" |
exec | "Execution failed" | "Execution succeeded" |
fsflags | "Filesystem flags failed" | "Filesystem flags succeeded" |
gid | "GID failed" | "GID succeeded" |
icmp | "Ping failed" | "Ping succeeded" |
instance | "Monit instance changed" | "Monit instance changed not" |
invalid | "Invalid type" | "Type succeeded" |
link | "Link down" | "Link up" |
nonexist | "Does not exist" | "Exists" |
packetin | "Download packets exceeded" | "Download packets ok" |
packetout | "Upload packets exceeded" | "Upload packets ok" |
permission | "Permission failed" | "Permission succeeded" |
pid | "PID failed" | "PID succeeded" |
ppid | "PPID failed" | "PPID succeeded" |
resource | "Resource limit matched" | "Resource limit succeeded" |
saturation | "Saturation exceeded" | "Saturation ok" |
size | "Size failed" | "Size succeeded" |
speed | "Speed failed" | "Speed ok" |
status | "Status failed" | "Status succeeded" |
timeout | "Timeout" | "Timeout recovery" |
timestamp | "Timestamp failed" | "Timestamp succeeded" |
uid | "UID failed" | "UID succeeded" |
uptime | "Uptime failed" | "Uptime succeeded" |
set alert foo@bar { nonexist, timeout, resource, icmp, connection }
set alert security@bar on { checksum, permission, uid, gid }
set alert admin@bar
【書式】 SET ALERT mail-address [WITH] REMINDER [ON] number [CYCLES] |
alert foo@bar with reminder on 10 cycles
alert foo@bar with reminder on 1 cycle
set httpd port 2812 and
# use address localhost # only accept connection from localhost
# allow localhost # allow localhost to connect to the server and
allow admin:monit # require user 'admin' with password 'monit'
with ssl { # enable SSL/TLS and set path to server certificate
pemfile: /etc/httpd/certs/latest/monit.pem
}
なお、ここで指定したポート番号をFirewallで通す必要があります。 # firewall-cmd --add-port=2812/tcp --zone=public --permanent # firewall-cmd --reload |
#include /etc/monit.d/*
include /etc/monit.d/*.conf