Microsoft Virtualization Discussions

Convert "LagTimeTS" output for Snapmirror into Days...

BAPTISTE_REVERET
3,068 Views

Hi,

i try to make a script to check snapmirror status and lagtimets.

Import-Module DataONTAP

Connect-NaController netapp-bap1 -Credential root

Get-NaSnapmirror | Format-Table -AutoSize SourceLocation,DestinationLocation,Status,State,LagTimeTS,LastTransferSize,LastTransferDuration

The output for this command give me this :

SourceLocation    DestinationLocation Status State  LagTimeTS  LastTransferSize LastTransferDuration

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

netapp-bap1:Prod1 netapp-bap2:Prod1   idle   source 2.15:15:19           471040                    5

Is there any ways to extract the date of the last successful snapmirror from LagTimeTS ?

I wanted to have something like :

the last date of successful Snapmirror is "..."

Or The Last successful Snapmirror date back to "..."

Thx for your help !

1 ACCEPTED SOLUTION

BAPTISTE_REVERET
3,068 Views

Finally, i find my own way to get the time info :

$controller = "XXX"

$vol = Get-NaVol


Import-Module DataONTAP

Connect-NaController $controller -Credential root

          Write-Host "SNAPMIRROR"

foreach ($snapmirror in $vol)

{

$status = (Get-NaSnapmirror $snapmirror).Status

$first = (Get-NaSnapmirror $snapmirror).LagTimeTS

$second = $first.Seconds

if ($second) {

          (Get-NaSnapmirror $snapmirror.name).LagTimeTS | foreach {write-host "Le SnapMirror du volume $snapmirror date de" $_.Days "jour" $_.Hours "heures" $_.Minutes "minutes | Status - $status"}

          Write-Host "  "

}

}

Thanks Clinton for your help and the clue on 'null values'.

View solution in original post

3 REPLIES 3

cknight
3,068 Views

Not difficult.  First, here we have a snapmirror with a 200-day lag time:

PS C:\> Get-NaSnapmirror dunn:vol2 | select LagTimeTS

LagTimeTS

---------

200.03:28:47

Let's get the last mirror date by subtracting that interval from the current date/time:

PS C:\> $lagTime = Get-NaSnapmirror dunn:vol2 | select -ExpandProperty LagTimeTS

PS C:\> $lastDate = [DateTime]::Now.Subtract($lagTime)

PS C:\> $lastDate

Tuesday, March 20, 2012 12:30:34 PM


Don't forget to check for null values of LagTimeTS.

BAPTISTE_REVERET
3,068 Views

It seems to work but the date have changed between two launch of my script.

I can see that in the file where i make the output of the command.

mercredi 3 octobre 2012 20:50:21

mercredi 3 octobre 2012 20:50:29

mercredi 3 octobre 2012 20:50:38

BAPTISTE_REVERET
3,069 Views

Finally, i find my own way to get the time info :

$controller = "XXX"

$vol = Get-NaVol


Import-Module DataONTAP

Connect-NaController $controller -Credential root

          Write-Host "SNAPMIRROR"

foreach ($snapmirror in $vol)

{

$status = (Get-NaSnapmirror $snapmirror).Status

$first = (Get-NaSnapmirror $snapmirror).LagTimeTS

$second = $first.Seconds

if ($second) {

          (Get-NaSnapmirror $snapmirror.name).LagTimeTS | foreach {write-host "Le SnapMirror du volume $snapmirror date de" $_.Days "jour" $_.Hours "heures" $_.Minutes "minutes | Status - $status"}

          Write-Host "  "

}

}

Thanks Clinton for your help and the clue on 'null values'.

Public