Sure … the following is the output.
username@hostname:/usr/lib64/nagios/plugins# sh -x pmp-check-mysql-status -l username -p password -H ip-address -x Threads_connected -o / -y max_connections -T pct -w 80 -c 95
- exec
- STATE_OK=0
- STATE_WARNING=1
- STATE_CRITICAL=2
- STATE_UNKNOWN=3
- STATE_DEPENDENT=4
- is_not_sourced
- [ pmp-check-mysql-status = pmp-check-mysql-status ]
- main -l username -p password -H ipaddress -x Threads_connected -o / -y max_connections -T pct -w 80 -c 95
- shift
- OPT_USER=username
- shift
- shift
- OPT_PASS=password
- shift
- shift
- OPT_HOST=ip address
- shift
- shift
- OPT_VAR1=Threads_connected
- shift
- shift
- OPT_OPER=/
- shift
- shift
- OPT_VAR2=max_connections
- shift
- shift
- OPT_TRAN=pct
- shift
- shift
- OPT_WARN=80
- shift
- shift
- OPT_CRIT=95
- shift
- OPT_COMP=>=
- [ -e /etc/nagios/mysql.cnf ]
- is_not_sourced
- [ pmp-check-mysql-status = pmp-check-mysql-status ]
- [ -n ]
- OPT_ERR=
- [ -z 9580 ]
- [ -z Threads_connected ]
- [ / -a -z max_connections ]
- [ max_connections -a -z / ]
- [ pct = pct -a -z max_connections ]
- [ pct ]
- [ / ]
- :
- NOTE=UNK could not evaluate the expression.
- mktemp -t pmp-check-mysql-status.XXXXXX
- local TEMP1=/tmp/pmp-check-mysql-status.khcnvL
- mktemp -t pmp-check-mysql-status.XXXXXX
- local TEMP2=/tmp/pmp-check-mysql-status.n1acml
- trap rm -f ‘/tmp/pmp-check-mysql-status.khcnvL’ ‘/tmp/pmp-check-mysql-status.n1acml’ >/dev/null 2>&1 EXIT
- get_status_variables /tmp/pmp-check-mysql-status.khcnvL /tmp/pmp-check-mysql-status.n1acml
- mysql_exec SHOW /!50000 GLOBAL/ STATUS
- mysql -hipaddress -uusername -ppassword -ss -e SHOW /!50000 GLOBAL/ STATUS
- mysql_exec SHOW /!40101 GLOBAL/ VARIABLES
- mysql -hipaddress -uusername -ppassword -ss -e SHOW /!40101 GLOBAL/ VARIABLES
- compute_result /tmp/pmp-check-mysql-status.khcnvL Threads_connected / max_connections pct
- local TEMP=/tmp/pmp-check-mysql-status.khcnvL
- local VAR1=Threads_connected
- local OPER=/
- local VAR2=max_connections
- local TRAN=pct
- [ max_connections ]
- awk -F\t
BEGIN {
got1 = “Could not find variable Threads_connected”;
got2 = “Could not find variable max_connections”;
}
$1 == “Threads_connected” {
var1 = $2;
got1 = “”;
}
$1 == “max_connections” {
var2 = $2;
got2 = “”;
}
END {
if ( got1 == “” && got2 == “” ) {
if ( var2 == 0 && “/” == “/” ) {
Divide-by-zero; make the result simply 0
val = 0;
}
else {
val = var1 / var2;
}
if ( “pct” == “pct” ) {
val = val * 100;
}
if ( val ~ /.[0-9]/ ) {
printf “%.6f\n”, val;
}
else {
print val;
}
}
else {
print got1, got2 | “cat 1>&2”;
exit 1;
}
}
/tmp/pmp-check-mysql-status.khcnvL
- LEVEL=7.500000
- [ 0 = 0 -a -n 7.500000 ]
- NOTE=Threads_connected / max_connections (pct)
- NOTE=Threads_connected / max_connections (pct) = 7.500000
- compare_result 7.500000 95 80 >= pct
- local VAR=7.500000
- local CRIT=95
- local WARN=80
- local CMP=>=
- local TRAN=pct
- echo 1
- awk END {
if ( “95” != “” ) {
if ( “pct” == “str” ) {
if ( “7.500000” >= “95” ) {
exit 2
}
} else {
if ( 7.500000 >= 95 ) {
exit 2
}
}
}
if ( “80” != “” ) {
if ( “pct” == “str” ) {
if ( “7.500000” >= “80” ) {
exit 1
}
} else {
if ( 7.500000 >= 80 ) {
exit 1
}
}
}
exit 0
} - NOTE=OK Threads_connected / max_connections (pct) = 7.500000
- [ pct = pct ]
- PERFDATA_MAX=100
- PERFDATA=Threads_connected/max_connections=7.500000;80;95;0;100
- NOTE=OK Threads_connected / max_connections (pct) = 7.500000 | Threads_connected/max_connections=7.500000;80;95;0;100
- echo OK Threads_connected / max_connections (pct) = 7.500000 | Threads_connected/max_connections=7.500000;80;95;0;100
- rm -f /tmp/pmp-check-mysql-status.khcnvL /tmp/pmp-check-mysql-status.n1acml
- OUTPUT=OK Threads_connected / max_connections (pct) = 7.500000 | Threads_connected/max_connections=7.500000;80;95;0;100
- EXITSTATUS=3
- EXITSTATUS=0
- echo OK Threads_connected / max_connections (pct) = 7.500000 | Threads_connected/max_connections=7.500000;80;95;0;100
OK Threads_connected / max_connections (pct) = 7.500000 | Threads_connected/max_connections=7.500000;80;95;0;100 - exit 0
username@hostname:/usr/lib64/nagios/plugins#