SQL Plugin Does not like space in Database Name

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

SQL Plugin Does not like space in Database Name

Post by kwhogster »

Nagios Core 4.3.4
Nsclient 4.3
Windows 2012 R2
SQL 2014

Using a SQL plugin to check the SQL database sizes. I posted this question earlier and we got most of the databases working. I have a new issue I would like help on.

Nagios show this
SQLDBSIZE-Managed Metadata Service OK 11-11-2018 00:19:17 0d 21h 36m 37s 1/10 C:Program FilesNSClient++scriptscheck_sqldbsize.vbs(24, 15) Microsoft VBScript runtime error: Type mismatch: 'cint'

I run the same on the server
root@tgcs017:/usr/local/nagios/etc/objects/windowsservers# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'TGCS014-N1' -c check_sqldbsize -a 'TGCS014-N1-SQLS\Sharepoint!Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0!8000!9500'

Code: Select all

define service {
        host_name               hostname
        service_description     SQLDBSIZE-Managed Metadata Service
        check_command           check_sqldbsize!'TGCS014-N1-SQLS\Sharepoint!Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0!8000!9500'
        check_interval          1440
        notification_interval   1440
        servicegroups           SQL DB Size
        check_period            backup_period
        notification_period     backup_period
        use                     generic-service
        }

Code: Select all

define command {
        command_name    check_sqldbsize
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c check_sqldbsize -a $ARG1$ $ARG2$ $ARG3$ $ARG4$
        }

The ONLY difference I found is that the Databases names have a space between them all the databases that are working do not have a space in the name.

I tried place "" around extra '' no luck.

Any ideas

Thank you

Tom
bolson

Re: SQL Plugin Does not like space in Database Name

Post by bolson »

Hello Tom,

Two things to try are:

1) Escape the database name with the Linux escape character "\" like this: my\ database (space after the \)
2) Single quote " ' " the database name.

If this doesn't resolve your issue, let me know and I'll attempt to recreate your issue.

Thank you for visiting the Nagios Support Forum!
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: SQL Plugin Does not like space in Database Name

Post by kwhogster »

Single Quotes

:/usr/local/nagios/etc/objects# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'TGCS014-N1' -c check_sqldbsize -a 'TGCS014-N1-SQLS\'Sharepoint!Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0!8000'!9500'

-su: !Managed: event not found

With the "\"

root@tgcs017:/usr/local/nagios/etc/objects# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'TGCS014-N1' -c check_sqldbsize -a 'TGCS014-N1-SQLS\Sharepoint!Managed\ Metadata\ Service_addd35ce8f5049a69f66716abf5879a0!8000!9500'
C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(24, 15) Microsoft VBScript runtime error: Type mismatch: 'cint'

Thanks
bolson

Re: SQL Plugin Does not like space in Database Name

Post by bolson »

Hello again Tom,

This error is not being generated by Nagios but rather by the VBScript itself. The next step in troubleshooting would be to run the script from the command line of the Windows host and post the output like this:

cscript check_sqldbsize.vbs SERVERINSTANCE DATABASE WARNING CRITICAL
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: SQL Plugin Does not like space in Database Name

Post by kwhogster »

Same results

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs TGCS014-N1-SQLS\SHAREPOINT Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0 8000 9600

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(24, 15) Microsoft VBScript runtime error: Type mismatch: 'cint'


C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs TGCS014-N1-SQLS\SHAREPOINT 'Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0' 8000 96
00
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(24, 15) Microsoft VBScript runtime error: Type mismatch: 'cint'



But when I place double quotes " it works

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs TGCS014-N1-SQLS\SHAREPOINT "Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0" 8000 96
00
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

OK: MANAGED METADATA SERVICE_ADDD35CE8F5049A69F66716ABF5879A0 database size is 4 MB.

Now from Nagios

/usr/local/nagios/etc/objects# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'TGCS014-N1' -c check_sqldbsize -a 'TGCS014-N1-SQLS\Sharepoint!"Managed Metadata Service_addd35ce8f5049a69f66716abf5879a0"!8000!9500'

OK: MANAGED METADATA SERVICE_ADDD35CE8F5049A69F66716ABF5879A0 database size is 4 MB.

Looks like I need double quotes around the database name

Will post final results later
bolson

Re: SQL Plugin Does not like space in Database Name

Post by bolson »

Thank you Tom,

Let us know once you've confirmed the solution so we can lock the thread.
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: SQL Plugin Does not like space in Database Name

Post by kwhogster »

They all worked but this one Sorry I missed this one before.

C:Program FilesNSClient++scriptscheck_sqldbsize.vbs(33, 1) Microsoft OLE DB Provider for SQL Server: Cannot open database "Search_Service_Application_PropertyStoreDB_2a6fb4d3dca4255b6a7dbd9d6abab60" requested by the login. The login failed.

Code: Select all

define service {
        host_name               hostname
        service_description     SQLDBSIZE-Search_Service_Application_PropertyStoreDB
        check_command           check_sqldbsize!'TGCS014-N1-SQLS\Sharepoint!Search_Service_Application_PropertyStoreDB_2a6fb4d3dca4255b6a7dbd9d6abab60!8000!9500'
        check_interval          1440
        notification_interval   1440
        servicegroups           SQL DB Size
        check_period            backup_period
        notification_period     backup_period
        use                     generic-service
        }
from the server command line

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs TGCS014-N1-SQLS\
SHAREPOINT "Search_Service_Application_PropertyStoreDB_2a6fb4d3dca4255b6a7dbd9d
6abab60" 8000 9500
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(33, 1) Microsoft OLE DB
Provider for SQL Server: Cannot open database "Search_Service_Application_Proper
tyStoreDB_2a6fb4d3dca4255b6a7dbd9d6abab60" requested by the login. The login failed.

Any ideas?
bolson

Re: SQL Plugin Does not like space in Database Name

Post by bolson »

Hello kwhogster,

Not being familiar with your environment, I can only guess that the error message should be taken literally. The sa password is hard coded in the script so that's probably where you want to look first. Let me know if this resolves your issue.

Thanks!
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: SQL Plugin Does not like space in Database Name

Post by kwhogster »

Added another account to the SQL logins

also the database was missing a single character copy and paste sometimes does not work lol

This can be locked as resolved now

Thank you
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: SQL Plugin Does not like space in Database Name

Post by scottwilkerson »

kwhogster wrote:Added another account to the SQL logins

also the database was missing a single character copy and paste sometimes does not work lol

This can be locked as resolved now

Thank you
great!

Locking
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked