My SQL is not amazing.... trying to trigger an alert when the total bandwidth on specific interfaces reaches a specific amount over a period of time.... for example (Alert needs to trigger when any of those interfaces hit 25Mb in the current month). I am able to get the values for each day, and the below code works for a "Daily Alert", but does not work at the monthly level because I need to be able to group them.... here is what i currently have:
SELECT Nodes.Caption, Nodes.NodeID FROM Nodes ****BECAUSE OF HOW ORION IS WITH SQL ALERTS, THIS "Select/From" can't be changed*******
JOIN InterfaceTrafficByDays itbd ON Nodes.NodeID = itbd.NodeID ****Joined the table with the data*******
WHERE
(InterfaceID = '96662' OR InterfaceID = '85498' OR InterfaceID = '96664' OR InterfaceID = '88157' OR InterfaceID = '99464' OR InterfaceID = '99470' OR InterfaceID = '96943') ****Picked the interfaces I needed*******
AND
(((itbd.In_TotalBytes + itbd.Out_TotalBytes)/1024)/1024 >= '25') ****Took the IN/OUT Rows and did some math for 25Mb.*******
AND
(
(itbd.DateTime >= DATEADD(month, DATEDIFF(month,0,GETDATE()),0) )
AND
(itbd.DateTime < DATEADD(month, DATEDIFF(month,0,GETDATE()) +1,0) ) ****Defined that this has to happen between the beginning of the month and the end of the month*******
)
I think i need a second Select Query inside the JOIN to add a "GROUP BY", but not sure how to do that. Any help would be greatly appreciated.