Redesign message format
[khatus.git] / bin / khatus
index 87b137a..ec8270f 100755 (executable)
@@ -36,18 +36,18 @@ run_producer() {
     2> >(
         while read line
         do
-            echo "ERROR${MSG_FS}${executable_name}${MSG_FS}$line" > "$pipe"
+            echo "${NODE}${MSG_FS}${executable_name}${MSG_FS}error${MSG_FS}$line" > "$pipe"
         done \
     ) \
     | while read line
         do
-            echo "OK${MSG_FS}${executable_name}${MSG_FS}$line" > "$pipe"
+            echo "${NODE}${MSG_FS}${executable_name}${MSG_FS}data${MSG_FS}$line" > "$pipe"
         done
     cmd_exit_code=${PIPESTATUS[0]}
     if [ "$cmd_exit_code" -ne 0 ]
     then
         echo
-            "ERROR${MSG_FS}${executable_name}${MSG_FS}NON_ZERO_EXIT_CODE${MSG_FS}$cmd_exit_code" \
+            "${NODE}${MSG_FS}${executable_name}${MSG_FS}error${MSG_FS}NON_ZERO_EXIT_CODE${MSG_FS}$cmd_exit_code" \
             > "$pipe"
     fi
 }
@@ -87,12 +87,12 @@ fork_poller() {
 
 main() {
     declare -A opts=(
+        ["--node"]=$(hostname)
         ["--dir_bin"]="$HOME/bin"
         ["--dir_perf_logs"]=''
         ["--file_pipe"]=$(mktemp)
         ["--weather_station_id"]='KJFK'
         ["--screen_brightness_device_name"]='acpi_video0'
-        ["--net_interfaces_to_show"]=''  # comma-separated
         ["--wifi_interface"]=''
         ["--disk_space_device"]='/'
         ["--disk_io_device"]='sda'
@@ -100,6 +100,7 @@ main() {
         ["--fan_path"]='/proc/acpi/ibm/fan'
         ["--pulseaudio_sink"]='0'
         ["--interval_datetime"]=1
+        ["--interval_procs"]=1
         ["--interval_brightness"]=1
         ["--interval_weather"]=$(( 30 * 60))  # 30 minutes
         ["--interval_mpd"]=1
@@ -160,6 +161,8 @@ main() {
         echo '----------------------------------------------'
     ) >&2
 
+    NODE="${opts['--node']}"
+
     screen_brightness_device_path='/sys/class/backlight'
     screen_brightness_device_path+="/${opts['--screen_brightness_device_name']}"
 
@@ -188,7 +191,9 @@ main() {
     cmd_sens_memory="khatus_sensor_memory $bin"
 
     fork_watcher                                           "$pipe" "$bin" "khatus_sensor_energy $bin"
+    fork_watcher                                           "$pipe" "$bin" "khatus_sensor_devices $bin"
     fork_poller "${opts['--interval_datetime']}"   "$perf" "$pipe" "$bin" khatus_sensor_datetime
+    fork_poller "${opts['--interval_procs']}"      "$perf" "$pipe" "$bin" "khatus_sensor_procs $bin"
     fork_poller "${opts['--interval_brightness']}" "$perf" "$pipe" "$bin" "$cmd_sens_screen_brightness"
     fork_poller "${opts['--interval_weather']}"    "$perf" "$pipe" "$bin" "$cmd_sens_weather"
     fork_poller "${opts['--interval_mpd']}"        "$perf" "$pipe" "$bin" "$cmd_sens_mpd"
@@ -203,23 +208,7 @@ main() {
     fork_poller "${opts['--interval_fan']}"        "$perf" "$pipe" "$bin" "$cmd_sens_fan"
     fork_poller "${opts['--interval_mem']}"        "$perf" "$pipe" "$bin" "$cmd_sens_memory"
 
-    stdbuf -o L tail -f "$pipe" \
-    | stdbuf -o L tee \
-        >(stdbuf -o L "$bin"/khatus_bar \
-            -F "$MSG_FS" \
-            -v Opt_Mpd_Song_Max_Chars=10 \
-            -v Opt_Net_Interfaces_To_Show="${opts['--net_interfaces_to_show']}" \
-            -v Opt_Pulseaudio_Sink="${opts['--pulseaudio_sink']}" \
-        | "$bin"/khatus_actuate_status_bar_to_xsetroot_name \
-        ) \
-        >(stdbuf -o L "$bin"/khatus_monitor_energy \
-        | "$bin"/khatus_actuate_alert_to_notify_send \
-        ) \
-        >(stdbuf -o L "$bin"/khatus_monitor_errors \
-        | "$bin"/khatus_actuate_alert_to_notify_send \
-        ) \
-    > /dev/null
-
+    stdbuf -o L tail -f "$pipe"
 }
 
 main $@
This page took 0.027476 seconds and 4 git commands to generate.