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?
-
- Veteran
- Posts: 315
- Liked: 38 times
- Joined: Sep 29, 2010 3:37 pm
- Contact:
-
- Veeam Software
- Posts: 1818
- Liked: 655 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: Monitor Replication
Couldn't really test it but something like this should work
Code: Select all
if ( ($_.CreationTime) -lt (get-date).AddHours(-2)) { echo "too old" }
-
- Veteran
- Posts: 315
- Liked: 38 times
- Joined: Sep 29, 2010 3:37 pm
- Contact:
Re: Monitor Replication
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"
}
Who is online
Users browsing this forum: Semrush [Bot] and 25 guests