Misleading 'Is Agent Running' and 'Agent Jobs' statuses. #806
Replies: 6 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
DBA Dash uses this query to check if the SQL Agent is running:
I've found this reliable, but I'm open to suggestions on how to improve it. Previously this was used:
It was changed to use the generic refresher for the following reasons:
Note: It's collected as part of the ServerExtraProperties collection which runs every 1hr by default. This could be a reason the status doesn't match up. The schedule can be updated if required and it can also be triggered on demand. Sorry for not responding to this post earlier. |
Beta Was this translation helpful? Give feedback.
-
I might consider changing it to check both and display a warning if the generic refresher isn't running. I've never seen a situation where the generic refresher isn't running and jobs are still executing. Do you know how I could create this situation in my lab environment? sys.dm_server_services isn't available on SQL2008 and SQL2005 which are still supported by DBA Dash but I can workaround that. sys.dm_server_services doesn't return any rows on a managed instance - don't think you actually have access to stop it though. The generic refresher check works on managed instance. |
Beta Was this translation helpful? Give feedback.
-
One scenario comes to mind. Someone here killed all the long running sessions on multiple servers. That action killed the generic refresher sessions. DBADash reported SQL Agent Service as not running. All the jobs continued to work without issues. I do not know how or if it affected alerts. We were able to replicate this multiple times.
This is what I use to check the Agent status.
SELECT @@ServerName AS ServerName,
CASE
WHEN NOT EXISTS
(
SELECT *
FROM sys.dm_exec_sessions
WHERE program_name = 'SQLAgent - Generic Refresher'
) THEN
CASE
WHEN
(
SELECT status_desc
FROM sys.dm_server_services
WHERE servicename LIKE '%agent%'
) = 'Running' THEN
'Possible Issue. Restart the SQL Agent Service.'
ELSE
'Not Running. Start the SQL Agent Service'
END
ELSE
'Running'
END AS Status;
Your DBADash application is outstanding. Great job with it. I use it daily.
|
Beta Was this translation helpful? Give feedback.
-
That makes sense - I've done a quick test and it seems like jobs continue to work after killing the session. Interestingly it comes back if you create a new job after killing the session. I can see people having something to kill off long running sessions being a cause for this. I still think it's something to be alerted on but as you said it's probably better to report separate from the running status. Thanks |
Beta Was this translation helpful? Give feedback.
-
That is correct. A new job or any changes to a job brings it back. Hence the need for a warning and not an offline status alert.
|
Beta Was this translation helpful? Give feedback.
-
From a previous discussion, I understand you use SQLAgent - Generic Refresher to test if SQL Agent Service is online.
If SQLAgent - Generic Refresher is not present in sys.dm_exec_sessions, DBADash reports it as not running and Agent Jobs also as not running.
I am looking at two servers right now in that state. However, the Agent is in fact running, and the jobs are firing at the scheduled time, all with no issues. No entries in SQL/Agent logs (I know the fix is to restart the Agent Service).
My question (and suggestion) is how do you determine the Agent Jobs state of Not Running? And, if the SQLAgent - Generic Refresher is not present, maybe do an additional step to check the actual state of the Agent Service. If the agent is running, I feel the alert should be yellow, a warning that a possible issue might be in play, not that the agent is not running (which is false). A hung state for the Generic Refresher does not a true indication of jobs not running and/or the agent is not running.
maybe I am going about this the wrong way, I feel the agent jobs status should not be tied to Is agent running at least not without actually checking.
Beta Was this translation helpful? Give feedback.
All reactions