找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 5241|回复: 8

用 monit 监控离线下载

[复制链接]
发表于 2017-1-23 15:46 | 显示全部楼层 |阅读模式
本帖最后由 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

  1. # 设置监控时间间隔:60秒
  2. set daemon  60     

  3. #设置发送邮件预警的邮件服务器(自行修改)
  4. set mailserver smtp.139.com USERNAME "admin@139.com PASSWORD "yourpassword"              

  5. #设置保存的目录(本例设置/var/monit),设置完受到mkdir目录,不设置的话邮件发送失败不会再次发送。
  6. set eventqueue
  7.      basedir /var/monit  # set the base directory where events will be stored
  8.      slots 100           # optionally limit the queue size
  9. #收到邮件的内容(自行修改,至少邮件帐号得改)
  10. set mail-format {
  11.    from: admin@139.com
  12.    subject: monit alert --  $EVENT $SERVICE
  13.    message: $EVENT Service $SERVICE
  14.                 Date:        $DATE
  15.                 Action:      $ACTION
  16.                 Host:        $HOST
  17.                 Description: $DESCRIPTION

  18.             Your faithful employee,
  19.             Monit
  20. }

  21. #设置接收邮件的帐号(自行修改)
  22. set alert admin@189.cn                       # receive all alerts

  23. #设置web状态窗口,设置了可以远程连接查看状态
  24. set httpd port 2812 and
  25.     use address 192.168.2.50   # only accept connection from localhost
  26.     allow localhost        # allow localhost to connect to the server and
  27.     allow  192.168.2.8
  28.     allow admin:monit      # require user 'admin' with password 'monit'
  29. #    allow @monit           # allow users of group 'monit' to connect (rw)
  30. #    allow @users readonly  # allow users of group 'users' to connect readonly

  31. ###############################################################################
  32. ## 系统监控
  33. ###############################################################################
  34. ##
  35. ## Check general system resources such as load average, cpu and memory
  36. ## usage. Each test specifies a resource, conditions and the action to be
  37. ## performed should a test fail.
  38. #
  39.   check system localhost
  40.     if loadavg (1min) > 6 then alert
  41.     if loadavg (5min) > 5 then alert
  42.     if memory usage > 75% then alert
  43. #    if swap usage > 25% then alert
  44.     if cpu usage (user) > 70% then alert
  45.     if cpu usage (system) > 30% then alert
  46.     if cpu usage (wait) > 20% then alert

  47. ##程序监控。监控etm进程
  48. check process etm with pidfile /var/run/xunlei.pid
  49.     start program = "/etc/init.d/etmsh start" with timeout 60 seconds
  50.     stop program  = "/etc/init.d/etmsh stop"
  51.    
  52.     # cpu占有超过60% 2次,则警告
  53.     if cpu > 60% for 2 cycles then alert
  54. #    if cpu > 80% for 5 cycles then restart
  55. #    if totalmem > 200.0 MB for 5 cycles then restart
  56. #    if children > 250 then restart
  57.      # 负载超过10 达到8次,重启迅雷
  58.     if loadavg(5min) greater than 10 for 8 cycles then restart
  59.     # http://127.0.0.1:/getsysinfo获取失败,重启迅雷
  60.     if failed host localhost port 9000 protocol http
  61.        and request "/getsysinfo"
  62.     then restart
  63. #    if failed port 443 type tcpssl protocol http
  64. #       with timeout 15 seconds
  65. #    then restart
  66. #    if 3 restarts within 5 cycles then timeout
  67. #    depends on apache_bin
  68. #    group server
  69. #   

  70. #自定义脚本监控   

  71. check program myscript with path /usr/sbin/tdrx.sh with timeout 15 seconds  
  72. #连续5次  返回状态0,警告(脚本调用vnstat -tr -ru获取网络接口速度,超过100kb/s,返回状态1;低于100kb/s,返回0;速度低于10kb,返回3)
  73.     start program = "/etc/init.d/etmsh start" with timeout 60 seconds
  74.     stop program  = "/etc/init.d/etmsh stop"
复制代码


结果:
1.邮件监控 (接收邮箱为qq邮箱)

自定义脚本运行状态:


返回1 (速度>100kb/s)



自定义脚本返回0,当前速度2.80kb/s,低于100kb/s


自动重启etm

  

2.web 状态







本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2017-1-23 15:48 | 显示全部楼层
结论:

用来监控迅雷,比脚本执行效率高。

top 看不到monit进程排名靠前,毕竟只c程序。
监控之后迅雷pro 没有离线过
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-1-23 16:43 | 显示全部楼层
磨拜大神,我的PRO开始不停死机之后直接换货了,现在新的还是挺稳定的,一周都没死机,。

点评

系统不好 占用系统资源极大 没有下载负载都 大于3 下载时负载4~6。。。。 xiazaibao:/root]#uptime 08:11:41 up 10:45, load average: 4.35, 4.14, 4.15 top:[attachimg]151216[/attachimg]  详情 回复 发表于 2017-1-24 08:13
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2017-1-24 08:13 | 显示全部楼层
solvend 发表于 2017-1-23 16:43
磨拜大神,我的PRO开始不停死机之后直接换货了,现在新的还是挺稳定的,一周都没死机,。

系统不好
占用系统资源极大

没有下载负载都 大于3

下载时负载4~6。。。。

xiazaibao:/root]#uptime
08:11:41 up 10:45,  load average: 4.35, 4.14, 4.15

top:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2017-1-24 08:15 | 显示全部楼层
本帖最后由 yjc666 于 2017-1-24 08:21 编辑

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-2-3 11:56 | 显示全部楼层
磨拜大神
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-2-5 21:09 | 显示全部楼层
/etc/init.d/etmsh
这个文件没有啊 能分享一下吗?

点评

下载宝 启动迅雷的程序  发表于 2017-2-6 09:15
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-26 06:36

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表