From 2d710f2862fb523a4fabac01c155dac692df910d Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Mon, 20 Aug 2018 22:28:12 -0400 Subject: [PATCH] Expose GC interval option --- bin/khatus_bar | 7 ++++--- sanity_check | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/khatus_bar b/bin/khatus_bar index 9b0fd7f..2c7ee32 100755 --- a/bin/khatus_bar +++ b/bin/khatus_bar @@ -13,6 +13,7 @@ BEGIN { FS = msg_fs ? msg_fs : "|" OFS = msg_fs ? msg_fs : "|" Kfs = key_fs ? key_fs : ":" + GC_Interval = GC_Interval ? GC_Interval : 3600 # seconds _total_to_diff["khatus_sensor_net_addr_io", "bytes_read" ] = 1 _total_to_diff["khatus_sensor_net_addr_io", "bytes_written" ] = 1 @@ -65,7 +66,7 @@ function cache_update( src, key, val, len_line, len_head, len_val, time) { _cache[src, key] = val time = cache_get_time() _cache_mtime[src, key] = time - if (time % 3600 == 0) { + if (time % GC_Interval == 0) { cache_gc() } } @@ -102,10 +103,10 @@ function cache_gc( src_and_key, parts, src, key, unused_for) { src = parts[1] key = parts[2] unused_for = cache_get_time() - _cache_atime[src, key] - if (unused_for > 3600) { + if (unused_for > GC_Interval) { print_msg_info(\ "cache_gc", - sprintf("Deleting unused SRC=%s KEY=%s", src, key) \ + sprintf("Deleting unused data SRC=%s KEY=%s", src, key) \ ) delete _cache[src, key] } diff --git a/sanity_check b/sanity_check index b8dec76..c10dcaf 100755 --- a/sanity_check +++ b/sanity_check @@ -8,6 +8,7 @@ -v Opt_Mpd_Song_Max_Chars=10 \ -v Opt_Net_Interfaces_To_Show=wlp3s0 \ -v Opt_Pulseaudio_Sink=0 \ + -v GC_Interval=5 \ ) \ >(stdbuf -o L ./bin/khatus_monitor_energy) \ >(stdbuf -o L ./bin/khatus_monitor_errors) \ -- 2.20.1