Our custom Linux installation process for infrastructure monitoring 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.
Install the agent
Before installation, check the compatibility and requirements.
Additional agent package options | Comments |
---|---|
Troubleshooting |
As of version 1.4.0, the infrastructure agent package includes the additional |
Daemon process |
As of version 1.5.59, the infrastructure agent package includes the additional |
To install the agent:
- Download the packaged agent file.
- Unpack the file.
- Make sure the file unpacks with the following structure:
newrelic-infra |-- config_defaults.sh |-- etc | |-- init_scripts | | |-- systemd | | | `-- newrelic-infra.service | | |-- sysv | | | `-- newrelic-infra | | `-- upstart | | `-- newrelic-infra | `-- newrelic-infra | `-- integrations.d |-- installer.sh |-- usr | `-- bin | |-- newrelic-infra | |-- newrelic-infra-ctl | `-- newrelic-infra-service `-- var |-- db | `-- newrelic-infra | |-- custom-integrations | |-- integrations.d | |-- LICENSE.txt | `-- newrelic-integrations |-- log | `-- newrelic-infra `-- run `-- newrelic-infra
- Install the service script.
- Optional: Additional install steps.
Install: Optional steps
You can also carry out these additional steps:
- Change the location of the configuration file.
- Change the location of the PID file.
- Change the user and runtime mode.
- Configure the plugin directory.
- Configure the agent directory.
- Configure the log file.
- 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
-
- Copy the service file
./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service
to/etc/systemd/system/newrelic-infra.service
- Enable the service script:
systemctl enable newrelic-infra.service
- Copy the service file
- SysV
-
- Copy the service file
./newrelic-infra/etc/init_scripts/sysv/newrelic-infra
to/etc/init.d/system/newrelic-infra
- Run the following commands:
update-rc.d newrelic-infra defaults update-rc.d newrelic-infra enable
- Copy the service file
- Upstart
-
- Copy the service file
./newrelic-infra/etc/init_scripts/upstart/newrelic-infra
to/etc/init/newrelic-infra.conf
- Run the following command:
initctl reload-configuration
- Copy the service file
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
-
- Open the service script
./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service
. - Search for the line
ExecStart=/usr/bin/newrelic-infra
. - Add the config flag and the config file path. In this example the config file is located in the
/opt
directoryExecStart=/usr/bin/newrelic-infra -config /opt/config.yaml
. - Save the file.
- Open the service script
- SysV
-
-
Open the service script
./newrelic-infra/etc/init_scripts/sysv/newrelic-infra
. - Search for the line
DAEMON=/usr/bin/$NAME”
. -
Below the DAEMON variable, add this new line:
EXTRA_OPTS="-config config_file"
(with the quotation marks). - Replace
config_file
with the path to the config file you want to use. - Save the file.
-
- Upstart
-
- Open the service script
./newrelic-infra/etc/init_scripts/upstart/newrelic-infra
. - Search for the line
exec /usr/bin/newrelic-infra
. - Add the
config flag
and theconfig file path
. Here theconfig file
is located in the/opt
directoryexec /usr/bin/newrelic-infra -config /opt/config.yaml
. - Save the file.
- Open the service script
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 thepid-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 filenewrelic-infra.yml
. - Provide the
pid_file
using the command line when running thenewrelic-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 thepid-file
location.Use the
chown
command to give owner rights to a user. For example, if the usernri-agent
is running the agent and thepid-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/
- Add the
- If the agent uses the PIDFILE environment variable
-
We do not recommend using the
PIDFILE
environment variable to manage thepid-file
.If the environment variable
PIDFILE
is set, the agent will not try to create thepid-file
. Create thepid-file
in a location of your choice.Use this approach if someone else takes care of the
pid-file
lifecycle. For example, ourinit
script sets thePIDFILE
variable for some service managers, such as SysV, because they handle the creation and content of thepid-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:
-
Edit the service script:
- Systemd
-
- Open the service script
./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service
. - Search for the line
[Service]
. - Add the line
User=user_name
, and replaceuser_name
with the user that you want to execute the agent (PRIVILEGED
orUNPRIVILEGED
). - Save the file.
- Open the service script
- SysV
-
- Open the service script
./newrelic-infra/etc/init_scripts/sysv/newrelic-infra
. - Search for the line
USER=root
. - Replace
root
with the user that you want to execute the agent (PRIVILEGED
orUNPRIVILEGED
). - Save the file.
- Open the service script
- Upstart
-
- Open the service script
./newrelic-infra/etc/init_scripts/upstart/newrelic-infra
. - Search for the line
exec /usr/bin/newrelic-infra
. - Replace it with
exec su -s /bin/sh -c ‘exec “$0” “$@“’ user_name-- /usr/bin/newrelic-infra
. -
Replace
user_name
with the user that you want to execute the agent (PRIVILEGED
orUNPRIVILEGED
). -
Save the file.
- Open the service script
- If you're running the agent as
PRIVILEGED
, you must give it two additional Linux capabilities:- Make sure the
libcap
library is installed in your host. (You need thesetcap
andgetcap
commands that come with it.) -
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
- The run mode will be selected based on the current user and the Kernel Capabilities assigned to it.
- Make sure the
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 theplugin_dir
field. - Pass it as a command line argument using
-plugin_dir
when you run thenewrelic-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 theagent_dir
field. - Pass it as a command line argument using
-agent_dir
when you run thenewrelic-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 thelog_file
field. - Pass it as a command line argument using
-log_file
when you run thenewrelic-infra
binary.
Change the location of the agent binary
To change the location of the executable, edit the service script:
- Systemd
-
- Open the service script
./newrelic-infra/etc/init_scripts/systemd/newrelic-infra.service
. - Search for the line
[ExecStart=/usr/bin/newrelic-infra]
. - Replace the path.
- Save the file.
- Open the service script
- SysV
-
- Open the service script
./newrelic-infra/etc/init_scripts/sysv/newrelic-infra
. - Search for the line
DAEMON=/usr/bin/$NAME
. - Replace the path.
- Save the file.
- Open the service script
- Upstart
-
- Open the service script
./newrelic-infra/etc/init_scripts/upstart/newrelic-infra
. - Search for the line
exec /usr/bin/newrelic-infra
. - Replace the path.
- Save the file.
- Open the service script
What's next?
You may also want to:
- Add custom attributes to annotate your infrastructure data.
- Connect your AWS account if your servers are hosted on Amazon EC2.
- Add other infrastructure integrations to collect data from external services.
- Manually start, stop, restart, or check the agent status.