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

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

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?

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

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

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#

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.

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

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.