Monitor Replication

PowerShell script exchange

Monitor Replication

Veeam Logoby lobo519 » Fri Jun 10, 2016 6:49 pm

I am trying to monitor my replication jobs. Basiclly I want to make sure they are running. I have run into a very human problem when the jobs are disabled for some type of maintenance and not re-enabled. I was thinking of using this script to find the last snapshot and send an email if its more than 2 hours old.

Get-VBRRestorePoint -Name $VM | Sort-Object {$_.creationtime} -Descending | Select -First 1

I'm just not sure how to setup the IF statement to fire the email if the time is more than 2 hours old. Anyone have any suggestions or a better way to accomplish this?
lobo519
Expert
 
Posts: 292
Liked: 34 times
Joined: Wed Sep 29, 2010 3:37 pm

Re: Monitor Replication

Veeam Logoby tdewin » Mon Jun 13, 2016 6:48 am

Couldn't really test it but something like this should work
Code: Select all
if ( ($_.CreationTime) -lt (get-date).AddHours(-2)) { echo "too old" }
tdewin
Veeam Software
 
Posts: 1043
Liked: 360 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Monitor Replication

Veeam Logoby lobo519 » Wed Feb 15, 2017 8:29 pm

it's been a while because this feel off my radar. I could swear I have this all worked out but for the life of me can't figure how why this won't work. It doesn't appear to be comparing the RPO time and the snaptime properly. Any thoughts?

Code: Select all
$RPO = (Get-Date).Addhours(2)

$getsnaptime = Get-VBRRestorePoint -Name $vm | Sort-Object {$_.creationtime} -Descending | Select -First 1 | select creationtime | format-table -hidetableheaders
$snaptime = ($getsnaptime | out-string).trim()
 
If ($snaptime -lt $RPO)

{

 Send-MailMessage -From $Sender -To $Recipients -Subject $Subject -Body "Check Replication jobs Last snapshot time for $vm is $snaptime" -DeliveryNotificationOption onFailure -SmtpServer $SMTPServer
 write-host "RPO out of Compliance"

}Else {

 write-host "RPO In Compliance"


}
lobo519
Expert
 
Posts: 292
Liked: 34 times
Joined: Wed Sep 29, 2010 3:37 pm


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests