Microsoft Virtualization Discussions

Snapmirror Monitoring Script

von
NetApp Alumni
6,432 Views

Does anyone out there have a Powershell Snapmirror Monitoring Script.   We have 4 filers that are behind a firewall and can not use OpsManager to provide this information.   We are looking for somthing that will provide a status  back to SA's  via email if  a  snapmirror fails.

2 REPLIES 2

steve_francis
6,432 Views

Not a direct answer, but if you have a windows (or linux) system inside the firewall (which seems to be the case, if you a proposing a powershell script that will have access to the filers) you could have a SaaS system that uses collectors to get the information and alert you appropriately, like LogicMonitor.

JOHNGARRETT
6,432 Views

You could try something like this:

Connect-NaController yourcontroller

$sms = Get-NaSnapmirror

$smerror = $null

$newline = "`n"

foreach ($sm in $sms){

    if ($sm.state -ne "snapmirrored"){

        Write-Host "Errors found. `tSource: $($sm.source)`t`t Destination: $($sm.Destination) `t`tState: $($sm.State)"

        $smerror += @($sm.Source,$sm.Destination,$sm.State,$newline)

        }

    }

Send-MailMessage -To "you@yourdomain.com" -From "powershell@yourdomain.com" -Subject "Snapmirror errors found!" -Body "$smerror" -BodyAsHtml -SmtpServer yoursmtpserver

I'm making some assumptions here though.

1. I'm assuming you're using powershell v3 and DataOntap toolkit v3.0.

2. I'm assuming you have cached credentials to your filers via add-nacredential.

3. You're able to make send-mailmessage look pretty

Also, I wouldn't modify this script to run in a loop forever - That's generally a no-no with powershell. Use task scheduler (or whatever other tasking tool) to launch it at set intervals.

Public