Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 10:07 AM
Points: 1,783, Visits: 1,921
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 @ 12:01 PM
Points: 12,744, Visits: 31,074
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1395695
Posted Wednesday, December 12, 2012 9:12 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Monday, April 14, 2014 1:34 PM
Points: 15,442, Visits: 9,588
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


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 26, 2014 12:36 PM
Points: 256, Visits: 1,063
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
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 10:33 AM
Points: 396, Visits: 533
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
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 14, 2014 3:21 AM
Points: 2,797, Visits: 3,079
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 2014, 2012, 2008 R2, 2008 and 2005. 25 March 2014: now over 28,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #1397201
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse