From b80cfeb186860ab6bd247d484b60dde1fd0c0322 Mon Sep 17 00:00:00 2001 From: robk-tahoe Date: Thu, 31 Jan 2008 21:04:23 -0700 Subject: [PATCH] munin stats: suppress output of data more that 5min old if a node fails to report stats, the natural thing to do in re munin is to supress the data for that data series. the previous tahoe-stats would output whatever data was present in the stats_gatherer's stats.pickle, regardless of how old. this change means that if the gatherer hasn't received data within the last 5 min, then no data is reported to munin for that node. --- misc/munin/tahoe-stats.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/munin/tahoe-stats.py b/misc/munin/tahoe-stats.py index 766f2246..c2609d3e 100644 --- a/misc/munin/tahoe-stats.py +++ b/misc/munin/tahoe-stats.py @@ -4,6 +4,9 @@ import os import pickle import re import sys +import time + +STAT_VALIDITY = 300 # 5min limit on reporting stats PLUGINS = { 'tahoe_storage_consumed': @@ -122,8 +125,11 @@ def main(argv): stats = open_stats(stats_file) + now = time.time() def output_nodes(output_section): for tubid, nodestats in stats.items(): + if (now - nodestats.get('timestamp', 0)) > STAT_VALIDITY: + continue name = smash_name("%s_%s" % (nodestats['nickname'], tubid[:4])) #value = nodestats['stats'][plugin_conf['category']].get(plugin_conf['statid']) category = plugin_conf['category'] -- 2.45.2