Microsoft Virtualization Discussions

Powershell Snapmirror lagtime problem

VKS
12,972 Views

Hi Guys,

 

I am using Netapp cluster mode 8.3. when i run the powershell snapmirror command, I get the below output where the lagtime shows somthing different. can anybody help me out to get the correct output. attached the output in notepad for easy understanding. 

 

PS C:\Windows> get-ncsnapmirror | select-Object SourceLocation,DestinationLocation,Status,MirrorState,LagTime,RelationshipType,Schedule,LagTimeSpecified |FT -autosize

SourceLocation DestinationLocation Status MirrorState LagTime RelationshipType Schedule LagTimeSpecified
-------------- ------------------- ------ ----------- ------- ---------------- -------- ----------------
PEPSN00033-PI: PEPSN00033-DR: idle snapmirrored 118 data_protection SVMDR-5min True
PEPSN00033-PI:vc_amtech PEPSN00033-DR:vc_amtech idle snapmirrored 117 data_protection True
PEPSN00033-PI:vc_Pephome PEPSN00033-DR:vc_Pephome idle snapmirrored 117 data_protection True
PEPSN00033-PI:vc_rdshome PEPSN00033-DR:vc_rdshome idle snapmirrored 117 data_protection True
PEPSN00033-PI:vc_rdsprofile PEPSN00033-DR:vc_rdsprofile idle snapmirrored 117 data_protection True
PEPSN00033-PI:vc_amtech PEPSN00044-DP:PEPSN00033_vb_amtech idle snapmirrored 44036 vault Daily@0530am True
PEPSN00033-PI:vc_home PEPSN00044-DP:PEPSN00033_vb_home idle snapmirrored 44036 vault Daily@0620 True
PEPSN00033-PI:vc_rdshome PEPSN00044-DP:PEPSN00033_vb_rdshome idle snapmirrored 44036 vault Daily@0720 True
PEPSN00033-PI:vc_rdsprofile PEPSN00044-DP:PEPSN00033_vb_rdsprofile idle snapmirrored 44036 vault Daily@0420 True
PEPSN00022:vn_PEPVM00004_nfs01 PEPSN00049-DP:PEPSN00022_vb_PEPVM00004_nfs01 idle snapmirrored 64438 data_protection Daily@0230pm True
PEPSN00022:vn_PEPVM00004_nfs02 PEPSN00049-DP:PEPSN00022_vb_PEPVM00004_nfs02 idle snapmirrored 57235 data_protection Daily@0930pm True
PEPSN00022:vn_PEPVM00004_nfs03 PEPSN00049-DP:PEPSN00022_vb_PEPVM00004_nfs03 idle snapmirrored 51838 data_protection Daily@06pm True
PEPSN00022:vn_PEPVM00009_nfs01 PEPSN00049-DP:PEPSN00022_vb_PEPVM00009_nfs01 idle snapmirrored 50038 data_protection Daily@1130pm True
PEPSN00022:vn_PEPVM00009_nfs02 PEPSN00049-DP:PEPSN00022_vb_PEPVM00009_nfs02 idle snapmirrored 64432 data_protection Daily@0930pm True


PS C:\Windows>

 

regards

VK

1 ACCEPTED SOLUTION

JGPSHNTAP
12,940 Views

If we review what Netapp did in 7-mode for snapmirror, they have absolutely done a terrible job in cDOT.

 

The available lagtimeTS objects in 7-mode do not exist in cDOT, and i'm very disappointed

 

/3600 is a terrible answer from netapp.

 

The objects in 7-mode need to be ported over if they are not there

 

In the old days we could have wrote this code

 

get-nasnapmirror | select @{N='Date';E={(get-date).tostring('ddd MMM dd h:mm yyyy')}},Source,Destination,Status,State,`
@{N='Current Lag Time';E={'{0} days, {1} hrs, {2} mins, {3} secs' -f $_.LagTimeTS.days, $_.LagTimeTS.Hours, $_.LagTimeTS.Minutes, $_.LagTimeTS.Seconds}}`
,@{expression={ConvertTo-FormattedNumber $_.lasttransfersize Datasize "0.0"};Label="Last Transfer size"} `
,@{N='Last Transfer Time';E={'{0} days, {1} hrs, {2} mins, {3} secs' -f $_.LastTransferDurationTS.days, $_.LastTransferDurationTS.Hours, $_.LastTransferDurationTS.Minutes, $_.LastTransferDurationTS.Seconds}} |export-csv c:\temp\japansm.csv -notypeinformation

View solution in original post

10 REPLIES 10

asulliva
12,925 Views

Hello VK,

 

Lag time is reported as the number of seconds which the mirror lags behind the source.  You can divide the value by 3600 to get the number of hours....

 

(Get-NcSnapmirror -Destination $destination).LagTime / 3600

Hope that helps.

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

JGPSHNTAP
12,941 Views

If we review what Netapp did in 7-mode for snapmirror, they have absolutely done a terrible job in cDOT.

 

The available lagtimeTS objects in 7-mode do not exist in cDOT, and i'm very disappointed

 

/3600 is a terrible answer from netapp.

 

The objects in 7-mode need to be ported over if they are not there

 

In the old days we could have wrote this code

 

get-nasnapmirror | select @{N='Date';E={(get-date).tostring('ddd MMM dd h:mm yyyy')}},Source,Destination,Status,State,`
@{N='Current Lag Time';E={'{0} days, {1} hrs, {2} mins, {3} secs' -f $_.LagTimeTS.days, $_.LagTimeTS.Hours, $_.LagTimeTS.Minutes, $_.LagTimeTS.Seconds}}`
,@{expression={ConvertTo-FormattedNumber $_.lasttransfersize Datasize "0.0"};Label="Last Transfer size"} `
,@{N='Last Transfer Time';E={'{0} days, {1} hrs, {2} mins, {3} secs' -f $_.LastTransferDurationTS.days, $_.LastTransferDurationTS.Hours, $_.LastTransferDurationTS.Minutes, $_.LastTransferDurationTS.Seconds}} |export-csv c:\temp\japansm.csv -notypeinformation

