有的人不知道本站开通的微信通知中心有什么用。那我就举个栗子!
功能说明:该脚本可以获取设备所有网卡链接状态和速率状态,并在发生改变时微信通知,方便提前处理链路隐患。比如某些情况下网口会从1G变成100M,但是如果在不之情的情况下继续用,会产生网络隐患和性能损失。该脚本定时运行即可完成周期性检测,异常自动微信通知。
ROS脚本
- :global oethlink
- :global oethspeed
- :global nethname ""
- :global nethlink ""
- :global nethspeed ""
- :global msg ""
- :global ethlink ""
- :global ethspeed ""
- :foreach ceth in=[/interface ethernet find] do={
- :global ethname [/interface ethernet get $ceth name]
- /interface ethernet mon $ethname once do={
- :set ethlink $"status"
- :set ethspeed $"rate"
- }
- :set nethname ($nethname.$ethname.",")
- :set nethlink ($nethlink.$ethlink.",")
- :set nethspeed ($nethspeed.$ethspeed.",")
- }
- :set nethname [:toarray [:pick $nethname 0 ([:len $nethname] -1)]]
- :set nethlink [:toarray [:pick $nethlink 0 ([:len $nethlink] -1)]]
- :set nethspeed [:toarray [:pick $nethspeed 0 ([:len $nethspeed] -1)]]
- :for ceths from=0 to=([:len $nethname] -1) do={
- :if ([:pick $nethlink $ceths] != [:pick $oethlink $ceths]) do={
- :set msg ($msg.[:pick $nethname $ceths]."状态变化为:".[:pick $nethlink $ceths].",")}
- :if (([:pick $nethspeed $ceths] != [:pick $oethspeed $ceths]) && ([:pick $nethlink $ceths] = "link-ok")) do={
- :set msg ($msg.[:pick $nethname $ceths]."速率变化为:".[:pick $nethspeed $ceths].",")}
- }
- :set msg [:pick $msg 0 ([:len $msg] -1)]
- :set oethlink $nethlink
- :set oethspeed $nethspeed
- :if ([:len $msg] >6) do={
- ###通知语言###
- :local lang "CN"
- ###通知微信ID或者群ID###
- :local wxid "ros6"
- ###通知节点名###
- :local nodename [/system identity get name]
- ###通知信息内容###
- :local info $msg
- /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}