[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] Replacing code for getting process uptime



commit f06b621813ec8bfc871df41449ba5b45d6ee6a41
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits