From 731a145eca3424118c9dfc6bb36d63c3b391e70c Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Fri, 22 Mar 2019 14:55:10 -0400 Subject: [PATCH] Add load average sensor --- x4/bin/khatus_x4_sensor_loadavg | 13 +++++++++++++ x4/sanity_check | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 x4/bin/khatus_x4_sensor_loadavg diff --git a/x4/bin/khatus_x4_sensor_loadavg b/x4/bin/khatus_x4_sensor_loadavg new file mode 100755 index 0000000..1228208 --- /dev/null +++ b/x4/bin/khatus_x4_sensor_loadavg @@ -0,0 +1,13 @@ +#! /bin/sh + +set -e + +bin_dir="$(dirname $(realpath $0))" + +. "$bin_dir/khatus_x4_lib_common_sensor.sh" + +sensor() { + awk '{ print("load_avg_1min", $1); }' /proc/loadavg +} + +run_as_poller diff --git a/x4/sanity_check b/x4/sanity_check index a01a0c1..62a23ea 100755 --- a/x4/sanity_check +++ b/x4/sanity_check @@ -21,6 +21,7 @@ sensors_fork_all() { ./bin/khatus_x4_sensor_mpd & ./bin/khatus_x4_sensor_energy & ./bin/khatus_x4_sensor_memory & + ./bin/khatus_x4_sensor_loadavg & } sensor_read_one() { @@ -42,7 +43,8 @@ sensors_read_all() { datetime="$(sensor_read_one ${dir}/khatus_x4_sensor_datetime/out/datetime)" mpd="$(sensor_read_one ${dir}/khatus_x4_sensor_mpd/out/status)" mem="$(sensor_read_one ${dir}/khatus_x4_sensor_memory/out/percent_used)" - echo "E[${battery_state} ${battery_percentage}] M:${mem}% [${mpd}] [$bluetooth_controllers $bluetooth_devices] ${datetime}" + load="$(sensor_read_one ${dir}/khatus_x4_sensor_loadavg/out/load_avg_1min)" + echo "E[${battery_state} ${battery_percentage}] M:${mem}% L:${load} [${mpd}] [$bluetooth_controllers $bluetooth_devices] ${datetime}" sleep 1 done } -- 2.20.1