#!/bin/sh # # Plugin to monitor domains managed by Alternc. # - total domains installed. # + mx managed # + dns managed # - total of sub-domains # + type 0 = pointing to a folder # + type 1 = redirection # + type 2 = pointing to an ip # + type 3 = pointing to squirrelmail (I think) # # 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=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 - domains' echo 'graph_vlabel quantity' echo 'graph_category alternc' echo 'totaldomains.label total of domains' echo 'domainswithmxhere.label domains with local mx' echo 'domainswithdnshere.label domains managed locally' echo 'totalsubdomains.label total of sub-domains' echo 'subdomainstype0.label sub-domains pointing to a folder' echo 'subdomainstype1.label sub-domains redirected' echo 'subdomainstype2.label sub-domains pointing to an ip' echo 'subdomainstype3.label sub-domains pointing to squirrelmail' echo 'graph_args --base 1000 -l 0' exit 0 fi /usr/bin/printf "totaldomains.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM domaines" 2>/dev/null || echo 'U') | awk '{print $1}'; /usr/bin/printf "domainswithmxhere.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM domaines WHERE gesmx = 1" 2>/dev/null || echo 'U') | awk '{print $1}' /usr/bin/printf "domainswithdnshere.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM domaines WHERE gesdns = 1" 2>/dev/null || echo 'U') | awk '{print $1}' /usr/bin/printf "totalsubdomains.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM sub_domaines" 2>/dev/null || echo 'U') | awk '{print $1}'; /usr/bin/printf "subdomainstype0.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM sub_domaines WHERE type = 0 " 2>/dev/null || echo 'U') | awk '{print $1}'; /usr/bin/printf "subdomainstype1.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM sub_domaines WHERE type = 1 " 2>/dev/null || echo 'U') | awk '{print $1}'; /usr/bin/printf "subdomainstype2.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM sub_domaines WHERE type = 2 " 2>/dev/null || echo 'U') | awk '{print $1}'; /usr/bin/printf "subdomainstype3.value " ($MYSQL $MYSQLOPTS -N -B -e "SELECT COUNT( * ) FROM sub_domaines WHERE type = 3 " 2>/dev/null || echo 'U') | awk '{print $1}';