Can someone tell me how to get the OID hrSystemUptime to show in the format of days hours, minutes and seconds?
documentation.solarwinds.com/.../core-transforming-poller-results-sw704.htm
This is somewhat unrelated, but may be helpful in what you are trying to accomplish. I create alerts for when an item goes down and another for when it comes back up. When it comes back up I include a line to document how long the item was down. You may be able to modify this to help.
Down for: ${SQL:Select '${N=Alerting;M=Downtime}'/1440} Days ${SQL: Select '${N=Alerting;M=Downtime}'%1440/60} Hours ${SQL: Select '${N=Alerting;M=Downtime}'%1440%60;} Minutes
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<br />>>> from datetime import datetime, timedelta<br />>>> ticks = 99439400<br />>>> seconds = ticks/100<br />>>><br />>>> # Using current time<br />>>> ini_time_for_now = datetime.now()<br />>>><br />>>> # printing initial_date<br />>>> print ("initial_date", str(ini_time_for_now))<br />initial_date 2023-05-24 10:51:21.238179<br />>>><br />>>> # Some another datetime<br />>>> new_final_time = ini_time_for_now + \<br />... timedelta(seconds=seconds)<br />>>><br />>>> # printing new final_date<br />>>> print ("new_final_time", str(new_final_time))<br />new_final_time 2023-06-04 23:04:35.238179<br />>>><br />>>><br />>>> # printing calculated past_dates<br />>>> print('Time difference:', str(new_final_time - \<br />... ini_time_for_now))<br />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 994394PS> $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.
PS> $TS = New-Timespan -Seconds 994394PS> $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 : 994394000
Showing 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.2430671296296TotalHours : 893.833611111111TotalMinutes : 53630.0166666667TotalSeconds : 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.