added global stale rate to graphs
authorForrest Voight <forrest@forre.st>
Fri, 27 Jan 2012 19:33:13 +0000 (14:33 -0500)
committerForrest Voight <forrest@forre.st>
Fri, 27 Jan 2012 19:33:13 +0000 (14:33 -0500)
p2pool/graphs.py
p2pool/main.py

index 02bed12..c85acbc 100644 (file)
@@ -47,12 +47,15 @@ else:
             
             self.putChild('poolrate_day', Renderer(lambda: ['--lower-limit', '0', '-M', '-E', '--start', '-1d',
                 'DEF:A=%s.poolrate:poolrate:AVERAGE' % (self.grapher.path,), 'LINE1:A#0000FF:Total (last day)',
+                'DEF:C=%s.stalerate:stalerate:AVERAGE' % (self.grapher.path,), 'LINE1:C#FF0000:Total stale (last day)',
                 'DEF:B=%s.localrate:localrate:AVERAGE' % (self.grapher.path,), 'LINE1:B#0000FF:Local (last day)']))
             self.putChild('poolrate_week', Renderer(lambda: ['--lower-limit', '0', '-M', '-E', '--start', '-1w',
                 'DEF:A=%s.poolrate:poolrate:AVERAGE' % (self.grapher.path,), 'LINE1:A#0000FF:Total (last week)',
+                'DEF:C=%s.stalerate:stalerate:AVERAGE' % (self.grapher.path,), 'LINE1:C#FF0000:Total stale (last week)',
                 'DEF:B=%s.localrate:localrate:AVERAGE' % (self.grapher.path,), 'LINE1:B#0000FF:Local (last week)']))
             self.putChild('poolrate_month', Renderer(lambda: ['--lower-limit', '0', '-M', '-E', '--start', '-1m',
                 'DEF:A=%s.poolrate:poolrate:AVERAGE' % (self.grapher.path,), 'LINE1:A#0000FF:Total (last month)',
+                'DEF:C=%s.stalerate:stalerate:AVERAGE' % (self.grapher.path,), 'LINE1:C#FF0000:Total stale (last month)',
                 'DEF:B=%s.localrate:localrate:AVERAGE' % (self.grapher.path,), 'LINE1:B#0000FF:Local (last month)']))
             
             def get_lines():
@@ -101,6 +104,13 @@ else:
                     'RRA:AVERAGE:0.5:7:288', # last week
                     'RRA:AVERAGE:0.5:30:288', # last month
                 )
+            if not os.path.exists(self.path + '.stalerate'):
+                rrdtool.create(self.path + '.stalerate', '--step', '300',
+                    'DS:stalerate:GAUGE:600:U:U',
+                    'RRA:AVERAGE:0.5:1:288', # last day
+                    'RRA:AVERAGE:0.5:7:288', # last week
+                    'RRA:AVERAGE:0.5:30:288', # last month
+                )
             if not os.path.exists(self.path + '.localrate'):
                 rrdtool.create(self.path + '.localrate', '--step', '300',
                     'DS:localrate:ABSOLUTE:43200:U:U',
@@ -116,8 +126,9 @@ else:
                     'RRA:AVERAGE:0.5:30:288', # last month
                 )
         
-        def add_poolrate_point(self, poolrate):
+        def add_poolrate_point(self, poolrate, stalerate):
             rrdtool.update(self.path + '.poolrate', '-t', 'poolrate', 'N:%f' % (poolrate,))
+            rrdtool.update(self.path + '.stalerate', '-t', 'stalerate', 'N:%f' % (stalerate,))
         
         def add_localrate_point(self, hashes, dead):
             rrdtool.update(self.path + '.localrate', '-t', 'localrate', 'N:%f' % (hashes,))
index 2f9eeae..2e40a76 100644 (file)
@@ -738,8 +738,9 @@ def main(args, net, datadir_path):
         def add_point():
             if tracker.get_height(current_work.value['best_share_hash']) < 720:
                 return
-            grapher.add_poolrate_point(p2pool_data.get_pool_attempts_per_second(tracker, current_work.value['best_share_hash'], 720)
-                / (1 - p2pool_data.get_average_stale_prop(tracker, current_work.value['best_share_hash'], 720)))
+            nonstalerate = p2pool_data.get_pool_attempts_per_second(tracker, current_work.value['best_share_hash'], 720)
+            poolrate = nonstalerate / (1 - p2pool_data.get_average_stale_prop(tracker, current_work.value['best_share_hash'], 720))
+            grapher.add_poolrate_point(poolrate, poolrate - nonstalerate)
         task.LoopingCall(add_point).start(100)
         
         reactor.listenTCP(args.worker_port, server.Site(web_root))