asulliva
12,900 Views

I don't have any reason why the returned properties changed, but that doesn't mean that the same output you're seeking isn't possible.

 

#
# ref https://nzfoo.wordpress.com/2014/01/21/converting-from-unix-timestamp/
#
# Converting a Unix (epoc) timestamp to a PowerShell object
#
function Get-UnixDate ($UnixDate) {
   [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($UnixDate))
}

$mirrors = @()

Get-NcSnapmirror | %{ 
    $sm = "" | Select "Date","Source","Destination","Status","State","Current Lag Time","Last Transfer Size","Last Transfer Time"

    $sm.Date = Get-Date -Format s
    $sm.Source = $_.SourceLocation
    $sm.Destination = $_.DestinationLocation
    $sm.Status = $_.Status
    $sm.State = $_.MirrorState

    $lastTransferTime = Get-UnixDate -UnixDate $_.LastTransferEndTimestamp
    $lagTime = New-TimeSpan -Start $lastTransferTime -End (Get-Date)

    $sm."Current Lag Time" = '{0} days, {1} hrs, {2} mins, {3} secs' -f $lagTime.Days, $lagTime.Hours, $lagTime.Minutes, $lagTime.Seconds
    $sm."Last Transfer Size" = ConvertTo-FormattedNumber $_.lasttransfersize Datasize "0.0"

    $transferTime = New-TimeSpan -Seconds $_.LastTransferDuration
    $sm."Last Transfer Time" = '{0} days, {1} hrs, {2} mins, {3} secs' -f $transferTime.days, $transferTime.Hours, $transferTime.Minutes, $transferTime.Seconds
    
    $mirrors += $sm

}

$mirrors | Format-Table -AutoSize

I have forwarded this thread to product management to get their feedback...maybe we can find out what happened : )

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

JGPSHNTAP
12,896 Views

Well, I know]Beam moved to another project or I would have emailed him.. but i'm still mostly 7-mode so I'm not so angry..

 

I have a convert module I added to load to my profile everytime which was done years ago...

 

it contains the following 

 

Function Convert-UnixTime()
{
#[CmdletBinding()]

Param(

[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]
[int]$utime
)

Process {
[TimeZone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($utime))
}


}


Function Convert-togb()
{
Param (
[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]
#[int]$data
$data
)

Process {
[math]::truncate($data/1gb)
}

}

Function Convert-totib()
{
Param (
[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]
#[int]$data
$data
)

Process {
[math]::truncate($data/0.90949470177293)
}

}

 

You're way is creative and works as well.. But shouldn't have to do that... They had something that worked in 7-mode and didn't port it to cDOT.... Unfortunately, we are finding too many of these missed steps.. Hopefully the gaps will close soon

asulliva
12,890 Views

Please feel free to reach out to me (community username @netapp.com) if/when you encounter those nuances and idiosyncrasies.  I can't guarantee anything will actually be done about them, but I'm happy to communicate with product management and the development team to find out what happened and if it's possible to fix them.

 

The PowerShell Toolkit, like pretty much any product, is only valuable if you find it useful...we want to make sure it's useful for you!

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

JGPSHNTAP
12,883 Views

Thx.. Appreciate it.. I've been very active in the community since version 1.0.. 

 

So don't worry, i'm very would be very vocal

VKS
12,832 Views

Hi Guys, 

 

I think the problem can be solved by dividing the output of Lagtime/86400, which will give output in hh:mm:ss format. i tried the same in ms excel and it worked for me. now if anyone can help me out to script in powershell with this formula then i may get the desired output.

 

regards

VK

 

JGPSHNTAP
12,818 Views

If you want to use 86400 which is 24hrs, you need to use an expression within a select statement

 

Look at my examples above.. that should help you get started

VKS
12,810 Views

Hi JGPSHNTAP,

 

can you please provide some sample as i am not good in powershell scripts.

 

regards

VK

JGPSHNTAP
10,129 Views

^^

Look at the examples above... 

 

I'm not going to write it for you.

 

just do 

man select -full

Public