Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / mysql / hs_write @ 75d48c96

Historique | Voir | Annoter | Télécharger (1,56 ko)

1
#!/bin/sh
2
#
3
: <<=cut
4

    
5
=head1 NAME
6

    
7
hs_write - Plugin to monitor HandlerSocket write port usage.
8

    
9
=head1 APPLICABLE SYSTEMS
10

    
11
All Linux systems
12

    
13
=head1 CONFIGURATION
14

    
15
The following is default configuration
16

    
17
  [hs_read_connections]
18
	env.mysql_host      localhost
19
	env.mysql_port	    3306
20
	env.mysql_user      root
21
	env.mysql_password  pass
22

    
23
=head1 AUTHOR
24

    
25
Konstantin Kuklin <konstantin.kuklin@gmail.com>
26

    
27
=head1 LICENSE
28

    
29
MIT
30

    
31
=cut
32

    
33

    
34
. $MUNIN_LIBDIR/plugins/plugin.sh
35

    
36
if [ "$1" = "autoconf" ]; then
37
    echo no
38
    exit 0
39
fi
40

    
41
if [ "$1" = "config" ]; then
42

    
43
    echo 'graph_title HS Write port connections'
44
    echo "graph_args --base 100 -r --lower-limit 0 --upper-limit $graphlimit"
45
    echo 'graph_category network'
46
    echo 'total.label Total'
47
    echo 'total.draw AREA'
48
    echo 'total.type DERIVE'
49
    echo 'total.min 0'
50
    echo 'active.label Active'
51
    echo 'active.draw LINE2'
52
    echo 'active.type DERIVE'
53
    echo 'active.min 0'
54
    exit 0
55
fi
56

    
57
# query
58
command='mysql';
59

    
60
if [![ -z $mysql_host ]]; then
61
    command="$command -h $mysql_host"
62
fi
63

    
64
if [![ -z $mysql_user ]]; then
65
    command="$command -u $mysql_user"
66
else
67
    command="$command -u root"
68
fi
69

    
70
if [![ -z $mysql_password ]]; then
71
    command="$command -p$mysql_password"
72
fi
73

    
74
if [![ -z $mysql_port ]]; then
75
    command="$command -P $mysql_port"
76
fi
77

    
78
totalConnections=$(echo 'show processlist;' | $command | awk ' /'mode=rw'/ {x += $11}; END {print x}')
79
totalActiveConnections=$(echo 'show processlist;' | $command | awk ' /'mode=rw'/ {x += $13}; END {print x}')
80

    
81
echo "total.$totalConnections";
82
echo "active.$totalActiveConnections";