Monitor Services on Windows Servers
This is not a UNIX / Linux question, though.
There are, say, 10 Windows 2008 servers on the Intranet. MS SQL Server 2008 R2 is running on them.
I want to write a script in Perl (preferred) or else in PowerShell that can alert (email) me if MS SQL Server Service is not running on any of the Windows Servers. I want to place this script on my local Windows 7 system. So, if email/alert is not working, it can still pop-up messages on my screen when I run the script manually.
Usually, this happens (in this organisation) when Windows Servers got shutdown or somebody manually stop the MS SQL Service and does not start it later. This is critical as these servers are part of ETL which needs to be fine.
I have not written scripts on Windows, so people, any help?
P.S.: This command tells me the status of the specified service on my local system. I want to write a script on my local system that can tell me the status of the service on 10 servers:
I would start by finding out the WMI commands necessary to 0) poll the system (it's a dependency) for being up or not and 1) extract the required information from the service and ensure you take note of all possible return values. Then see if you can query a machine remotely with WMI and then encapsulate those commands in whatever scripting solution you want. If learning is the name of the game or if wheel-reinvention is your fetish then that's fine but do note if you're looking for an resilient / efficient monitoring solution you should have a separate monitoring server to begin with and that for example Nagios already can monitor W2K8 and services.
1. There are already tools like this you could use rather than writing your own scripts, nagios, openNMS, etc.
2. Monitoring the service stats isn't going to be reliable, the service could remain running but the service not responding to requests. Since your monitoring SQL in this example you could make a simple table called test with one piece of data 'It Works!' then select * from test and if 'it works!' is returned then your probably good, even better would be better to execute part of whatever code your running in sql. You could also monitor time, if it takes too long to get a result then you may have issues.
|All times are GMT -5. The time now is 10:48 PM.|