RE: SCRIPT: Monitor any auto-start SERVICE not in Running State.
|
Logged in as: Guest
|
|
Users viewing this topic:
none
|
|
Login | |
|
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!
|
|
|
|
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.
|
|
|
|
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 |
|
|