(tested with rutx11). modified 2025-11 because the router OS doesn't let you put files in the webroot anymore.
Sometimes you want to know how much data your field router has already consumed on a mobile link. T-Mobile (Telekom Deutschland) provides pass.telekom.de as status page and has a handy json output.
If you reach your teltonika remotely, you can periodically fetch the site to produce output like:
Wed Nov 27 17:32:13 CET 2024
used:
32,13 GB
remaining:
3 Tage 06 Std.
This is an example to fetch the json, parse it, store it and be able to serve it locally via http:
A. Create the script vi /etc/telekomdata.sh:
#!/bin/ash
date
DATA=$(curl -sL http://pass.telekom.de/api/service/generic/v1/status)
echo -e '\nused: '
USED=$(echo $DATA | jsonfilter -e "@.usedVolumeStr")
echo $USED
echo -e '\nremaining: '
REMAIN=$(echo $DATA | jsonfilter -e "@.remainingTimeStr")
echo $REMAIN
echo -e '\n\n'
#echo $DATA
DATA2="${DATA//\"/_}"
echo $DATA2
ubus call log write_ext '{"event": "used: '"${USED}"' remain: '"${REMAIN}"' \n '"${DATA2}"'", "sender": "DATAUSAGE", "table": 0, "write_db": 1}'
ubus call log write_ext '{"event": "pass.telekom.de says: used '"${USED}"' remain: '"${REMAIN}"'", "sender": "DATAUSAGE", "table": 2, "write_db": 1}'
and make it executable chmod +x /etc/telekomdata.sh
B. Add to crontab, crontab -e (this is a vi also!)
*/15 * * * * /etc/telekomdata.sh
C. Wait for the quarter to pass and look at http://ip-to-your-teltonika/usage.txt Look at the events log.