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

4 REPLIES 4

Re: Strange time format from RestAPI

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.

Re: Strange time format from RestAPI

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.

Re: Strange time format from RestAPI

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

 

Re: Strange time format from RestAPI

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

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums
Public