Mikrotik Hotspot User Statistics Script

This script will create a file name “DATE Usage Report.txt” and send the file to the specified email address.

The file contents will be the /ip hotspot user stats which include: Name,Uptime,bytes out and bytes in

Once the file has been generated the stats will be cleared.

##Created by Chris@BroadNetworks.co.za 22092019##
/system script
add dont-require-permissions=no name=”Usage Report” policy=\
ftp,reboot,read,write,test,password,sniff,sensitive,romon source=”:local date ([:pick [/system clock get date] 0 3] . \
[:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 7 11]);\r\
\n:local fileName (.\$date.\”Usage Report.txt\”)\r\
\n:local logger [/log warning message=\”Creating Usage Report\”]\r\
\n:local filer [/file print file=\”\$fileName\”]\r\
\n:local usage [/ip hotspot user print bytes file=\”\$fileName\”]\r\
\n:delay 30s\r\
\n:local logd [/log warning message=\”Usage Report Complete,Sending Email\”]\r\
\n:local time [/system clock get time]\r\
\n:local dater [/system clock get date]\r\
\n/tool e-mail send to=\”your@email.com\” subject=\”Monthly Usage report\” file=\”\$fileName\” body=\”Site Usage \
report – Runtime: \$dater \$time\r\
\n\n Usage Report is attached,Old Statistics have been cleared.\n\r\
\nRegards,\r\
\nChris@broadnetworks.co.za\”\r\
\n:delay 15s\r\
\n:local ecomplete [/log warning message=\”Email Sent\”]\r\
\n:local logclear [/log warning message=\”Clearing Usage Statistics\”]\r\
\n:local clearsession [/ip hotspot user reset-counters]\r\
\n:delay 5s\r\
\n:local sescomplete [/log warning message=\”Usage Statistics Cleared\”]”

The only thing needed to be changed is “your@email.com” , replace the text with your email address and run the script.

Make sure your /tool email is set up correctly otherwise the emails wont send.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *