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.
Jase – this got it working in windows time format. grabbed the snippet from fjohn here:
http://communities.netapp.com/thread/8879
#Pull The Data
$body = Get-NaSnapmirror|Select SourceLocation,DestinationLocation,Status,State,
@{Name=”LagTime”;Expression={[timezone]::CurrentTimeZone.ToLocalTime(([datetime]’1/1/1970′).AddSeconds($_.LagTime))}},
LastTransferSize,LastTransferDuration|Out-String
hope this pastes well
-don
Thanks for the extra legwork!
I’ve been a little too busy to push it over the edge.
Thanks Jase for the fantastic starting ground here. Excellent work, nice of you to make my life easier.
I would like to point out a couple tweaks that will make the time output human readable.
According to Clinton Knight at the below discussion, we can use the LagTimeTS and LastTransferDurationTS to give us a more human readable output.
http://communities.netapp.com/message/46541
Output will look like this:
SourceLocation : Filer1:NFS1
DestinationLocation : Filer2:NFS1_Mirror
Status : idle
State : snapmirrored
LagTimeTS : 11:26:28
LastTransferSize : 13794803712
LastTransferDurationTS : 00:57:05
My next step is to convert the transfer size to MB rather than just bytes.
Good code there. I haven’t really had any need for NetApp code lately, given that I work for EMC.
Cheers,
Jase