monitoring/contrib/find_bad_mesh.py

14 lines
655 B
Python
Raw Normal View History

2015-11-27 15:54:47 +01:00
#!/usr/bin/python3
2015-09-03 16:56:07 +02:00
from pymongo import MongoClient
client = MongoClient()
db = client.freifunk
2015-11-27 15:54:47 +01:00
for router in db.routers.find({"hood": {"$exists": True}, "neighbours": {"$exists": True}, "status": "online"}, {"stats": 0}):
2015-09-03 16:56:07 +02:00
for neighbour in router["neighbours"]:
if "_id" in neighbour and "position" in neighbour:
2015-11-27 15:54:47 +01:00
neighbour_router = db.routers.find_one({"_id": neighbour["_id"]}, {"stats": 0})
if router["hood"] != neighbour_router["hood"] and neighbour_router["status"] == "online":
2015-09-03 16:56:07 +02:00
print("Illegal inter-hood-mesh between %s (%s) and %s (%s)!" % (router["hostname"], router["hood"], neighbour_router["hostname"], neighbour_router["hood"]))