Starting a RM Agent as a service on Windows

To ensure that the Resource Monitoring agent starts by itself when the host is running, you can set up the environment in such a way that the Resource Monitoring agent can be started as a service.

Before you begin

Previously to starting a Resource Monitoring Agent as a service on Windows, you need to have:

  • Java 8 installed on the host.
  • IBM® Rational® Test Automation Server added to the PATH environment variable.
  • An offline token to connect the agent securely with appropriate permissions. You can create an offline token from the User menu of the Resource Monitoring page or you can re-use your active offline token. The token expires if it is not used for a month.

    To allow remote access to the performance data on Windows 10, you must have considered the following information:

    • The user name and password are the same on the local and remote servers. Otherwise you must have provided remote server credentials.
    • The remote user must be a member of the Performance Monitor Users group (start lusrmgr.msc and add the user to this group).
    • The Remote Registry service must be running on the remote host (start services.msc) and must have verified the Remote Registry status).
    • File and printer sharing must be enabled on the Network Interface of the remote host that is implied in the communication with the local host.
    • The remote firewall is not blocking access; the following Windows Firewall rules must be activated:
      • File and Printer Sharing (NB-Name-In)
      • File and Printer Sharing (NB-Session-In)
      • File and Printer Sharing (*)

Procedure

  1. Download the latest release of winsw. You can choose to download WinSW.Net2.exe or WinSW.Net4.exe depending on the version of .Net framework that you already have on the host Windows.
  2. Create a folder on your local hard drive like RMAgent-winservice.
  3. Copy the downloaded executable to this new folder and rename the file to RMAgent-winservice.exe.
  4. Create a new text file in the same folder and name it RMAgent-winservice.xml.
  5. To set up the offline token, copy and adapt the following content to this new RMAgent-winservice.xml file:
    <service>
          <id>RMAgent-winservice</id>
          <name>Resource Monitoring Agent</name>
          <description>This service runs the Resource Monitoring Agent.</description>
          <executable>java</executable>
          <env name="HCL_ONETEST_OFFLINE_TOKEN" value="(Enter your offline token here"/>
          <arguments>-jar %BASE%\RMAgent.jar --serviceUrl=https://<service-host>/rm --projectId=<projet-id> --autoUpgradeDownloadThen=execute:cmd,/c,start,%BASE%\auto-upgrade.bat</arguments>
          <onfailure action="restart" delay="10 sec"/>
          <logmode>rotate</logmode>
    </service>
    
    Note:
    • Replace <service-host> by the host name of the host that runs IBM® Rational® Test Automation Server.
    • Replace <project-id> which is the number you find after /projects/ in the browser's URL when browsing to this project.
  6. Create a new text file in the same folder and name it auto-upgrade.bat.
  7. To upgrade the agent .jar file automatically, copy the following content to this new file:
    @echo off
    for /f "tokens=*" %%a in ('dir /b /od %BASE%\com.hcl.test.rm.agent-*.jar') do set newest=%%a
    %BASE%\RMAgent-winservice.exe stop
    del %BASE%\RMAgent.jar
    mklink %BASE%\RMAgent.jar %BASE%\%newest%
    %BASE%\RMAgent-winservice.exe start
    
  8. Start the command prompt as an administrator and change the directory to the newly created directory RMAgent-winservice.
  9. Download the Agent .jar file that is available from the Agents page in the Resource Monitoring service, under the Extend the Resource Monitoring service with agents section and save it to the same directory.
  10. In the command prompt, type the following command to create a symbolic link named RMAgent.jar to the agent jar file:
    mklink RMAgent.jar com.hcl.test.rm.agent-<version-and-datetime>.jar
  11. Type the following commands:
    RMAgent-winservice install
    RMAgent-winservice start
  12. In the Services Windows application, you can check whether the service is up and running.
  13. You can see in the Resource Monitoring page whether the Resource Monitoring Agent is disconnected or connected.
    Connected agentConnected agent

Results

The Resource Monitoring Agents write the logs to the same folder in files named RMAgent-winservice.out.log, RMAgent-winservice.err.log and RMAgent-winservice.wrapper.log. Look at those files if the Windows service for the Agent is not started or if it does not appear to be connected to the Resource Monitoring service.

The Windows Agent is added to the main page of the Resource Monitoring service in IBM® Rational® Test Automation Server.

What to do next

You can monitor the Windows agent by selecting counters. For more details about monitoring resources, see the related links.