When I designed a DR solution a while back, I knew what I needed to do, what the software/hardware involved would do, but wasn’t sure about a couple things, including how to monitor it.
I did a Google search on NetApp SnapMirror Monitoring, and didn’t find much, given the route I chose to take, a Windows system running Snap Manager for Virtual Infrastructure (SMVI). I chose to have this system report the SnapMirror status.
It didn’t make sense to me to use a Linux/Unix system to handle this role (as I don’t have many of these systems). It did make sense to me to have my system running SMVI to perform the task.
I started by using plink.exe to execute the “snapmirror status” command on my remote Filer. I like plink, because it can execute a ssh command remotely, and can be scripted.
To make plink.exe execute a remote snapmirror status command, the syntax would be something like this:
plink user@filername_or_ip -pw password “snapmirror status”
I will admit, it isn’t the best method to use a clear password in a script. I don’t. I generated an ssh key and included it in my authorized_keys on my target Filer. I’m not going to go into that process in this post.
Now, the next step, is to be able to grab the information that the target filer responds with. This information would look something like this:
Snapmirror is on.
Source Destination State Lag Status
sourcefiler:/vol/nfs_volume/nfs_volume destfiler:/vol/nfs_volume_dr/nfs_volume Snapmirrored 02:09:16 Idle
Let me go into a little detail on the way the volumes are configured. On both Filers, there is a volume presented as NFS to ESX named nfs_volume. Also, there is a qtree named nfs_volume within the volume (nfs_volume).
Confusing? A little bit.
The reason I created qtrees with the same name, is because I’m doing SnapMirror replication at the qtree level, and not at the volume level. This is because to successfully replicate from volume to volume, the two Filers have to be running the same version of ONTAP. I cannot always be sure that both Filers will be at the same version (or revision), so I decided to replicate at the qtree level. Replication of qtrees does not require the Filers to be on the same version of ONTAP.
The hard part
Plink very easily returns data back from a command line. That is unless you want to pipe that to a file. And when you grab that information, how do you get it in a tangible medium.
My first script
Here is a copy of my first script. It is pretty rudimentary, but it was a start.
‘* NetApp SnapMirror Monitoring Script version 0.1
‘* October 2009
‘* Jase McCarty
‘Set our output file
outFile = “C:pathplinkout.TXT”
‘Set our Mail Server’s DNS Name
SMTPServer = “mail.domain.com”
‘Setup a Wscript Shell Object so we can execute a command line instruction
set objShell = wscript.createObject(“wscript.shell”)
‘Run the command
iReturn = objShell.Run(“CMD /C plink.exe email@example.com -pw password ” & CHR(34) & “snapmirror status” & CHR(34) & ” > ” & outFile & ” 2>>&1 “, , True)
‘ Set a File System Object, so we can read the created file
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
‘Check for the file, and read it if it is present
If objFSO.FileExists(outFile) Then
‘Start Reading the File and Loop through it
Set objFile = objFSO.OpenTextFile(outFile, 1)
Do While Not objFile.AtEndOfStream
sText = objFile.ReadLine
sMessage = sMessage & sText & VbCrLf
‘Rename the file with the current date time
objFSO.MoveFile outFile, “c:pathreplication-” & Now() & “.log”
‘Log a success and the message content to the Event log
objShell.LogEvent EVENTLOG_INFORMATION, sMessage
sSubject = “NetApp Replication Status as of ” & Now()
‘If the file isn’t present, there was a problem
sSubject = “NetApp Replication Status Script Error”
sMessage = “NetApp Replication Status Script Encountered an error with the file ” & outFile
‘Log a failure and the message content to the Event log
objShell.LogEvent EVENTLOG_ERROR, sMessage
‘Send an e-mail with the Replication status
Set objMessage = CreateObject(“CDO.Message”)
objMessage.From = “SMVI@domain.com”
objMessage.To = “firstname.lastname@example.org”
objMessage.Subject = sSubject
objMessage.Textbody = sMessage
‘This section provides the configuration information for the remote SMTP server.
‘Normally you will only change the server name or IP.
(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
‘Name or IP of Remote SMTP Server
(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = SMTPServer
‘Server port (typically 25)
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
‘End remote SMTP server configuration section
Not too bad for a rough draft
The script executes plink, and outputs the data to a file. The script then checks to make sure the file was created properly and collects the contents to be e-mailed. It also renames the file according to the time of execution, so a “physical” history of the results can be referred to later. This script can then be run as a Windows scheduled task to execute at desired intervals.
I have modified the script a little more extensively, including things like posting the results to a database as well as some replication lag alerting. Look for more information about how to do this in some followup posts.