找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 12837|回复: 1

[脚本] 网卡速率状态变化自动微信通知

[复制链接]
发表于 2020-5-7 19:02:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
有的人不知道本站开通的微信通知中心有什么用。那我就举个栗子!
功能说明:该脚本可以获取设备所有网卡链接状态和速率状态,并在发生改变时微信通知,方便提前处理链路隐患。比如某些情况下网口会从1G变成100M,但是如果在不之情的情况下继续用,会产生网络隐患和性能损失。该脚本定时运行即可完成周期性检测,异常自动微信通知。

点击添加微信通知中心为好友

  1. :global oethlink
  2. :global oethspeed
  3. :global nethname ""
  4. :global nethlink ""
  5. :global nethspeed ""
  6. :global msg ""
  7. :global ethlink ""
  8. :global ethspeed ""
  9. :foreach ceth in=[/interface ethernet find] do={
  10. :global ethname [/interface ethernet get $ceth name]
  11. /interface ethernet mon $ethname once do={
  12. :set ethlink $"status"
  13. :set ethspeed $"rate"
  14. }
  15. :set nethname ($nethname.$ethname.",")
  16. :set nethlink ($nethlink.$ethlink.",")
  17. :set nethspeed ($nethspeed.$ethspeed.",")
  18. }
  19. :set nethname [:toarray [:pick $nethname 0 ([:len $nethname] -1)]]
  20. :set nethlink [:toarray [:pick $nethlink 0 ([:len $nethlink] -1)]]
  21. :set nethspeed [:toarray [:pick $nethspeed 0 ([:len $nethspeed] -1)]]
  22. :for ceths from=0 to=([:len $nethname] -1) do={
  23. :if ([:pick $nethlink $ceths] != [:pick $oethlink $ceths]) do={
  24. :set msg ($msg.[:pick $nethname $ceths]."状态变化为:".[:pick $nethlink $ceths].",")}
  25. :if (([:pick $nethspeed $ceths] != [:pick $oethspeed $ceths]) && ([:pick $nethlink $ceths] = "link-ok")) do={
  26. :set msg ($msg.[:pick $nethname $ceths]."速率变化为:".[:pick $nethspeed $ceths].",")}
  27. }
  28. :set msg [:pick $msg 0 ([:len $msg] -1)]
  29. :set oethlink $nethlink
  30. :set oethspeed $nethspeed
  31. :if ([:len $msg] >6) do={
  32. ###通知语言###
  33. :local lang "CN"
  34. ###通知微信ID或者群ID###
  35. :local wxid "ros6"
  36. ###通知节点名###
  37. :local nodename [/system identity get name]
  38. ###通知信息内容###
  39. :local info $msg
  40. /tool fetch url=("http://mail.ROS6.com/wx/msg.php\?act=sendmsg&wxid=$wxid&node=$nodename&msg=$info&lang=$lang") mode=http keep-result=no}
复制代码



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

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-3-28 22:32 , Processed in 0.069876 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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