Projet

Général

Profil

Révision 75d48c96

ID75d48c9630a4b9ee938afb320a6eb4283d74f8a2
Parent c32b9ebc
Enfant c69a5761

Ajouté par Konstantin Kuklin il y a plus de 11 ans

added plugins to monitoring Mysql HandlerSocket connections

Voir les différences:

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

  
5
=head1 NAME
6

  
7
hs_read - Plugin to monitor HandlerSocket read 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
. $MUNIN_LIBDIR/plugins/plugin.sh
34

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

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

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

  
56
# query
57
command='mysql';
58

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

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

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

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

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

  
80
echo "total.$totalConnections";
81
echo "active.$totalActiveConnections";
plugins/mysql/hs_write
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";

Formats disponibles : Unified diff