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

Notices



Reply
 
Search this Thread
Old 05-30-2013, 02:45 AM   #1
devUnix
Member
 
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: 557

Rep: Reputation: 46
Lightbulb Monitor Services on Windows Servers


Hi,


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?


Thanks!

Dev.



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:


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

SERVICE_NAME: 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 03:38 AM.
 
Old 06-01-2013, 04:44 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,718
Blog Entries: 54

Rep: Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967Reputation: 2967
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, 09:21 AM   #3
enine
Member
 
Registered: Nov 2003
Distribution: Slackware 14.1
Posts: 819
Blog Entries: 3

Rep: Reputation: 91
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.
 
  


Reply


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 08:30 AM
Servers? Services? What?! muppski Linux - Networking 3 12-18-2004 10:47 AM
Help, what services are needed for a windows to access Linux servers Wolfy Linux - Networking 6 07-12-2004 09:36 PM
services/servers trouble Orion Pax Mandriva 3 10-30-2003 11:31 PM
RH9 Services/servers Duke03 Linux - Newbie 1 07-21-2003 01:15 PM


All times are GMT -5. The time now is 10:15 AM.

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