Bandwidth monitoring script

Hi,

I would like to use this WAN Data Monitoring script from Syed Jahanzaib to save daily reports for my pppoe client interface:
https://aacable.wordpress.com/2015/03/09/5386/

I added the script on my Mikrotik RB751U 6.30 and it looks like this:

# MONITOR_DATA Script (to get interface usage in file)
# First Part of WAN Data Quota Monitoring System
# Syed Jahanzaib / aacable@hotmail.com
# https://aacable.wordpress.com

# Set WAN interface you want to monitor
:local INT pppoe-thome             *this is the name of my interface

# Gather Interface RX bytes
:local counter [/interface get $INT rx-byte]

# Set Counter DATA value gathered by Interface RX bytes and add  TX bytes to get combined value
:set $counter ($counter + [/interface get $INT tx-byte])

:local traffic

# If previous data file not found, then create new one
:if ([:len [/file find where name=wandatauseage.txt]] < 1 ) do={
/file print file=wandatauseage.txt where name=wandatauseage.txt;
# Add some delay, for slow or high load routers
/delay delay-time=2;

# Adding Traffic Value in the file

/file set wandatauseage.txt contents="0";
};
:local before value=[/file get wandatauseage.txt contents]

:if ($counter > $before) do={
/file set wandatauseage.txt contents=$counter
} else= {
:set $traffic ($counter+$before)
/file set wandatauseage.txt contents=$traffic
};

When I run the script the wandatauseage.txt file is created but the numbers in the file are completely unrelated to the TX byte/RX byte counters on my interface.
The number in the script looks like this:
106258568


Could someone please check and see if there are any errors/if it’s incompatible with 6.30

Thank you

I just tested this script and it looks ok to me.

It added tx and rx bytes and comparing that to what winbox shows for my pppoe interface it is the same total number of bytes.
Beware that the script will save the number in bytes, while winbox shows the numbers in KiB,MiB,GiB (so make sure to divide that number by 1024 as many times as you need to get a ‘readable’ number in MiB,GiB etc)

I tested it on v5.26 though. I didn’t have access to a v6.30 router with pppoe client interface.