Commit af2021e3 authored by Hiro's avatar Hiro 🏄
Browse files

Count total moat and obsf4 bridges on the network

parent a28d025e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ try:
    if err:
        g_warnings.labels(host, "Problem grepping log - {}".format(err)).set(1)
    else:
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"'])
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"' and len(x)>1]])
        for c in list_of_errors:
            g_warnings.labels(host, c[0], c[1]).set(list_of_errors[c])

+17 −3
Original line number Diff line number Diff line
@@ -81,7 +81,9 @@ for relay in online_relays:
bridges = details['bridges']
total_bridges = len(bridges)
obfs4_bridges = []
all_obfs4_bridges = []
moat_bridges = []
all_moat_bridges = []

for bridge in bridges:
    if bridge.get('running') == True:
@@ -93,11 +95,17 @@ for bridge in bridges:
            moat_bridges.append(bridge)
    else:
        offline_bridges.append(bridge)
        if transports is not None and "obfs4" in transports:
            all_obfs4_bridges.append(bridge)
        if bridge.get('bridgedb_distributor') == "moat":
            all_moat_bridges.append(bridge)

total_online_bridges = len(online_bridges)
total_offline_bridges = len(offline_bridges)
total_online_obfs4_bridges = len(obfs4_bridges)
total_obsf4_bridges = len(all_obsf4_bridges)
total_online_moat_bridges = len(moat_bridges)
total_moat_bridges = len(all_moat_bridges)

for bridge in online_bridges:
    if bridge.get('overload_general_timestamp'):
@@ -165,11 +173,17 @@ total_network_bridges.set(total_bridges)
total_online_network_bridges = Gauge('total_online_bridges', 'Current number of online bridges on the network', registry=registry)
total_online_network_bridges.set(total_online_bridges)

total_online_network_obsf4_bridges = Gauge('total_online_obsf4_bridges', 'Current number of online bridges on the network', registry=registry)
total_online_network_obsf4_bridges = Gauge('total_online_obsf4_bridges', 'Current number of online obsf4 bridges on the network', registry=registry)
total_online_network_obsf4_bridges.set(total_online_obfs4_bridges)

total_online_network_moat_bridges = Gauge('total_online_moat_bridges', 'Current number of online bridges on the network', registry=registry)
total_online_network_moat_bridges.set(total_online_moat_bridges)
total_network_obsf4_bridges = Gauge('total_network_obsf4_bridges', 'Current number of obsf4 bridges on the network', registry=registry)
total_network_obsf4_bridges.set(total_obfs4_bridges)

total_online_network_moat_bridges = Gauge('total_online_moat_bridges', 'Current number of online moat bridges on the network', registry=registry)
total_online_network_moat_bridges.set(tota_moat_bridges)

total_network_moat_bridges = Gauge('total_network_moat_bridges', 'Current number of moat bridges on the network', registry=registry)
total_network_moat_bridges.set(total_moat_bridges)

relays_network_overload_general = Gauge('relays_overload_general', 'Current number of relays in overload_general state', registry=registry)
relays_network_overload_general.set(len(relays_overload_general))
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ try:
    if err:
        g_warnings.labels(host, "Problem grepping log - {}".format(err)).set(1)
    else:
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"'])
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"' and len(x)>1]])
        for c in list_of_errors:
            g_warnings.labels(host, c[0], c[1]).set(list_of_errors[c])

+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ try:
    if err:
        g_warnings.labels(host, "Problem grepping log - {}".format(err)).set(1)
    else:
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"'])
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"' and len(x)>1])
        for c in list_of_errors:
            g_warnings.labels(host, c[0], c[1]).set(list_of_errors[c])

+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ try:
    if err:
        g_warnings.labels(host, "Problem grepping log - {}".format(err)).set(1)
    else:
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"'])
        list_of_errors = Counter([(x.split(' ')[2], x.split(' ')[3].split(':')[0]) for x in str(out).split('\\n') if x != '"' and len(x)>1]])
        for c in list_of_errors:
            g_warnings.labels(host, c[0], c[1]).set(list_of_errors[c])