November 18, 2009 at 2:15 pm
We have SQL Server 2000 and 2005 running on Windows 2003. I want to know if any one could provide me two simple scripts that would
1) Send an email when the disk space is running low
2) Send an email when sql server crashes (for example, if the main sql server service stops running or any process which would indicate sql server is down.)
Thanks in advance, Kevin
November 18, 2009 at 2:45 pm
You should look into building or buying WMI querying services that allow you to monitor for such events remotely.
The problem with trying to have the server send you an e-mail when it's crashed is, well ,that it's crashed, so it might not be in an any state to e-mail you.
If you don't find anything shareware that fits your needs, set up a couple of .NET console apps, which you can run from another server to watch the ones you want. If need be - set up box 1 to monitor box 2, etc....
Of course - this all fails when the network switch burns out, but it's a step in the right direction......
----------------------------------------------------------------------------------
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?
November 19, 2009 at 6:22 am
Thank You. However, I still would like to know is there any way to monitor whether SQL Server is up or down by using Windows O/S commands? (Like with Unix and Oracle, you may use Unix commands to check on the Oracle Background Processes.) I am really trying to avoid shareware and other tools if possible. Also, are there any ideas on monitoring disk space using alerts, jobs and emails?
Thanks, Kevin
November 19, 2009 at 10:00 am
well - you can use the OSQL command-line tool to check on an instance.
For example :
Osql -E -S<server instance> -Q "Select @@servername"
Should return the name if the server is up and ready to accept queries, should fail otherwise. (it's better this way than to simply check to see if the SQL server is up, because the server can be hung and the service is stlil "on")
Setting up the alerts through perfmon is easy (open up perfmon, expand the performance group, highlight alerts, click add and ollow the prompts)., but even still - if you plan on sending via e-mail - you will need an actual script or program to do just that, at which point you might as well just dive into the WMI components you can add to your executable (it's a library you can include to perform these kinds of queries).
----------------------------------------------------------------------------------
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?
November 20, 2009 at 9:58 am
Thank You.
Now, how will I schedule this task? May I put this osql command in a batch file and schedule it using the Windows Scheduled Tasks? Is there a Windows command I can use to send an email with the output of the osql command? (I do not want to use SQL Agent Jobs because if the sql server is down the job will not run.)
Thanks in advance, Kevin
November 20, 2009 at 4:23 pm
There is not a built-in Windows command that will allow you to send an e-mail. Not automatically anyway. What you could do though is if you are running a command through osql, if you have a scripting language like VBScript to run the command, you could capture the output in a variable and then use a CDO object to send an e-mail with the data in the e-mail.
Here's a link on how to send an e-mail with VBScript:
http://www.paulsadowski.com/WSH/cdo.htm
Joie Andrew
"Since 1982"
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply