VBScript runtime error: Type mismatch: 'cint'

Nagios Core 4.3.4   running on Ubuntu 17.4
Nsclient 4.3
Windows 2012 R2
SQL 2012 and 2014

I have a Nagios plugin check_sqldbsize.vbs that checks the size of my sql databases.

On my SQL 2012 server I have one instance and the check works fine from the server and from Nagios.

On my SQL 2014 server I have three (3) instances I have 1 of the three working the other two give me this error CINT



/usr/local/nagios/etc/objects/windowsservers# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'SERV014-N1' -c check_sqldbsize -a 'SERV014-N1-SQLC\ORF 8000 5000'
C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(25, 15)


/usr/local/nagios/etc/objects/windowsservers# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'SERV014-N1' -c check_sqldbsize -a 'SERV014-N1-SQLS\WSS_Content 8000 5000'

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


from the server I ran the command against both instances and it works fine.

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs SERV014-N1-SQLC ORF 6000 9000
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

OK: ORF database size is 3 MB.

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs SERV014-N1-SQLS WSS_Content 6000 9000
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

OK: WSS_CONTENT database size is 45 MB.


The error only happens when I run this o my Nagios server
Microsoft VBScript runtime error: Type mismatch: 'cint'

Any ideas on the CINT error?
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
What are the parameters "8000 5000"?  The failed one uses that and the working one uses "6000 9000"?

Is it possible the nagios execution is running a different script from a different folder?

Can you post the script?
Fabrice LambertConsultingCommented:
Without seeing your script, nothing we can say.
Thomas GrassiSystems AdministratorAuthor Commented:
I already tried changing the values.

/usr/local/nagios/etc/objects/windowsservers# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'SERV014-N1' -c  check_sqldbsize -a "SERV014-N1-SQLC\ORF 6000 9000"
C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(25, 15) Microsoft VBScript runtime error: Type mismatch: 'cint'

Here is the script.

'
' Check_SQLDBSize.vbs v1.1
'
' Nagios Plugin for checking SQL DB Size
' Tested with NSClient++ v0.4.1.105, Nagios Core 4.0.8 and SQL Server 2008 Express
'
' Author: Gregor Blaj
' Email: gregor[at]nzsystems[dot]com
' Created on: 29/04/2015
'
' Credit to
' https://gallery.technet.microsoft.com/scriptcenter/a6a9d2a4-705f-4e37-86db-33caca7473cb
' http://www.codeproject.com/Tips/469070/SQL-Server-Get-All-Databases-Size
'
' Change Log
' 1.1: Exclude Log from DB size
'

Const adOpenStatic = 3
Const adLockOptimistic = 3
 
Dim dbserver :  dbserver = WScript.Arguments.Item(0)
Dim dbname :  dbname = WScript.Arguments.Item(1)
Dim dbwarn :  dbwarn = cint(WScript.Arguments.Item(2))
Dim dbcrit :  dbcrit = cint(WScript.Arguments.Item(3))
'Dim dbuser :  dbuser = WScript.Arguments.Item(4)
'Dim dbpwd :  dbpwd = WScript.Arguments.Item(5)
Dim dbsize

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider=SQLOLEDB;Data Source=" & dbserver & ";"  & _
        "Trusted_Connection=Yes;Initial Catalog=" & dbname & ";" ' & _
             ' "User ID=sa;Password=password;"
 
objRecordSet.Open "SELECT d.name, ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs FROM sys.master_files mf INNER JOIN sys.databases d ON d.database_id = mf.database_id WHERE d.database_id > 4 AND d.name='" & dbname & "' AND type_desc <> 'Log' GROUP BY d.name", _
        objConnection, adOpenStatic, adLockOptimistic
 
While NOT objRecordSet.EOF
    For Each field In objRecordSet.Fields
        dbsize = field.Value
    next
    objRecordSet.MoveNext
Wend

if dbsize > dbcrit then
    wscript.echo "CRITICAL: " & ucase(dbname) & " database size is " & dbsize & " MB."
    exitcode = 2
elseif dbsize > dbwarn then
    wscript.echo "WARNING: " & ucase(dbname) & " database size is " & dbsize & " MB."
    exitcode = 1
else
    wscript.echo "OK: " & ucase(dbname) & " database size is " & dbsize & " MB."
    exitcode = 0
end if

wscript.quit exitcode

Open in new window



The SA account and password are the same for each instance.

Same vbs script is called for each of the checks.
slightwv (䄆 Netminder) Commented:
Missed the subtle difference between the calls.  The code helped!

The script expects 4 arguments.

If you look when you call it manually, you have 4 parameters with spaces.

When you called it from a script it looks like you have three:
 'SERV014-N1-SQLS\WSS_Content 8000 5000'

There is a '\' between the server and dbname

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thomas GrassiSystems AdministratorAuthor Commented:
Yes that fixed it
I was using the same syntax that I see when connect to my sql server manage console.

Thank you for all the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.