I'd like to convert SWIS cast/convert Orion.Nodes.SystemUptime to a days/hours/mins format in SWIS. Is this possible?
I think I stole this method from someone else on thwack in the past, but this is typically how I perform Day/Hour/Minute for any custom SWQL widgets of mine:
SELECTn.Caption, n.LastBoot, CASEWHEN TOSTRING(FLOOR(HOURDIFF(n.LastBoot,GETUTCDATE())/24.0)) <> 0THEN CONCAT(TOSTRING(FLOOR(HOURDIFF(n.LastBoot,GETUTCDATE())/24.0)), 'd') ELSE ''END + ' '+ CASEWHEN TOSTRING(FLOOR(MINUTEDIFF(n.LastBoot,GETUTCDATE())/60.0 % 24)) <> 0THEN CONCAT(TOSTRING(FLOOR(MINUTEDIFF(n.LastBoot,GETUTCDATE())/60.0 % 24)), 'h') ELSE ''END + ' '+ CASEWHEN TOSTRING(FLOOR(MINUTEDIFF(n.LastBoot,GETUTCDATE())%60)) <> 0THEN CONCAT(TOSTRING(FLOOR(MINUTEDIFF(n.LastBoot,GETUTCDATE())%60)), 'm') ELSE ''END AS [Uptime]FROM Orion.Nodes nORDER BY n.SystemUpTime DESC
You can use this method for any table that has a DateTime formatted field. You would just replace "n.LastBoot" in each of the CASE statements with whatever the DateTime field would be.Since this converts the duration to a string, I would still use a DateTime field for your ORDER BY statement so you can preserve ascending/descending order for duration.
SWQL Guru @tdanner posted a reply in this: thwack.solarwinds.com/.../given-sysuptime-in-seconds-how-are-you-doing-date-math-to-display-days-hours-mins-secondsAlso try looking at LastBoot as it is in a DateTime format.
SELECTn.Caption,n.Lastboot,DayDiff(n.LastBoot, GetUtcDate()) as [Days_Since_LastBoot],n.SystemUptime AS [SystemUpTime_Seconds],ROUND( n.SystemUpTime / 86400, 0 ) AS [SystemUpTime_Days]FROM Orion.Nodes nORDER BY n.SystemUptime DESC
And if you haven't seen it: github.com/.../SWQL-Functions
PALO-ALG - Logging.xmlPalo Alto Networks ALG Security Technical Implementation Guide :: Version 2, Release: 3 Benchmark Date: 27 Oct 2022
Alert Cleared.htmlHello, I would like to share the HTML template details we have prepared so that Solarwinds alarms can become more meaningful. It can list alarm object details and connected device details separately in HTML template. Except for object and device details, you can easily add custom property information…
Cisco ASR Devices.pollerCisco ASR Devices
SWQL is built on the framework of SQL and as such supports most of the standard clauses as part of a query. A very simple example query is: SELECT Caption, IPAddress, Vendor, ResponseTime FROM Orion.Nodes Dissecting this query is relatively straightforward: show some fields (Caption, IP address, Vendor, and Response Time)…