init
This commit is contained in:
30
check_clients.py
Executable file
30
check_clients.py
Executable 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)
|
||||
Reference in New Issue
Block a user