1
0
This commit is contained in:
root
2018-05-03 20:27:22 +02:00
commit 3ca191dd2f
10 changed files with 767 additions and 0 deletions

30
check_clients.py Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/python3
import json
from urllib.request import urlopen
from pprint import pprint
import sys
JSON_URL = "https://netinfo.freifunk-stuttgart.de/json/alfred-json-159.json"
if len(sys.argv) != 2:
print("UNKNOWN: Invalid arguments "+sys.argv[0]+" <node mac>")
exit(3)
node_mac = sys.argv[1]
response = urlopen(JSON_URL)
data = json.loads(response.read().decode("utf-8"))
node = {}
try:
node = data[node_mac]
except KeyError as e:
print("CRITICAL: Node not found: "+str(e))
exit(2)
performance_data = ""
for key,value in node['clients'].items():
performance_data += "|"+str(key)+"="+str(value)+"\n"
print("OK - %d Clients"%node['clients']['total']+performance_data)
exit(0)