paulbsd-salt/states/zabbix/scripts/ipblc.py

23 lines
415 B
Python
Raw Normal View History

2023-02-10 13:53:05 +01:00
#!/usr/bin/env python3
import socket
import json
HOST = "127.0.0.1"
PORT = 8060
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(b"1")
data = bytes()
while True:
recv = s.recv(512)
if len(recv) > 0:
data += recv
else:
break
out = data.decode()
jsout = json.loads(out)
print(len(jsout.keys()))