Page 2 of 3

Re: DB-Lib error message 20009, severity 9

Posted: Tue Nov 24, 2015 3:34 pm
by dlukinski
lmiltchev wrote:Can you show us the actual command that you are running from the command line along with the output of it? Hide sensitive info.

Example:

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H x.x.x.x -U 'username' -P 'password' -I 'instancename' --time2connect --warning 1 --critical 5
OK: Time to connect was 0.00740003585815s|time=0.00740003585815s;1;5;;
You can use either port or an instance name but not both. Also, check the permissions of your user. I believe, the user needs server level permissions of "Connect SQL" and "View server state." Also needs database level permissions of "Connect" and "Select". To check these permissions, the user have to log in the MSSQL server, and run the following queries:

Code: Select all

SELECT * FROM fn_my_permissions(null, 'DATABASE')
SELECT * FROM fn_my_permissions(null, 'SERVER')

CLI-based check works
[root@fikc-nagxidev01 ~]# /usr/local/nagios/libexec/check_mssql_server.py -H 10.x.x.30 -U 'nagiosxi' -P 'xxxxxxxx' -I 'FIHPSQL04S1' --time2connect --warning 1 --critical 5
OK: Time to connect was 0.0354108810425s|time=0.0354108810425s;1;5;;

GUI-based does not (generated by the Wizard)
COMMAND: /usr/local/nagios/libexec/check_mssql_server.py -H 10.x.x.30 -U 'nagiosxi' -P \'xxxxxxx
#- "\" actually not there; password is incomplete; no ending (') or the rest of the argument wizard placed into ARG2

OUTPUT: DB-Lib error message 20009, severity 9:
Unable to connect: Adaptive Server is unavailable or does not exist
Net-Lib error during Connection refused Error 111 - Connection refused

Re: DB-Lib error message 20009, severity 9

Posted: Tue Nov 24, 2015 4:43 pm
by lmiltchev
This must be an escaping issue. Do you have any special characters in the password, such as "!"?

What is the version of the MSSQL Server wizard that you are currently using?

Admin->Manage Config Wizards

Re: DB-Lib error message 20009, severity 9

Posted: Tue Nov 24, 2015 8:27 pm
by dlukinski
lmiltchev wrote:This must be an escaping issue. Do you have any special characters in the password, such as "!"?

What is the version of the MSSQL Server wizard that you are currently using?

Admin->Manage Config Wizards
- Password contains these characters: @#$

- Configuration Wizard: MSSQL Database

Re: DB-Lib error message 20009, severity 9

Posted: Wed Nov 25, 2015 1:33 pm
by rkennedy
Does it work if you setup a user macro in the file /usr/local/nagios/etc/resource.cfg?

Add a new $USERn$ macro, then call that directly in the service definition for your mssql check.

Re: DB-Lib error message 20009, severity 9

Posted: Wed Nov 25, 2015 4:53 pm
by dlukinski
rkennedy wrote:Does it work if you setup a user macro in the file /usr/local/nagios/etc/resource.cfg?

Add a new $USERn$ macro, then call that directly in the service definition for your mssql check.
Could you please show me the example of the macro? (never did this)

Re: DB-Lib error message 20009, severity 9

Posted: Wed Nov 25, 2015 10:46 pm
by Box293

Re: DB-Lib error message 20009, severity 9

Posted: Thu Nov 26, 2015 2:57 pm
by dlukinski
Box293 wrote:This guide explains it:
https://assets.nagios.com/downloads/nag ... Macros.pdf
I apologise, but this is now NCPA configurations, where is we are talking about Nagios XI out-of-the-box SQL monitoring configuration errors!
So far I have clear case of SQL Instance monitoring wizard errors. So how do we fix the product instead of trying to come up workarounds?!

Re: DB-Lib error message 20009, severity 9

Posted: Thu Nov 26, 2015 7:01 pm
by Box293
So the wizard is not going to be able to accept your special characters, it's a limitation and we need to work around it with macros.

It's just a matter of putting your password in a macro in resources.cfg and then going to CCM to edit the services and change the incorrect password to the macro you created.

If you can't complete the wizard using your special password, simply use a password like password123 and then when the wizard is complete go into CCM to edit the services and change the incorrect password to the macro.

Does this make sense?

Re: DB-Lib error message 20009, severity 9

Posted: Fri Nov 27, 2015 8:51 am
by dlukinski
Box293 wrote:So the wizard is not going to be able to accept your special characters, it's a limitation and we need to work around it with macros.

It's just a matter of putting your password in a macro in resources.cfg and then going to CCM to edit the services and change the incorrect password to the macro you created.

If you can't complete the wizard using your special password, simply use a password like password123 and then when the wizard is complete go into CCM to edit the services and change the incorrect password to the macro.

Does this make sense?
Wait, you did not tell me they were special (much easier to change the password)
going to try it today

Re: DB-Lib error message 20009, severity 9

Posted: Fri Nov 27, 2015 1:12 pm
by dlukinski
dlukinski wrote:
Box293 wrote:So the wizard is not going to be able to accept your special characters, it's a limitation and we need to work around it with macros.

It's just a matter of putting your password in a macro in resources.cfg and then going to CCM to edit the services and change the incorrect password to the macro you created.

If you can't complete the wizard using your special password, simply use a password like password123 and then when the wizard is complete go into CCM to edit the services and change the incorrect password to the macro.

Does this make sense?
Wait, you did not tell me they were special (much easier to change the password)
going to try it today
After changing password:

COMMAND: /usr/local/nagios/libexec/check_mssql_server.py -H 10.x.x.x -U 'nagiosxi' -P 'aaaaaBBB1' -p 1438 --bufferhitratio --warning 90: --critical 95:
OUTPUT: SQL Server message 297, severity 16, state 1, line 1:
The user does not have permission to perform this action.
DB-Lib error message 297, severity 16:
General SQL Server error: Check messages from the SQL Server