1、ADSL断线自动报警(适用于3.0以上版本)
/interface pppoe-client monitor pppoe-out1 once do={ :if ($status != "connected") do={ :beep length=2s frequency=1000;:delay 5 :log info "〖ADSL 断线〗" } }
2、在线用户统计(适用于5.0以上 PS:3.X 4.X没测试过)
:local nyr [/system clock get date] :local yy ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $nyr 0 3]]+1) :if ($yy<10) do={:set yy (0 . $yy)} :local n ([:pick $nyr 7 11]) :local r ([:pick $nyr 4 6]) :local time [/sys cl get time] :local user [:len [/ip firewall address-list find list=Online]] /interface monitor-traffic Lan once do={ :local rx [($"tx-bits-per-second"/1000)] :if ($rx < 1000) do={ :log warning ( "统计:" . $n . "年" . $yy . "月" . $r . "日 时间" .$time . " 当前在线上网人数【" . $user . "】人 出口流量为:【$rx K】")} :if ($rx >= 1000) do={ :local rx [($"tx-bits-per-second"/1000000)] :log warning ( "统计:" . $n . "年" . $yy . "月" . $r . "日 时间" .$time . " 当前在线上网人数【" . $user . "】人 出口流量为:【$rx M】")} }
3、ROS备份并发送至邮箱(前提:设置好too-Email里面选项)
/system backup save name=([/system identity get name] . “-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]); /tool e-mail send to=325887984@vip.qq.com subject=([/system identity get name] . ” Backup ” . [/system clock get date]) file=([/system identity get name] . “-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.backup”); :delay 10; /file rem [/file find name=([/system identity get name] . “-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.backup”)]; :log info (“System Backup emailed at ” . [/sys cl get time] . ” ” . [/sys cl get date])
:local nyr [/system clock get date]
:local yy ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $nyr 0 3]]+1)
:if ($yy<10) do={:set yy (0 . $yy)}
:local n ([:pick $nyr 7 11])
:local r ([:pick $nyr 4 6])
:local time [/sys cl get time]
:local user [:len [/ip firewall address-list find list=Online]]
/interface monitor-traffic Lan once do={
:local rx [($”tx-bits-per-second”/1000)]
:if ($rx < 1000) do={
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx K】”)}
:if ($rx >= 1000) do={
:local rx [($”tx-bits-per-second”/1000000)]
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx M】”)}
}:local nyr [/system clock get date]
:local yy ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $nyr 0 3]]+1)
:if ($yy<10) do={:set yy (0 . $yy)}
:local n ([:pick $nyr 7 11])
:local r ([:pick $nyr 4 6])
:local time [/sys cl get time]
:local user [:len [/ip firewall address-list find list=Online]]
/interface monitor-traffic Lan once do={
:local rx [($”tx-bits-per-second”/1000)]
:if ($rx < 1000) do={
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx K】”)}
:if ($rx >= 1000) do={
:local rx [($”tx-bits-per-second”/1000000)]
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx M】”)}
}:local nyr [/system clock get date]
:local yy ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $nyr 0 3]]+1)
:if ($yy<10) do={:set yy (0 . $yy)}
:local n ([:pick $nyr 7 11])
:local r ([:pick $nyr 4 6])
:local time [/sys cl get time]
:local user [:len [/ip firewall address-list find list=Online]]
/interface monitor-traffic Lan once do={
:local rx [($”tx-bits-per-second”/1000)]
:if ($rx < 1000) do={
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx K】”)}
:if ($rx >= 1000) do={
:local rx [($”tx-bits-per-second”/1000000)]
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx M】”)}
}:local nyr [/system clock get date]
:local yy ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $nyr 0 3]]+1)
:if ($yy<10) do={:set yy (0 . $yy)}
:local n ([:pick $nyr 7 11])
:local r ([:pick $nyr 4 6])
:local time [/sys cl get time]
:local user [:len [/ip firewall address-list find list=Online]]
/interface monitor-traffic Lan once do={
:local rx [($”tx-bits-per-second”/1000)]
:if ($rx < 1000) do={
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx K】”)}
:if ($rx >= 1000) do={
:local rx [($”tx-bits-per-second”/1000000)]
:log warning ( “统计:” . $n . “年” . $yy . “月” . $r . “日 时间” .$time . ” 当前在线上网人数【” . $user . “】人 出口流量为:【$rx M】”)}
}
未经允许不得转载:运维大虾 » ROS实用脚本(2014.03修改)