三月 14
讓RouterOS自動把Log檔Mail出去,這個動作可以拆成2個步驟來執行
1.在System->Script建立相關的Script(產生Log檔案,發送mail)
2.在System->Scheduler建立排程(判斷Log的行數到達我們的設定值就Mail出去)
第1個部份,先建立2個Script
建立一個名為MailLog的Script
請修改SMTP伺服器位置(記得ROS的DNS要有,才可以解析)、寄件人、收件人的資訊
#Script在RouterOS 3.20中測試通過
#Date:2009/03/14
#Script Name:MailLog
#SMTP伺服器位置
:local SMTP "xxx.smtp.com"
#寄件人
:local MailFrom "ROSLog<ROS@xxxxxxxxx.com>"
#收件人
:local MailTo "REC@xxxxxxxxx.com"
#Log檔的名稱(位於/file)
:local LogFileName
#寄出後是否刪除已存檔的Log(/file裡的檔案)
#0=保留 1=刪除
:local DeleteLogFile 1
:set LogFileName ([/system identity get name] . "Log-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".txt");
/tool e-mail set from=$MailFrom;
/log print file=[$LogFileName];
/tool e-mail send to=$MailTo server=[:resolve $SMTP] subject=([/system identity get name] . " Log " . [/system clock get date]) file=[$LogFileName];
:delay 10;
:if ($DeleteLogFile =1) do={
/file rem [/file find name=($LogFileName)];
}
:log info ("System Log emailed at " . [/sys cl get time] . " " . [/sys cl get date]);
接下來建立名為AutoMailLog的Script
超過幾條就把Log寄出去請依照你的實際需要設置
寄出後會自動清空Log,如果你想保留Log
那就把:local IsClearLog 1 改為:local IsClearLog 0
不過這樣子會造成每次都會寄發Mail,請特別注意
#Script在RouterOS 3.20中測試通過
#Date:2009/03/14
#Script Name:AutoMailLog
#超過幾條就把Log寄出去
:local MaxLine 300
#寄出後是否要清空現有的Log資訊
#0=保留 1=清空
:local IsClearLog 1
:if ([/log print count-only] >= $MaxLine) \
do={
/system script run MailLog;
:if ($IsClearLog = 1) \
do={/system script run ClearMemoryLog;}
}
第2個部份是建立Scheduler排程
在System->Scheduler 新增一個名為MailLog的排程
內容只有一行,時間是我是設定為5分鍾跑一次
/system script run AutoMailLog
最後總結一下,整個流程如下圖








七月 17th, 2009 at 15:14:20
請問大大 我用GMAIL 測試 都失敗
該怎樣設定ㄋ?
七月 17th, 2009 at 16:11:09
GMail 的SMTP是需要帶帳號密碼驗証的,而RouterOS 3.20(含)以下目前並沒有支援
不過3.25版以上似乎就有支援此種帶帳號密碼驗証的方式。因手邊沒有最新的版本,沒辦法試。
/tool e-mail send to="myhotmail@hotmail.com" from="myhotmail@hotmail.com" user="myhotmail@hotmail.com" password="myhotmailpass" server=65.55.172.254 s
ubject="testing" body="testing testing" file=testfile
可以參考這個網址
http://forum.mikrotik.com/viewtopic.php?f=9&t=32814
七月 18th, 2009 at 16:29:46
那請問版大 你是用哪一個MAIL
來做設定的ㄋ?
順道問依下 版大 方便留 MSN 給小弟
讓我有問題 直接方便 請教
七月 22nd, 2009 at 15:38:22
抱歉最近比較忙沒時間回覆
我是使用Hinet的線路,所以是使用Hinet提供的SMTP
如果你也是Hinet的線路的話
可以把 Script 裡的 SMTP 換成下面這樣
#SMTP伺服器位置
:local SMTP "msa.hinet.net"
有問題的話大家再研究一下
一月 17th, 2011 at 10:51:42
[...] 把以下的Script存到ROS裡面(請參考讓RouterOS自動把Log檔email出去),並把MAC改成你想啟動電腦的網卡MAC位置。 [...]
六月 22nd, 2011 at 06:40:28
Pills Round White Y Logo http://www.neveahwellness.com/ - cheap valium online Using valium may lead to some negative side effects including sedation, retrograde amnesia (especially at higher doses), extreme excitement, rage or even the worsening of seizures in those with epilepsy. [url=http://www.neveahwellness.com/]buy cheap valium[/url]