The idata.sh script, and its partner send_idata.sh script, are for
monitoring the amount of data sent/received via a modem. My ISP is
unfortunately making it increasingly difficult to access their own
usage statistics.
The send_idata.sh script runs on a router running OpenWrt (though any
Linux system with /proc/net/dev should do), and is called from
idata.sh running on another computer on the LAN via SSH. It sends
the number of bytes uploaded and downloaded through the configured
network interface since the last request or system reboot. The
idata.sh script saves a permanent count of bytes uploaded/downloaded
and outputs this data converted to Megabytes for reading.
The reason for separating the two functions on different systems is
that the router uses a Flash memory chip which isn't designed for
regular writes. It's possible (maybe) that even writing small
values once a day before it's turned off for the night will wear
the chip out. The idata.sh script must be run soon before the
router is turned off in order to keep the count accurate.
Dropbear's dbclient SSH client is used in order to easily support
password auth. The call to "dbclient" in the script could be
replaced with "ssh" from the more-common OpenSSH tools if key-based
authentication is used to log into the router.
Other network monitoring solutions are described in the OpenWrt
documentation:
https://openwrt.org/docs/guide-user/services/network_monitoring/start
This project was entered in OFFLFIRSOCH 2024:
gopher://zaibatsu.circumlunar.space/0/~solderpunk/phlog/announcing-offlfirsoch-2024.txt
My related long rambly Phlog post:
gopher://aussies.space/0/~freet/phlog/2024-03-10Off_and_On_Line.txt