From f910d9e246e8824238d9aba5d6494892561eeedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Wed, 24 Apr 2013 18:03:39 -0400 Subject: [PATCH] Add wsrep_flow_control_paused check If this value is > 0.1 usually there is a problem. Also add default exit value to UNKNOWN. --- README.md | 4 +++- check_galera_cluster | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a165bf..adafb54 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Version 1.0, Guillaume Coré check_galera_cluster is a Nagios plugin to monitor Galera cluster status. - check_galera_cluster -u USER -p PASSWORD [-H HOST] [-P PORT] [-w SIZE] [-c SIZE] [-0] + check_galera_cluster -u USER -p PASSWORD [-H HOST] [-P PORT] [-w SIZE] [-c SIZE] [-f FLOAT] [-0] Options: u) @@ -21,5 +21,7 @@ Version 1.0, Guillaume Coré Sets minimum number of nodes in the cluster when WARNING is raised. (default is same as critical). c) Sets minimum number of nodes in the cluster when CRITICAL is raised. (default is 2). + f) + Sets critical value of wsrep_flow_control_paused (default is 0.1). 0) Rise CRITICAL if the node is not primary diff --git a/check_galera_cluster b/check_galera_cluster index dd1efb4..ce55a14 100755 --- a/check_galera_cluster +++ b/check_galera_cluster @@ -7,6 +7,7 @@ ST_OK=0 ST_WR=1 ST_CR=2 ST_UK=3 +ST_FINAL=$ST_UK print_version() { echo "$VERSION $AUTHOR" @@ -17,7 +18,7 @@ print_help() { echo "" echo "$PROGNAME is a Nagios plugin to monitor Galera cluster status." echo "" - echo "$PROGNAME -u USER -p PASSWORD [-H HOST] [-P PORT] [-w SIZE] [-c SIZE] [-0]" + echo "$PROGNAME -u USER -p PASSWORD [-H HOST] [-P PORT] [-w SIZE] [-c SIZE] [-f FLOAT] [-0]" echo "" echo "Options:" echo " u)" @@ -32,6 +33,8 @@ print_help() { echo " Sets minimum number of nodes in the cluster when WARNING is raised. (default is same as critical)." echo " c)" echo " Sets minimum number of nodes in the cluster when CRITICAL is raised. (default is 2)." + echo " f)" + echo " Sets critical value of wsrep_flow_control_paused (default is 0.1)." echo " 0)" echo " Rise CRITICAL if the node is not primary" exit $ST_UK @@ -41,8 +44,9 @@ print_help() { crit=2 port='3306' mysqlhost='localhost' +fcp=0.1 -while getopts “hvu:p:H:P:w:c:0” OPTION; do +while getopts “hvu:p:H:P:w:c:f:0” OPTION; do case $OPTION in h) print_help @@ -70,6 +74,9 @@ while getopts “hvu:p:H:P:w:c:0” OPTION; do c) crit=$OPTARG ;; + f) + fcp=$OPTARG + ;; 0) primary='TRUE' ;; @@ -100,6 +107,17 @@ fi r1=$(mysql -h$mysqlhost -P$port -u$mysqluser -p$password -e "show status like 'wsrep_cluster_size'"|grep wsrep_cluster_size|cut -f 2) r2=$(mysql -h$mysqlhost -P$port -u$mysqluser -p$password -e "show status like 'wsrep_cluster_status'"|grep wsrep_cluster_status|cut -f 2) +r3=$(mysql -h$mysqlhost -P$port -u$mysqluser -p$password -e "show status like 'wsrep_flow_control_paused'"|grep wsrep_flow_control_paused|cut -f 2) + +if [ -z "$r3" ]; then + echo "UNKNOWN: wsrep_flow_control_paused is empty" + ST_FINAL=$ST_UK +fi + +if [ $(echo "$r3 > $fcp" | bc) = 1 ]; then + echo "CRITICAL: wsrep_flow_control_paused is > $fcp" + ST_FINAL=$ST_CR +fi if [ "$primary" = 'TRUE' ]; then if [ "$r2" != 'Primary' ]; then