Archive

Posts Tagged ‘SMVI’

NetApp SnapMirror Monitor Script – Part 3 with DataONTAP PowerShell Toolkit v1.0

June 15th, 2010 4 comments

My second attempt also worked out pretty well, but the DataONTAP PowerShell Toolkit, has been released, and I wanted to update my script to leverage a supported toolkit. If you have a NetApp, and are getting deeper into using Powershell, this toolkit is for you.

I’m not going to go deep into the details of how this script works, as most of that is covered in the previous post.

What I am going to detail is the difference between the old and new scripts.

The Old Script

#Load the PoshOnTap Module
Import-Module PoshOnTap

#Connect to the Filer
Connect-NaServer -Filer netapp2

#Pull The Data
$body = Get-NaSnapMirror|Select Source,Destination,Status,State,Lag,LastTransferSize,LastTransferDurration|Out-String

#Send e-mail
Send-MailMessage -From "user@yourdomain.com" -To "user@yourdomain" -Subject "NetApp Replication Script" -SmtpServer mail.domain.com -Body $body

The New Script

#Load the DataONTAP Module
Import-Module DataONTAP

#Connect to the Filer
Connect-NaController netapp2

#Pull The Data
$body = Get-NaSnapmirror|Select SourceLocation,DestinationLocation,Status,State,LagTime,LastTransferSize,LastTransferDuration|Out-String

#Send e-mail
Send-MailMessage -From "user@yourdomain.com" -To "user@yourdomain" -Subject "NetApp Replication Script" -SmtpServer mail.domain.com -Body $body

The only differences between the 2 scripts are at lines 5 and 8.

Line 5:

  • Connect-NaServer -Filer becomes Connect-NaController

Line 8:

  • Source becomes SourceLocation
  • Destination becomes DestinationLocation
  • Lag becomes LagTime
  • LastTransferDurration becomes LastTransferDuration (obvious typo in PoshOnTap)

Other than those 2 lines, the scripts are identical.

I’d like to give a shout out to Glenn Sizemore for leading the way with PoshOnTap and NetApp for following his lead with the DataONTAP PowerShell Toolkit.

Update to this post
I was digging a little deeper on this post, and apparently dates are returned as INT64 Integers.  Makes things a little messy, and requires some data manipulation.

There’s a post about it on the NetApp Communities that details a workaround (again, kind of messy).  PoshOnTap handles dates better, so maybe NetApp will see the issue, and quickly release a v1.1 of the toolkit to correct the problem.  Nevertheless, I’ll continue using the supported (albeit a little more clunky with regard to dates) toolkit.

As soon as I find a clean/optimized way to address the situation, I will update this post.

Using Powershell I can execute the same command, and actually get more information.
Categories: Virtualization Tags: , , ,

VMworld 2010 Call for Papers – Need a little help

May 14th, 2010 No comments

Well I have submitted papers for the last 3 VMworlds, and unfortunately have not been selected.  I’ll admit some of those previous submissions were good enough, but missed a the oomph to put them over the top.

I submitted a paper, yes, just a single paper this year, and with some help, I could be selected.  This year, VMware is doing something a little different.  Public voting is being considered in the select process.

The paper I submitted details how to leverage VMware vSphere, NetApp SnapMirror, NetApp SnapManager for Virtual Infrastructure (SMVI), vSphere PowerCLI, and PoshOnTap to spin up a warm DR site.  I chose this topic, because this is how I set a solution up last year when VMware SRM did not support NFS storage.  This session talks about how to quickly recover a SnapMirror replicated site using PowerCLI, with some PoshOnTap included.

So if you feel like voting for my session, head over to VMworld.com at the following URL: http://www.vmworld.com/community/conferences/2010/cfpvote/pcbusiness.

You will be required to login to vote, but joining VMworld.com is free.

Thanks for any and all votes, and best of luck to everyone else who submitted a paper/presentation.

