让网维变得简单,快速,准确。拒绝浪费时间,解放出更多的时间陪陪家人。 注册 | 登陆

网卡速率状态变化自动微信通知

有的人不知道本站开通的微信通知中心有什么用。那我就举个栗子!

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

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

ROS脚本
  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}  

 

Tags: ros, 通知, 微信, 告警, 消息

« 上一篇 | 下一篇 »

 

发表评论

评论内容 (必填):