diff --git a/plugins/mysql/hs_read b/plugins/mysql/hs_read new file mode 100644 index 00000000..4e2dd0ca --- /dev/null +++ b/plugins/mysql/hs_read @@ -0,0 +1,81 @@ +#!/bin/sh +# +: <<=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 + +=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' + echo "graph_args --base 100 -r --lower-limit 0 --upper-limit $graphlimit" + echo 'graph_category network' + echo 'total.label Total' + echo 'total.draw AREA' + echo 'total.type DERIVE' + echo 'total.min 0' + echo 'active.label Active' + echo 'active.draw LINE2' + echo 'active.type DERIVE' + echo 'active.min 0' + exit 0 +fi + +# query +command='mysql'; + +if [![ -z $mysql_host ]]; then + command="$command -h $mysql_host" +fi + +if [![ -z $mysql_user ]]; then + command="$command -u $mysql_user" +else + command="$command -u root" +fi + +if [![ -z $mysql_password ]]; then + command="$command -p$mysql_password" +fi + +if [![ -z $mysql_port ]]; then + 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}') + +echo "total.$totalConnections"; +echo "active.$totalActiveConnections"; diff --git a/plugins/mysql/hs_write b/plugins/mysql/hs_write new file mode 100644 index 00000000..88ee6d80 --- /dev/null +++ b/plugins/mysql/hs_write @@ -0,0 +1,82 @@ +#!/bin/sh +# +: <<=cut + +=head1 NAME + +hs_write - Plugin to monitor HandlerSocket write 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 + +=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 Write port connections' + echo "graph_args --base 100 -r --lower-limit 0 --upper-limit $graphlimit" + echo 'graph_category network' + echo 'total.label Total' + echo 'total.draw AREA' + echo 'total.type DERIVE' + echo 'total.min 0' + echo 'active.label Active' + echo 'active.draw LINE2' + echo 'active.type DERIVE' + echo 'active.min 0' + exit 0 +fi + +# query +command='mysql'; + +if [![ -z $mysql_host ]]; then + command="$command -h $mysql_host" +fi + +if [![ -z $mysql_user ]]; then + command="$command -u $mysql_user" +else + command="$command -u root" +fi + +if [![ -z $mysql_password ]]; then + command="$command -p$mysql_password" +fi + +if [![ -z $mysql_port ]]; then + command="$command -P $mysql_port" +fi + +totalConnections=$(echo 'show processlist;' | $command | awk ' /'mode=rw'/ {x += $11}; END {print x}') +totalActiveConnections=$(echo 'show processlist;' | $command | awk ' /'mode=rw'/ {x += $13}; END {print x}') + +echo "total.$totalConnections"; +echo "active.$totalActiveConnections";