In my first installment, I want to show a simple way to get the highest lag time of all your NetApp Snapmirror relationships, with Powershell. This is useful for anyone running Orion, WhatsUpGold, Nagios, or any other monitoring tool which can call out to scripts and remote hosts for custom checks.
If you work in a windows environment, and you do not use or have Powershell and the NetApp DataONTAP toolkit, stop reading this, and go get it. You’ll thank me later.
Let’s look at an environment running SnapMirror, where it is regularly out of sync due to network issues.:
fas3020a> snapmirror status
Snapmirror is on.
Source Destination State Lag Status
prodfas3020a:ThinApp fas3020a:ml_ThinApp Snapmirrored – In-sync
fas3020a:home Prodfas3020a:fas3020a_home_SnapMirror Source 11:16:05 Idle
fas3020a:SharePoint_Backup fas3020b:SharePoint_Mirr_Backup Source 20546:22:43 Idle
Wow, that’s some bad lag! I wish our monitoring system would have let us know before it was too late! Wait, few monitoring systems can handle this sort of thing… but that is where Powershell can help!
You will first need to download and install the DataOntap Powershell Toolkit from here: https://communities.netapp.com/community/products_and_solutions/microsoft/powershell
Next, create a simple SnapmirrorLag.ps1 script in notepad or your editor of choice. Below,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
############################ BEGIN SnapmirrorLag.ps1 ####################################### # SIMPLE SNAPMIRROR CHECK ~ v0.1 - R. Jarett Kulm / JK-47 # REQUIRES NETAPP POWERSHELL TOOLKIT / PowerShell 2.0 recommended! ################################################## # Import the proper powershell module Import-module DataONTAP # Set your alert time here, this is in seconds. Below = 4 hours lag. $alertseconds = "14440" # Set your root password $filerpassword = "YourNetAppRootPassword" # Set your Filer IP or FQDN $filername = "YourFiler.YourDomain.Com" # Create an encrypted string which the API will use — Change password below $password = ConvertTo-SecureString $filerpassword -AsPlainText –Force # Create a credential object in powershell against the root user – Change root user if you use a different admin user $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "root",$password # Connect to the Filer using the credential created above – You can change the FQDN or IP below $connection = Connect-NaController $filername -Credential $cred # Use the powershell commandlet to grab all snapmirror information, pull out specifics for the Max and Average LagTIme $smlag = Get-NaSnapmirror | Measure-Object -Property LagTime -Max –Average # Report out in the case of lag greater than the alert seconds set above. if ($smlag.Maximum -gt $alertseconds) {write-host "CRITICAL: Highest LagTime" $smlag.Maximum " exceeded normal values!"} ############################ END SnapmirrorLag.ps1 ####################################### |
If you have snapmirror relationships which are lagging, you will see output such as this: CRITICAL: Highest LagTime 73966407 exceeded normal values! You can format this output to match what your monitoring platform expects.
[asa]0596801505[/asa]