HI,
Following the "SOLARWINDS LAB #65 - Orion Database Maintenance" and after some issues with the maintenance job taking a good few hours to run i created some reports that run to check the duration without trawling the logs daily.
The first report is the daily report within Orion and is scheduled to run at 8am each day (maintenance runs at 2:15am), it's a simple SQL query looking for EventType 1000 in the Events DB table:
SELECT TOP 1000
[EventTime]
,[EventType]
,[Message]
,[Acknowledged]
,[EngineID]
FROM [SolarWindsOrionNPM].[dbo].[Events]
WHERE EventType = '1000' and EventTime between dateadd(day,-1,getutcdate()) and getutcdate()
ORDER by EventTime ASC
this gives me:
if i can't or forget to check my emails everyday and i want to see how this compares to previous days i then have to rely on a native SQL job to run this script to catch the starting and completed messages and give me the duration for each day over the last 30 days:
WITH Starting as
(
SELECT
[EventTime] as 'StartTime'
,[Message]
,datepart(day,EventTime) as 'ID'
FROM [SolarWindsOrionNPM].[dbo].[Events]
WHERE EventType = '1000'
and message = 'Starting Nightly Maintenance'
and EventTime between dateadd(day,-30,getutcdate()) and getutcdate()
),
Completed as
(
SELECT
[EventTime] as 'Endtime'
,[Message]
,datepart(day,EventTime) as 'ID'
FROM [SolarWindsOrionNPM].[dbo].[Events]
WHERE EventType = '1000'
and message = 'Nightly Maintenance Completed'
and EventTime between dateadd(day,-30,getutcdate()) and getutcdate()
)
SELECT starting.StartTime, Completed.EndTime, datediff(minute, starting.StartTime, Completed.endtime) 'Job Duration in Minutes' from starting left join completed on starting.id = completed.id
In my case i output to CSV and get:
"StartTime","EndTime","Job Duration in Minutes"
"5/24/2018 2:15:00 AM","5/24/2018 3:54:35 AM","99"
"5/25/2018 2:15:01 AM","5/25/2018 3:48:33 AM","93"
"5/26/2018 2:15:00 AM","5/26/2018 4:05:02 AM","110"
"5/27/2018 2:15:00 AM","",""
"5/28/2018 2:15:00 AM","",""
"5/30/2018 2:15:00 AM","5/30/2018 9:09:25 AM","414"
"5/31/2018 2:15:00 AM","",""
"6/1/2018 2:15:00 AM","6/1/2018 10:45:33 AM","510"
"6/2/2018 2:15:00 AM","6/2/2018 8:45:29 AM","390"
"6/3/2018 2:15:00 AM","6/3/2018 12:18:36 PM","603"
"6/4/2018 2:15:00 AM","6/4/2018 9:41:17 AM","446"
"6/5/2018 2:15:01 AM","6/5/2018 10:44:04 AM","509"
"6/6/2018 2:15:01 AM","6/6/2018 6:30:34 AM","255"
"6/7/2018 2:15:01 AM","6/7/2018 5:58:56 AM","223"
"6/8/2018 2:15:00 AM","6/8/2018 4:20:21 AM","125"
"6/9/2018 2:15:00 AM","6/9/2018 3:21:42 AM","66"
"6/10/2018 2:15:00 AM","6/10/2018 2:52:20 AM","37"
"6/11/2018 2:15:00 AM","6/11/2018 3:33:02 AM","78"
"6/12/2018 2:15:00 AM","6/12/2018 3:49:58 AM","94"
"6/13/2018 2:15:00 AM","6/13/2018 3:28:15 AM","73"
"6/14/2018 2:15:00 AM","6/14/2018 3:29:45 AM","74"
"6/15/2018 2:15:00 AM","6/15/2018 3:41:56 AM","86"
"6/16/2018 2:15:00 AM","6/16/2018 3:06:31 AM","51"
"6/17/2018 2:15:00 AM","6/17/2018 2:51:04 AM","36"
"6/18/2018 2:15:00 AM","6/18/2018 3:08:58 AM","53"
"6/19/2018 2:15:00 AM","6/19/2018 3:51:17 AM","96"
"6/20/2018 2:15:00 AM","6/20/2018 2:57:16 AM","42"
"6/21/2018 2:15:01 AM","6/21/2018 3:55:28 AM","100"
"6/22/2018 2:15:00 AM","6/22/2018 2:59:40 AM","44"
Any days with no end time or job duration is days that the job failed to complete and had to be killed.
No more trawling the swdebugMaintenance log file unless i need to see in detail whats happening.
Hope this helps