Track lo IO rates in the conglomerate network section
[khatus.git] / bin / khatus_show
index fc4415a..4545a1f 100755 (executable)
@@ -38,23 +38,49 @@ memory=$(
 
 temp=$(awk 'NR == 1 {print $1 / 1000}' /sys/class/thermal/thermal_zone0/temp)
 
+disk_io=$(
+    awk '
+        {
+            bytes_per_sector = 512
+            bytes_per_unit   = 1024 * 1024
+
+            curr_sectors_read  = $3
+            curr_sectors_write = $7
+
+            prev_file_prefix        = "/home/siraaj/var/run/status/disk_io"
+            prev_sectors_read_file  = prev_file_prefix "_sectors_read"
+            prev_sectors_write_file = prev_file_prefix "_sectors_write"
+
+            getline prev_sectors_read  < prev_sectors_read_file
+            getline prev_sectors_write < prev_sectors_write_file
+
+            diff_read_sectors  = (curr_sectors_read  - prev_sectors_read)
+            diff_write_sectors = (curr_sectors_write - prev_sectors_write)
+
+            diff_read_bytes  = diff_read_sectors  * bytes_per_sector
+            diff_write_bytes = diff_write_sectors * bytes_per_sector
+
+            diff_read  = diff_read_bytes  / bytes_per_unit
+            diff_write = diff_write_bytes / bytes_per_unit
+
+            print curr_sectors_read  > prev_sectors_read_file
+            print curr_sectors_write > prev_sectors_write_file
+
+            printf("%0.3f▲ %0.3f▼\n", diff_write, diff_read);
+
+        }
+        ' /sys/block/dm-1/stat
+)
+
 disk=$(
     df \
-    | awk '
+    | awk -v disk_io="$disk_io" '
         function round(n) {return int(n + 0.5)}
 
         $1 == "/dev/mapper/kubuntu--vg-root" {
-            curr_blocks = $3;
             curr_perc = $5; sub("%$", "", curr_perc);
-            prev_file_prefix = "/home/siraaj/var/run/status/disk_space_used";
-
-            prev_perc_file   = prev_file_prefix "_percentage";
-            prev_blocks_file = prev_file_prefix "_blocks";
-
-            getline prev_blocks < prev_blocks_file;
+            prev_perc_file = "/home/siraaj/var/run/status/disk_space_used";
             getline prev_perc   < prev_perc_file;
-
-            print curr_blocks > prev_blocks_file;
             print curr_perc > prev_perc_file;
             if (curr_perc > prev_perc) {
                 direction = ">";
@@ -63,12 +89,11 @@ disk=$(
             } else {
                 direction = "=";
             }
-            diff_blocks = curr_blocks - prev_blocks;
-            printf("%s[%d%% %d]", direction, curr_perc, diff_blocks);
+            printf("%s[%d%% %s]", direction, curr_perc, disk_io);
         }')
 
-io_net=$(
-    awk '
+network=$(
+    awk -v wifi_conn=$(cat $STATUS_FILE__WIFI) '
         BEGIN {
             bytes_per_unit = 1024 * 1024
         }
@@ -91,7 +116,14 @@ io_net=$(
             print curr_read  > prev_read_file;
             print curr_write > prev_write_file;
 
-            printf("%s %0.3f▲ %0.3f▼\n", device, diff_write, diff_read);
+            devices[device] = sprintf("%0.3f▲ %0.3f▼", diff_write, diff_read);
+        }
+
+        END {
+            lo   = devices["lo"]
+            #eth = devices["enp0s25"]
+            wifi = devices["wlp3s0"]
+            printf("[%s | %s %s]", lo, wifi_conn, wifi)
         }
     ' /proc/net/dev
 )
@@ -160,8 +192,6 @@ volume_pactl=$(
 
 volume="[$volume_pactl]"
 
-wifi=$(cat $STATUS_FILE__WIFI)
-
 screen_brightness=$(
     max=$(cat /sys/class/backlight/acpi_video0/max_brightness)
     cur=$(cat /sys/class/backlight/acpi_video0/brightness)
@@ -320,23 +350,22 @@ echo \
  M$memory\
  \
  \
- D$disk\
- \
- \
  C=[$cpu  ${temp}°C ${fan}rpm]\
  \
  \
S=$screen_brightness\
D$disk\
  \
  \
V=$volume\
N:$network\
  \
  \
  B:$bluetooth_power\
  \
  \
- W:[$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\
+ S=$screen_brightness\
+ \
  \
+ V=$volume\
  \
  $mpd_state\
  \
This page took 0.042686 seconds and 4 git commands to generate.