From: Siraaj Khandkar Date: Wed, 1 Aug 2018 00:40:50 +0000 (-0400) Subject: Redirect stderr of each sensor to a (common) log file X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=f1b794f56264cf9e5eb0c22e0c1e20735d4039fc;p=khatus.git Redirect stderr of each sensor to a (common) log file --- diff --git a/bin/khatus b/bin/khatus index f6f5e18..5a3d8a0 100755 --- a/bin/khatus +++ b/bin/khatus @@ -17,13 +17,15 @@ consume() { spawn() { pipe="$1" dir_bin="$2" - cmd="$3" - msg_head="$4" - interval="$5" + log="$3" + cmd="$4" + msg_head="$5" + interval="$6" while true; do "$dir_bin"/$cmd | while read line; do echo "${msg_head} $line" > "$pipe" - done + done \ + 2> "$log" sleep "$interval" done & } @@ -249,22 +251,23 @@ main() { cmd_sens_fan="khatus_sensor_fan $fan_path" # TODO: Redirect each worker's stderr to a dedicated log file - spawn "$pipe" "$dir_bin" khatus_sensor_datetime 'in:DATE_TIME' $interval_inp_datetime - spawn "$pipe" "$dir_bin" "$cmd_sens_screen_brightness" 'in:SCREEN_BRIGHTNESS' $interval_inp_brightness - spawn "$pipe" "$dir_bin" "$cmd_sens_weather" 'in:WEATHER' $interval_inp_weather - spawn "$pipe" "$dir_bin" khatus_sensor_mpd_state 'in:MPD_STATE' $interval_inp_mpd_state - spawn "$pipe" "$dir_bin" khatus_sensor_mpd_song 'in:MPD_SONG' $interval_inp_mpd_song - spawn "$pipe" "$dir_bin" khatus_sensor_volume 'in:VOLUME' $interval_inp_volume - spawn "$pipe" "$dir_bin" khatus_sensor_bluetooth_power 'in:BLUETOOTH_POWER' $interval_inp_bluetooth - spawn "$pipe" "$dir_bin" khatus_sensor_net_wifi_status 'in:NET_WIFI_STATUS' $interval_inp_net_wifi - spawn "$pipe" "$dir_bin" khatus_sensor_net_addr_io 'in:NET_ADDR_IO' $interval_inp_net_io - spawn "$pipe" "$dir_bin" "$cmd_sens_disk_space" 'in:DISK_SPACE' $interval_inp_disk_space - spawn "$pipe" "$dir_bin" "$cmd_sens_disk_io" 'in:DISK_IO' $interval_inp_disk_io - spawn "$pipe" "$dir_bin" khatus_sensor_loadavg 'in:LOAD_AVG' $interval_inp_loadavg - spawn "$pipe" "$dir_bin" "$cmd_sens_temperature" 'in:TEMPERATURE' $interval_inp_temp - spawn "$pipe" "$dir_bin" "$cmd_sens_fan" 'in:FAN' $interval_inp_fan - spawn "$pipe" "$dir_bin" khatus_sensor_memory 'in:MEMORY' $interval_inp_mem - spawn "$pipe" "$dir_bin" khatus_sensor_energy 'in:ENERGY' $interval_inp_energy + log="$dir_data"/sensors.log + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_datetime 'in:DATE_TIME' $interval_inp_datetime + spawn "$pipe" "$dir_bin" "$log" "$cmd_sens_screen_brightness" 'in:SCREEN_BRIGHTNESS' $interval_inp_brightness + spawn "$pipe" "$dir_bin" "$log" "$cmd_sens_weather" 'in:WEATHER' $interval_inp_weather + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_mpd_state 'in:MPD_STATE' $interval_inp_mpd_state + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_mpd_song 'in:MPD_SONG' $interval_inp_mpd_song + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_volume 'in:VOLUME' $interval_inp_volume + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_bluetooth_power 'in:BLUETOOTH_POWER' $interval_inp_bluetooth + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_net_wifi_status 'in:NET_WIFI_STATUS' $interval_inp_net_wifi + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_net_addr_io 'in:NET_ADDR_IO' $interval_inp_net_io + spawn "$pipe" "$dir_bin" "$log" "$cmd_sens_disk_space" 'in:DISK_SPACE' $interval_inp_disk_space + spawn "$pipe" "$dir_bin" "$log" "$cmd_sens_disk_io" 'in:DISK_IO' $interval_inp_disk_io + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_loadavg 'in:LOAD_AVG' $interval_inp_loadavg + spawn "$pipe" "$dir_bin" "$log" "$cmd_sens_temperature" 'in:TEMPERATURE' $interval_inp_temp + spawn "$pipe" "$dir_bin" "$log" "$cmd_sens_fan" 'in:FAN' $interval_inp_fan + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_memory 'in:MEMORY' $interval_inp_mem + spawn "$pipe" "$dir_bin" "$log" khatus_sensor_energy 'in:ENERGY' $interval_inp_energy consume \ "$pipe" \