Community discussions

MikroTik App
 
Zeup
just joined
Topic Author
Posts: 3
Joined: Thu Aug 08, 2013 4:53 pm

Daily Report Script

Thu Aug 08, 2013 5:40 pm

Hello,

My problem is the following:
I would like to have a script that stores the movements of all users in a file and then send it as an email to me.

I need infomation about:
Username
Download
Upload
Uptime
and more.....

This information I can get all from the User-Manager with:
/tool user-manager session print
But I can't select only one day........

This is my try:
:log info "Start DailySessionReport Script"
:local count

/tool user-manager session print append file="total_session.txt"
:delay 2s
/tool user-manager session print value-list file="daily_session.txt"
:set count [/tool user-manager session print count-only;]

:local i [/tool user-manager session print count-only;]
:local x 1

:while ($i >= ($x )) do={

/tool user-manager session print;
/system script run Remove
:set x  ($x + 1);

}

/tool e-mail send to="xxxx.xxxxx@xxxxx.de"  body="Bewegungen im PPPPPP-XXXXX Es wurden $count Bewegungen gezählt. " subject="Bewegungen im PPPPPP-XXXXX " file=("daily_session.txt")

:log info "END DailySessionReport Script"
And here I delete step by step each entry:
:log info "Remove Start"
/tool user-manager session remove numbers=0
:log info "Remove End"
but there I delete all information from the session every day
and this isn't what I want!

The session information should not be deleted from the user manager.

has someone an idea?
I use RouterOS V6.1

Thanks.


Regards
Zeup
 
Zeup
just joined
Topic Author
Posts: 3
Joined: Thu Aug 08, 2013 4:53 pm

Re: Daily Report Script

Mon Aug 12, 2013 1:25 pm

I had a new idea:
:log info "Start"

:local count
:local date [/system clock get date]
:local x 1
:local i [/tool user-manager session print count-only]
:local sess

/tool user-manager session print
:do {

:set sess [/tool user-manager session get number=$x value-name=from-time]

:log info "$sess"


:if ($sess = $date) do={
/tool user-manager session print append file="DailyReport" where from-time=$sess
}
:set x ($x + 1)

} while ($i > $x)


#/tool e-mail send to="xxx.yyyy@aaaa.de"  body="Bewegungen im TestNetz" subject="Bewegungen im TestNetz " file=("DailyReport.txt")

:log info "END"
but i can't compare from-time with the date of today, because the date in from-time is store as a string and not as time value.

If I can convert a string to time value then my script will work.
Or can I cut a string from "mmm/dd/yyyy hh:mm:ss" to "mmm/dd/yyyy"
If that work I need not to convert the string.

But How??

Have someone an idea??

Regards

Zeup

Who is online

Users browsing this forum: DNAT and 35 guests