Microsoft Virtualization Discussions

Snapmirror Monitoring Script

NetApp Alumni

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.



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.


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 "" -From "" -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.

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner