#!/bin/sh # # Plugin to monitor the high bandwidth size managed by Alternc. # # Parameters: # # config # autoconf # # Configuration variables # # mysqlopts - Options to pass to mysql which should include the # username, password, host and alternc database. # # Example of the entry in plugin-conf.d/munin-node # [alternc*] # user root # env.mysqlopts --defaults-file=/etc/mysql/alternc.cnf # # $Log$ # Revision 0.1 Sat Aug 4 15:55:27 ART 2007 sebas # On part! Ce plugin est base sur mysql_thread. # # #%# family=contrib #%# capabilities=autoconf MYSQLOPTS="$mysqlopts" MYSQL="${mysql:-mysql}" # NOTE: we use only part of the username for privacy and security reasons LIST_USERS_QUERY="select CONCAT('membre', m.uid, '.label'), CONCAT(m.uid, '(', SUBSTRING(m.login, 1, 2), ')') from size_web as s, membres as m where m.uid = s.uid order by s.size desc limit 15" if [ "$1" = "autoconf" ]; then $MYSQL --version 2>/dev/null >/dev/null if [ $? -eq 0 ] then $MYSQL $MYSQLOPTS -N -B -e "$LIST_USERS_QUERY" 2> /dev/null >&2 if [ $? -eq 0 ] then echo yes exit 0 else echo "no (could not connect to mysql)" fi else echo "no (mysql client not found)" fi exit 1 fi if [ "$1" = "config" ]; then echo 'graph_title AlternC - high disk usage' echo 'graph_vlabel quantity' echo 'graph_category alternc' # echo 'graph_scale no' # echo 'graph_args --base 1024 -l 0' $MYSQL $MYSQLOPTS -N -B -e "$LIST_USERS_QUERY" 2>/dev/null exit 0 fi # NOTE: we multiply by 1024 so that values appear as Gigs and not as Megs. $MYSQL $MYSQLOPTS -N -B -e "select CONCAT('membre', m.uid, '.value'), s.size * 1024 from size_web as s, membres as m where m.uid = s.uid order by s.size desc limit 15"