Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rolling scheduled reboots of server groups.

Status
Not open for further replies.

sparkbyte

Technical User
Sep 20, 2002
879
US
I am needing a way to reboot groups of servers and once they have rebooted confirm that certain services have started. Only then can the next group start their reboots.

Reason behind this.

As with most everyone here. (MIS Admins with windows servers) A little after "black tuesday" we are required to patch all of our windows servers.

Issues:

Patch manager/installer cannot run on a schedule with dependancies. i.e. Patch DB servers first, when finished with DB servers and they have checked back in then patch App/Web servers and so on.

We don't have anything in place (yet) that verifies that Application services are running.


Proposed resolution: Albiet, hopefully temporary.

Have a script that will reboot a group of servers, ping them unitl they are active again and then check and start any services that didn't start automatically. Then move to the next group of servers doing the same thing.


What I have so far.

I have a script that will enumerate all the server in the domain. From this I can split the server name to get which servers to reboot.

what I need is a way to reboot the servers, wait for the reboot to finish, then check the remote services and start anything that did start properly.

Now, I have considered making the a seperate script that will run locally on each server that only runs a startup to check the services and start them.

Any suggestions???



Thanks

John Fuhrman
Titan Global Services
 
I would think you would want your script doing the rebooting to also check the services...that is, seeing how you only want the next server rebooted when everything checks out on the first one.

Are you monitoring for the same set of services on each server or a different set for each one?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
The reboot is for a group of servers, not so much one at a time.

The services are different for each server, but the naming convention for those services makes it fairly easy to parse them out.

SynSrv_[branch#]_[Port#]

SynSrv_RPC_[branch#]_[port#]

SynSrv_Web_[version]_[port#]

Based on this I should be able to check the service for a name beginning with "SynSrv_" set to automatic. If it is not started, sart it and move on to the next until all services are running. On each Server.

Servers groups would be like this.
Database Servers:
LXOLCDDB02
LXOLCDDB03
LXOLCDDB04

App/Web
LXOLCDAPP01
LXOLCDAPP02
LXOLCDAPP03 UP TO 40

Interface Servers
LXOLCDINT01
LXOLCDINT02 AND SO FORTH

The most critical server to make sure are running before all others are the DB servers because they are the licence servers for the CORE product. Without them running nothing talks to the end users. (Well cleints can log onto the software but cannot retrieve any data.)


Thanks

John Fuhrman
Titan Global Services
 
This work for parsing the servers needed.

Code:
Option Explicit

Dim objRootDSE, strRootDomain, objRootDomain, objConnection, objCommand, objRecordSet, strSystem

Set objRootDSE = GetObject("LDAP://rootDSE")
 
strRootDomain = "LDAP://" & objRootDSE.Get("rootDomainNamingContext")
Set objRootDomain = GetObject(strRootDomain)

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from '" & strRootDomain & "' Where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
strSystem = objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
    
    If Mid(strSystem,7,2) = "DB" Then
    WScript.Echo strSystem
    End If
 Loop

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
	strSystem = objRecordSet.Fields("Name").Value
	objRecordSet.MoveNext

	If Mid(strSystem,7,3) = "APP" Then
	WScript.Echo strSystem
	End If
Loop 

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strSystem = objRecordSet.Fields("Name").Value
	 objRecordSet.MoveNext
    If Mid(strSystem,7,3) = "INT" Then
    WScript.Echo strSystem
    End If
Loop

Now just need to figure out the rest.

Thanks

John Fuhrman
Titan Global Services
 
Untested, but maybe it will help get you started.

Code:
Option Explicit

' Define query looking for service that stars with SynSrv_ and is set to automatic
Dim strWQL : strWQL = "Select * From Win32_Service Where Name Like 'SynSrv_%' " & _
					  "And StartMode='Auto'"
Dim strComputer : strComputer = "."
' Bind to WMI
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
' Execute query
Dim colServices : Set colServices = objWMIService.ExecQuery(strWQL)
' get the collection item count
Dim intCount : intCount = colServices.Count
' loop until the intCount is 0
Dim serviceItem
Do Until intCount = 0
	' Execute the query to get the current status of the services
	Set colServices = objWMIService.ExecQuery(strWQL)
	' Loop through each service returned
	For Each serviceItem In colServices
' 		WScript.Echo serviceItem.Name & vbTab & serviceItem.State
		' check the states
		Select Case UCase(serviceItem.State)
			Case "RUNNING" 
				' if running, then subtract 1 from intCount
				intCount = intCount - 1
			Case "STOPPED"
				' if stopped, try to start the service; intCount is
				' not decreased so the loop will continue until they 
				' are all "running"
				serviceItem.StartService()
		End Select
	Next
	' make a small pause to allow for the service to start and check again
	WScript.Sleep 5000
Loop

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Exactly the start I was looking for!! Thanks!!!

Let you know when I make some more progress on this.

Thanks

John Fuhrman
Titan Global Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top