mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-26 02:48:28 +00:00
Add presence suffix
This commit is contained in:
parent
9fdf46699a
commit
478522124b
1 changed files with 93 additions and 58 deletions
|
@ -25,63 +25,98 @@ import os
|
||||||
import telnetlib
|
import telnetlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
mode = ""
|
try:
|
||||||
try: mode = sys.argv[1]
|
mode = sys.argv[1]
|
||||||
except Exception, IndexError: mode = ""
|
except IndexError:
|
||||||
wildcard = sys.argv[0].split("prosody_")[1].split("_")[0]
|
mode = ""
|
||||||
|
wildcard = sys.argv[0].split("prosody_")[1].split("_")[0]
|
||||||
if mode == "suggest":
|
host = os.environ.get('host', 'localhost')
|
||||||
print "c2s"
|
port = int(os.environ.get('port', 5582))
|
||||||
print "s2s"
|
|
||||||
sys.exit(0)
|
if mode == "suggest":
|
||||||
|
print "c2s"
|
||||||
|
print "s2s"
|
||||||
|
print "presence"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
if wildcard == "c2s":
|
if wildcard == "c2s":
|
||||||
if mode == "config":
|
if mode == "config":
|
||||||
print "graph_title Prosody C2S Connections"
|
print "graph_title Prosody C2S Connections"
|
||||||
print "graph_vlabel users"
|
print "graph_vlabel users"
|
||||||
print "graph_category Prosody"
|
print "graph_category Prosody"
|
||||||
|
|
||||||
print "all_client_connections.label client connections"
|
print "all_client_connections.label client connections"
|
||||||
print "secure_client_connections.label secure client connections"
|
print "secure_client_connections.label secure client connections"
|
||||||
print "insecure_client_connections.label insecure client connections"
|
print "insecure_client_connections.label insecure client " \
|
||||||
sys.exit(0)
|
"connections"
|
||||||
|
sys.exit(0)
|
||||||
else:
|
|
||||||
Regex = re.compile(r"Total:\s(\d+)\s")
|
else:
|
||||||
telnet = telnetlib.Telnet('localhost', 5582)
|
connection_count_re = re.compile(r"Total:\s(\d+)\s")
|
||||||
telnet.write("c2s:show_secure()")
|
telnet = telnetlib.Telnet(host, port)
|
||||||
telnetResponse = telnet.read_until("secure client connections", 5)
|
telnet.write("c2s:show_secure()")
|
||||||
ParsedInfo = Regex.findall(telnetResponse)
|
telnet_response = telnet.read_until("secure client connections",
|
||||||
scc = int(ParsedInfo[0])
|
5)
|
||||||
print "secure_client_connections.value %s" % (scc)
|
parsed_info = connection_count_re.findall(telnet_response)
|
||||||
|
secure_client_connections = int(parsed_info[0])
|
||||||
telnet.write("c2s:show_insecure()")
|
print "secure_client_connections.value %s" % \
|
||||||
telnetResponse = telnet.read_until("insecure client connections", 5)
|
(secure_client_connections)
|
||||||
ParsedInfo = Regex.findall(telnetResponse)
|
|
||||||
icc = int(ParsedInfo[0])
|
telnet.write("c2s:show_insecure()")
|
||||||
print "insecure_client_connections.value %s" % (icc)
|
telnet_response = telnet.read_until("insecure client connections",
|
||||||
cc = scc + icc
|
5)
|
||||||
print "all_client_connections.value %s" % (cc)
|
parsed_info = connection_count_re.findall(telnet_response)
|
||||||
|
insecure_client_connections = int(parsed_info[0])
|
||||||
elif wildcard == "s2s":
|
print "insecure_client_connections.value %s" % \
|
||||||
if mode == "config":
|
(insecure_client_connections)
|
||||||
print "graph_title Prosody S2S Connections"
|
all_client_connections = secure_client_connections + \
|
||||||
print "graph_vlabel servers"
|
insecure_client_connections
|
||||||
print "graph_category Prosody"
|
print "all_client_connections.value %s" % (all_client_connections)
|
||||||
|
|
||||||
print "outgoing_connections.label outgoing connections"
|
elif wildcard == "s2s":
|
||||||
print "incoming_connections.label incoming connections"
|
if mode == "config":
|
||||||
sys.exit(0)
|
print "graph_title Prosody S2S Connections"
|
||||||
|
print "graph_vlabel servers"
|
||||||
else:
|
print "graph_category Prosody"
|
||||||
Regex = re.compile(r"(\d+) outgoing, (\d+)")
|
|
||||||
telnet = telnetlib.Telnet('localhost', 5582)
|
print "outgoing_connections.label outgoing connections"
|
||||||
telnet.write("s2s:show()")
|
print "incoming_connections.label incoming connections"
|
||||||
telnetResponse = telnet.read_until("connections", 5)
|
sys.exit(0)
|
||||||
ParsedInfo = Regex.findall(telnetResponse)
|
|
||||||
print "outgoing_connections.value %s" % (ParsedInfo[0][0])
|
else:
|
||||||
print "incoming_connections.value %s" % (ParsedInfo[0][1])
|
server_connections_re = re.compile(r"(\d+) outgoing, (\d+)")
|
||||||
|
telnet = telnetlib.Telnet(host, port)
|
||||||
|
telnet.write("s2s:show()")
|
||||||
|
telnet_response = telnet.read_until("connections", 5)
|
||||||
|
parsed_info = server_connections_re.findall(telnet_response)
|
||||||
|
print "outgoing_connections.value %s" % (parsed_info[0][0])
|
||||||
|
print "incoming_connections.value %s" % (parsed_info[0][1])
|
||||||
|
|
||||||
|
elif wildcard == "presence":
|
||||||
|
if mode == "config":
|
||||||
|
print "graph_title Prosody Client Presence"
|
||||||
|
print "graph_vlabel clients"
|
||||||
|
print "graph_category Prosody"
|
||||||
|
|
||||||
|
print "available.label Avaible Clients"
|
||||||
|
print "chat.label Ready for Chat Clients"
|
||||||
|
print "away.label Away Clients"
|
||||||
|
print "xa.label Extended Away Clients"
|
||||||
|
print "dnd.label Do Not Disturb Clients"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
else:
|
||||||
|
client_presence_re = re.compile(r"- (.*?)\(\d+\)")
|
||||||
|
telnet = telnetlib.Telnet(host, port)
|
||||||
|
telnet.write("c2s:show()")
|
||||||
|
telnet_response = telnet.read_until("clients", 5)
|
||||||
|
parsed_info = client_presence_re.findall(telnet_response)
|
||||||
|
print "available.value %s" % (parsed_info.count("available"))
|
||||||
|
print "chat.value %s" % (parsed_info.count("chat"))
|
||||||
|
print "away.value %s" % (parsed_info.count("away"))
|
||||||
|
print "xa.value %s" % (parsed_info.count("xa"))
|
||||||
|
print "dnd.value %s" % (parsed_info.count("dnd"))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue