plugin-mysql_thread_extended: mysql_threads_extended

File mysql_threads_extended, 1.8 kB (added by menole, 5 years ago)
Line 
1 #!/bin/sh
2 #
3 # Plugin to monitor the number of threads on a mysql-server. Faster than
4 # ps_mysql.
5 # Added Threads_connected by Michael Mende <debian@menole.net>
6 #
7 # Parameters:
8 #       
9 #       config
10 #       autoconf
11 #
12 # Configuration variables
13 #
14 #       mysqlopts    - Options to pass to mysql
15 #
16 # $Log$
17 # Revision 1.2  2004/05/20 13:57:12  jimmyo
18 # Set categories to some of the plugins.
19 #
20 # Revision 1.1  2004/01/02 18:50:00  jimmyo
21 # Renamed occurrances of lrrd -> munin
22 #
23 # Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
24 # Import of LRRD CVS tree after renaming to Munin
25 #
26 # Revision 1.6  2003/11/07 17:43:16  jimmyo
27 # Cleanups and log entries
28 #
29 #
30 #
31 #%# family=auto
32 #%# capabilities=autoconf
33
34 MYSQLOPTS="$mysqlopts"
35 MYSQLADMIN=${mysqladmin:-mysqladmin}
36
37 if [ "$1" = "autoconf" ]; then
38         $MYSQLADMIN --version 2>/dev/null >/dev/null
39         if [ $? -eq 0 ]
40         then
41                 $MYSQLADMIN $MYSQLOPTS status 2>/dev/null >/dev/null
42                 if [ $? -eq 0 ]
43                 then
44                         echo yes
45                         exit 0
46                 else
47                         echo "no (could not connect to mysql)"
48                 fi
49         else
50                 echo "no (mysqladmin not found)"
51         fi
52         exit 1
53 fi
54
55 if [ "$1" = "config" ]; then
56         echo 'graph_title MySQL threads extended'
57         echo 'graph_order threads_connected threads_running'
58         echo 'graph_vlabel connected / running'
59         echo 'graph_category mysql'
60         echo 'graph_args --base 1000'
61
62         echo 'threads_connected.label threads connected'
63         echo 'threads_connected.type GAUGE'
64
65         echo 'threads_running.label threads running'
66         echo 'threads_running.type GAUGE'
67
68         exit 0
69 fi
70
71 $MYSQLADMIN $MYSQLOPTS extended-status | grep Threads_ | awk '/Threads_(connected|running)/ { res[tolower($2)]=$4 } END {for (var in res)print substr(var,0,length(var)+1)".value "res[var] }'