Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all articles
Browse latest Browse all 2677

How to Get a List of Down Devices and the Time They Went Down?

$
0
0

I have found several permutations of this question, but could never track down a solid answer for my specific question. I need to run an SQL Query via the reporting Resource. I am a network admin so my SQL knowledge is rather limited, but I do have a background in coding. Below is my attempt at a basic start to this mess:

 

     SELECT Nodes.Caption as Name,  Nodes.Status as Status, Nodes.Monitoring_CAT as Is_CAT, EventTime as Events

     FROM [dbo].[Nodes], [dbo].[Events]

     WHERE Nodes.Monitoring_CAT=1 AND (Status=0 OR Status=2)

     ORDER BY Nodes.Caption

 

This query above does work. So, down to the root of my issues...

    1. I need to be able to get the Last event from EventTime, but have no clue how to do that. I suspect there some crazy INNER JOIN stuff for that one.

 

I was using the Query below for reference from another Thwack post, but there is very little I can understand from it once you get into the event time section:

 

SELECT * FROM (

    SELECT

    Nodes.StatusLED,

    Nodes.Caption,

    Nodes.NodeID,

    Nodes.MachineType,

    StartTime.Message,

    StartTime.EventTime AS DownEventTime,

    Monitoring_CCM,

    (

        SELECT TOP 1 EventTime

    ) AS UpEventTime,

DATEDIFF(Mi, StartTime.EventTime,(

            SELECT TOP 1 EventTime FROM Events AS Endtime

            where EndTime.EventTime > StartTime.EventTime AND EndTime.EventType = 5 AND EndTime.NetObjectType = 'N'

                AND EndTime.NetworkNode = StartTime.NetworkNode ORDER BY EndTime.EventTime)

        ) AS OutageDurationInMinutes

    FROM Events StartTime

    INNER JOIN Nodes ON StartTime.NetworkNode = Nodes.NodeID

    WHERE (StartTime.EventType = 1)

) AS UpTimeTable

where outageDurationInMinutes IS NOT NULL AND outageDurationInMinutes >= '15'

AND datepart(hour, DownEventTime) >= 8

AND datepart(hour, UpEventTime) >= 8

AND datepart(hour, DownEventTime) <= 17

AND datepart(hour, UpEventTime) <= 17

ORDER BY Caption ASC, DownEventTime DESC

 

 

All help is appreciated, Thanks!


Viewing all articles
Browse latest Browse all 2677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>