- +44 1293 403636
- This e-mail address is being protected from spambots. You need JavaScript enabled to view it.
- Follow us on Twitter
- Google+
SCL Blogs
Script to restart Oracle Load Testing agents
- Details
- Published on Monday, 19 December 2011 13:35
- Written by Jamie Lockhart
In a recent load test using Oracle Load Testing I had to provision and use 50 agent machines. Obviously, I didn't want to have to manually re-start the agents if there was an issue with one or more of them so I wrote a Windows batch script to automate re-starting all of the agents. You need to have the appropriate privileges to do this so my account was added to a 'Desktop Admins' group in AD.
-
Create a file that contains a list of the agent machines and call it agents.txt
machine1
machine2
machine3 -
Save the following as a .bat in the same location as agents.txt
@echo off
REM Script to restart OLT agents.
REM Requires local admin access to the PC on which agent runs.
for /F "tokens=*" %%G IN (agents.txt) DO call :stop_agent %%G
:stop_agent
if "%1"=="" (goto :nothing)
set agent=%1
echo Agent is %agent%
echo Stopping agent on %agent%
sc \\%agent% stop eloadAgentMon
REM sleep not required but allows more time for agent service to stop
sleep 3
REM Now check on the status of the service before trying to start it
for /F "tokens=2 delims=: " %%G IN ('c:\windows\system32\sc.exe \\%agent% query eloadAgentMon ^| find "STATE"') DO set status=%%G
echo Status = %status%
:while
if %status% EQU 1 (GOTO :stopped)
REM echo %status%
for /F "tokens=2 delims=: " %%G IN ('c:\windows\system32\sc.exe \\%agent% query eloadAgentMon ^| find "STATE"') DO set status=%%G
goto while
:stopped
echo Starting agent on %agent%
sc \\%agent% start eloadAgentMon
:nothing
Hope you find it useful.
Jamie


