|
本帖最后由 yjc666 于 2017-1-23 15:58 编辑
Monit是一款功能非常丰富的进程、文件、目录和设备的监测软件,用于Unix平台。它可以自动修复那些已经停止运作的程序,特使适合处理那些由于多种原因导致的软件错误。
更多的自行百度。使用一段时间后,发现系统资源占用极低,非常适合用来监控迅雷,aria2等耗资源,容易死的程序。
环境:迅雷下载宝pro(MT7621,RAM256)
目的:解决迅雷下载宝PRO离线
1. 安装
opkg install http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620n/packages/packages/monit-nossl_5.8.1-2_ramips_24kec.ipk
2. 配置
修改 /etc/monitrc
- # 设置监控时间间隔:60秒
- set daemon 60
- #设置发送邮件预警的邮件服务器(自行修改)
- set mailserver smtp.139.com USERNAME "admin@139.com PASSWORD "yourpassword"
- #设置保存的目录(本例设置/var/monit),设置完受到mkdir目录,不设置的话邮件发送失败不会再次发送。
- set eventqueue
- basedir /var/monit # set the base directory where events will be stored
- slots 100 # optionally limit the queue size
- #收到邮件的内容(自行修改,至少邮件帐号得改)
- set mail-format {
- from: admin@139.com
- subject: monit alert -- $EVENT $SERVICE
- message: $EVENT Service $SERVICE
- Date: $DATE
- Action: $ACTION
- Host: $HOST
- Description: $DESCRIPTION
- Your faithful employee,
- Monit
- }
- #设置接收邮件的帐号(自行修改)
- set alert admin@189.cn # receive all alerts
- #设置web状态窗口,设置了可以远程连接查看状态
- set httpd port 2812 and
- use address 192.168.2.50 # only accept connection from localhost
- allow localhost # allow localhost to connect to the server and
- allow 192.168.2.8
- 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
- ###############################################################################
- ## 系统监控
- ###############################################################################
- ##
- ## Check general system resources such as load average, cpu and memory
- ## usage. Each test specifies a resource, conditions and the action to be
- ## performed should a test fail.
- #
- check system localhost
- if loadavg (1min) > 6 then alert
- if loadavg (5min) > 5 then alert
- if memory usage > 75% then alert
- # if swap usage > 25% then alert
- if cpu usage (user) > 70% then alert
- if cpu usage (system) > 30% then alert
- if cpu usage (wait) > 20% then alert
- ##程序监控。监控etm进程
- check process etm with pidfile /var/run/xunlei.pid
- start program = "/etc/init.d/etmsh start" with timeout 60 seconds
- stop program = "/etc/init.d/etmsh stop"
-
- # cpu占有超过60% 2次,则警告
- if cpu > 60% for 2 cycles then alert
- # if cpu > 80% for 5 cycles then restart
- # if totalmem > 200.0 MB for 5 cycles then restart
- # if children > 250 then restart
- # 负载超过10 达到8次,重启迅雷
- if loadavg(5min) greater than 10 for 8 cycles then restart
- # http://127.0.0.1:/getsysinfo获取失败,重启迅雷
- if failed host localhost port 9000 protocol http
- and request "/getsysinfo"
- then restart
- # if failed port 443 type tcpssl protocol http
- # with timeout 15 seconds
- # then restart
- # if 3 restarts within 5 cycles then timeout
- # depends on apache_bin
- # group server
- #
- #自定义脚本监控
- check program myscript with path /usr/sbin/tdrx.sh with timeout 15 seconds
- #连续5次 返回状态0,警告(脚本调用vnstat -tr -ru获取网络接口速度,超过100kb/s,返回状态1;低于100kb/s,返回0;速度低于10kb,返回3)
- start program = "/etc/init.d/etmsh start" with timeout 60 seconds
- stop program = "/etc/init.d/etmsh stop"
复制代码
结果:
1.邮件监控 (接收邮箱为qq邮箱)
自定义脚本运行状态:
返回1 (速度>100kb/s)
自定义脚本返回0,当前速度2.80kb/s,低于100kb/s
自动重启etm
2.web 状态
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|