Advertisement
vicendominguez

Console report for failed jobs from Commvault Backup

Jan 2nd, 2013
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Dirty script to check Failed backups from Commvault 9.00
  2. ' Author: Vicente Dominguez - contact via Twitter @vicendominguez ;)
  3. ' Require: qlist from qcommands (Commvault 9.00)
  4. ' Save as check_commvaulthistory.vbs in server with commvault sw install
  5. ' Command line to execute: cscript //nologo check_commvaulthistory.vbs
  6. ' Remember to execute 'qlogin' to validate the user/pass
  7.  
  8. Option Explicit
  9. ' On Error Resume Next
  10.  
  11. Function getCommandOutput(theCommand)
  12.     Dim objShell, objCmdExec
  13.     Set objShell = CreateObject("WScript.Shell")
  14.     Set objCmdExec = objshell.exec(thecommand)
  15.     getCommandOutput = objCmdExec.StdOut.ReadAll
  16. end Function
  17.  
  18. ' Formatting output from qlist command (if qlist output changes... be careful here)
  19. Function CreateArrayClient()
  20.     Dim ClientList(), ClientAux, ClientArray, ClientName, NumList
  21.     ClientArray = split (getCommandOutput ("qlist client"), vbNewLine)
  22.     NumList = 0
  23.     For Each ClientAux in ClientArray
  24.     ' Dynamic array resize
  25.        redim preserve ClientList (NumList)
  26.     ' Output 'qlist' validation, min two chars in name to be ok
  27.    If Len (ClientAux) > 2 Then
  28.             ClientName = Split (ClientAux, "  ")
  29.         ' Client must be "ACTIVE"
  30.            If InStr (Mid(ClientAux,47), "Yes") Then
  31.             ClientList(NumList) = ClientName(0)
  32.             NumList = NumList + 1
  33.         End If
  34.     End If
  35.     Next
  36.     CreateArrayClient = ClientList
  37. End Function
  38.  
  39. Function GetHostHistory (Hostname)
  40.     Dim HostHistory
  41.     HostHistory = getCommandOutput("qlist jobhistory -c '" & Hostname & "'")
  42.     GetHostHistory = HostHistory
  43. End Function
  44.    
  45. Function GetHostFailedHistory (Hostname)
  46.     Dim HostHistory
  47.     HostHistory = getCommandOutput("qlist jobhistory -js Failed -c '" & Hostname & "'")
  48.     If InStr (HostHistory, "No jobs to display") Then
  49.         GetHostFailedHistory = 0
  50.     Else  
  51.         GetHostFailedHistory = 1
  52.     End If
  53. End Function
  54.  
  55. Sub BackupAudit ()
  56.     Dim Hostname
  57.     For Each Hostname in CreateArrayclient
  58.         If Len (HostName) > 1 Then
  59.         If GetHostFailedHistory (Hostname) Then
  60.             Wscript.Echo Hostname & " FAIL: " & GetHostHistory (Hostname)
  61.         Else
  62.             Wscript.Echo Hostname & " OK "
  63.         End If
  64.     End If
  65.     Next
  66. End Sub
  67. BackupAudit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement