cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, please help. What is the format of systemUpTime in an answer of API GET call of /xapi/v1/monitor/devices?ownerID=xxxxxx

Hello, please help. What is the format of systemUpTime in an answer of API GET call of /xapi/v1/monitor/devices?ownerID=xxxxxx

jozef_rebjak
New Contributor

For me its showing "systemUpTime": 1568392255171,

 

in a HiveManager it's equal to the someting around 37d 15h 4m. I want to convert it to the human time. Thank you

 

 

2 REPLIES 2

jozef_rebjak
New Contributor

@Doug Kraemer​ Hello,

 

Thank you. You helped me a lot. I decided to share solution to get human readable output. Here is the BASH script if it will somebody need it. 

I will publish a full Nagios script on GitHub later.

 

#!/bin/bash

 

# Example value from the output of API CALL

AP_UPTIME=1568392266173 

 

# Get current timestamp in milliseconds

CURRENT_TIME=`date +%s%3N`

 

# Difference between current date and date since AP was active

UPTIME=$(( $CURRENT_TIME - $AP_UPTIME ))

 

# Converting from milliseconds to seconds

CONVERT=`echo "scale=2;${UPTIME}/1000" | bc`

 

# Rounding seconds

seconds=`echo $CONVERT | awk '{printf("%d
",$1 + 0.5)}'`

 

# Converting to Days, Hours, Minutes, Seconds

OUTPUT=`eval "echo $(date -ud "@$seconds" +'$((%s/3600/24)) days %H hours %M minutes %S seconds')"`

echo $OUTPUT

 

# Example Output: 38 days 17 hours 10 minutes 23 seconds

 

dkraemer
New Contributor

Hello,,

That is the Unix Time stamp. tells you the date it has been active since, you will need to subtract that from the current date to get the uptime. You may use this page to do manual conversions, but it also has examples of how to convert it in almost all programming languages, and even some programs like Excel.

https://www.epochconverter.com/

 

-Doug Kraemer

-ASC

GTM-P2G8KFN