Tarball manual install of Infrastructure for Linux

Our custom installation process for Infrastructure for Linux allows you to tailor all aspects of the installation process, and to place files and folders on your filesystem. You have full control of the installation.

The manual install process is not supervised. If you opt for manual install, you are responsible for placing the different files in the correct folders, providing the correct parameterized configuration values, and ensuring the agent has all the permissions to execute.

Before installation, check the compatibility and requirements.

Install the agent

As of version 1.4.0, the Infrastructure agent package includes the additional newrelic-infra-ctl binary, which is used to help troubleshoot a running agent. Although this binary is not required to execute the agent, we recommend to add it in your path. See our docs for more information.

To install the agent:

  1. Download the packaged agent file.
  2. Unpack the file.
  3. Make sure the file unpacks with the following structure:
    Infra-linux-files.png
  4. Install the service script.
  5. Optional: Additional install steps.

Install: Optional steps

You can also carry out these additional steps:

  1. Optional: Change the location of the configuration file.
  2. Optional: Change the location of the PID file.
  3. Optional: Change the user and runtime mode.
  4. Optional: Configure the plugin directory.
  5. Optional: Configure the agent directory.
  6. Optional: Configure the log file.
  7. Optional: Change the location of the agent binary.

Install the service script

Before you proceed to install the service script, you need to determine which service manager your system is using:

  • If you use one of the supported service managers (SystemD, SysV, and Upstart), use the service script provided in the tarball.
  • If you use a service manager we do not support, you must write your own service script.

In case of doubt, check your Linux distribution's official documentation.

Determine your service manager

There's no good way you can programmatically know which service manager is being used in your host, but we can give you some heuristics.

To determine the service manager, use the following commands:

  • command -v systemctl (used in Systemd)
  • command -v update-rc.d (used in SysV)
  • command -v initctl (used in Upstart)

The first command that returns an output indicates which service manager your system uses.

For example, run the following sequence:

$ command -v systemctl
$ command -v initctl
/sbin/initctl

Based on this output, Upstart is the service manager, since it's the command that obtained a return.

Before copying the service manager script, check if you need to change the user, the path of the agent’s binary, or the pid file location. All these changes need to be reflected in the service script.

If you use one of the supported service managers, install the service script for your host:

Systemd
  1. Copy the service file ./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service ​to /etc/systemd/system/newrelic-infra.service
  2. Enable the service script:
    systemctl enable newrelic-infra.service
SysV
  1. Copy the service file ./newrelic-infra/etc/init_scripts/sysv/newrelic-infra ​to /etc/init.d/system/newrelic-infra
  2. Run the following commands:
    initctl reload-configuration
    update-rc.d newrelic-infra defaults
    update-rc.d newrelic-infra enable
Upstart
  1. Copy the service file ./newrelic-infra/etc/init_scripts/upstart/newrelic-infra ​to /etc/init/newrelic-infra.conf
  2. Run the following command:
    initctl reload-configuration

Your service script is configured. Configure the rest of the options and start the service manually.

Change config file's location

The Infrastructure agent includes a configuration file, usually named newrelic-infra.yml, to fine-tune the agent's behavior. For more information, see a config file template and how to configure the agent.

By default, the agent searches for the configuration file in one of these locations:

  • newrelic-infra.yml (working directory root folder)
  • /etc/newrelic-infra.yml
  • /etc/newrelic-infra/newrelic-infra.yml

To specify a different location, use the -config flag command-line. For example:

usr/bin/newrelic-infra -config /whatever/path/custom_config_name.yml

To make this change permanent, edit the service script:

Systemd
  1. Open the service script ./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service.
  2. Search for the line ExecStart=/usr/bin/newrelic-infra.
  3. Add the config flag and the config file path. In this example the config file is located in the /opt directory ExecStart=/usr/bin/newrelic-infra -config /opt/config.yaml.
  4. Save the file.
SysV
  1. Open the service script ./newrelic-infra/etc/init_scripts/sysv/newrelic-infra.

  2. Search for the line DAEMON=/usr/bin/$NAME”.
  3. Below the DAEMON variable, add this new line:

    EXTRA_OPTS="-config config_file" (with the quotation marks).

  4. Replace config_file with the path to the config file you want to use.
  5. Save the file.
Upstart
  1. Open the service script ./newrelic-infra/etc/init_scripts/upstart/newrelic-infra.
  2. Search for the line exec /usr/bin/newrelic-infra.
  3. Add the config flag and the config file path. Here the config file is located in the /opt directory exec /usr/bin/newrelic-infra -config /opt/config.yaml.
  4. Save the file.

Change the pid-file location

The Infrastructure agent uses a pid-file to keep the process identification number (pid), which is used to identify a running instance of the agent. How to change the location of the pid-file depends on how the agent is configured.

By default, we recommend that the agent creates the pid-file. You can edit the location if necessary.

To change the location of the pid-file:

If the agent creates the pid-file

On startup, the agent writes its process pid into the pid-file. If the file doesn’t exist it will create it.

By default, the agent creates the pid-file using the path /var/run/newrelic-infra/newrelic-infra.pid. To modify it, use one of these options:

  • Add the pid_file configuration option in the configuration file newrelic-infra.yml.
  • Provide the pid_file using the command line when running the newrelic-infra binary.
  • Set the NRIA_PID_FILE environment variable.

