2014-10-05 22:29:29 +02:00
|
|
|
#!/bin/bash
|
2014-08-13 05:05:38 +02:00
|
|
|
#
|
|
|
|
: <<=cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
hs_read - Plugin to monitor HandlerSocket read port usage.
|
|
|
|
|
|
|
|
=head1 APPLICABLE SYSTEMS
|
|
|
|
|
|
|
|
All Linux systems
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
The following is default configuration
|
|
|
|
|
|
|
|
[hs_read_connections]
|
|
|
|
env.mysql_host localhost
|
|
|
|
env.mysql_port 3306
|
|
|
|
env.mysql_user root
|
|
|
|
env.mysql_password pass
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Konstantin Kuklin <konstantin.kuklin@gmail.com>
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
MIT
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
. $MUNIN_LIBDIR/plugins/plugin.sh
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
echo no
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
|
|
|
echo 'graph_title HS Read port connections'
|
2014-10-04 12:34:51 +02:00
|
|
|
echo "graph_args --base 1000 -l 0"
|
2017-02-21 00:41:40 +01:00
|
|
|
echo 'graph_category db'
|
2014-08-13 05:05:38 +02:00
|
|
|
echo 'total.label Total'
|
|
|
|
echo 'total.draw AREA'
|
|
|
|
echo 'total.min 0'
|
|
|
|
echo 'active.label Active'
|
|
|
|
echo 'active.draw LINE2'
|
|
|
|
echo 'active.min 0'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# query
|
|
|
|
command='mysql';
|
|
|
|
|
2014-10-04 12:34:51 +02:00
|
|
|
if [[ ! -z $mysql_host ]]; then
|
2014-08-13 05:05:38 +02:00
|
|
|
command="$command -h $mysql_host"
|
|
|
|
fi
|
|
|
|
|
2014-10-04 12:34:51 +02:00
|
|
|
if [ -z $mysql_user ]; then
|
2014-08-13 05:05:38 +02:00
|
|
|
command="$command -u root"
|
2014-10-04 12:34:51 +02:00
|
|
|
else
|
|
|
|
command="$command -u $mysql_user"
|
2014-08-13 05:05:38 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-04 12:34:51 +02:00
|
|
|
if [[ ! -z $mysql_password ]]; then
|
2014-08-13 05:05:38 +02:00
|
|
|
command="$command -p$mysql_password"
|
|
|
|
fi
|
|
|
|
|
2014-10-04 12:34:51 +02:00
|
|
|
if [[ ! -z $mysql_port ]]; then
|
2014-08-13 05:05:38 +02:00
|
|
|
command="$command -P $mysql_port"
|
|
|
|
fi
|
|
|
|
|
|
|
|
totalConnections=$(echo 'show processlist;' | $command | awk ' /'mode=rd'/ {x += $11}; END {print x}')
|
|
|
|
totalActiveConnections=$(echo 'show processlist;' | $command | awk ' /'mode=rd'/ {x += $13}; END {print x}')
|
|
|
|
|
2014-10-04 12:34:51 +02:00
|
|
|
echo "total.value $totalConnections";
|
|
|
|
echo "active.value $totalActiveConnections";
|