cmd_sens_fan="khatus_sensor_fan $fan_path"
cmd_sens_bluetooth="khatus_sensor_bluetooth_power $dir_bin"
cmd_sens_mpd_state="khatus_sensor_mpd_state $dir_bin"
+ cmd_sens_net_addr_io="khatus_sensor_net_addr_io $dir_bin"
# TODO: Redirect each worker's stderr to a dedicated log file
pipe="$file_pipe"
fork_poller $interval_inp_volume "$pipe" "$dir_bin" "$log" khatus_sensor_volume 'in:VOLUME'
fork_poller $interval_inp_bluetooth "$pipe" "$dir_bin" "$log" "$cmd_sens_bluetooth" 'in:BLUETOOTH_POWER'
fork_poller $interval_inp_net_wifi "$pipe" "$dir_bin" "$log" khatus_sensor_net_wifi_status 'in:NET_WIFI_STATUS'
- fork_poller $interval_inp_net_io "$pipe" "$dir_bin" "$log" khatus_sensor_net_addr_io 'in:NET_ADDR_IO'
+ fork_poller $interval_inp_net_io "$pipe" "$dir_bin" "$log" "$cmd_sens_net_addr_io" 'in:NET_ADDR_IO'
fork_poller $interval_inp_disk_space "$pipe" "$dir_bin" "$log" "$cmd_sens_disk_space" 'in:DISK_SPACE'
fork_poller $interval_inp_disk_io "$pipe" "$dir_bin" "$log" "$cmd_sens_disk_io" 'in:DISK_IO'
fork_poller $interval_inp_loadavg "$pipe" "$dir_bin" "$log" khatus_sensor_loadavg 'in:LOAD_AVG'
--- /dev/null
+#! /usr/bin/awk -f
+
+/^[0-9]+:/ {
+ sub(":$", "", $1)
+ sub(":$", "", $2)
+ sequence = $1
+ interface = $2
+ interfaces[sequence] = interface
+}
+
+/^ +inet [0-9]/ {
+ sub("/[0-9]+", "", $2)
+ addr = $2
+ addrs[interface] = addr
+}
+
+/^ +RX: / {transfer_direction = "r"}
+/^ +TX: / {transfer_direction = "w"}
+
+/^ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ *$/ {
+ io[interface, transfer_direction] = $1;
+}
+
+END {
+ for (seq=1; seq<=sequence; seq++) {
+ interface = interfaces[seq]
+ label = substr(interface, 1, 1)
+ addr = addrs[interface]
+ if (addr) {
+ curr_read = io[interface, "r"]
+ curr_write = io[interface, "w"]
+ print(interface, addr, curr_write, curr_read)
+ } else {
+ print(interface)
+ }
+ }
+}
set -e
-ip -s addr \
-| awk '
- /^[0-9]+:/ {
- sub(":$", "", $1)
- sub(":$", "", $2)
- sequence = $1
- interface = $2
- interfaces[sequence] = interface
- }
+dir_bin="$1"
- /^ +inet [0-9]/ {
- sub("/[0-9]+", "", $2)
- addr = $2
- addrs[interface] = addr
- }
-
- /^ +RX: / {transfer_direction = "r"}
- /^ +TX: / {transfer_direction = "w"}
-
- /^ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ *$/ {
- io[interface, transfer_direction] = $1;
- }
-
- END {
- for (seq=1; seq<=sequence; seq++) {
- interface = interfaces[seq]
- label = substr(interface, 1, 1)
- if (addrs[interface]) {
- curr_read = io[interface, "r"]
- curr_write = io[interface, "w"]
- print(interface, addrs[interface], curr_write, curr_read)
- } else {
- print(interface)
- }
- }
- }'
+ip -s addr | "$dir_bin"/khatus_parse_ip_addr