Since the agent creates or updates the pid-file every time it’s initialized, the user who runs the agent must have read/write permissions over the pid-file location.

Use the chown command to give owner rights to a user. For example, if the user nri-agent is running the agent and the pid-file location is set to/var/run/newrelic-infra-custom/nr.pid, then you can give the user rights with:

chown nri-agent:nri-agent /var/run/newrelic-infra-custom/
If the agent uses the PIDFILE environment variable

We do not recommend using the PIDFILE environment variable to manage the pid-file.

If the environment variable PIDFILE is set, the agent will not try to create the pid-file. Create the pid-file in a location of your choice.

Use this approach if someone else takes care of the pid-file lifecycle. For example, our init script sets the PIDFILE variable for some service managers, such as SysV, because they handle the creation and content of the pid-file.

Change the user and runtime mode

The Linux agent runs as root by default, but it also supports running with users with less privileges: PRIVILEGED and UNPRIVILEGED. For more information, see our documentation on agent running modes.

To execute the agent as a non-root user (PRIVILEGED or UNPRIVILEGED), make sure to grant read/write access to the folders and files provided in the tarball.

To change the running mode:

  1. Edit the service script:

    Systemd
    1. Open the service script ./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service.
    2. Search for the line [Service].
    3. Add the line User=user_name, and replace user_name with the user that you want to execute the agent (PRIVILEGED or UNPRIVILEGED).
    4. Save the file.
    SysV
    1. Open the service script ./newrelic-infra/etc/init_scripts/sysv/newrelic-infra.
    2. Search for the line USER=root.
    3. Replace root with the user that you want to execute the agent (PRIVILEGED or UNPRIVILEGED).
    4. Save the file.
    Upstart
    1. Open the service script ./newrelic-infra/etc/init_scripts/upstart/newrelic-infra.
    2. Search for the line exec /usr/bin/newrelic-infra.
    3. Replace it with exec su -s /bin/sh -c ‘exec “$0” “$@“’ user_name-- /usr/bin/newrelic-infra.
    4. Replace user_name with the user that you want to execute the agent (PRIVILEGED or UNPRIVILEGED).

    5. Save the file.

  2. If you're running the agent as PRIVILEGED, you must give it two additional Linux capabilities:
    1. Make sure the libcap library is installed in your host. (You need the setcap and getcap commands that come with it.)
    2. Extract the contents of the tarball and execute the following command with root permission:

      setcap CAP_SYS_PTRACE,CAP_DAC_READ_SEARCH=+ep ./newrelic-infra/usr/bin/newrelic-infra
    3. The run mode will be selected based on the current user and the Kernel Capabilities assigned to it.

Configure the plugin directory

The Infrastructure agent allows you to install integrations that monitor and report data from popular services such as Kubernetes, AWS, MySQL, Redis, Kafka, etc. Each integration has its own configuration file, named by default integration-name-config.yml, placed in the predefined location /etc/newrelic-infra/integrations.d/. On initialization, the agent loads the config file.

To overwrite the predefined location of the integration configuration file, use one of the following methods:

  • Set the location in the NRIA_PLUGIN_DIR environment variable.
  • Set the custom path in the newrelic-infra.yml configuration file using the plugin_dir field.
  • Pass it as a command line argument using -plugin_dir when you run the newrelic-infra binary.

Configure the agent directory

The agent requires its own defined directory to run the installed integrations, caching data (inventory), etc. The default location is /var/db/newrelic-infra/.

The agent directory has the following structure and content:

  • LICENSE: Text file containing the New Relic Infrastructure agent license.
  • custom-integrations: Directory that stores the installed the custom integrations.
  • newrelic-integrations: Directory that stores the New Relic official integrations.
  • data: Directory where the agent stores cache data (inventory).

The user running the agent must have read/write permissions to the agent directory.

To overwrite the predefined location of the agent directory, use one of the following methods:

  • Set the location in the NRIA_AGENT_DIR environment variable.
  • Set the custom path in the newrelic-infra.yml configuration file using the agent_dir field.
  • Pass it as a command line argument using -agent_dir when you run the newrelic-infra binary.

Configure the log file

By default the agent stores the log files in /var/db/newrelic-infra/newrelic-infra.log.

The user running the agent must have write permissions on the log file.

To overwrite the predefined location of the log file, use one of the following methods:

  • Set the location in the NRIA_LOG_FILE environment variable.
  • Set the custom path in the newrelic-infra.yml configuration file using the log_file field.
  • Pass it as a command line argument using -log_file when you run the newrelic-infra binary.

Change the location of the agent binary

To change the location of the executable, edit the service script:

Systemd
  1. Open the service script ./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service.
  2. Search for the line [ExecStart=/usr/bin/newrelic-infra].
  3. Replace the path.
  4. Save the file.
SysV
  1. Open the service script ./newrelic-infra/etc/init_scripts/sysv/newrelic-infra.
  2. Search for the line DAEMON=/usr/bin/$NAME.
  3. Replace the path.
  4. Save the file.
Upstart
  1. Open the service script ./newrelic-infra/etc/init_scripts/upstart/newrelic-infra.
  2. Search for the line exec /usr/bin/newrelic-infra.
  3. Replace the path.
  4. Save the file.

What's next?

You may also want to:

For more help

Recommendations for learning more: