Link to home
Start Free TrialLog in
Avatar of Member_2_6492660_1
Member_2_6492660_1Flag for United States of America

asked on

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?
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

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?
Without seeing your script, nothing we can say.
Avatar of Member_2_6492660_1

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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