Page 1 of 2
Problems with check_xi_mssql_query
Posted: Fri Aug 05, 2016 3:47 am
by Rampant
Hi,
I am trying to monitor the current free space of a database to keep a tab on database growth.
But it seems I am unable to run query's for some reason. I have created a service user on the database itself and I am not using any special characters in the password as I have seen this may cause an issue.
When i test without a query it connects
nagios success.jpg
When i add my query it fails
nagios fail.jpg
The query I am trying to run is:
SELECT DB_NAME() AS DbName,
name AS FileName,
size/128.0 AS CurrentSizeMB,
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB
FROM sys.database_files;
I have tested the query and it runs just fine. Permissions should not be an issue either. Firewall disabled. Any ideas what I am doing wrong?
Re: Problems with check_xi_mssql_query
Posted: Fri Aug 05, 2016 10:21 am
by rkennedy
The test check command isn't the best as it escapes things differently than an organic Nagios check would. If you let it run it's full course, does it work?
If not, please post the full check_command for us to look at. It might just be a matter of quotes, but without seeing exactly how you have it setup we're a bit limited.
Re: Problems with check_xi_mssql_query
Posted: Mon Aug 08, 2016 1:17 am
by Rampant
Tried running it but it gives the same result as before.
Here is the full check_command
Code: Select all
check_xi_mssql_query--username 'username' --password 'password' --database database --instance instance --query "SELECT+DB_NAME%28%29+AS+DbName%2C+%0D%0Aname+AS+FileName%2C+%0D%0Asize%2F128.0+AS+CurrentSizeMB%2C+%0D%0Asize%2F128.0+-+CAST%28FILEPROPERTY%28name%2C+%27SpaceUsed%27%29+AS+INT%29%2F128.0+AS+FreeSpaceMB+%0D%0AFROM+sys.database_files%3B"
Re: Problems with check_xi_mssql_query
Posted: Mon Aug 08, 2016 4:30 pm
by ssax
Please click the Test Check Command button and copy the full command and run it from the command line of the XI server to see if it works that way, make sure to "su - nagios" before running it.
Thank you
Re: Problems with check_xi_mssql_query
Posted: Tue Aug 09, 2016 1:57 am
by Rampant
Hi,
Got the same result when running it from cmd line.
nagios cmd.jpg
Re: Problems with check_xi_mssql_query
Posted: Tue Aug 09, 2016 9:53 am
by rkennedy
Are you using a SQL account to authenticate, or a domain account?
Re: Problems with check_xi_mssql_query
Posted: Wed Aug 10, 2016 1:36 am
by Rampant
sql account
Re: Problems with check_xi_mssql_query
Posted: Wed Aug 10, 2016 3:48 pm
by tgriep
Are you seeing any errors on the MSSQL server for that account?
Can you login to the nagios server using the nagios user account on the server, then run the check to see if it still fails?
Re: Problems with check_xi_mssql_query
Posted: Fri Aug 12, 2016 6:42 am
by Rampant
Not seeing any errors on that user, and tried manual login and running the query with the same user and it works as it should.
I also tested this with PRTG and it works as intended, but I would rather it worked with Nagios.
Still fails when running from server :/
Re: Problems with check_xi_mssql_query
Posted: Fri Aug 12, 2016 10:49 am
by tgriep
What version of the plugin is installed on your server?
Run the following command and post the output.
Code: Select all
/usr/local/nagios/libexec/check_mssql -V
Thanks