LM20.2 Cinnamon Reset net bandwidth usage

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
sadhu
Level 5
Level 5
Posts: 860
Joined: Fri Nov 22, 2013 9:48 am
Location: Sri Lanka
Contact:

LM20.2 Cinnamon Reset net bandwidth usage

Post by sadhu »

Via DuckDuckGo I found a cute script that produces an overview of bandwidth usage for my mobile broadband dongle:

Code: Select all

#!/bin/bash

netu() {
    # [net]work [u]sage: check network usage stats

    net_device=$(ip route | awk '/via/ {print $5}')
    TRANSMITTED=$(ifconfig "$net_device" | awk '/TX packets/ {print $6$7}')
    RECEIVED=$(ifconfig "$net_device" | awk '/RX packets/ {print $6$7}')

    printf "%s\n" "$(tput bold)🔼 TRANSMITTED $(tput sgr0): $TRANSMITTED"
    printf "%s\n" "$(tput bold)🔽 RECEIVED    $(tput sgr0): $RECEIVED"
}

netu

This is the output for today, so far:

Code: Select all

sadhu@desk:~ $ netu
🔼 TRANSMITTED : (347.3MB)
🔽 RECEIVED    : (772.9MB)
sadhu@desk:~ $
I can reset the count by unplugging the dongle and plugging it back in. I was just wondering if there is way a set of terminal commands that will reset the count, which I can then put into a script.

Thanks,
-Sadhu
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
sabbe sattā bhavantu sukhitattā. LM 21.2-64 Cinn 5.8.4
Locked

Return to “Scripts & Bash”