Monit is a very rich process, file, directory and device monitoring software for the Linux/unix platform. It automatically fixes those programs that have stopped working, and the envoy is ready to handle software errors due to a variety of reasons, Monit contains an embedded HTTP (S) Web interface that you can use to easily view the servers that Monit monitors.
1. Download Monit
CentOS can go to: http://pkgs.repoforge.org/monit/Download the corresponding number of bits RPM package installation.
32-bit: Wget-c HTTP://PKGS.REPOFORGE.ORG/MONIT/MONIT-5.2.5-1.EL5.RF.I386.RPM;RPM-IVH monit-5.2.5-1.el5.rf.i386.rpm
64-bit: Wget-c HTTP://PKGS.REPOFORGE.ORG/MONIT/MONIT-5.2.5-1.EL5.RF.X86_64.RPM;RPM-IVH monit-5.2.5-1.el5.rf.x86_64. Rpm
Go to the RPM download directory and execute the install command RPM-IVH monit-5.2.5-1.el5.rf.x86_64.rpm
Debian can be installed directly: Apt-get install Monit.
2. Edit Configuration Monit Monitor Program
CentOS with RPM package installed if the configuration file in:/etc/monit.conf;debian apt-get installation of the words configuration file in:/ETC/MONIT/MONITRC;
There is a description in the configuration file:
Set daemon #设置检测时间
set logfile/var/log/monit.log #monit日志
set alert www@vpser.net with Reminder on 1 cycle #出现1次错误的时候发报警邮件到指定的邮箱
set mailserver mail.vpser.net #设置邮件服务器
set httpd port 2812 and # Set the port of the HTTP Monitoring page use
address 74.207.246.99 # HTTP Monitoring page IP allow localhost # allows local access
Allow 123.23.45.0/24 # allows this IP segment access
#allow 0.0.0.0/0.0.0.0 # allows all IP access allow
Username:password #设置访问用户名密码
The wiki of how to set up the operation can refer to http://mmonit.com/monit/documentation/monit.html#program_status_testing
The configuration of the FreeSWITCH is:
Check process FreeSWITCH with
pidfile/usr/local/freeswitch/log/freeswitch.pid
Start program = "/usr/local/ FREESWITCH/BIN/FREESWITCH-NC-HP "
Stop program ="/usr/local/freeswitch/bin/freeswitch-stop "
if memory > 1000.0 MB for 5 cycles then alert
if memory > 1500.0 MB for 5 cycles then alert
if memory > 2000.0 MB for 5 Cycles then restart
if CPU > 60% for 5 cycles then alert
if failed
port 5060 type UDP protocol SIP
Then Restart
3. After configuration, perform telinit q to activate just the configuration
Run Ps-ef at this time | grep FreeSWITCH Find FreeSWITCH's Fs_pid
Kill-9 Fs_pid
Wait a while (over set daemon 120) and you can see that the FreeSWITCH process is running again.
4. Start-Stop Monit
Chkconfig Monit on//join boot
/etc/init.d/monit {start|stop|restart|force-reload|syntax}
5. Issues to be aware of
Because the Monit is set to the daemon, and the system-initiated settings are added to the Inittab, the init process restarts the monit process if it stops, and Monit monitors the other services, which means that the services monitored by monit cannot be stopped using the usual method. Because of the stop, Monit will start it again. To stop a service that Monit is monitoring, you should use a command such as Monit stop name, such as to stop Tomcat:
Monit Stop Tomcat
To stop all monit monitored services, you can use Monit stop all.
To start a service you can use a command such as Monit stop name, start all with Monit start all