Community maintenance is complete. Thank you for your patience!

Active IQ Unified Manager Discussions

Strange time format from RestAPI

marcusgross

Hi,

 

if I use the RestAPI for Ontap 9.7 to get Snapmirror details, the lag time has a strange format to me:

 

i.e. PT8H35M42S or P28DT3H59M55S

 

Which format is it? How can I parse it into days, hours and minutes using Powershell?

 

Marcus

1 ACCEPTED SOLUTION

JohnChampion

This is actually ISO 8601 time span format: 

https://en.wikipedia.org/wiki/ISO_8601#Durations

 

Here's a link to a PowerShell function that might help you get the end result you want (at least the regex stuff): 

https://www.powershellgallery.com/packages/AzureSimpleREST/0.1.8/Content/internal%5Cfunctions%5CConvert-ISO8601ToTimespan.ps1 

 

View solution in original post

4 REPLIES 4

CHRISMAKI

Looking at your two examples, this is how I interpret them:

 

P28DT3H59M55S → 28 Days, 3 Hours, 59 Minutes, 55 Seconds....I think.

 

PT8H35M42S → 8 Hours, 35 Minutes, 42 Seconds.

 

Perhaps you could issue the API call at roughly the same time as the CLI command:

 

snapmirror show -fields lag-time

 

Comparing the two may provide you with the necessary insight to decode, feel free to post the output of the two here and I'll have a look.

CHRISMAKI

I've just had a look at this using a lab environment and confirm what I had stated, have a look:

 

Screen Shot 2021-03-16 at 11.07.19 AM.png

 

I was unable to grab a screenshot with the two times perfectly synced as the GUI refreshes on it's own constantly in an attempt to provide near-realtime status.

marcusgross

Hi,

 

I don't need near real-time values.  I need a format to parse it into days hour:minute.

The format of the string depends on the time. Thats a regex-if expression hell to extract the info.

 

The lag time in seconds delivered by the API is more helpful.

 

Marcus

 

JohnChampion

This is actually ISO 8601 time span format: 

https://en.wikipedia.org/wiki/ISO_8601#Durations

 

Here's a link to a PowerShell function that might help you get the end result you want (at least the regex stuff): 

https://www.powershellgallery.com/packages/AzureSimpleREST/0.1.8/Content/internal%5Cfunctions%5CConvert-ISO8601ToTimespan.ps1 

 

View solution in original post

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public