How to escape special characters in query
Posted: Fri May 22, 2015 9:44 am
Hello,
I am trying to execute below command in Nagios server but it shows below error though the query works well locally and dont_blame_nrpe set to 1.
[test1@Nagios_server ~]$ /usr/local/nagios/libexec/check_nrpe -H postdb.domain.COM -t 80 -u -c check_postgres -a '--dbuser=postgres --dbname=db12 --dbpass=pos0!23 --port=5432 --action=custom_query --query="select count (date_created) as result from msg where DATE_CREATED >= (now() - INTERVAL '6 hour') and channel_id ='12v' and status ilike 'complete';" -c 2001 --reverse --showperf=1 --include=result --PGBINDIR=/opt/pgsql93/bin/'
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
Command declared in postgres server:
command[check_postgres]=/usr/lib64/nagios/plugins/check_postgres.pl $ARG1$ $ARG2$ $ARG3$
Log message in the postgres DB server
May 22 08:41:11 postdb nrpe[17904]: Error: Request contained illegal metachars!
May 22 08:41:11 postdb nrpe[17904]: Client request was invalid, bailing out...
Please help to resolve the problem
I am trying to execute below command in Nagios server but it shows below error though the query works well locally and dont_blame_nrpe set to 1.
[test1@Nagios_server ~]$ /usr/local/nagios/libexec/check_nrpe -H postdb.domain.COM -t 80 -u -c check_postgres -a '--dbuser=postgres --dbname=db12 --dbpass=pos0!23 --port=5432 --action=custom_query --query="select count (date_created) as result from msg where DATE_CREATED >= (now() - INTERVAL '6 hour') and channel_id ='12v' and status ilike 'complete';" -c 2001 --reverse --showperf=1 --include=result --PGBINDIR=/opt/pgsql93/bin/'
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
Command declared in postgres server:
command[check_postgres]=/usr/lib64/nagios/plugins/check_postgres.pl $ARG1$ $ARG2$ $ARG3$
Log message in the postgres DB server
May 22 08:41:11 postdb nrpe[17904]: Error: Request contained illegal metachars!
May 22 08:41:11 postdb nrpe[17904]: Client request was invalid, bailing out...
Please help to resolve the problem