DB-Lib error message 20009, severity 9

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: DB-Lib error message 20009, severity 9

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: DB-Lib error message 20009, severity 9

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: DB-Lib error message 20009, severity 9

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: DB-Lib error message 20009, severity 9

Post 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.
Former Nagios Employee
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: DB-Lib error message 20009, severity 9

Post 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)
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: DB-Lib error message 20009, severity 9

Post by Box293 »

As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: DB-Lib error message 20009, severity 9

Post 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?!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: DB-Lib error message 20009, severity 9

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: DB-Lib error message 20009, severity 9

Post 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
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: DB-Lib error message 20009, severity 9

Post 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
Locked