Microsoft Virtualization Discussions

DataONTAP snap mirror status lagtime problem

andrew_gay
9,752 Views

Hey guys,

I'm new to Netapp and also Powershell so bare with me if i sound like a newbie.

I have implemented this script into powershell so send a snap mirror status result to email

#Load the DataONTAP Module

Import-Module DataONTAP

#Connect to the snapmirror filer

Connect-NaController ip.ip.ip.ip

#Pull the data

$body = Get-NaSnapmirror | ft SourceLocation,DestinationLocation,Status,State,@{Name="Lagtime";Expression={ConvertTo-Time $_.Lagtime}},LastTransferSize,LastTransferDuration|Out-String

#Send email report

Send-MailMessage -From "from" -To "me.com" -Subject "Snap Mirror Status" -SmtpServer ip.ip.ip.ip -Body $body

#end

its just a simple piece of code but when it comes to the lagtime, it displays a data of 1/1/1970

any ideas on what i could do to get around this?

thanks

1 ACCEPTED SOLUTION

cknight
9,752 Views

Try this:

PS C:\> Get-NaSnapmirror | ft SourceLocation,DestinationLocation,Status,State,LagTimeTS

SourceLocation          DestinationLocation     Status                  State                   LagTimeTS
--------------          -------------------     ------                  -----                   ---------
dunn:vol2               benson:dunn_vol2_mirror transferring            source                  130.20:04:02
dunn:vol2               dunn:dunn_vol2_mirror   idle                    unknown                 00:00:00
dunn:AS_5_12_1          fas2050b:AS_5_12_1_N... idle                    source                  20.20:29:31
dunn:SC_3_3_0           fas2050b:SnapCreator... idle                    source                  20.20:29:04

The snapmirror object has two lag values: LagTime is just the unix time value (seconds since 1/1/1970) as reported by Data ONTAP, while LagTimeTS is the same value converted to a .NET TimeSpan object.  The latter provides various methods to display or manipulate the lag time.

View solution in original post

9 REPLIES 9

lagenevoise
9,752 Views

Andrew,

I'm not use powershell however:

It's seem normal, Lag time is mumber of Hours:Minutes:Seconde since last succeed transfert. (with snapmirror status)

You retreive the number of sec since the last transfert, il you want to have the date you must do something like that now - lag --> convert to Human Time.

now (number of secon since 01/01/1970 (0 Epoc Time))

Regards

cknight
9,753 Views

Try this:

PS C:\> Get-NaSnapmirror | ft SourceLocation,DestinationLocation,Status,State,LagTimeTS

SourceLocation          DestinationLocation     Status                  State                   LagTimeTS
--------------          -------------------     ------                  -----                   ---------
dunn:vol2               benson:dunn_vol2_mirror transferring            source                  130.20:04:02
dunn:vol2               dunn:dunn_vol2_mirror   idle                    unknown                 00:00:00
dunn:AS_5_12_1          fas2050b:AS_5_12_1_N... idle                    source                  20.20:29:31
dunn:SC_3_3_0           fas2050b:SnapCreator... idle                    source                  20.20:29:04

The snapmirror object has two lag values: LagTime is just the unix time value (seconds since 1/1/1970) as reported by Data ONTAP, while LagTimeTS is the same value converted to a .NET TimeSpan object.  The latter provides various methods to display or manipulate the lag time.

andrew_gay
9,752 Views

Works perfectly! thank you!

andrew_gay
9,752 Views

one more thing, when I perform a snapmirror status via a putty connection to the controller, the give different lag times? any ideas?

thanks again!

cknight
9,752 Views

Snapmirror lag times naturally vary continuously based on multiple factors.  The CLI values appear to display in hh:mm:ss format (i.e. 503:10:27), whereas the TimeSpan values use dd.hh:mm:ss format (i.e. 20.23:10:27) by default.

andrew_gay
9,752 Views

thanks again for the helpful comment!!

One more thing hopefully you could help me with, when using the FT command within this type of string -

$body = Get-NaSnapmirror | FT SourceLocation,DestinationLocation,MirrorTimestampDT,Status,State,lagtimeTS,LastTransferSize,LastTransferDurationTS|Out-String

the results look like this -

SourceLocation DestinationLoc MirrorTimestam Status         State          LagTimeTS      LastTransferSi LastTransferDu

               ation          pDT                                                                     ze rationTS    

-------------- -------------- -------------- ------         -----          ---------      -------------- --------------

x650003:xxx... S650001:CEE... 11/01/2011 ... idle           snapmirrored   00:17:16           2836705280 00:02:30    

x650003:xxx... S650001:CEE... 11/01/2011 ... idle           snapmirrored   00:12:16            250089472 00:00:31    

x650003:xxx... S650001:CEE... 10/01/2011 ... idle           snapmirrored   20:17:13          10474045440 00:02:59    

x650001:xxx... S650003:CEE... 11/01/2011 ... idle           source         00:17:16            821231616 00:00:52    

x650001:xxx... S650003:CEE... 11/01/2011 ... idle           source         00:12:16            240975872 00:00:25    

x650001:xxx... S650003:CEE... 10/01/2011 ... idle           source         20:17:16           2132885504 00:01:21    

x650001:vxxx   S650004:CEE... 11/01/2011 ... idle           source         00:17:16              8740864 00:00:09  

is there anyway to space out the table?

thanks!

cknight
9,752 Views

You might try increasing the width of your window.  Also experiment with the -Autosize parameter to Format-Table.  But any way you slice it, that's a lot of columns to fit into a table.

andrew_gay
9,752 Views

thanks once again for all your advice!!

One more quick question, when incorperating more than one filer, i tried to use a for each loop but when it comes to sending the email, i get back an error saying the body argument is null or empty?

$filers = @()

$filer += "00.000.0.00"

$filer += "00.000.0.00"

$body  = @()

ForEach($filer in $filers)

{

      Connect-nacontroller $filer

      $snapstat = Get-NaSnapMirror select SourceLocation,DestinationLocation|out-string

      $body = $body + $snapstat

      disconnect-nacontroller

}

#end

$body = $body|out-string

Send-MailMessage -From "server.com" -To "me.com" -Subject "Snap Mirror Status" -SmtpServer 10.10.10.10 -Body $body

glenn_sizemore
9,752 Views

How about something like this.

# Connect to target controllers.            
$Controllers = 'Ntap01','Ntap02' |             
    ForEach-Object {            
        Connect-NaController -Name $_ -Transient            
    }            
            
# Get the snapmirror status foreach controller.            
$body = $Controllers | ForEach-Object {            
    Get-NaSnapmirror -Controller $_ |             
        Format-Table SourceLocation,DestinationLocation,Status,State,LagTimeTS -AutoSize            
}            
            
# Send status in an email.            
Send-MailMessage -From "server.com" `
    -To "me.com" `
    -Subject "Snap Mirror Status" `
    -SmtpServer 10.10.10.10 `
    -Body ($body|Out-String)

Hope that helps,

~Glenn

Public