Skip to content

Instantly share code, notes, and snippets.

@vicendominguez
Created February 4, 2014 15:59
Show Gist options
  • Save vicendominguez/8806451 to your computer and use it in GitHub Desktop.
Save vicendominguez/8806451 to your computer and use it in GitHub Desktop.
Terminal report for failed jobs from Commvault Backup
' Dirty script to check Failed backups from Commvault 9.00
' Author: Vicente Dominguez - contact via Twitter @vicendominguez ;)
' Require: qlist from qcommands (Commvault 9.00)
' Save as check_commvaulthistory.vbs in server with commvault sw install
' Command line to execute: cscript //nologo check_commvaulthistory.vbs
' Remember to execute 'qlogin' to validate the user/pass
Option Explicit
' On Error Resume Next
Function getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function
' Formatting output from qlist command (if qlist output changes... be careful here)
Function CreateArrayClient()
Dim ClientList(), ClientAux, ClientArray, ClientName, NumList
ClientArray = split (getCommandOutput ("qlist client"), vbNewLine)
NumList = 0
For Each ClientAux in ClientArray
' Dynamic array resize
redim preserve ClientList (NumList)
' Output 'qlist' validation, min two chars in name to be ok
If Len (ClientAux) > 2 Then
ClientName = Split (ClientAux, " ")
' Client must be "ACTIVE"
If InStr (Mid(ClientAux,47), "Yes") Then
ClientList(NumList) = ClientName(0)
NumList = NumList + 1
End If
End If
Next
CreateArrayClient = ClientList
End Function
Function GetHostHistory (Hostname)
Dim HostHistory
HostHistory = getCommandOutput("qlist jobhistory -c '" & Hostname & "'")
GetHostHistory = HostHistory
End Function
Function GetHostFailedHistory (Hostname)
Dim HostHistory
HostHistory = getCommandOutput("qlist jobhistory -js Failed -c '" & Hostname & "'")
If InStr (HostHistory, "No jobs to display") Then
GetHostFailedHistory = 0
Else
GetHostFailedHistory = 1
End If
End Function
Sub BackupAudit ()
Dim Hostname
For Each Hostname in CreateArrayclient
If Len (HostName) > 1 Then
If GetHostFailedHistory (Hostname) Then
Wscript.Echo Hostname & " FAIL: " & GetHostHistory (Hostname)
Else
Wscript.Echo Hostname & " OK "
End If
End If
Next
End Sub
BackupAudit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment