Skip to content

Commit

Permalink
MOTD: fix error when traffic info is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Sep 15, 2024
1 parent 2c51748 commit f6e950f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,24 @@ display "Battery" "$battery_percent" "20" "1" "%" "$status_battery_text" ; a=$((

line=0
if [[ -n "$PRIMARY_INTERFACE" ]] && vnstat -i "$PRIMARY_INTERFACE" &> /dev/null; then
traffic=$(vnstat -i $PRIMARY_INTERFACE --oneline | cut -d";" -f4,5)
traffic_rx=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f1 | cut -d"," -f1)
traffic=$(LC_ALL=C vnstat -i $PRIMARY_INTERFACE --oneline | cut -d";" -f4,5)
traffic_rx=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f1 | cut -d"." -f1)
traffic_rx_unit=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f2)
traffic_tx=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f1 | cut -d"," -f1)
traffic_tx=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f1 | cut -d"." -f1)
traffic_tx_unit=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f2)
[[ "$traffic" == *"Not enough"* ]] && { traffic_tx="n/a "; traffic_rx="n/a "; }
case $PRIMARY_DIRECTION in
tx)
display " TX today" "$traffic_tx" 500 0 " $traffic_tx_unit" ""
display " TX today" "$traffic_tx" 500 0 "" "$traffic_tx_unit" ""
line=$((line+1))
;;
rx)
display " RX today" "$traffic_rx" 500 0 " $traffic_rx_unit" ""
display " RX today" "$traffic_rx" 500 0 "" "$traffic_rx_unit" ""
line=$((line+1))
;;
both)
display " TX today" "$traffic_tx" 500 0 " $traffic_tx_unit" ""
display "RX today" "$traffic_rx" 500 0 " $traffic_rx_unit" ""
display " TX today" "$traffic_tx" 500 0 "" "$traffic_tx_unit" ""
display "RX today" "$traffic_rx" 500 0 "" "$traffic_rx_unit" ""
line=$((line+1))
;;
*) #off or whatever
Expand Down

0 comments on commit f6e950f

Please sign in to comment.