Problems with check_xi_mssql_query

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Rampant
Posts: 6
Joined: Fri Aug 05, 2016 3:32 am

Problems with check_xi_mssql_query

Post 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?
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Problems with check_xi_mssql_query

Post 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.
Former Nagios Employee
Rampant
Posts: 6
Joined: Fri Aug 05, 2016 3:32 am

Re: Problems with check_xi_mssql_query

Post 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"
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Problems with check_xi_mssql_query

Post 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
Rampant
Posts: 6
Joined: Fri Aug 05, 2016 3:32 am

Re: Problems with check_xi_mssql_query

Post by Rampant »

Hi,

Got the same result when running it from cmd line.
nagios cmd.jpg
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Problems with check_xi_mssql_query

Post by rkennedy »

Are you using a SQL account to authenticate, or a domain account?
Former Nagios Employee
Rampant
Posts: 6
Joined: Fri Aug 05, 2016 3:32 am

Re: Problems with check_xi_mssql_query

Post by Rampant »

sql account
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Problems with check_xi_mssql_query

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Rampant
Posts: 6
Joined: Fri Aug 05, 2016 3:32 am

Re: Problems with check_xi_mssql_query

Post 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 :/
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Problems with check_xi_mssql_query

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked