Forums  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Member List  Search  FAQ  Ticket List  Log Out

 

RE: SCRIPT: Monitor any auto-start SERVICE not in Running State.

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [Networking & Security] >> GFI Network Server Monitor >> RE: SCRIPT: Monitor any auto-start SERVICE not in Running State. Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
RE: SCRIPT: Monitor any auto-start SERVICE not in Runni... - 20.May2004 4:49:00 PM   
totalstu

 

Posts: 31
Joined: 19.May2004
From: Toronto
Status: offline
Hehe. i just edited my last post seeing if you had other goodies up your sleeve and then after adding the edit I noticed you had posted your reply.

There is a thread where someone wrote a script to monitor memory:
http://forums.gfi.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=11;t=000021

Maybe, if you have time you could check it out and report back. Of course I had trouble with that one as well [Smile]

Time to go home for the day here in the east. Have a good rest of yours.

Thanks as always.

Stuart

(in reply to schnazzy)
Post #: 16
RE: SCRIPT: Monitor any auto-start SERVICE not in Runni... - 26.May2004 2:49:00 PM   
Spoot

 

Posts: 13
Joined: 6.May2004
From: Austin, TX
Status: offline
Alex,

Thanks for posting the script. I looked at it and wanted it to list all dead services as well as to attempt to restart them. Here is the modified script. Hope you don't mind me gettin' all script kiddie on ya!

' /////////////////////////////////////////////////////////////////////////////
' This file is designed for specific use with the VBScript monitor for GFI
' Network Server Manager.
'
' ServerServies takes a computer name as an argument and will check that computer
' for all services not in a "Running" state and are set to "Auto" start. There is
' a comma delimited string (strIgnore) that can be used to specify services to
' ignore if they are not "Running" but set to "Auto" start. A good example is the
' Performance Logs and Alerts service. While the string is comma delimited there
' is no requirement for the comma except for logical seperation for the programmer.
'
' There is no warranty expressed or implied for the script or code within this file.
' Test the script and modify it for your own requirements.
'
' Use of complete or partial code is at your own risk.
'
'USAGE: The VB Function name is ServerServices
'USAGE: The Parameter1 is the servername to monitor.
'
' Copyright 2004, Alex Hertz
' Version 20040510.0
'
' /////////////////////////////////////////////////////////////////////////////

Option Explicit
Const retvalUnknown = 1

Function ServerServices( strComputer )
On Error Resume Next
Dim objWMIService, colItems, strIgnore, stoppedItem, StoppedServices, SSCount
StoppedServices = ""
SSCount = 0

' strIgnore is a comma delimited list of "Display Names" of
' auto start services that are known to not be in a running state.
' Display names can be found via the services snap-in or the "net start"
' command in a cmd.exe window.
strIgnore = "TSM StorageAgent1,"+ _
"Performance Logs and Alerts,Computer Browser,Certificate Services"

' Make a connection via WMI to the argumented remote computer.
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
If( Err.Number <> 0 ) Then
ServerServices = retvalUnknown
EXPLANATION = "Unable to access '" & strComputer & "'"
Exit Function
End If

' Make a WMI query for Services (on the remote computer) that are set to
' auto start but are not in a Running state. (I.E. stopped, pending... etc.)
Set colItems = objWMIService.ExecQuery("select * from Win32_Service " + _
"where State!='Running' and StartMode='Auto'",,48)

' Search the strIgnore string with auto start services that are not running.
' If a non-running auto start service is not in the strIgnore string, then
' fail and return the service name. Note that if multiple auto start services
' are not running only the first one will be listed.
For Each stoppedItem in colItems
If instr(strIgnore,stoppedItem.Displayname) = 0 Then
StoppedServices = StoppedServices & stoppedItem.Displayname & ", "
SSCount = SSCount + 1
stoppedItem.StartService()
End If
Next
SELECT CASE SSCount
Case 0
ServerServices = True
EXPLANATION = "All Auto-Start services are in a Running state."
Case Else
ServerServices = False
EXPLANATION = "Service(s) Not Started: " & StoppedServices
End Select
End Function

Spoot!

(in reply to schnazzy)
Post #: 17
RE: SCRIPT: Monitor any auto-start SERVICE not in Runni... - 26.May2004 2:56:00 PM   
schnazzy

 

Posts: 32
Joined: 2.Apr.2004
From: Seattle
Status: offline
No problem. However you may want to put an Edited statement under the copyright so people know it has been modified. (if it is shared).

I don't start because (a) I need to know when something fails and (b) store.exe in exchange rarely will start.

(in reply to schnazzy)
Post #: 18
RE: SCRIPT: Monitor any auto-start SERVICE not in Runni... - 26.May2004 4:12:00 PM   
Spoot

 

Posts: 13
Joined: 6.May2004
From: Austin, TX
Status: offline
Fundamentally, the script is your code, I didn't want to muddy up your notes on it.

Also, for those that would like to put into service with the service restart, it is a good idea to comment out the start command {'stoppedItem.StartService()} and let the script run through your systems a few times. You may find it would like to start services you don't want started.

The start command certainly has a level of danger. [Eek!]

Spoot.

(in reply to schnazzy)
Post #: 19
Page:   <<   < prev  1 [2]
All Forums >> [Networking & Security] >> GFI Network Server Monitor >> RE: SCRIPT: Monitor any auto-start SERVICE not in Running State. Page: <<   < prev  1 [2]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts