Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to notify through DB MAIL when sql server agent stopped automatically? Expand / Collapse
Author
Message
Posted Monday, December 10, 2012 11:50 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, September 18, 2013 4:14 AM
Points: 38, Visits: 198
Hello all,
Can someone tell me how can we send email when my sql sevrer agent stops automatically, i have my dbmail configured...

Thanks,
Post #1394907
Posted Wednesday, December 12, 2012 6:42 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 2:20 PM
Points: 2,532, Visits: 2,946
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.
Post #1395641
Posted Wednesday, December 12, 2012 8:20 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:41 PM
Points: 14,556, Visits: 38,433
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!
Post #1395695
Posted Wednesday, December 12, 2012 9:12 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Monday, August 29, 2016 1:09 PM
Points: 13,999, Visits: 9,728
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
Post #1395745
Posted Wednesday, December 12, 2012 2:37 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 4:25 PM
Points: 313, Visits: 1,270
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.
Post #1395892
Posted Wednesday, December 12, 2012 8:58 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, September 18, 2013 4:14 AM
Points: 38, Visits: 198
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...
Post #1395966
Posted Thursday, December 13, 2012 10:18 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, November 16, 2016 8:13 AM
Points: 409, Visits: 646
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.
Post #1396289
Posted Monday, December 17, 2012 5:04 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 12:19 PM
Points: 3,059, Visits: 3,780
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: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2016, 2014, 2012, 2008 R2, 2008 and 2005. 29 Aug 2016: now over 38,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Quote: "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
Post #1397201
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse