mirror of
https://github.com/andrey271192/vps_monitoring.git
synced 2026-09-20 11:55:34 +00:00
fix(keenetic): Web/AnyDesk links and import sync
Add web_url/anydesk to router records, host fallback for Web button on offline cards, cache-bust app.js, and scripts to sync import list. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
43
scripts/check_keenetic.py
Normal file
43
scripts/check_keenetic.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check Keenetic API connectivity for all routers."""
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from server.services.keenetic_client import KeeneticClient
|
||||
|
||||
DATA = Path("/opt/vps-monitoring/data/keenetic.json")
|
||||
|
||||
|
||||
async def check(dev):
|
||||
c = KeeneticClient(
|
||||
host=dev.get("host", ""),
|
||||
login=dev.get("login", "admin"),
|
||||
password=dev.get("password", ""),
|
||||
web_url=dev.get("web_url", ""),
|
||||
)
|
||||
try:
|
||||
m = await c.collect_metrics()
|
||||
if m.get("online"):
|
||||
return "online"
|
||||
err = (m.get("error") or "unknown")[:80]
|
||||
return f"offline: {err}"
|
||||
except Exception as e:
|
||||
return f"err: {str(e)[:80]}"
|
||||
finally:
|
||||
await c.close()
|
||||
|
||||
|
||||
async def main():
|
||||
with open(DATA) as f:
|
||||
devices = json.load(f)
|
||||
for d in devices:
|
||||
r = await check(d)
|
||||
print(f"{d['name']:22} {r}")
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user