[ejabberd] Client statistics script?

Badlop badlop at gmail.com
Sun Aug 17 15:50:37 MSD 2008


On Sat, Aug 16, 2008 at 12:15 AM, Peter Schwindt
<ejabberd at schwindt-net.de> wrote:
> I'm just wondering what clients my users are using (percentage and such).
> Has anyone here on this list already created some script for checking out
> above information?
>
> To ask another question: Is there a possibility to check whether clients are
> (have been) connected via classic SSL / plaintext / starttls?

If you are really interested, you can take a look at
http://www.ejabberd.im/mod_statsdx

I also wrote a small script for jabber.org, that I describe here.

Regarding both methods, I accept bugreports and patches.
But I don't accept feature requests or support questions.


1. First create the file global-stats.sh with this content:
**********
SESSIONS=$1

echo "Session data file: $SESSIONS"
echo ""

echo -n "Num sessions: "
cat $SESSIONS | grep "\",\"jabber.org\",\"" | sed 's/,/, /g;' | wc -l

echo ""

echo "Most popular resources: "
cat $SESSIONS | grep "\",\"jabber.org\",\"" | sed 's/,/, /g;' | awk
'{print $3}' | sed 's/"},//g;' | sed 's/^"//g;' | sed
's/^centerim[0-9A-Z]*/centerim/g;' | sort -g | uniq -c | sort -g -r |
head

echo ""

echo "Most popular IPs: "
cat $SESSIONS | grep "\[{ip,{{" | sed 's/\[{ip,{//g;' | sed
's/,[0-9]*}},{conn,/ /g;' | sed 's/}\]}.*//g;' | awk '{print $1}' |
sort -g | uniq -c | sort -g -r | head

echo ""

echo "Most popular Conn: "
cat $SESSIONS | grep "\[{ip,{{" | sed 's/\[{ip,{//g;' | sed
's/,[0-9]*}},{conn,/ /g;' | sed 's/}\]}.*//g;' | awk '{print $2}' |
sort -g | uniq -c | sort -g -r | head

# cat $SESSIONS | grep "\",\"jabber.org\",\"" | sed 's/,/, /g;' | awk
'{print $3}' | sed 's/"},//g;' | sed 's/^"//g;' | sed
's/^centerim[0-9A-Z]*/centerim/g;' | sort -g | uniq -c | sort -g -r |
head

echo ""
********************

2. Now the basic commands to execute are:

$ erl -sname constats -remsh ejabberd at localhost
> {ok, Fd} = file:open("session_table.txt", write).
> io:format(Fd, "~p", [ets:tab2list(session)]).
> file:close(Fd).
Ctrl+c, Ctrl+c
$ ./global-stats.sh session_table.txt


3. The result will be:

Session data file: session_table.txt
Num sessions: 12222
Most popular resources:
   2345 Home
   1775 Miranda
    806 Gaim
    756 Kopete
    578 Pandion
    540 Adium
    389 AQQ
    384 QIP
    343 Psi
    220 BitlBee
Most popular IPs:
     27 {207,236,208,226}
     27 {200,207,117,124}
     26 {200,175,79,36}
     25 {195,85,225,201}
     23 {201,75,224,135}
     22 {15,235,147,254}
     21 {189,47,166,34}
     20 {200,243,93,136}
     18 {189,19,32,251}
     15 {65,171,77,76}
Most popular Conn:
   8897 c2s_tls
   2797 c2s
    380
    307 c2s_compressed


---


More information about the ejabberd mailing list