#!/bin/sh # # Plugin to monitor the number of people who connected in the last 30 minutes # (we do not have a precise way to know who is still connected) # # 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 # # #%# family=auto #%# capabilities=autoconf MYSQLOPTS="$mysqlopts" MYSQL=${mysql:-mysql} if [ "$1" = "autoconf" ]; then $MYSQL --version 2>/dev/null >/dev/null if [ $? -eq 0 ] then $MYSQL $MYSQLOPTS -N -B -e 'SELECT COUNT(*) FROM domaines' 2>/dev/null >/dev/null 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 - number of connected users' echo 'graph_vlabel quantity' echo 'graph_category alternc' echo 'totalusers.label total of connected users' exit 0 fi /usr/bin/printf "totalusers.value " $MYSQL $MYSQLOPTS -N -B -e "select count(*) from membres where lastlogin > DATE_SUB(NOW(), interval 30 minute)" 2>/dev/null | awk '{print $1}';