随笔 - 0, 文章 - 264, 评论 - 170, 引用 - 0
数据加载中……

监控系统服务和端口,异常时实现自动重启

详见:http://www.51testing.com/html/86/n-214186.html

示例,监听ssh服务,如果停止则自动重启服务,步骤如下:
1、vi /etc/monit.d/sshd.monit。
2、撰写内容,如下:
check process sshd with pidfile /var/run/sshd.pid
    start program = "/etc/init.d/sshd start"
    stop program = "/etc/init.d/sshd stop"
    if failed port 22 protocol ssh then restart
    if 5 restarts within 5 cycles then timeout
3、如果要设置monit的相关参数,比如多长时间检测一次,请修改/etc/monit.conf,示例文件如下:
set daemon 300

set logfile /var/log/monit.log
set idfile /var/monit/id
set statefile /var/monit/state

set httpd port 2812 and use address 127.0.0.1
    allow 127.0.0.1
    allow surfront:surfront

check system 127.0.0.1

include /etc/monit.d/*.monit
4、重启monit服务,/etc/init.d/monit restart。
5、完毕,monit的相关日志位于/var/log/monit.log。

posted on 2013-03-01 17:08 小一败涂地 阅读(2986) 评论(0)  编辑  收藏 所属分类: linux相关性能调优相关surfront问题清单


只有注册用户登录后才能发表评论。


网站导航: