Community discussions

MikroTik App
 
c95539
just joined
Topic Author
Posts: 23
Joined: Fri Apr 25, 2014 4:11 pm

Help with simple script to email current user's info

Thu May 07, 2015 11:03 am

Image
I want to email current user's info
as:
current users:7xh2vemh,uptime:12h32m;30i7sz9h,uptime:1d12h30m;hrv6xi7a,uptime:17h32m;tr22ayeq,uptime:12h32m;djip9r2c,uptime:12h32m;

how to script?
 
c95539
just joined
Topic Author
Posts: 23
Joined: Fri Apr 25, 2014 4:11 pm

Re: Help with simple script to email current user's info

Fri May 08, 2015 9:20 am

help me
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 282
Joined: Tue Feb 10, 2015 3:21 pm

Re: Help with simple script to email current user's info

Fri May 08, 2015 1:58 pm

{
/file print file=File.txt
/file set File.txt contents="current users:"
:foreach user in=[/ip hotspot active find] do={
:local name [/ip hotspot active get $user user];
:local uptime [/ip hotspot active get $user uptime];
:local content [/file get File.txt contents];
/file set File.txt contents="$content,$name,uptime:$uptime"

}
}

This will give you output like this:

current users:7xh2vemh,uptime:12h32m;30i7sz9h,uptime:1d12h30m;hrv6xi7a,uptime:17h32m;tr22ayeq,uptime:12h32m;djip9r2c,uptime:12h32m;
 
c95539
just joined
Topic Author
Posts: 23
Joined: Fri Apr 25, 2014 4:11 pm

Re: Help with simple script to email current user's info

Fri May 08, 2015 4:08 pm

{
/file print file=File.txt
/file set File.txt contents="current users:"
:foreach user in=[/ip hotspot active find] do={
:local name [/ip hotspot active get $user user];
:local uptime [/ip hotspot active get $user uptime];
:local content [/file get File.txt contents];
/file set File.txt contents="$content,$name,uptime:$uptime"

}
}

This will give you output like this:

current users:7xh2vemh,uptime:12h32m;30i7sz9h,uptime:1d12h30m;hrv6xi7a,uptime:17h32m;tr22ayeq,uptime:12h32m;djip9r2c,uptime:12h32m;
thank you!
 
c95539
just joined
Topic Author
Posts: 23
Joined: Fri Apr 25, 2014 4:11 pm

Re: Help with simple script to email current user's info

Fri May 08, 2015 6:24 pm

Thank you!
I get user's donwload bytes
as:
:local downbyte [/ip hotspot active get $user bytes-out];

how can I convert "downbyte " to MiB???
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Help with simple script to email current user's info

Fri May 08, 2015 11:54 pm

how can I convert "downbyte " to MiB???
Divide by 1048576 (which is 1024 * 1024). One thing to keep in mind is that RouterOS will round to whole numbers, so doing something like 3000000/1048576 = 2.
:local downMB ($downbyte / 1048576)
 
c95539
just joined
Topic Author
Posts: 23
Joined: Fri Apr 25, 2014 4:11 pm

Re: Help with simple script to email current user's info

Sat May 09, 2015 1:08 pm

:local downMB ($downbyte / 1048576)
[/quote]

thank you!