# pmp-check-mysql-status -l $USER3$ -p $USER4$ ......

**URL:** <https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156>\
**Category:** Percona Monitoring Plugins\
**Created:** [December 18, 2013, 2:38pm UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156 "2013-12-18T14:38:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![desmondkan](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@desmondkan](https://forums.percona.com/u/desmondkan)\
**Post date:** [December 18, 2013, 2:38pm UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/1 "2013-12-18T14:38:32Z")

</div>

Hello there,

I have been trying to setup the nagios plugins to my monitoring server and I defined the following command on the remote server’s nrpe\_local.cfg.

pmp-check-mysql-status -l $USER3$ -p $USER4$ -H $HOSTADDRESS$ -x Threads\_connected -o / -y max\_connections -T pct -w 80 -c 95

(Of course, I replaced the username, password and hostaddress with all the appropriate info.)

and I got the following output on the monitoring server. [TABLE]  
[TR]  
[TD=“class: dataVal”]awk: line 8: syntax error at or near )  
awk: line 13: syntax error at or near if  
awk: line 24: syntax error at or near exit  
CRIT Threads\_connected / max\_connections (pct) = 1.986755[/TD]  
[/TR]  
[TR]  
[TD=“class: dataVar”]Performance Data:[/TD]  
[TD=“class: dataVal”]Threads\_connected/max\_connections=1.986755;80;95$;0;100[/TD]  
[/TR]  
[/TABLE]

can someone tell me how to fix it ?

Sorry, I am new to nagios.

Thanks for looking at my post and for your help in advance.

-D

---

<div class="post-metadata">

**Author:** ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)\
**Post date:** [December 24, 2013, 3:37am UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/2 "2013-12-24T03:37:23Z")

</div>

Please run the command manually using sh -x pmp-check-mysql-status … and show the excerpt of the output with awk errors.  
Also what’s the OS?

---

<div class="post-metadata">

**Author:** ![desmondkan](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@desmondkan](https://forums.percona.com/u/desmondkan)\
**Post date:** [December 24, 2013, 8:45pm UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/3 "2013-12-24T20:45:58Z")

</div>

Hello Weber,

Thanks for your post. The following is excerpt of the output. Also, the OS is Ubuntu 12.04.

hostname:/usr/lib64/nagios/plugins# sh -x pmp-check-mysql-status

- 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
- OPT\_COMP=\>=
- [-e /etc/nagios/mysql.cnf]
- is\_not\_sourced
- [pmp-check-mysql-status = pmp-check-mysql-status]
- [-n]
- OPT\_ERR=
- [-z]
- OPT\_ERR=you must specify either -c or -w
- 
- [you must specify either -c or -w]
- echo Error: you must specify either -c or -w. Try --help.
- exit 1
- OUTPUT=Error: you must specify either -c or -w. Try --help.
- EXITSTATUS=3
- echo Error: you must specify either -c or -w. Try --help.  
Error: you must specify either -c or -w. Try --help.
- exit 3  
hostname:/usr/lib64/nagios/plugins#

Thanks for your help in advance.  
-D

---

<div class="post-metadata">

**Author:** ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)\
**Post date:** [December 26, 2013, 6:07am UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/4 "2013-12-26T06:07:52Z")

</div>

desmondkan, can you run the full command with “sh -x” to get the error with “awk” command, e.g.  
sh -x /usr/lib64/nagios/plugins/pmp-check-mysql-status -l user -p pass -H somehost -x Threads\_connected -o / -y max\_connections -T pct -w 80 -c 95

---

<div class="post-metadata">

**Author:** ![desmondkan](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@desmondkan](https://forums.percona.com/u/desmondkan)\
**Post date:** [December 26, 2013, 10:04pm UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/5 "2013-12-26T22:04:31Z")

</div>

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#

---

<div class="post-metadata">

**Author:** ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)\
**Post date:** [December 27, 2013, 5:35am UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/6 "2013-12-27T05:35:47Z")

</div>

Unfortunately, there are no errors in the output like you posted initially:  
awk: line 8: syntax error at or near )  
awk: line 13: syntax error at or near if  
awk: line 24: syntax error at or near exit

Please re-run the similar sh -x command for debugging purpose once you get the errors with awk to track it down.

---

<div class="post-metadata">

**Author:** ![desmondkan](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@desmondkan](https://forums.percona.com/u/desmondkan)\
**Post date:** [December 27, 2013, 3:31pm UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/7 "2013-12-27T15:31:32Z")

</div>

Weber,

That’s true. I don’t see the errors anymore if I ran the command manually but I am still getting the same error message If I put the same command into the nrpe\_local.cfg (which is on the remote server).

I guess my syntax is NOT right in the cfg file or should I put this command into the monitoring server instead of the remote server?

could you tell me where I should define the command if I should put this command into the monitoring server?

Thanks for your help.  
I am really appreciated.

-D

---

<div class="post-metadata">

**Author:** ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)\
**Post date:** [January 1, 2014, 7:44am UTC](https://forums.percona.com/t/pmp-check-mysql-status-l-user3-p-user4/3156/8 "2014-01-01T07:44:03Z")

</div>

The command like this “pmp-check-mysql-status -l $USER3$ -p $USER4$ -H $HOSTADDRESS$ -x Threads\_connected -o / -y max\_connections -T pct -w 80 -c 95” should go to the nagios config and nagios replaces those vars with the respective values.
