fork_poller "${opts['--interval_inp_mem']}" "$perf" "$pipe" "$bin" "$cmd_sens_memory"
stdbuf -o L tail -f "$pipe" \
- | stdbuf -o L "$bin"/khatus_transform_total_to_diff \
- -F "$MSG_FS" \
- -v status='OK' \
- -v src='khatus_sensor_net_addr_io' \
- -v key_prefix='bytes_read' \
- | stdbuf -o L "$bin"/khatus_transform_total_to_diff \
- -F "$MSG_FS" \
- -v status='OK' \
- -v src='khatus_sensor_net_addr_io' \
- -v key_prefix='bytes_written' \
- | stdbuf -o L "$bin"/khatus_transform_total_to_diff \
- -F "$MSG_FS" \
- -v status='OK' \
- -v src='khatus_sensor_disk_io' \
- -v key_prefix='sectors_read' \
- | stdbuf -o L "$bin"/khatus_transform_total_to_diff \
- -F "$MSG_FS" \
- -v status='OK' \
- -v src='khatus_sensor_disk_io' \
- -v key_prefix='sectors_written' \
| stdbuf -o L "$bin"/khatus_bar \
-F "$MSG_FS" \
-v opt_debug=""${opts['--debug']}"" \
FS = msg_fs ? msg_fs : "|"
OFS = msg_fs ? msg_fs : "|"
Kfs = key_fs ? key_fs : ":"
+
+ _total_to_diff["khatus_sensor_net_addr_io", "bytes_read" ] = 1
+ _total_to_diff["khatus_sensor_net_addr_io", "bytes_written" ] = 1
+ _total_to_diff["khatus_sensor_disk_io" , "sectors_read" ] = 1
+ _total_to_diff["khatus_sensor_disk_io" , "sectors_written"] = 1
}
# -----------------------------------------------------------------------------
len_val = len_line - len_head
val = substr($0, len_head + 1, len_val)
- Data[src, key] = val
+ Data[src, key] = Data_maybe_total_to_diff(src, key, val)
time = Data_get_time()
M_time[src, key] = time
}
}
+function Data_maybe_total_to_diff(src, key, val, key_parts) {
+ split(key, key_parts, Kfs)
+ if (_total_to_diff[src, key_parts[1]]) {
+ _prev[src, key] = _curr[src, key]
+ _curr[src, key] = val
+ return (_curr[src, key] - _prev[src, key])
+ } else {
+ return val
+ }
+}
+
# -----------------------------------------------------------------------------
# Status bar
# -----------------------------------------------------------------------------
+++ /dev/null
-#! /usr/bin/awk -f
-
-BEGIN {
- FS = msg_fs ? msg_fs : "|"
- OFS = msg_fs ? msg_fs : "|"
- Kfs = key_fs ? key_fs : ":"
-}
-
-# Modify the record we're interested in
-$1 == status && $2 == src && ($3 ~ ("^" key_prefix)) {
- key = $3
- val = $4
- prev[key] = curr[key]
- curr[key] = val
- diff[key] = curr[key] - prev[key]
- print($1, $2, $3, diff[key])
- next
-}
-
-# Let everything else through untouched
-//