percona-monitoring-plugins
percona-monitoring-plugins copied to clipboard
pmp-check-mysql-status fails if a status variable contains a space
To test, run pmp-check-mysql-status against a status variable containing a space:
Variable_name: wsrep_provider_vendor
Value: Codership Oy `<[email protected]>
-bash-4.2$ /usr/lib64/nagios/plugins/pmp-check-mysql-status -x wsrep_provider_vendor -C '!=' -T str -w Synced
awk: cmd. line:8: if ( Codership Oy <[email protected]> != 0 ) {
awk: cmd. line:8: ^ syntax error
awk: cmd. line:19: if ( Codership Oy <[email protected]> != Synced ) {
awk: cmd. line:19: ^ syntax error
fix is to add escaped quotes around ${VAR} in awk sections:
-bash-4.2$ diff -u /usr/lib64/nagios/plugins/pmp-check-mysql-status ./pmp-check-mysql-status
--- /usr/lib64/nagios/plugins/pmp-check-mysql-status 2016-12-09 18:22:03.000000000 +0000
+++ ./pmp-check-mysql-status 2020-02-06 09:40:15.643168709 +0000
@@ -172,7 +172,7 @@
exit $STATE_CRITICAL
}
} else {
- if ( ${VAR} ${CMP} ${CRIT:-0} ) {
+ if ( \"${VAR}\" ${CMP} \"${CRIT:-0}\" ) {
exit $STATE_CRITICAL
}
}
@@ -183,7 +183,7 @@
exit $STATE_WARNING
}
} else {
- if ( ${VAR} ${CMP} ${WARN:-0} ) {
+ if ( \"${VAR}\" ${CMP} \"${WARN:-0}\" ) {
exit $STATE_WARNING
}
}