solarwinds / OrionSDK

SDK for the SolarWinds Orion platform, including tools, documentation, and samples in PowerShell, C#, Go, Perl, and Java.
https://thwack.com/OrionSDK
Apache License 2.0
397 stars 139 forks source link

Format SWQL on command [Enhancement] #296

Open kmsigma opened 3 years ago

kmsigma commented 3 years ago

What are the chances that we could add a button (or shortcut key, etc.) to format the SWQL Query after we copy and paste all over a ton? The plugin I use from within Notepad++ is published at TaoK/PoorMansTSqlFormatter and it does exactly what I need about 95% of the time.

Not that you need them, but these are the settings I use:

image

Makes my SWQL very pretty regardless of how it looked before:

SELECT [N].Caption AS [Node]
     , [N].DetailsUrl AS [_LinkFor_Node]
     , [N].Status AS [_IconFor_NodeStatus]
     , [N].IP_Address AS [IP Address]
     , [N].DetailsUrl AS [_LinkFor_IP Address]
     , [N].StatusDescription AS [Status Description]
     , [N].ObjectSubType AS [Collection Type]
     , [N].Engine.ServerName
     , [N].statcollection AS [Interval]
     , CASE 
          WHEN [N].ObjectSubType != 'SNMP'
               THEN 'Not Used'
          WHEN [N].Community = ''
               THEN 'Not Used'
          ELSE [N].Community
          END AS [SNMPv2 Community]
     , CASE 
          WHEN c.Name IS NULL
               THEN 'Not Used'
          ELSE c.Name
          END AS [WMI/SNMPv3 Credential]
     , ToLocal([N].LastSystemUptimePollUTC) AS [Last Stat Collection]
     , ToLocal([N].LastSync) AS [Last Ping]
     , DayDiff(LastSystemUptimePollUTC, GetUtcDate()) AS [Days Since Polled]
     , 'Edit' AS [Edit]
     , '/Orion/Nodes/NodeProperties.aspx?Nodes=' + ToString([N].NodeID) AS [_LinkFor_Edit]
     , '/Orion/images/nodemgmt_art/icons/icon_edit.gif' AS [_IconFor_Edit]
FROM Orion.nodes AS n
LEFT JOIN Orion.NodeSettings AS ns
     ON [N].NodeID = ns.NodeID
          AND SettingName LIKE '%Credential%'
LEFT JOIN Orion.Credential AS c
     ON ns.SettingValue = c.ID
INNER JOIN Orion.Engines e
     ON e.engineid = [N].engineid
WHERE STATUS <> 2
     AND STATUS <> 9
     AND objectsubtype != 'ICMP'
     AND minutediff(lastsystemuptimepollUTC, getutcdate()) > 20
     --and DayDiff(lastsystemuptimepollUTC,getutcdate())>1