VBScript runtime error: Type mismatch: 'cint'

Thomas Grassi
Thomas Grassi used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Distinguished Expert 2018

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 LambertConsulting
Distinguished Expert 2017

Commented:
Without seeing your script, nothing we can say.
Thomas GrassiSystems Administrator

Author

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.
Most Valuable Expert 2012
Distinguished Expert 2018
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
Thomas GrassiSystems Administrator

Author

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial