[tor-commits] [arm/master] Replacing code for getting process uptime
atagar at torproject.org
atagar at torproject.org
Tue Sep 9 02:33:48 UTC 2014
commit f06b621813ec8bfc871df41449ba5b45d6ee6a41
Author: Damian Johnson <atagar at torproject.org>
Date: Mon Sep 8 16:51:10 2014 -0700
Replacing code for getting process uptime
We had a hack here where we got more attributes than we wanted to piggyback on
cached values fetched for other things. That hack no longer works, and stem has
a very nice function for this so using that.
---
arm/graphing/bandwidth_stats.py | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/arm/graphing/bandwidth_stats.py b/arm/graphing/bandwidth_stats.py
index ce8b5b1..f8fea43 100644
--- a/arm/graphing/bandwidth_stats.py
+++ b/arm/graphing/bandwidth_stats.py
@@ -143,30 +143,14 @@ class BandwidthStats(graph_panel.GraphStats):
if or_port == '0':
return
- # gets the uptime (using the same parameters as the header panel to take
- # advantage of caching)
- # TODO: stem dropped system caching support so we'll need to think of
- # something else
-
- uptime = None
- query_pid = controller.get_pid(None)
-
- if query_pid:
- query_param = ['%cpu', 'rss', '%mem', 'etime']
- query_cmd = 'ps -p %s -o %s' % (query_pid, ','.join(query_param))
- ps_call = system.call(query_cmd, None)
-
- if ps_call and len(ps_call) == 2:
- stats = ps_call[1].strip().split()
-
- if len(stats) == 4:
- uptime = stats[3]
+ start_time = system.start_time(controller.get_pid(None))
+ uptime = time.time() - start_time if start_time else None
# checks if tor has been running for at least a day, the reason being that
# the state tracks a day's worth of data and this should only prepopulate
# results associated with this tor instance
- if not uptime or '-' not in uptime:
+ if not uptime or uptime < (24 * 60 * 60):
log.notice(msg('panel.graphing.prepopulation_failure', error = 'insufficient uptime'))
return False
More information about the tor-commits
mailing list