MUM 2010
It is currently Tue Feb 09, 2010 5:13 am

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: script to save logs and send via email
PostPosted: Sat Mar 01, 2008 11:12 am 
Offline
newbie

Joined: Fri Jun 15, 2007 11:25 am
Posts: 30
Hi all,

i m looking for a script to save the logs 1 time per day (to my cf card) and then send it to my email.
Can anybody help me ?


Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Sun Mar 02, 2008 8:16 am 
Offline
Member
Member
User avatar

Joined: Tue Dec 05, 2006 6:16 am
Posts: 338
Location: South Carolina
Code:
/system script add name="LogDump" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source="
:local body
:foreach int in=[/log find ] do={
  :set body ("$body\r\n" . [/log get $int])
}
/tool e-mail send to="YOU@DOMAIN.COM" subject=([/system identity get name] . " Log " . [/system clock get date]) body=$body
/system logging action set memory memory-lines=1
/system logging action set memory memory-lines=100"


Code:
/system script add disabled=no interval=1d name="Run Log Dump" on-event=LogDump start-date=jan/01/1970 start-time=00:00:00


-Louis


Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Sun Mar 02, 2008 2:40 pm 
Offline
newbie

Joined: Fri Jun 15, 2007 11:25 am
Posts: 30
Letni wrote:
Code:
/system script add name="LogDump" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source="
:local body
:foreach int in=[/log find ] do={
  :set body ("$body\r\n" . [/log get $int])
}
/tool e-mail send to="YOU@DOMAIN.COM" subject=([/system identity get name] . " Log " . [/system clock get date]) body=$body
/system logging action set memory memory-lines=1
/system logging action set memory memory-lines=100"


Code:
/system script add disabled=no interval=1d name="Run Log Dump" on-event=LogDump start-date=jan/01/1970 start-time=00:00:00


-Louis


thank you for you reply....

I found at the forum, but again thank you very much!!!!

Btw, do u suggest any program to analysing this log files ?


Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Sun Mar 02, 2008 5:05 pm 
Offline
Long time Member
Long time Member
User avatar

Joined: Tue Oct 23, 2007 8:58 pm
Posts: 504
Location: WAY upstate NY
xakou wrote:
Letni wrote:
Code:
/system script add name="LogDump" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source="
:local body
:foreach int in=[/log find ] do={
  :set body ("$body\r\n" . [/log get $int])
}
/tool e-mail send to="YOU@DOMAIN.COM" subject=([/system identity get name] . " Log " . [/system clock get date]) body=$body
/system logging action set memory memory-lines=1
/system logging action set memory memory-lines=100"


Code:
/system script add disabled=no interval=1d name="Run Log Dump" on-event=LogDump start-date=jan/01/1970 start-time=00:00:00


-Louis


thank you for you reply....

I found at the forum, but again thank you very much!!!!

Btw, do u suggest any program to analysing this log files ?
wordpad :roll:

_________________
~Agricultural WISP "ZONE"~ Beware of oncoming cattle and dont hit the farmer!!! I need to ask him about using his silo for an AP first"~

*Automated Billing Installer* http://wiki.mikrotik.com/wiki/AutomatedBilling Built by Krige ;-)


Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Thu May 15, 2008 8:41 pm 
Offline
Member Candidate
Member Candidate

Joined: Mon Jan 23, 2006 1:00 pm
Posts: 115
Location: Germany
I wanted this script under V3.9 to work,
but unfortunately is not ..

Can someone help?



Code:
source="
:local body
:foreach int in=[/log find ] do={
  :set body ("$body\r\n" . [/log get $int])
}
/tool e-mail send to="YOU@DOMAIN.COM" subject=([/system identity get name] . " Log " . [/system clock get date]) body=$body
/system logging action set memory memory-lines=1
/system logging action set memory memory-lines=100"



Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Fri May 16, 2008 6:01 am 
Offline
Member
Member
User avatar

Joined: Tue Dec 05, 2006 6:16 am
Posts: 338
Location: South Carolina
Modify this line
Code:
  :set body ("$body\r\n" . [/log get $int])

to
Code:
  :set body ("$body\r\n" . [/log get $int message])


I have a 153 at my house with v3.9. When I ran my original script my CPU went to 100%, then the routerboard would reboot after a couple of seconds. Modifying it with the message option seems to correct that issue.

-Louis


Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Fri May 16, 2008 11:01 am 
Offline
Member Candidate
Member Candidate

Joined: Mon Jan 23, 2006 1:00 pm
Posts: 115
Location: Germany
Thanks for the Help @ Louis

I have the script a little added / modified.
It will now also the time in the body.

Code:
#read log
:local logcontent
:foreach int in=[/log find ] do={
:set logcontent ("$logcontent\r\n" .[/log get $int time]. " - " .[/log get $int message])
}
#send email
/tool e-mail send to="log@xxxx.xxx" subject=([/system identity get name] . " Log " . [/system clock get date]) body=$logcontent
#delete old log
/system logging action set memory memory-lines=1
/system logging action set memory memory-lines=65000



Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Mon May 19, 2008 12:50 pm 
Offline
just joined

Joined: Sat Jun 03, 2006 12:38 am
Posts: 13
hej itsh.net
When I copy your script in terminal, I receive this ???
Ros = 2.9.49

Code:
[erik@Trekanten] > #read log
[erik@Trekanten] > :local logcontent
[erik@Trekanten] > :foreach int in=[/log find ] do={
{... :set logcontent ("$logcontent\r\n" .[/log get $int time]. " - " .[/log get $int message])
{... }
no such command or directory (find)
invalid expression


Erik


Top
 Profile  
 
 Post subject: Re: script to save logs and send via email
PostPosted: Mon May 19, 2008 1:36 pm 
Offline
Member Candidate
Member Candidate

Joined: Mon Jan 23, 2006 1:00 pm
Posts: 115
Location: Germany
hey Erik

your must add to the Script (i had post the blank script)
and then run the Script

Code:
/system script add name="LogDump" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff

#read log
:local logcontent
:foreach int in=[/log find ] do={
:set logcontent ("$logcontent\r\n" .[/log get $int time]. " - " .[/log get $int message])
}
#send email
/tool e-mail send to="log@xxxx.xxx" subject=([/system identity get name] . " Log " . [/system clock get date]) body=$logcontent
#delete old log
/system logging action set memory memory-lines=1
/system logging action set memory memory-lines=65000



i used the V3.9 and the script run fine..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
MUM Poland and MUM China free REGISTRATION OPEN