Here is Report Writer SQL code that produces the duration of down time for a node. I need to be able to convert this to SWQL and populate the 'hours down' time into a custom property field. I want to use the 'hours down' time custom property field in conjunction with changing Google map Icon colors once time frame meets specified thresholds. I'm not very savvy with SQL or coding so all suggestions are welcome. Thanks everyone.
SELECT DATEDIFF(hh, T1.DownTime, CURRENT_TIMESTAMP) AS HoursDown, Nodes.Caption, Nodes.IP_Address,
T1.DownTime, Nodes.NodeID
FROM (SELECT MAX(EventTime) AS DownTime, NetObjectID, NetworkNode
FROM Events
WHERE (EventType = 1) AND (NetObjectType = 'N')
GROUP BY NetObjectID, NetworkNode) AS T1 INNER JOIN
Nodes ON T1.NetworkNode = Nodes.NodeID
WHERE (Nodes.Status = '2') AND (Nodes.Owner = 'RHD')
ORDER BY HoursDown DESC, Nodes.Caption, T1.DownTime DESC, Nodes.NodeID
Output from this Query:
HoursDown | Node | IP Address | DownTime | Node ID |
139 | rtr.316864.ph.us.tgr.net | 10.165.4.1 | 11/2/2012 14:18 | 18188 |
131 | rt2.023675.ph.us.tgr.net | 10.180.119.2 | 11/2/2012 22:13 | 16384 |
120 | rt2.013146.ph.us.tgr.net | 10.81.4.2 | 11/3/2012 9:56 | 15487 |
63 | rt2.013426.ph.us.tgr.net | 10.250.112.2 | 11/5/2012 18:13 | 15560 |
42 | rtr.023040.ph.us.tgr.net | 10.80.164.1 | 11/6/2012 15:48 | 16194 |
41 | rt2.012626.ph.us.tgr.net | 10.81.76.2 | 11/6/2012 16:55 | 15348 |
39 | rt2.013236.ph.us.tgr.net | 10.7.34.2 | 11/6/2012 18:22 | 15534 |
39 | rtr.023016.ph.us.tgr.net | 10.80.141.1 | 11/6/2012 18:01 | 16174 |
36 | rt2.008384.ph.us.tgr.net | 10.74.64.2 | 11/6/2012 21:13 | 14776 |
24 | rt2.026530.ph.us.tgr.net | 10.76.43.2 | 11/7/2012 9:46 | 17140 |
17 | rt2.013122.ph.us.tgr.net | 10.81.94.2 | 11/7/2012 16:11 | 15475 |
17 | rt2.013139.ph.us.tgr.net | 10.81.103.2 | 11/7/2012 16:18 | 15484 |
16 | rtr.012934.ph.us.tgr.net | 10.82.80.1 | 11/7/2012 17:48 | 15429 |
15 | rt2.006231.ph.us.tgr.net | 10.13.12.2 | 11/7/2012 18:28 | 14567 |