X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=blobdiff_plain;f=bin%2Fkhatus_bar;h=e2e505ce85e4c0bed0578e143bf78096ce436057;hp=fed9b11d3d0b999037a678c36803ae1bb4a9222b;hb=bd3e26c879dada3c8ba006b0169f67d441ec6f6d;hpb=8ab38d67c4dbbd640673a47d44ad4c87da223090 diff --git a/bin/khatus_bar b/bin/khatus_bar index fed9b11..e2e505c 100755 --- a/bin/khatus_bar +++ b/bin/khatus_bar @@ -4,6 +4,11 @@ BEGIN { 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 } # ----------------------------------------------------------------------------- @@ -36,7 +41,7 @@ function Data_update( src, key, val, len_line, len_head, len_val, time) { 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 @@ -73,6 +78,17 @@ function Data_gc( src_and_key, unused_for) { } } +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 # -----------------------------------------------------------------------------