[JDEV] JEP-0039 (Statistics Gathering) implementation for jabberd 1.4
Jacek Konieczny
jajcus at bnet.pl
Wed Apr 23 07:28:03 CDT 2003
Hello,
I wrote basic, but very extensible statistics gathering module for
jabberd1.4. It has handlers to read: uptime, number of users online,
number of files in a directory (a hack to get number of registered
users, but works well) and an "external" handler, which starts external
command to get the statistic (I am not sure if it is OK to use popen()
in jabberd, but it works for me).
To use it add mod_stats.c file to jsm/modules directory of jabber
sources, include it in jsm/Makefile and jsm/modules/Makefile and build
new jsm.so using make in the main directory of jabberd sources.
Configuration is easy, just add <stats/> element listing all stats you
want to gather to <jsm/> section.
Example <stats/> section:
<stats>
<stat name='time/uptime' handler='uptime'/>
<stat name='users/online' units='users' handler='online_users'/>
<stat name='users/registered' units='users'
handler='count_files'>/var/lib/jabber/spool/%H</stat>
<stat name='memory/system-used' units='kbytes'
handler='external'>free | awk '/^Mem:/ {print $3}'</stat>
</stats>
"name" is the name of the stat, as it will be seen by the requester.
"handler" is a name of internal handler which is responsible for generating
the stat, "units" contains units to be returned. If not given, then handler's
default units will be used. The <stat/> element may contain (usually as CDATA)
extra arguments for the handler.
Following handlers are available:
"uptime" - returns the uptime of the server
"online_users" - returns the number of users logged in to the server
"count_files" - returns the number of files in given direcotry
"external" - returns the output of given command
"%H" in "count_files" and "external" handlers argument will be substituted with
the servers name.
mod_stats may be used for monitoring jabberd itself, but it can be used to
gather any other statistics.
I am going to write a python/rrdtool script to gather statistics using
JEP-0039 and make graphs based on collected data.
The module mod_stats is available here:
http://www.bnet.pl/~jajcus/jabberd14/mod_stats.c
Greets,
Jacek
More information about the JDev
mailing list