From: Brian Warner Date: Thu, 8 May 2008 18:37:30 +0000 (-0700) Subject: run a stats provider even if there's no gatherer, since the HTTP /statistics page... X-Git-Tag: allmydata-tahoe-1.1.0~146 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/%22news.html/?a=commitdiff_plain;h=462ef2a0aca32f4cd8536b74a6fea5f625568894;p=tahoe-lafs%2Ftahoe-lafs.git run a stats provider even if there's no gatherer, since the HTTP /statistics page is then useful. Only run the once-per-second load-monitor if there is a gatherer configured --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index cb96b495..95cd8ff7 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -114,12 +114,9 @@ class Client(node.Node, testutil.PollMixin): def init_stats_provider(self): gatherer_furl = self.get_config('stats_gatherer.furl') - if gatherer_furl: - self.stats_provider = StatsProvider(self, gatherer_furl) - self.add_service(self.stats_provider) - self.stats_provider.register_producer(self) - else: - self.stats_provider = None + self.stats_provider = StatsProvider(self, gatherer_furl) + self.add_service(self.stats_provider) + self.stats_provider.register_producer(self) def get_stats(self): return { 'node.uptime': time.time() - self.started_timestamp } diff --git a/src/allmydata/stats.py b/src/allmydata/stats.py index 5a50b571..96621311 100644 --- a/src/allmydata/stats.py +++ b/src/allmydata/stats.py @@ -131,25 +131,31 @@ class StatsProvider(foolscap.Referenceable, service.MultiService): def __init__(self, node, gatherer_furl): service.MultiService.__init__(self) self.node = node - self.gatherer_furl = gatherer_furl + self.gatherer_furl = gatherer_furl # might be None self.counters = {} self.stats_producers = [] - self.load_monitor = LoadMonitor(self) - self.load_monitor.setServiceParent(self) - self.register_producer(self.load_monitor) + # only run the LoadMonitor (which submits a timer every second) if + # there is a gatherer who is going to be paying attention. Our stats + # are visible through HTTP even without a gatherer, so run the rest + # of the stats (including the once-per-minute CPUUsageMonitor) + if gatherer_furl: + self.load_monitor = LoadMonitor(self) + self.load_monitor.setServiceParent(self) + self.register_producer(self.load_monitor) self.cpu_monitor = CPUUsageMonitor() self.cpu_monitor.setServiceParent(self) self.register_producer(self.cpu_monitor) def startService(self): - if self.node: + if self.node and self.gatherer_furl: d = self.node.when_tub_ready() def connect(junk): nickname = self.node.get_config('nickname') - self.node.tub.connectTo(self.gatherer_furl, self._connected, nickname) + self.node.tub.connectTo(self.gatherer_furl, + self._connected, nickname) d.addCallback(connect) service.MultiService.startService(self)