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
How to escape special characters in query
-
sureshkraj2012
- Posts: 65
- Joined: Tue Aug 06, 2013 11:06 pm
Re: How to escape special characters in query
In a case like this, it's quite possibly easier to manage the configuration on the client side of things. Since you stated that the query works well locally, it'd be a simple matter of adding it to nrpe.cfg and calling that command from Nagios. Let me know if you need further elaboration.
If you would like to stick with your current method, I would try stripping our pieces of your command until we figure out where exactly it's failing:
Does the above return proper output?
If you would like to stick with your current method, I would try stripping our pieces of your command until we figure out where exactly it's failing:
Code: Select all
/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"-
sureshkraj2012
- Posts: 65
- Joined: Tue Aug 06, 2013 11:06 pm
Re: How to escape special characters in query
Yes. It returns output
/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=connection --PGBINDIR=/opt/pgsql93/bin/"
POSTGRES_CONNECTION OK: DB "db12" version 9.3.5 | time=0.10s
/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=connection --PGBINDIR=/opt/pgsql93/bin/"
POSTGRES_CONNECTION OK: DB "db12" version 9.3.5 | time=0.10s
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: How to escape special characters in query
The exclamation mark ! in your password is the cause of the problem. Either change the password or put the password into a user macro.sureshkraj2012 wrote:--dbpass=pos0!23
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.