Can someone tell me how to get the OID hrSystemUptime to show in the format of days hours, minutes and seconds?
Can someone tell me how to get the OID hrSystemUptime to show in the format of days hours, minutes and seconds?
Well, that depends on the system reporting it. The reference for the OID says it returns TICKS. On some systems a TICK=SECONDS/100 it is different on others. The OID that Cisco uses is hundredths of a second. So, a PYTHON conversion might look like:
>>> # Timedelta function demonstration
>>> from datetime import datetime, timedelta
>>> ticks = 99439400
>>> seconds = ticks/100
>>>
>>> # Using current time
>>> ini_time_for_now = datetime.now()
>>>
>>> # printing initial_date
>>> print ("initial_date", str(ini_time_for_now))
initial_date 2023-05-24 10:51:21.238179
>>>
>>> # Some another datetime
>>> new_final_time = ini_time_for_now + \
... timedelta(seconds=seconds)
>>>
>>> # printing new final_date
>>> print ("new_final_time", str(new_final_time))
new_final_time 2023-06-04 23:04:35.238179
>>>
>>>
>>> # printing calculated past_dates
>>> print('Time difference:', str(new_final_time - \
... ini_time_for_now))
Time difference: 11 days, 12:13:14
In other environments is can be different for example on my MS Windows PC using PowerShell you get:
PS> $TS = New-Timespan -Seconds 994394
PS> $TS
Days : 11
Hours : 12
Minutes : 13
Seconds : 14
Milliseconds : 0
Ticks : 9943940000000
TotalDays : 11.5091898148148
TotalHours : 276.220555555556
TotalMinutes : 16573.2333333333
TotalSeconds : 994394
TotalMilliseconds : 994394000Showing TICKS at 12,340,000,000 is SECONDS*10,000,000 or put another way SECONDS=TICKS/10,000,000.
Really need to know where you want the conversation to occur.
Thanks for your response, the system that is reporting the system uptime is a Palo Alto Firewall
I checked and the Palo Alto firewall is using the standard seconds = ticks/100. Our firewall responded with 321780053. Using PowerShell [because it is easy]
$TS = New-Timespan -Seconds (321780053/100)
$TS
Days : 37
Hours : 5
Minutes : 50
Seconds : 1
Milliseconds : 0
Ticks : 32178010000000
TotalDays : 37.2430671296296
TotalHours : 893.833611111111
TotalMinutes : 53630.0166666667
TotalSeconds : 3217801
TotalMilliseconds : 3217801000
This corresponds to the Uptime reported in the GUI.
You can transform the Universal poller on that OID to get the Number of Days the system has been up:
Truncate((({hrSystemUptime}/100)/3600)/24,4) or
Truncate((({hrSystemUptime}/8640000),4)
This gives you 4 decimal places which gets you down into milliseconds, if you need it.
Tominannlli, thanks for the insight worked great? Another question, I have a dashboard with a custom table showing firewall objects how can I add this UDP as a column in the table?
Tominannlli, thanks for the insight worked great? Another question, I have a dashboard with a custom table showing firewall objects how can I add this UDP as a column in the table?
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 195,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.