Get cellular data usage

Hi community,

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?

Thank you.

Greetings, @johnny.v,

Welcome to Teltonika Community!

Could you please clarify the alert logic a bit?

  • Should the router send an alert every time 2 GB of data is used?
  • Is the data calculated as combined TX/RX?
  • From your screenshots, I can see that the limit reset period is set to “day.” Can the limit exceed 2 GB more than once per day?

This information will help me investigate the issue further.

Please note that custom script writing is beyond our technical support scope; however, we can provide you with some general guidance.

I look forward to your reply.

Best wishes,
V.

Hi Vilius,

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.

Hello,

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.

Please note that both the data limit and the usage values are displayed in bytes.

You can find more details in our API documentation here:
https://developers.teltonika-networks.com/reference/rutx11/7.20.3/v1.12.1/data-limit#get-data_limit-status

If you have any additional questions, feel free to let me know.

Best regards,
V.