From 549ccc0f41f20dfce4d3da52a4ff5199a2c03c08 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 20:09:35 +0100 Subject: Added networkup and networkdown modules --- modules/networkdowntraffic | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 modules/networkdowntraffic (limited to 'modules/networkdowntraffic') diff --git a/modules/networkdowntraffic b/modules/networkdowntraffic new file mode 100755 index 0000000..d82d24b --- /dev/null +++ b/modules/networkdowntraffic @@ -0,0 +1,31 @@ +#!/bin/bash + +# Prints out the current down network traffic in DJNADJNA + +PREFIX=' ' + +get_down_traffic() +{ + RECIEVE1=0 + RECIEVE2=0 + + IFACES=$(ip -o link show | awk -F': ' '{print $2}') + for IFACE in $IFACES; do + if [ $IFACE != "lo" ]; then + RECIEVE1=$(($(ip -s -c link show wlan0 | tail -n3 | head -n 1 | cut -d " " -f5) + $RECIEVE1)) + fi + done + + sleep 2 + + IFACES=$(ip -o link show | awk -F': ' '{print $2}') + for IFACE in $IFACES; do + if [ $IFACE != "lo" ]; then + RECIEVE2=$(($(ip -s -c link show wlan0 | tail -n3 | head -n 1 | cut -d " " -f5) + $RECIEVE2)) + fi + done + + echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000000)MB" +} + +get_down_traffic -- cgit v1.2.3 From 8a259103551d200fc5b5b641e36b7eada0728759 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 20:14:42 +0100 Subject: Added a delta var for the network up and down modules --- modules/networkdowntraffic | 5 +++-- modules/networkuptraffic | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/networkdowntraffic') diff --git a/modules/networkdowntraffic b/modules/networkdowntraffic index d82d24b..ea270e3 100755 --- a/modules/networkdowntraffic +++ b/modules/networkdowntraffic @@ -1,11 +1,12 @@ #!/bin/bash -# Prints out the current down network traffic in DJNADJNA +# Prints out the current down network traffic in MB PREFIX=' ' get_down_traffic() { + DELTA=2 RECIEVE1=0 RECIEVE2=0 @@ -16,7 +17,7 @@ get_down_traffic() fi done - sleep 2 + sleep $DELTA IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do diff --git a/modules/networkuptraffic b/modules/networkuptraffic index 6907928..5c7dc13 100755 --- a/modules/networkuptraffic +++ b/modules/networkuptraffic @@ -1,11 +1,12 @@ #!/bin/bash -# Prints out the current up network traffic in DJNADJNA +# Prints out the current up network traffic in MB PREFIX=' ' get_up_traffic() { + DELTA=2 TRANSMIT1=0 TRANSMIT2=0 @@ -16,7 +17,7 @@ get_up_traffic() fi done - sleep 2 + sleep $DELTA IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do -- cgit v1.2.3 From fe7633cd1b14275540dfba051b67c6bcef03ecc7 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Fri, 25 Oct 2019 12:39:51 +0100 Subject: Changed units in networkup/down modules --- TODO.org | 2 -- modules/networkdowntraffic | 5 ++--- modules/networkuptraffic | 5 ++--- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'modules/networkdowntraffic') diff --git a/TODO.org b/TODO.org index c99764c..fdf747e 100644 --- a/TODO.org +++ b/TODO.org @@ -12,8 +12,6 @@ Each module writes to stdout. * Todo List - Delay in archupdates module (if minutes divisible by 5/4) - Add dependencies like bc -- Networkup/down modules in kb instead of mb? and change sleep to 1s so that - output is XMb/s Bugs to fix: None diff --git a/modules/networkdowntraffic b/modules/networkdowntraffic index ea270e3..f1b5584 100755 --- a/modules/networkdowntraffic +++ b/modules/networkdowntraffic @@ -6,7 +6,6 @@ PREFIX=' ' get_down_traffic() { - DELTA=2 RECIEVE1=0 RECIEVE2=0 @@ -17,7 +16,7 @@ get_down_traffic() fi done - sleep $DELTA + sleep 1 IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do @@ -26,7 +25,7 @@ get_down_traffic() fi done - echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000000)MB" + echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000)KB/s" } get_down_traffic diff --git a/modules/networkuptraffic b/modules/networkuptraffic index 5c7dc13..6b002e6 100755 --- a/modules/networkuptraffic +++ b/modules/networkuptraffic @@ -6,7 +6,6 @@ PREFIX=' ' get_up_traffic() { - DELTA=2 TRANSMIT1=0 TRANSMIT2=0 @@ -17,7 +16,7 @@ get_up_traffic() fi done - sleep $DELTA + sleep 1 IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do @@ -26,7 +25,7 @@ get_up_traffic() fi done - echo "$PREFIX$(expr $(expr $TRANSMIT2 - $TRANSMIT1) / 1000000)MB" + echo "$PREFIX$(expr $(expr $TRANSMIT2 - $TRANSMIT1) / 1000)KB/s" } get_up_traffic -- cgit v1.2.3