Sql-server – SQL Agent not Running

sql serversql-server-agent

Please Help. I have been trying this for the past 3 days.

I need to send an alert mail when the SQL Server Agent is not running. That is, there can be instances where SQL Server is is running, but Agent is not running. I need to set up the same as startup procedure to check whether the agent is disabled or not when the service starts.I had already made the procedure and set up the same as start up procedure. I had also made a job based on the same, but had not scheduled.

Thanks in advance. Please help

Best Answer

Instead of having SQL Server monitor one of its subprocesses, why don't you have a script at the operating system level - WMI, PowerShell, what have you - periodically poll the services to make sure Agent is running? This seems a lot more foolproof than a startup procedure (which only runs when the SQL Server service starts, and potentially will finish before Agent starts, so it's not going to catch many scenarios - like when Agent suddenly fails or is forcibly shut down without touching the SQL Server service).

A job is absolutely not the way to do this. How can a job tell you that SQL Server Agent is not running? Catch-22. That's like your car driving itself to go get gas when it is out of gas.

Also, creating a watchdog for the Agent service seems way too reactive to me. Have you looked into why the service isn't starting or is getting shut down? The Windows event logs should have information about this.