Vor kurzem habe ich meinen XMPP Server von ejabberd zu prosody migriert.
Die Übernahme der Useraccounts war dank verfügbarer Scripts unproblematisch.
Munin liefert standardmäßig kein Plugin für die Überwachung von prosody mit, aber bei Munin Exchange bin ich fündig geworden.
Leider lieferte mir das Munin Plugin nicht die Informationen die ich gerne gehabt hätte. Die ejabberd-Statistiken waren da deutlich ergiebiger.
Mir fehlte die Anzahl der registrierten User und die Uptime des prosody Servers.
Über das prosody Plugin mod_console kann man diverse Informationen des prosody Servers über telnet am lokalen Host abfragen, so auch die Uptime. Leider aber nicht die Anzahl der registrierten User. Dies ist momentan noch nicht in prosody implementiert.
Wenn man als Storage für prosody jedoch internal gewählt hat – was auch die Standardeinstellung ist – kann man die Anzahl der User über das Dateisystem ermitteln.
Man zählt dazu einfach nur die Anzahl der Dateien im Unterordner accounts des jeweiligen virtuellen Hosts.
Ich habe nun das vorhandene Plugin von Christoph Heer in Version 3 um die Möglichkeiten erweitert die Uptime und die Anzahl der registrierten User auszugeben.
Folgende Änderungen habe ich vorgenommen:
Ab Zeile 37:
37 38 39 40 41 42 43 | if mode == "suggest": print "c2s" print "s2s" print "presence" print "uptime" print "users" sys.exit(0) |
Ab Zeile 120:
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | elif wildcard == "uptime": if mode == "config": print "graph_title Prosody Uptime" print "graph_args --base 1000 -l 0" print "graph_scale no" print "graph_vlabel uptime in days" print "graph_category Prosody" print "graph_order uptime" print "uptime.draw AREA" print "uptime.min U" print "uptime.max U" print "uptime.label uptime" print "uptime.type GAUGE" sys.exit(0) else: uptime_re = re.compile(r"\d+") telnet = telnetlib.Telnet(host, port) telnet.write("server:uptime()") telnet_response = telnet.read_until("minutes (", 5) parsed_info = uptime_re.findall(telnet_response) uptime_value = float(parsed_info[0]) + float(parsed_info[1])/24 + float(parsed_info[2])/60/24 print "uptime.value %s" % (uptime_value) elif wildcard == "users": if mode == "config": print "graph_title Prosody Registered Users" print "graph_vlabel users" print "graph_category Prosody" basedir = "/var/lib/prosody" if os.path.exists(basedir): vhosts = listdirs(basedir) for vhost in vhosts: accountdir = basedir + os.sep + vhost + os.sep + "accounts" if os.path.exists(accountdir): accounts = listfiles(accountdir) headcount = 0 for account in accounts: headcount += 1 if mode == "config": print vhost.replace("%2e","_") + ".label %s" % (vhost.replace("%2e",".")) else: print vhost.replace("%2e","_") + ".value %s" % (headcount) def listdirs(folder): return [d for d in os.listdir(folder) if os.path.isdir(os.path.join(folder, d))] def listfiles(folder): return [d for d in os.listdir(folder) if os.path.isfile(os.path.join(folder, d))] |
Und so sehen die neuen Munin Graphen dann aus:
Die neue Version 4 kann wie gewohnt bei Munin-Exchange heruntergeladen werden.
Nachtrag: Wenn Du auch von ejabberd zu prosody migrieren möchtest, findest Du hier eine gute Anleitung dafür.