Veeam Backup Jobs Failed – VBScript Nagios Check

' Nagios Plugn for reading Veeam Backup and Replication's log
' It is intended to use with NSClient++


Dim rad,txt,dag,alert,status

Set cnn = CreateObject("ADODB.Connection")
Set Rs = CreateObject("ADODB.Recordset")

cnn.ConnectionString = "driver={SQL Server};server=localhost\VEEAMSQL2012;Trusted_Connection=Yes;database=VeeamBackup"
cnn.Open
rs.ActiveConnection = cnn
exitcode = 0
txt=""
allert()
rs.close
If txt > "" Then
  txt = "BACKUP VIRTUAL MACHINE IN ERRORE: \n" & txt & " | "
else
  txt = "OK"
  exitcode=0
End If

wscript.echo(txt)
wscript.quit exitcode

Function allert()
  Const ForReading = 1, ForWriting = 2, ForAppending = 8
  Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
  'strsql = "SELECT name, repo_name,progress,result,target_host_name   FROM [VeeamBackup].[dbo].[ReportJobsView]   where latest_result=2"
  strsql = "SELECT b.object_name as object_name, a.job_name as job_name, a.creation_time as creation_time, a.end_time as end_time, a.total_size as total_size, a.stored_size as stored_size FROM dbo.ReportSessionView a inner join dbo.ReportSessionInfoView b on a.id = session_id where a.result = '2' and a.id is not null and cast(a.creation_time as date) > dateadd(day,-1, cast(getdate() as date)) order by 2 desc"
  rs.Open strsql , cnn,3,3
  Do While Not rs.EOF 
  
                rad = rs("object_name") & " Job: " & rs("job_name") & " Data Inizio: " & rs("creation_time") & " Data Fine: " & rs("end_time") & " Dimensioni Totali: " & rs("total_size") & " Dimensioni Compresse: " & rs("stored_size") & "\n "
        
            Set fso = CreateObject("Scripting.FileSystemObject")
            txt = txt + rad 
        
        rs.MoveNext
    Loop
    exitcode = 2
    Exit Function
End Function

modified from: https://exchange.nagios.org/directory/Plugins/Backup-and-Recovery/Check-Veeam-Backup-Jobs/details

Rispondi