logo top
logo middle
  • +44 1293 403636
  • This e-mail address is being protected from spambots. You need JavaScript enabled to view it.
  • Follow us on Twitter
  • Facebook
  • Google+

Jamie Lockhart

Senior Consultant

Contact me:

jamie dot lockhart at scl dot com

LinkedIn: linkedin.com/in/jamielockhart

Script to restart Oracle Load Testing agents

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.

  1. Create a file that contains a list of the agent machines and call it agents.txt

    machine1
    machine2
    machine3

  2. 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

    Post your comments...

    Contact us

    1. First name(*)
      Invalid Input
    2. Last name(*)
      Invalid Input
    3. Organization
      Invalid Input
    4. email(*)
      Invalid Input
    5. Message
      Invalid Input