All pastes #1993215 Raw Edit

check_nbu_drives.vbs

public text v1 · immutable
#1993215 ·published 2010-11-16 10:32 UTC
rendered paste body
'Check status of NetBackup drive paths
'2/9/2009
'Charles Schlesinger
'MGP Ingredients, Inc.

set args = wscript.arguments

'Set your Warning and Critical Thresholds
Dim intWarning
Dim intCritical
intWarning = Int(args(0))
intCritical = Int(args(1))

' Which drive type to look for
Dim strDriveType
strDriveType = args(2)

'set Path to tpconfig.exe executable file on server
'strTpconfigPath = "C:\Program Files\Veritas\Volmgr\bin\tpconfig.exe"
Dim strTpconfigPath
strTpconfigPath = args(3)

Dim arrDown()
intSize = 0

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec(strTpconfigPath + " -l")

'throw away the first three lines of headers
strJunk = objExecObject.StdOut.ReadLine()
strJunk = objExecObject.StdOut.ReadLine()
strJunk = objExecObject.StdOut.ReadLine()

Do Until objExecObject.StdOut.AtEndOfStream
    'Push data to array
    strWorkString = (objExecObject.StdOut.ReadLine())
    strWorkString = Trim(strWorkString)
    intWorkstr = Len(strWorkString)
    For i = intWorkStr to 2 Step -1
        strChars = Space(i)
        strWorkString = Replace(strWorkString, strChars, " ")
    Next
	
    arrValues = Split(strWorkString, " ")
    If arrValues(3) = strDriveType Then
        If (arrValues(5) <> "UP") Then
            ReDim Preserve arrDown(intSize)
            arrDown(intSize) = arrValues(7) & " " & arrValues(8)
            intSize = intSize + 1
        End If
    End If
Loop

strDown = ""
'Compute the results
If (intSize > 0) Then
    For j = LBound(arrDown) to UBound(arrDown)
        If j = UBound(arrDown) Then
            strDown = strDown + arrDown(j)
        Else
            strDown = strDown + arrDown(j) + ", "
        End If
    Next
End If

'WScript.Echo(strDown & intSize)
If (intSize >= intCritical) Then
    strResult = "CRITICAL - " & intSize & " paths " + strDown + " are down!"
    intQuitCode = 2
ElseIf (intSize >= intWarning) Then
    strResult = "WARNING - " & intSize & " paths " + strDown + " are down!"
    intQuitCode = 1
Else
    strResult = "OK - All Paths are Up"
    intQuitCode = 0
End If

Wscript.Echo(strResult)
WScript.Quit(intQuitCode)

' EOF