mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Fix prosody plugin by encoding telnetlib commands
This commit is contained in:
parent
daba178eef
commit
7784ddf4d8
1 changed files with 20 additions and 20 deletions
|
@ -56,20 +56,20 @@ def main():
|
||||||
else:
|
else:
|
||||||
connection_count_re = re.compile(r"Total:\s(\d+)\s")
|
connection_count_re = re.compile(r"Total:\s(\d+)\s")
|
||||||
telnet = telnetlib.Telnet(host, port)
|
telnet = telnetlib.Telnet(host, port)
|
||||||
telnet.write("c2s:show_secure()\n")
|
telnet.write(b"c2s:show_secure()\n")
|
||||||
telnet_response = telnet.read_until("secure client connections", 5)
|
telnet_response = telnet.read_until(b"secure client connections", 5)
|
||||||
parsed_info = connection_count_re.findall(telnet_response)
|
parsed_info = connection_count_re.findall(telnet_response.decode('ascii'))
|
||||||
secure_client_connections = int(parsed_info[0])
|
secure_client_connections = int(parsed_info[0])
|
||||||
print("secure_client_connections.value %s" % secure_client_connections)
|
print("secure_client_connections.value %s" % secure_client_connections)
|
||||||
|
|
||||||
telnet.write("c2s:show_insecure()\n")
|
telnet.write(b"c2s:show_insecure()\n")
|
||||||
telnet_response = telnet.read_until("insecure client connections", 5)
|
telnet_response = telnet.read_until(b"insecure client connections", 5)
|
||||||
parsed_info = connection_count_re.findall(telnet_response)
|
parsed_info = connection_count_re.findall(telnet_response.decode('ascii'))
|
||||||
insecure_client_connections = int(parsed_info[0])
|
insecure_client_connections = int(parsed_info[0])
|
||||||
print("insecure_client_connections.value %s" % insecure_client_connections)
|
print("insecure_client_connections.value %s" % insecure_client_connections)
|
||||||
all_client_connections = secure_client_connections + insecure_client_connections
|
all_client_connections = secure_client_connections + insecure_client_connections
|
||||||
print("all_client_connections.value %s" % (all_client_connections))
|
print("all_client_connections.value %s" % (all_client_connections))
|
||||||
telnet.write("quit\n")
|
telnet.write(b"quit\n")
|
||||||
|
|
||||||
elif wildcard == "s2s":
|
elif wildcard == "s2s":
|
||||||
if mode == "config":
|
if mode == "config":
|
||||||
|
@ -84,12 +84,12 @@ def main():
|
||||||
else:
|
else:
|
||||||
server_connections_re = re.compile(r"(\d+) outgoing, (\d+)")
|
server_connections_re = re.compile(r"(\d+) outgoing, (\d+)")
|
||||||
telnet = telnetlib.Telnet(host, port)
|
telnet = telnetlib.Telnet(host, port)
|
||||||
telnet.write("s2s:show()\n")
|
telnet.write(b"s2s:show()\n")
|
||||||
telnet_response = telnet.read_until("connections", 5)
|
telnet_response = telnet.read_until(b"connections", 5)
|
||||||
parsed_info = server_connections_re.findall(telnet_response)
|
parsed_info = server_connections_re.findall(telnet_response.decode('ascii'))
|
||||||
print("outgoing_connections.value %s" % (parsed_info[0][0]))
|
print("outgoing_connections.value %s" % (parsed_info[0][0]))
|
||||||
print("incoming_connections.value %s" % (parsed_info[0][1]))
|
print("incoming_connections.value %s" % (parsed_info[0][1]))
|
||||||
telnet.write("quit\n")
|
telnet.write(b"quit\n")
|
||||||
|
|
||||||
elif wildcard == "presence":
|
elif wildcard == "presence":
|
||||||
if mode == "config":
|
if mode == "config":
|
||||||
|
@ -105,17 +105,17 @@ def main():
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
client_presence_re = re.compile(r"[-\]] (.*?)\(\d+\)")
|
client_presence_re = re.compile("[\]] (.*?)\(\d+\)")
|
||||||
telnet = telnetlib.Telnet(host, port)
|
telnet = telnetlib.Telnet(host, port)
|
||||||
telnet.write("c2s:show()\n")
|
telnet.write(b"c2s:show()\n")
|
||||||
telnet_response = telnet.read_until("clients", 5)
|
telnet_response = telnet.read_until(b"clients", 5)
|
||||||
parsed_info = client_presence_re.findall(telnet_response)
|
parsed_info = client_presence_re.findall(telnet_response.decode('ascii'))
|
||||||
print("available.value %s" % parsed_info.count("available"))
|
print("available.value %s" % parsed_info.count("available"))
|
||||||
print("chat.value %s" % (parsed_info.count("chat")))
|
print("chat.value %s" % (parsed_info.count("chat")))
|
||||||
print("away.value %s" % (parsed_info.count("away")))
|
print("away.value %s" % (parsed_info.count("away")))
|
||||||
print("xa.value %s" % (parsed_info.count("xa")))
|
print("xa.value %s" % (parsed_info.count("xa")))
|
||||||
print("dnd.value %s" % (parsed_info.count("dnd")))
|
print("dnd.value %s" % (parsed_info.count("dnd")))
|
||||||
telnet.write("quit\n")
|
telnet.write(b"quit\n")
|
||||||
|
|
||||||
elif wildcard == "uptime":
|
elif wildcard == "uptime":
|
||||||
if mode == "config":
|
if mode == "config":
|
||||||
|
@ -135,13 +135,13 @@ def main():
|
||||||
else:
|
else:
|
||||||
uptime_re = re.compile(r"\d+")
|
uptime_re = re.compile(r"\d+")
|
||||||
telnet = telnetlib.Telnet(host, port)
|
telnet = telnetlib.Telnet(host, port)
|
||||||
telnet.write("server:uptime()\n")
|
telnet.write(b"server:uptime()\n")
|
||||||
telnet_response = telnet.read_until("minutes (", 5)
|
telnet_response = telnet.read_until(b"minutes (", 5)
|
||||||
parsed_info = uptime_re.findall(telnet_response)
|
parsed_info = uptime_re.findall(telnet_response.decode('ascii'))
|
||||||
uptime_value = (float(parsed_info[0]) + float(parsed_info[1]) / 24
|
uptime_value = (float(parsed_info[0]) + float(parsed_info[1]) / 24
|
||||||
+ float(parsed_info[2]) / 60 / 24)
|
+ float(parsed_info[2]) / 60 / 24)
|
||||||
print("uptime.value %s" % (uptime_value))
|
print("uptime.value %s" % (uptime_value))
|
||||||
telnet.write("quit\n")
|
telnet.write(b"quit\n")
|
||||||
|
|
||||||
elif wildcard == "users":
|
elif wildcard == "users":
|
||||||
if mode == "config":
|
if mode == "config":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue