How to notify through DB MAIL when sql server agent stopped automatically?

  • Hello all,

    Can someone tell me how can we send email when my sql sevrer agent stops automatically, i have my dbmail configured...

    Thanks,

  • The problem is that SQL Agent is the program you'd typically use to do monitoring and alerting. It sounds like what you really need is some kind of watchdog program that ensures Windows services are running on your servers.

    Another option might also be able to setup some script or something to run when the service fails. In the Control Panel \ Administrative Tools \ Services, right click on the service, and select the Recovery tab. You can specify here what happens when the service fails.

  • Chris Harshman (12/12/2012)


    The problem is that SQL Agent is the program you'd typically use to do monitoring and alerting. It sounds like what you really need is some kind of watchdog program that ensures Windows services are running on your servers.

    Another option might also be able to setup some script or something to run when the service fails. In the Control Panel \ Administrative Tools \ Services, right click on the service, and select the Recovery tab. You can specify here what happens when the service fails.

    yep I', with Chris;

    this is the "how can i make the watchman notifyme if the watchman dies?"

    you can't, you have to use a different tool, something that the item you ar emonitoring does not depend on or use.

    if you search for SQL monitoring software or network monitoring software, you'll find a lot of items;

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • You theoretically could set up a proc that would run indefinitely, which would check the state of the SQL Agent every few seconds, and send an e-mail when it finds it not running. Set it up in master, set it to run automatically when SQL starts, and it would monitor SQL Agent from within the SQL service.

    It's a really bad idea, but it could be done. One main reason it's a bad idea is that if anything takes down both SQL and SQL Agent, like a serious Windows error, then it won't monitor anything. So counting on it is unreliable.

    The advice already given, that you should get some third-party monitoring tool, is the right way to go.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • This is not an explicit answer to your question but it may provide an acceptable work-around if you haven't already implemented it.

    Right-click on "SQL Server Agent" in your SSMS GUI and select "Properties". The "General" tab has settings for SQL Server and SQL Server Agent that will ensure they automatically restart if they inadvertently stop.

  • That is how it we set it but still agent stopped...so i was just thinking if i can find a work around for it...

  • The other thing to think about is that email isn't really a successful alert system unless it arrives, and there are a whole host of issues that can prevent an email from arriving even if it is sent correctly by SQL Server.

    What we do is set up an agent job on each server to send a dummy email every two hours, and then have a script check the folder in our email system that the right number of emails were received by the right number of servers. If all is well, the emails are deleted. If there is a disconnect, a warning email or page goes off.

    Yes, there are issues that can prevent the second warning email/page from sending, and yes, what happens if the monitor fails in addition to email on a server is a problem, but those are multiple simultaneous failure scenarios and watching both for a successful send (via agent) and a successful receipt (by the monitoring script) is better than nothing.

  • The Windows Service Control manager can detect when a service stops unexpectedly. You can use this to automatically restart your service or automatically run a command.

    If you want to automatically send an email, then check this out for the syntax needed: http://serverfault.com/questions/110057/easiest-way-to-send-an-email-from-the-command-line-using-windows-2003-r2

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply