Skip to main content

Deployment

Prerequisites

Before deploying the Agent, you need to ensure that the local browser time and the server time zone and time are consistent. If there are multiple servers, make sure the local browser and all servers have the same time zone and time. Otherwise, data accuracy may be affected, such as incorrect topology.

UniAgent Deployment

When there are applications in multiple languages on the server, it is recommended to use UniAgent for installation. For installation steps, please refer to UniAgent Deployment Guide.

The UniAgent package integrates Agents for Java/PHP/.NET/.NET Core/Node.js/Python. After installation, you do not need to manually modify the application's configuration files. All Agent embedding actions are automatically completed by UniAgent, and it can automatically monitor applications inside Docker containers.

By default, UniAgent only supports applications compiled as dll files. If your application is compiled as exe or bin, you need to modify the ./conf/interceptor.conf file.

For example: If a .NET Core application is compiled as netcore-demo.exe and you want to monitor netcore-demo.exe, modify the C:\Program Files\tingyun\monitor\conf\interceptor.conf file:

netcore.namelist=w3wp,dotnet,netcore-demo.exe
  • Windows OS

Modify the ./conf/interceptor.conf file, save the configuration, restart the TingyunMonitor service via "Task Manager" or "Services", and finally restart the netcore-demo.exe application.

  • Linux OS

Modify the ./conf/interceptor.conf file, save the configuration, and then restart the netcore-demo application.

Standalone Agent Deployment on Windows

  1. Download the installer tingyun-agent-netcore-version.exe.

  2. Double-click the installer, configure the license and collector address, select the installation path, and complete the installation.

12

  1. Modify the .NET application startup script to add a call to <installation_path>\tingyun-enable.bat For example, the original .NET application startup script:

    ...
    dotnet c:\interpub\myapp\myapp.dll

    If the Agent is installed at C:\Program Files(x86)\Networkbench.COM\NetCore Profiler, the modified script:

    ...
    call "C:\Program Files(x86)\Networkbench.COM\NetCore Profiler\tingyun-enable.bat"
    dotnet c:\interpub\myapp\myapp.dll
  2. Restart the application.

  3. If the application is deployed to IIS, please also install the .NET Agent (tingyun-agent-dotnet-version.exe), start the .NET Agent GUI NBUI.EXE, click "Disable Monitoring" and then click "Enable Monitoring".

Standalone Agent Deployment on Linux

  1. Download the installer tingyun-agent-netcore-version.bin.

  2. Run tingyun-agent-netcore-version.bin, configure the license and collector address, select the installation path, and complete the installation.

    [user@localhost  tmp]$  chmod  +x  tingyun-agent-netcore-version.bin
    [user@localhost tmp]$ sudo ./tingyun-agent-netcore-version.bin
    unzip to /usr/lib/tingyun-dotnet ...
    Enter license key (please enter the license key):
    Enter collector address (please enter the collector address):

    Silent installation is supported. When running the installer, use the --license and --collector options.

    sudo  ./tingyun-agent-netcore-version.bin  --license=123-456-789  --collector=192.168.1.8:7665
  3. Modify the application startup script to add tingyun-enable.

    • If the Agent is installed with root privileges

      Add .tingyun-enable to the application startup script. For example, the original .NET application startup script:

      ...
      dotnet /opt/myapp/myapp.dll

      Modified script:

      ...
      .tingyun-enable
      dotnet /opt/myapp/myapp.dll
    • If the Agent is installed with a regular user

      Add ./<installation_path>/bin/tingyun-enable to the application startup script. For example, the original .NET application startup script:

      ...
      dotnet /opt/myapp/myapp.dll

      If the Agent is installed at /opt/tingyun/, the modified script:

      ...
      ./opt/tingyun/bin/tingyun-enable
      dotnet /opt/myapp/myapp.dll
    • If using systemd to manage the application

      Add the Agent environment variables to the environment section of the systemd configuration file.

      For example, the original .NET application configuration file:

    [Service] ExecStart=/usr/bin/dotnet /opt/myapp/myapp.dll Type=notify Restart=on-failure


    Modified .NET application configuration file:

    > **Note**: The following is for reference only. Please modify according to your actual situation. The path specified by CORECLR_PROFILER_PATH must match the Agent path.

    ```sh
    [Service]
    ExecStart=/usr/bin/dotnet /opt/myapp/myapp.dll
    Type=notify
    Restart=on-failure
    Environment=CORECLR_ENABLE_PROFILING=1
    Environment=CORECLR_PROFILER="{8BEB2128-D285-4E1D-91B6-11ACD43EC0EE}"
    Environment=CORECLR_PROFILER_PATH="/usr/lib/tingyun-dotnet/tingyun_profiler.so"

    Reload the systemd configuration:

    systemctl daemon-reload
    • If using supervisor to manage the application

      Add the Agent environment variables to the environment section of the supervisor configuration file.

      For example, the original .NET application configuration file:

      [program:superset]
      command=dotnet /opt/myapp/myapp.dll
      autostart=true
      startsecs=1
      autorestart=true
      environment=ASPNETCORE_ENVIRONMENT=PRODUCT

      Modified .NET application configuration file:

      Note: The following is for reference only. Please modify according to your actual situation. The path specified by CORECLR_PROFILER_PATH must match the Agent path.

      [program:superset]
      command=dotnet /opt/myapp/myapp.dll
      autostart=true
      startsecs=1
      autorestart=true
      environment=ASPNETCORE_ENVIRONMENT=PRODUCT,
      CORECLR_ENABLE_PROFILING=1,
      CORECLR_PROFILER="{8BEB2128-D285-4E1D-91B6-11ACD43EC0EE}",
      CORECLR_PROFILER_PATH="/usr/lib/tingyun-dotnet/tingyun_profiler.so"

      Reload the supervisor configuration:

      supervisorctl reread
      supervisorctl update
  4. Restart the application.

Standalone Agent Deployment in Docker

  1. Download the installer tingyun-agent-netcore-version.bin to the Dockerfile directory.

  2. Modify the Dockerfile.

    Note: The following script is for reference only. Please modify according to your actual situation.

    FROM microsoft/dotnet:3.1.0-aspnetcore-runtime

    # web application
    RUN mkdir /app
    WORKDIR /app
    COPY publish /app
    ENV ASPNETCORE_URLS http://*:5000

    # install tingyun agent
    COPY tingyun-agent-netcore-version.bin /tmp
    RUN chmod +x /tmp/tingyun-agent-netcore-version.bin
    RUN /tmp/tingyun-agent-netcore-version.bin --license=\${TINGYUN_LICENSE} --collector=\${TINGYUN_APM_COLLECTOR}
    RUN rm -f /tmp/tingyun-agent-netcore-version.bin

    # run web application with tingyun agent
    RUN echo "#! /bin/bash" > /app/run.sh
    RUN echo ". tingyun-enable" >> /app/run.sh
    RUN echo "export TINGYUN_APP_NAME=demo" >> /app/run.sh
    RUN echo "dotnet /app/demo.dll" >> /app/run.sh
    RUN chmod +x /app/run.sh
    ENTRYPOINT ["/app/run.sh"]

    Or

    FROM microsoft/dotnet:3.1.0-aspnetcore-runtime

    # web application
    RUN mkdir /app
    WORKDIR /app
    COPY publish /app
    ENV ASPNETCORE_URLS http://*:5000

    # install tingyun agent
    COPY tingyun-agent-netcore-version.bin /tmp
    RUN chmod +x /tmp/tingyun-agent-netcore-version.bin
    RUN /tmp/tingyun-agent-netcore-version.bin --license=\${TINGYUN_LICENSE} --collector=\${TINGYUN_APM_COLLECTOR}
    RUN rm -f /tmp/tingyun-agent-netcore-version.bin

    # setup env for tingyun agent
    ENV CORECLR_ENABLE_PROFILING 1
    ENV CORECLR_PROFILER {8BEB2128-D285-4E1D-91B6-11ACD43EC0EE}
    ENV CORECLR_PROFILER_PATH /usr/lib/tingyun-dotnet/tingyun_profiler.so

    # setup application name
    ENV TINGYUN_APP_NAME=demo

    # run web application with tingyun agent
    ENTRYPOINT ["dotnet", "/app/demo.dll"]
  3. Rebuild the image.

    docker build -t demo:1.0 .
  4. Run the image.

    docker run -e TINGYUN_LICENSE=<license_key> -e TINGYUN_APM_COLLECTOR=<collector_address:port> demo:1.0