I want to set SMS alert for every 2GB cellular data usage.
This function is not yet featured.
I use RUT361 R07.19.4.
I intend to make a shell script for this task. However, getting data usage from /sys/class/net/wwan0/statistics/tx_bytes and /sys/class/net/wwan0/statistics/rx_bytes is incorrect.
It does not match data used in Data limit or realtime data/mobile usage as picture below.
where can I get the correct data usage?
The goal is to get a notification for every amount of data used; in my case, it is 2GB, but it should be any value. I want to receive an update notification and top up my data allowance if needed.
The data limit feature does match my goal
Exp: The data bank: x GB, regular notification: y GB.
1st notification: RUT has used more y GB of data, total used y GB, data left (x - y) GB.
2nd notification: RUT has used more y GB of data, total used 2y GB, data left (x-2y) GB.
My idea: build a shell script and add it to crontab for a regular check (15 min). Calculate the data used and compare it to the first run of the script; if the data used < y, no SMS alert else update data used, total data used, and send notification (SMS).
I combined /sys/class/net/wwan0/statistics/tx_bytes and /sys/class/net/wwan0/statistics/rx_bytes as the data source; however, they do not reflect the actual data.
The question is: how can I get the values needed to calculate the data?
BTW, I also prefer sending SMS notifications to multiple recipients (customers and Operators) with the current data limit feature.
To retrieve the data usage information, you can utilize the API. Once a data limit is configured, you can obtain both the limit and the amount of data used via the following API endpoint:
/api/data_limit/status
The output should look similar to the example shown below.