NetApp SnapMirror Monitor Script – Part 2 using PoshOnTap

March 21st, 2010 2 comments

My first attempt at this worked out pretty well, but I’ve been looking into PoshOnTap, and come up with a more efficient script.  PoshOnTap is really something to look at if you have a NetApp, and are getting deeper into using Powershell.

To get started, download PoshOnTap from http://poshontap.codeplex.com/, and install it.

Once PoshOnTap is installed, to use the cmdlets, it must be imported into your Powershell session using Import-Module PoshOnTap

Now to connect to my second filer, the one that is performing the SnapMirror role, I need to connect to it.  This is done with Connect-NaServer -Filer filername -UserName user -Password password. I’ve omitted the username and password, as my Filer is joined to my Active Directory Domain.  My Powershell session is being run from an account which is part of the domain.

In my previous post, I had to remotely execute a “snapmirror status” command using ssh through plink.  Not very elegant.  From the command line, “snapmirror status”, will only show Source, Destination, State, Lag, and Status.

Using Powershell I can execute the same type command, and actually get more information. Information like:

  • BaseTimeStamp (time of the last update)
  • BaseSnaphot (name of the Snapshot on the destination filer)
  • ContentState
  • CurrentTransferSize (showing the size of a current transfer)
  • CurrentTransferType
  • LastTransferSize (how many bytes were transferred)
  • LastTransferDuration (how long the last SnapMirror took)
  • LastTransferType (Did an initialization occur? Did an update take place?)

So how would I get the same information through Powershell?

Get-NaSnapMirror by itself will show the same information as snapmirror status does, albeit in a different order.

Now, if we change the output format from Format-Table (default) to Format-List (or FL) we will see some very different output.

Now to use some of that output for our monitoring.  I created the following script to pull more information than my last script

#Load the PoshOnTap Module
Import-Module PoshOnTap

#Connect to the Filer
Connect-NaServer -Filer netapp2

#Pull Our Data
get-NaSnapMirror|select Source,Destination,Status,State,Lag,LastTransferSize,LastTransferDurration|ft

Which returns

Now, to get the output into e-mail, I’m going to have to massage the output a little bit.  Here’s the resulting script:

#Load the PoshOnTap Module
Import-Module PoshOnTap

#Connect to the Filer
Connect-NaServer -Filer netapp2

#Pull The Data
$body = Get-NaSnapMirror|Select Source,Destination,Status,State,Lag,LastTransferSize,LastTransferDurration|Out-String

#Send e-mail
Send-MailMessage -From "user@yourdomain.com" -To "user@yourdomain" -Subject "NetApp Replication Script" -SmtpServer mail.domain.com -Body $body

Which will give an output something like this:

Pretty cool how Powershell will let us use less code, and get more done.

I can add “Where-Object { $_.Lag -gt “01:0:00″} |” between “Get-NaSnapMirror |” and “Select Source,” to only show the volumes that have a lag greater than 1 hour.  Again, pretty flexible.

Now I’m off to work on Part 3, where I post this information to a SQL database for historical purposes.

Using Powershell I can execute the same command, and actually get more information.

NetApp SnapMirror Monitor Script – Part 1

January 25th, 2010 4 comments

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 user@netapp.domain.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

Loop

‘Rename the file with the current date time
objFSO.MoveFile outFile, “c:pathreplication-” & Now() & “.log”
objFile.Close

‘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
Else

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

End If

‘Send an e-mail with the Replication status
SendEMail sSubject,sMessage

Sub SendEmail(sSubject,sMessage)

Set objMessage = CreateObject(“CDO.Message”)
objMessage.From = “SMVI@domain.com”
objMessage.To = “user@domain.com”
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.
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2

‘Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = SMTPServer

‘Server port (typically 25)
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25

objMessage.Configuration.Fields.Update

‘End remote SMTP server configuration section

objMessage.Send

End Sub

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.