home
/
code
/
khatus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Expose GC interval option
[khatus.git]
/
bin
/
khatus_bar
diff --git
a/bin/khatus_bar
b/bin/khatus_bar
index
bd31283
..
2c7ee32
100755
(executable)
--- 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 : ":"
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
_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
_cache[src, key] = val
time = cache_get_time()
_cache_mtime[src, key] = time
- if (time %
3600
== 0) {
+ if (time %
GC_Interval
== 0) {
cache_gc()
}
}
cache_gc()
}
}
@@
-96,14
+97,18
@@
function cache_get_time( src, key, time) {
return time
}
return time
}
-function cache_gc( src_and_key, unused_for) {
+function cache_gc( src_and_key,
parts, src, key,
unused_for) {
for (src_and_key in _cache) {
for (src_and_key in _cache) {
- unused_for = cache_get_time() - _cache_atime[src_and_key]
- if (unused_for > 3600) {
+ split(src_and_key, parts, SUBSEP)
+ src = parts[1]
+ key = parts[2]
+ unused_for = cache_get_time() - _cache_atime[src, key]
+ if (unused_for > GC_Interval) {
print_msg_info(\
print_msg_info(\
- "cache_gc", "Deleting unused src_and_key: " src_and_key \
+ "cache_gc",
+ sprintf("Deleting unused data SRC=%s KEY=%s", src, key) \
)
)
- delete _cache[src
_and_
key]
+ delete _cache[src
,
key]
}
}
}
}
}
}
This page took
0.028329 seconds
and
4
git commands to generate.