Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > General
User Name
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!


  Search this Thread
Old 05-30-2013, 01:45 AM   #1
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 584

Rep: Reputation: 59
Lightbulb 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:

C:\Users\Dev>sc query MSSQL$SQLEXPRESS

        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Last edited by devUnix; 05-30-2013 at 02:38 AM.
Old 06-01-2013, 03:44 AM   #2
Registered: May 2001
Posts: 29,359
Blog Entries: 55

Rep: Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546
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.
Old 06-03-2013, 08:21 AM   #3
Senior Member
Registered: Nov 2003
Distribution: Slackware 14.2, SlackwareArm-current
Posts: 1,200
Blog Entries: 4

Rep: Reputation: 183Reputation: 183
Couple things
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Daemon to monitor services on two servers and failover ? ALInux Linux - Networking 2 04-24-2013 07:30 AM
Servers? Services? What?! muppski Linux - Networking 3 12-18-2004 09:47 AM
Help, what services are needed for a windows to access Linux servers Wolfy Linux - Networking 6 07-12-2004 08:36 PM
services/servers trouble Orion Pax Mandriva 3 10-30-2003 10:31 PM
RH9 Services/servers Duke03 Linux - Newbie 1 07-21-2003 12:15 PM > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 09:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration