Seite 1 von 1

Munin-Plugin für Benutzer Online und Beiträge

Verfasst: 02.09.2006 13:52
von R. U. Serious
Munin ( http://munin.projects.linpro.no/ ) ist eine Server-Monitoring Software welche auf rrdtool aufbaut und die Attribute eines Servers alle 5 Minuten sampled und nette Grafiken drauf bastelt.

[ externes Bild ]

Ich hab für users-online und für geschriebe Beiträge zwei kleine Skripte/Plugins für Munin geschrieben. Da nichtmal bei phpBB.com genug Interesse da war, habe ich die nicht mehr aufgeräumt. Sollte aber jeder leicht selbst hinbekommen, denke ich...

Users Online:

Code: Alles auswählen

#!/bin/bash
# phpBB online stats
#%# family=contrib
#%# capabilities=autoconf

MYOPTIONS=' -uxxxxxxx -pyyyyyyyyy -Dname_of_db'

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = config ]; then
        echo 'graph_title phpBB users online'
        echo 'graph_args --base 1000 -l 0'
        echo 'graph_vlabel users'
        echo 'graph_category phpBB'
        echo 'userreg.label registered'
        echo 'userreg.draw AREA'
        echo 'userguests.label guests'
        echo 'userguests.draw STACK'
        echo 'graph_total total users'
        echo 'graph_order userreg userguests'
        echo 'graph_info phpBB users online'
        exit 0
fi

function number {
        egrep '[0-9]+'
}

USERREG=$(echo "SELECT COUNT(session_id) FROM phpbb_sessions WHERE (session_time + 900) > UNIX_TIMESTAMP(NOW()) AND phpbb_sessions.session_logged_in=1"  | mysql $MYOPTIONS | number)

USERGUEST=$(echo "SELECT COUNT(DISTINCT session_ip) FROM phpbb_sessions WHERE (session_time + 900) > UNIX_TIMESTAMP(NOW()) AND session_logged_in=0" | mysql $MYOPTIONS | number)

echo "userreg.value "$USERREG
echo "userguests.value "$USERGUEST

Posts:

Code: Alles auswählen

#!/bin/bash
# phpBB users
#%# family=contrib
#%# capabilities=autoconf

MYOPTIONS=' -uxxxxxxxx -pyyyyyyyyy -Dname_of_db'

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = config ]; then
        echo 'graph_title phpBB posts'
        echo 'graph_args --base 1000 -l 0'
        echo 'graph_vlabel posts / ${graph_period}'
        echo 'graph_category phpBB'
        echo 'delposts.label deleted posts'
        echo 'delposts.type COUNTER'
        echo 'delposts.draw AREA'
        echo 'delposts.cdef delposts,-1,*'
        echo 'totalposts.label total posts'
        echo 'totalposts.type COUNTER'
        echo 'totalposts.draw AREA'
        echo 'totalposts.cdef totalposts,1,*'
        echo 'graphorder delposts totalposts'
        echo 'graph_period minute'
        echo 'graph_scale no'
        echo 'graph_sums yes'
        exit 0
fi

function number {
        egrep '[0-9]+'
}

TOTPO=$(echo "SELECT MAX(post_id) FROM phpbb_posts"  | mysql $MYOPTIONS | number)

REALPO=$(echo "SELECT COUNT(post_id) FROM phpbb_posts" | mysql $MYOPTIONS | number) 

#18 and 23 are forum_ids of forums that act as a Trash-Can
TRASHPO=$(echo "SELECT COUNT(post_id) FROM phpbb_posts p, phpbb_users u WHERE forum_id IN (18,23) AND u.user_id=p.poster_id AND u.user_level < 1" | mysql $MYOPTIONS | number)

DELPO=$(expr $TOTPO - $REALPO + $TRASHPO)

echo "totalposts.value "$TOTPO
echo "delposts.value "$DELPO