PowerShell script exchange
Post Reply
alamb200
Novice
Posts: 9
Liked: never
Joined: Sep 28, 2015 9:52 am
Full Name: Anthony Lamb
Contact:

Script to monitor Veeam backups

Post by alamb200 »

Hi,
We for many years have used a VBS script in conjunction with our Centreon monitoring solution to let us know if the Veeam jobs have been successful, but since the move to PostGreSQL we are unable to use it anymore.
The script we use is this:

Code: Select all

'
' Nagios Plugn for reading BackupExec's error log
' It is intended to use with NSClient++
'
' To reset the alerts, accnolage the alerts in BackupExec
'
' Author: Nils Cronstedt
' Email: nils.cronstedt[at]gmail[dot]com
' Created on: 2010-05-15


Dim rad,txt,dag,alert,status

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

cnn.ConnectionString = "driver={SQL Server};server=VEEAM\VEEAMSQL2016;Trusted_Connection=Yes;database=VeeamBackup"
cnn.Open
rs.ActiveConnection = cnn
exitcode = 0
txt=""
allert()
rs.close
If txt > "" Then
	txt = "Error in Backup or Replication Job " & 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  FROM [dbo].[Bjobs] where latest_result=1"
	rs.Open strsql , cnn,3,3
	Do While Not rs.EOF 
	
                rad = rs("name") & ", "
        
            Set fso = CreateObject("Scripting.FileSystemObject")
            txt = txt + rad 
        
        rs.MoveNext
    Loop
    exitcode = 2
    Exit Function
End Function
I may be looking from a very simplistic point of view, but I think if we can get this line set up to match what the new database type uses we can get this working:

Code: Select all

cnn.ConnectionString = "driver={SQL Server};server=VEEAM\VEEAMSQL2016;Trusted_Connection=Yes;database=VeeamBackup"
Is anyone able to help?
Thanks,
Anthony
Mildur
Product Manager
Posts: 10298
Liked: 2748 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Script to monitor Veeam backups

Post by Mildur »

Hello Anthony

I found an sample to initiate a PostgreSQL DB connection from a VBS script on Github: https://gist.github.com/yakovsh/91714d1a9231923d9bc4

Please note that the database schema may change between different versions of Veeam. Additionally, we do not support interacting with the database outside of official APIs or product consoles. Instead of using VBS scripts to access the database, you should consider using the official PowerShell cmdlets to gather the required information. This approach ensures that your script will continue to work even after migrating databases or updating our product.

Another option, if Centreon can function as a Syslog server, is to utilize our syslog integration:
https://helpcenter.veeam.com/docs/backu ... ml?ver=120


Best,
Fabian
Product Management Analyst @ Veeam Software
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 15 guests