Monit คือ tools สำหรับ automatic monitor program, services, file หรือ permission ซึ่ง monit นั้นมาพร้อมกับ web interface ให้สามารถจัดการได้ง่ายขึ้น ซึ่ง build-in มากับ monit อยู่แล้วไม่ได้ติดตั้ง web server ใดๆ โดยในตัวอย่างจะติดตั้งบน Ubuntu Server 14.04 มีขั้นตอนดังนี้
ติดตั้งผ่าน package manager apt
sudo apt-get install monit
path ของ config file อยู่ที่ /etc/monit/monitrc ทำการเพิ่ม config ดังนี้
### เปิด web interface ให้สามารถแสดง monitor บน web set httpd port 2812 and use address 192.168.56.120 # only accept connection from localhost allow 127.0.0.1 # allow localhost to connect to the server allow 192.168.56.1 # allow another PC to connect to the server allow admin:monit # require user 'admin' with password 'monit' allow @monit # allow users of group 'monit' to connect (rw) allow @users readonly # allow users of group 'users' to connect readonly ### Monitor service nginx check process nginx with pidfile /var/run/nginx.pid start program = "/etc/init.d/nginx start" stop program = "/etc/init.d/nginx stop"
แล้ว restart service monit
sudo service monit restart
ทดสอบพิมพ์คำสั่ง
sudo monit status
ผลลัพธ์
ทดลองเข้า Monit ผ่าน web browser URL:http://:2812 แล้วใส่ Username และ Password ที่ได้ใส่ไปใน config ไฟล์ monitrc เมื่อ login สำเร็จจะขึ้นหน้าแรกดังรูป
แล้วคลิ๊กที่ host ใน List ในตัวอย่างจะคลิ๊ก monit.example.local จะแสดง item ต่างๆ ที่ monitor ได้
แล้วลองคลิ๊กที่ nginx ที่อยู่ใน list process
ก็จบสำหรับการติดตั้ง และใช้งานเบื้องต้นของ monit ครับ