NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform.
You will still be able to view content, but posting and replying will be temporarily disabled.
To learn more, please review the information in this blog post.

Microsoft Virtualization Discussions

Snapmirror Monitoring Script

von
NetApp Alumni
7,449 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
7,449 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
7,449 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 "[email protected]" -From "[email protected]" -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