Notified when sql server/agent is stopped

  • Is there a way to be notified of the sql services stopping that doesn't include 3rd party products? I have the MS training kit for the 70-444 exam and it mentions (very briefly) that you can raise alerts on the services stopping. The only way i could think of starting to do something like this is sending the mail via agent mail, but if the service is stopped then logically it wont send the alert.

    Just wondered what other people do for these kinda things.

  • On the Windows side you can run a job or send a NETSEND (maybe more in W2K3 or 2K8) when a service stops.

    I don't think SQL Server helps here because the alerts come out of SQLAgent.

    Servers Alive used to be very reasonably priced and would look for service issues.

  • Assuming you have some .NET expertise - you can leverage a simple WMI query to find out which services are running, or if specific services are. You could also set up a simple "heartbeat" (for Agent), whereby it simply writes the date and time to a text file. Any number of simple batch files or console apps can read said file and check the time against the system time (if <30 minutes - send an e-mail/raise an alert).

    Finally - you could use something REALLY basic like - having a batch file try to start the service ( NET START MSSQL$yourinstance), and redirect that to a text file. If the ERROR file does NOT have "THIS SERVICE HAS ALREADY BEEN STARTED" - then you have a problem.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • I run a job that uses master.dbo.xp_servicecontrol 'QueryState', 'SQLServerAgent'

    go

    master.dbo.xp_servicecontrol 'QueryState', 'MSSQLServer'

    from a remote monitoring box, if I get a non running state the code inserts into a table and then an email is triggered.

  • Thanks all for your responses!! 3 very different solutions to the same problem 🙂 I think ill give the last solution a go monitoring from a remote box as i dont have any .NET experiance yet 🙁 and that solution looks like it will do the job, unless of course the monitor goes down 😛

    Thanks again

    John

  • You create a windows alert with NET SEND MSG when sql services stops and starts.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • I use a utility called Alchemy Eye to watch my Servers. It can send alerts to pagers, e-mails, SMS devices, etc. Of course, I use it for my than just MSSQL, but it's easy and does what I need it to do.

    Check it out here http://www.alchemy-lab.com/products/eye/

    Regards, Irish 

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

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