7. monit基本設定
• # cat /etc/monit/monitrc| grep -v "^#"
• set daemon 60
• with start delay 240
• set mailserver smtp.gmail.com port 587 username
"example@example.com" password "example" using tlsv1
• set alert example@example.com not { instance }
• set httpd port 2812 and
• use address localhost # only accept connection from localhost
• allow localhost # allow localhost to connect to the server and
• include /etc/monit/conf.d/*.conf
• monitのhttpdを動かさないとステータスが取れない
9. VNC
• # cat /etc/monit/conf.d/vnc4server.conf
• check process vnc4server matching Xvnc4
• start program "/bin/su user -c 'vnc4server :1 -geometry 1200x768'"
• stop program "/bin/su user -c 'vnc4server -kill :1'"
• #if failed port 5901 then alert
• #if failed port 5901 for 5 cycles then restart
• VNCのポートを認証無しでアクセスを繰り返すと通常のVNCアクセスも出
来なくなる。
10. Iceweasel/Firefox
• # cat /etc/monit/conf.d/iceweasel.conf
• check process iceweasel matching firefox-bin
• start program "/bin/su user -c 'DISPLAY=:1.0 /usr/bin/iceweasel & '"
• stop program "/usr/bin/pkill -9 firefox-bin"
• if totalmem > 500.0 MB for 5 cycles then restart
• if cpu > 60% for 5 cycles then alert
• if cpu > 90% for 5 cycles then restart
• depends on vnc4server
• プロセス名でのマッチングはマニュアル記載サンプルの方法では文法エ
ラー
• NG:
• check process matching "/sbin/dynamic_pager -F /private/var/vm/swapfile"
• OK:
CHECK PROCESS <unique name> <PIDFILE <path> | MATCHING <regex>>
11. Process 'vnc4server'
monit status コマンド • Process 'iceweasel'
status Running • status Running
monitoring status Monitored
pid 9360 • monitoring status Monitored
parent pid 1 • pid 3639
uptime 65d 6h 51m • parent pid 1
children 0
memory kilobytes 23284 • uptime 11m
memory kilobytes total 23284 • children 0
memory percent 4.5% • memory kilobytes 73596
memory percent total 4.5%
cpu percent 0.0% • memory kilobytes total 73596
cpu percent total 0.0% • memory percent 14.4%
data collected Thu, 19 Jul 2012 00:30:40 • memory percent total 14.4%
Process 'sshd'
• cpu percent 0.0%
status Running • cpu percent total 0.0%
monitoring status Monitored • data collected Thu, 19 Jul 2012 00:30:40
pid 11381
parent pid 1
uptime 20d 6h 40m • System 'system_joesvps.dip.jp'
children 11 • status Running
memory kilobytes 332
• monitoring status Monitored
memory kilobytes total 39288
memory percent 0.0% • load average [0.51] [0.28] [0.36]
memory percent total 7.7% • cpu 0.0%us 0.0%sy 0.0%wa
cpu percent 0.0%
• memory usage 190004 kB [37.3%]
cpu percent total 0.0%
port response time 0.062s to localhost:22 [SSH via TCP] • swap usage 48892 kB [3.3%]
data collected Thu, 19 Jul 2012 09:30:40 • data collected Thu, 19 Jul 2012 00:30:40
上記のような出力が得られる monitのhttpdの動作が必要(前述)
# monit status