Page 1 of 2
GUI not giving output
Posted: Sun Aug 23, 2020 8:48 pm
by RebeccaIlene
Hi Team,
When I run the following SQL query from the Nagios server command line we get the correct output.
However, when running this on GUI it throws a WARNING - Use of uninitialized value $sql in sprintf at $USER$2/check_mssql_health line 6509.
What can be done to fix this?
Working:
[root@Hostname ~]#$USER$2/check_mssql_health -t 20 --server hostname --username=domain\\nagios_account --password=$password$ --mode=sql --name "`cat $USER$%/edt.sql`" --name2 'EDT job status' --warning 60 --critical 120
OK - edt job status: 11 | 'edt'=11;60;120;;
Re: GUI not giving output
Posted: Mon Aug 24, 2020 3:21 pm
by benjaminsmith
Hi Rebecca,
I believe the data is not getting parsed correctly when being passed over the PHP scripts, trying using single quotes instead of double quotes on the name argument. For example:
Code: Select all
check_mssql_health -t 20 --server hostname --username=domain\\nagios_account --password=$password$ --mode=sql --name '`cat $USER$%/edt.sql`' --name2 'EDT job status' --warning 60 --critical 120
Let me know if that resolves the error.
Benjamin
Re: GUI not giving output
Posted: Tue Aug 25, 2020 2:31 am
by RebeccaIlene
Hi Benjamin,
Thanks for your reply.
I have updated the double quotes to single quotes but it didn't help.
The output still shows as "WARNING - Use of uninitialized value $sql in sprintf".
Re: GUI not giving output
Posted: Tue Aug 25, 2020 4:32 pm
by jdunitz
Hi Rebecca!
Can you take a screenshot of the config screen for this and post it?
Somewhere between what the config screenshot has, and what you're ending up with from quoting will be where we need to look.
--Jeffrey
Re: GUI not giving output
Posted: Thu Aug 27, 2020 1:23 am
by RebeccaIlene
Thanks! Please find attached screenshot.
Re: GUI not giving output
Posted: Thu Aug 27, 2020 5:15 pm
by benjaminsmith
Hi Rebecca,
The command in the screenshot is a little different than the one posted earlier. It looks like you hardcoded the path for
/usr/local/nagios/local/DB/SQL/EDT.sql, and I was going to suggest doing that, but that's still not working.
So, let's make sure the nagios user account can access this file. It's like the root user can but nagios cannot. What is the output of the following command:
Code: Select all
ls -l /usr/local/nagios/local/DB/SQL/EDT.sql
Re: GUI not giving output
Posted: Mon Aug 31, 2020 11:34 am
by RebeccaIlene
Thanks for checking this Benjamin.
Here is the output:
[root@hostname ~]# ls -l /usr/local/nagios/local/DB/SQL/EDT.sql
-rwxrwxrwx 1 root root 105 Jun 17 11:54 /usr/local/nagios/local/DB/SQL/EDT.sql
Re: GUI not giving output
Posted: Tue Sep 01, 2020 12:47 pm
by benjaminsmith
Hi Rebecca
Thanks for posting the file permissions, that looks ok. After digging into this issue a little further, the CCM is more restrictive now as far as passing commands for improving security. It's likely stripping the backticks and not allowing you to run the command.
Can verify this by sending a simple test query into the check command instead. And if there are special characters in the SQL string, you may need to use the --encode option.
sql
Result of a user-defined SQL statement, which returns a numerical value. The statement is passed to the plugin as an argument to the –sql parameter. A label for the performancedata can be defined with the –name2 parameter. A unit can be appended by using –units. If the SQL statement contains special characters, it is recommended to encode it first by calling check_mssql_health with the –encode parameter and sending the statement to STDIN
Reference:
https://www.claudiokuenzler.com/blog/72 ... thresholds
Re: GUI not giving output
Posted: Wed Sep 02, 2020 11:34 pm
by RebeccaIlene
Hi Benjamin,
The other DB services work fine on this server. We also are running another custom query which gives the correct output.
By encode did you mean to change the mode to encode?
Re: GUI not giving output
Posted: Thu Sep 03, 2020 3:59 pm
by ssax
Try changing these:
Code: Select all
--username=domain\\nagios_account --password=$password$
To this (
surrounding them with single quotes):
Code: Select all
--username='domain\nagios_account' --password='$password$'
Then test again.
Please PM me the SQL file you are running so I can take a look at it.