diff --git a/tor-daemon/tor-daemon.py b/tor-daemon/tor-daemon.py
--- a/tor-daemon/tor-daemon.py
+++ b/tor-daemon/tor-daemon.py
#
@@ -46,6 +46,36 @@ def send_and_respond(sock, command):
#
return ''.join(res).split('\r\n')
#
+def get_guard_counts(s):
#
+ ''' Get guard info and build a set of counters
#
+ res = send_and_respond(s, "GETINFO entry-guards")
#
+ if len(res) < 1 or not res[0].startswith("250+"):
#
+ print("failed to get guard info")
#
+ # Strip the response code and trailers
#
+ "never-connected" : 0,
#
+ for line in res[0:-2]:
#
+ counters["total"] += 1
#
def build_lp(measurement_name, state):
#
''' Build a Line Protocol response
#
@@ -70,6 +100,22 @@ def build_lp(measurement_name, state):
#
v = entry['name'] + '="' + entry["value"] + '"'
#
+ # Process counters - these are always ints
#
+ for counter in state["counters"]:
#
+ # First list element is a category for the counters
#
+ prefix = counter[0] + "_"
#
+ for nm in counter[1]:
#
+ # Take the name and prepend the prefix, gives us
#
+ fname = prefix + nm.replace("-","_")
#
+ v = fname + "=" + str(counter[1][nm]) + "i"
#
return " ".join([l, f])
#
@@ -77,7 +123,8 @@ def build_lp(measurement_name, state):
#
"conn_status" : "failed",
#
# Initialise a connection
#
@@ -116,6 +163,8 @@ for stat in stats:
#
+state["counters"].append(["guards", get_guard_counts(s)])
#
print(build_lp(MEASUREMENT, state))