diff --git a/i2pd-statistics/i2pd-statistics.py b/i2pd-statistics/i2pd-statistics.py
--- a/i2pd-statistics/i2pd-statistics.py
+++ b/i2pd-statistics/i2pd-statistics.py
#
@@ -31,17 +31,34 @@ def process_uptime(inp):
#
seconds = (int(res["hours"][0]) * 3600) + (int(res["minutes"][0]) * 60) + int(res["seconds"][0])
#
+def process_netstatus(inp):
#
+ ''' Extract the reported network status
#
+ Valid values are defined here https://github.com/PurpleI2P/i2pd/blob/openssl/daemon/HTTPServer.cpp#L223
#
+ return inp.split("</b>")[1].lstrip()
#
def process_percentage(inp):
#
''' Extract a percentage value
#
- perc = getMatches(inp, "([0-9]+)%")
#
+ perc = getMatches(inp, "([0-9,\.]+)%")
#
+def extract_number(inp):
#
+ ''' Extract an integer
#
+ i = getMatches(inp, "([0-9]+)")
#
def extract_throughput(inp):
#
''' The unit changes based on volume, but the minimum unit used is KiB
#
@@ -77,6 +94,41 @@ def extract_throughput(inp):
#
+def extract_version(inp):
#
+ ''' Extract the version string
#
+ ver = getMatches(inp, "([0-9,\.]+)")
#
+def split_counter_row(inp):
#
+ ''' The counter row is a single line with multiple counters on it
#
+ lines = inp.split('<b>')
#
+ if line.startswith("Routers:"):
#
+ routers = extract_number(line)
#
+ elif line.startswith("Floodfills:"):
#
+ floodfills = extract_number(line)
#
+ elif line.startswith("LeaseSets:"):
#
+ leasesets = extract_number(line)
#
+ elif line.startswith("Client Tunnels:"):
#
+ clienttunnels = extract_number(line)
#
+ elif line.startswith("Transit Tunnels:"):
#
+ transittunnels = extract_number(line)
#
+ return routers, floodfills, leasesets, clienttunnels, transittunnels
#
homepage = getPage("/", HOST)
#
@@ -84,9 +136,15 @@ homepage = getPage("/", HOST)
#
bold_fields = getMatches(homepage, "<b>(.+)<br>")
#
+network_status_v6 = "disabled"
#
for line in bold_fields:
#
if line.startswith("Uptime:"):
#
uptime = process_uptime(line)
#
+ if line.startswith("Network status:"):
#
+ network_status = process_netstatus(line)
#
+ if line.startswith("Network status v6:"):
#
+ network_status_v6 = process_netstatus(line)
#
elif line.startswith("Tunnel creation success rate:"):
#
creation_success = process_percentage(line)
#
elif line.startswith("Received:"):
#
@@ -95,7 +153,19 @@ for line in bold_fields:
#
out_vol, out_through = extract_throughput(line)
#
elif line.startswith("Transit:"):
#
transit_vol, transit_through = extract_throughput(line)
#
+ elif line.startswith("Version:"):
#
+ version = extract_version(line)
#
+ elif line.startswith("Routers:"):
#
+ routers, floodfills, leasesets, x, y = split_counter_row(line)
#
+ elif line.startswith("Client Tunnels:"):
#
+ x, y, z, clienttunnels, transittunnels = split_counter_row(line)
#
fields = "uptime={uptime}i,tunnel_creation_success_rate={success_rate},in_bytes={in_bytes}i,in_avg_bps={in_bps}".format(
#
@@ -115,9 +185,25 @@ fields = "{fields},out_bytes={out_bytes}i,out_avg_bps={out_bps},transit_bytes={t
#
transit_bps = transit_through
#
-lp = "{measurement},url={url} {fields}".format(
#
+fields = "{fields},routers={routers}i,floodfills={floodfills}i,leasesets={leasesets}i,clienttunnels={clienttunnels}i,transittunnels={transittunnels}i".format(
#
+ floodfills = floodfills,
#
+ leasesets = leasesets,
#
+ clienttunnels = clienttunnels,
#
+ transittunnels = transittunnels
#
+tags = "url={url},version={version},network_status={network_status},network_status_v6={network_status_v6}".format(
#
+ network_status = network_status,
#
+ network_status_v6 = network_status_v6
#
+lp = "{measurement},{tags} {fields}".format(
#
measurement = MEASUREMENT,