From 887d3829ad6f00ac46bd3c861ba64dc56675022e Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Tue, 5 Mar 2019 20:50:50 -0500 Subject: [PATCH] Implement a simplified net interface status method --- x2/sanity_check | 4 ++-- x2/src/awk/exe/bar.awk | 8 ++++++++ x2/src/awk/exe/gen_bar_make_status.awk | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/x2/sanity_check b/x2/sanity_check index 8131813..aec8138 100755 --- a/x2/sanity_check +++ b/x2/sanity_check @@ -10,8 +10,8 @@ -v Opt_Pulseaudio_Sink=0 \ -v GC_Interval=300 \ -f <(./bin/khatus_gen_bar_make_status \ - -v Status_Fmt=' E=%s%% M=%d%% P=[%s %sr %sd %st %si %sz] C=[%s %s°C %srpm] D=[%s%% %s▲ %s▼] W=[%s %s▲ %s▼] B=%s *=%s%% (%s) [%s] %s°F %s ' \ - -v Status_Args='@energy_percent,@memory_percent,@processes_count_all,@processes_count_r,@processes_count_d,@processes_count_t,@processes_count_i,@processes_count_z,@cpu_loadavg,@cpu_temp,@cpu_fan_speed,@disk_space,@disk_io_w,@disk_io_r,@net_wifi:wlp4s0,@net_io_w:wlp4s0,@net_io_r:wlp4s0,@bluetooth_power,@backlight_percent,@volume:0,@mpd,@weather_temp_f,@datetime' \ + -v Status_Fmt=' E=%s%% M=%d%% P=[%s %sr %sd %st %si %sz] C=[%s %s°C %srpm] D=[%s%% %s▲ %s▼] W=[%s %s▲ %s▼] E:%s B=%s *=%s%% (%s) [%s] %s°F %s ' \ + -v Status_Args='@energy_percent,@memory_percent,@processes_count_all,@processes_count_r,@processes_count_d,@processes_count_t,@processes_count_i,@processes_count_z,@cpu_loadavg,@cpu_temp,@cpu_fan_speed,@disk_space,@disk_io_w,@disk_io_r,@net_wifi:wlp4s0,@net_io_w:wlp4s0,@net_io_r:wlp4s0,@net_iface_status:enp0s31f6,@bluetooth_power,@backlight_percent,@volume:0,@mpd,@weather_temp_f,@datetime' \ ) \ ) \ >(stdbuf -o L ./bin/khatus_monitor_energy) \ diff --git a/x2/src/awk/exe/bar.awk b/x2/src/awk/exe/bar.awk index c6fd9ef..97b5202 100644 --- a/x2/src/awk/exe/bar.awk +++ b/x2/src/awk/exe/bar.awk @@ -152,6 +152,14 @@ function bar_make_status_disk_io_r( src) { # Network # ----------------------------------------------------------------------------- +function bar_make_status_net_iface_status(interface, addr) { + cache_get(addr, "khatus_sensor_net_addr_io", "addr" Kfs interface, 5) + if (!addr["is_expired"] && addr["value"]) + return "up" + else + return "--" +} + function bar_make_status_net_addr(interface, src) { src = "khatus_sensor_net_addr_io" return cache_get_fmt_def(src, "addr" Kfs interface, 5, "%s", "") diff --git a/x2/src/awk/exe/gen_bar_make_status.awk b/x2/src/awk/exe/gen_bar_make_status.awk index 63b5e5b..587b102 100644 --- a/x2/src/awk/exe/gen_bar_make_status.awk +++ b/x2/src/awk/exe/gen_bar_make_status.awk @@ -29,6 +29,8 @@ BEGIN { params["@net_io_r"] = 1 aliases["@net_wifi"] = "bar_make_status_net_wifi(\"%s\")" params["@net_wifi"] = 1 + aliases["@net_iface_status"] = "bar_make_status_net_iface_status(\"%s\")" + params["@net_iface_status"] = 1 aliases["@bluetooth_power"] = "bar_make_status_bluetooth_power()" @@ -54,6 +56,7 @@ BEGIN { function_call = aliases[alias] } else if (n_expected_params == 1) { function_call = sprintf(aliases[alias], arg_parts[2]) + # TODO: Support params > 1 } else { printf(\ "Unsupported number of params: %d in %s\n", -- 2.20.1