From: Siraaj Khandkar Date: Tue, 10 Jul 2018 02:15:35 +0000 (-0400) Subject: Show net interface status even if disconnected X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=37d619ee47f76d552e4d492a20aa3ce7288a70b3;p=khatus.git Show net interface status even if disconnected --- diff --git a/bin/khatus_show b/bin/khatus_show index 523f22a..50c6c97 100755 --- a/bin/khatus_show +++ b/bin/khatus_show @@ -99,7 +99,7 @@ network=$( bytes_per_unit = 1024 * 1024 } - /^[0-9]/ { + /^[0-9]+:/ { sub(":$", "", $1) sub(":$", "", $2) sequence = $1 @@ -134,26 +134,29 @@ network=$( getline prev_read < prev_read_file getline prev_write < prev_write_file - diff_r = (curr_read - prev_read ) / bytes_per_unit - diff_w = (curr_write - prev_write) / bytes_per_unit + diff_read = (curr_read - prev_read ) / bytes_per_unit + diff_written = (curr_write - prev_write) / bytes_per_unit print curr_read > prev_read_file print curr_write > prev_write_file - if (interface == "wlp3s0") { - label = wifi_conn - } else { - label = interface - } + io_stat = sprintf("%0.3f▲ %0.3f▼", diff_written, diff_read) + } else { + io_stat = "--" + } - if (i == sequence) { - sep = "" - } else { - sep = " | " - } + label = substr(interface, 1, 1) + if (interface == "wlp3s0") { + label = label ":" wifi_conn + } - printf("%s %0.3f▲ %0.3f▼%s", label, diff_w, diff_r, sep) + if (i == sequence) { + sep = "" + } else { + sep = " | " } + + printf("%s:%s%s", label, io_stat, sep) } }' )