source: alternc-munin/trunk/usr/share/munin/plugins/alternc_tophd @ 2635

Revision 2635, 1.9 KB checked in by azerttyu, 3 years ago (diff)

Integrons dans la gestion des suggestions tous les scripts de monitoring

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# Plugin to monitor the high bandwidth size managed by Alternc.
4#
5# Parameters:
6#       
7#       config
8#       autoconf
9#
10# Configuration variables
11#
12#       mysqlopts    - Options to pass to mysql which should include the
13#                       username, password, host and alternc database.
14#
15# Example of the entry in plugin-conf.d/munin-node
16#       [alternc*]
17#       user root
18#       env.mysqlopts --defaults-file=/etc/mysql/alternc.cnf
19#
20# $Log$
21# Revision 0.1  Sat Aug  4 15:55:27 ART 2007 sebas
22# On part! Ce plugin est base sur mysql_thread.
23#
24#
25#%# family=auto
26#%# capabilities=autoconf
27
28MYSQLOPTS="$mysqlopts"
29MYSQL="${mysql:-mysql}"
30
31# NOTE: we use only part of the username for privacy and security reasons
32LIST_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"
33
34if [ "$1" = "autoconf" ]; then
35        $MYSQL --version 2>/dev/null >/dev/null
36        if [ $? -eq 0 ]
37        then
38                $MYSQL $MYSQLOPTS -N -B -e "$LIST_USERS_QUERY" 2> /dev/null >&2
39                if [ $? -eq 0 ]
40                then
41                        echo yes
42                        exit 0
43                else
44                        echo "no (could not connect to mysql)"
45                fi
46        else
47                echo "no (mysql client not found)"
48        fi
49        exit 1
50fi
51
52if [ "$1" = "config" ]; then
53        echo 'graph_title AlternC - high disk usage'
54        echo 'graph_vlabel quantity'
55        echo 'graph_category alternc'
56        # echo 'graph_scale no'
57        # echo 'graph_args --base 1024 -l 0'
58
59        $MYSQL $MYSQLOPTS -N -B -e "$LIST_USERS_QUERY" 2>/dev/null
60        exit 0
61fi
62
63# NOTE: we multiply by 1024 so that values appear as Gigs and not as Megs.
64$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"
65
Note: See TracBrowser for help on using the repository browser.