cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tip: So, you want to monitor Nginx on Linux... but how to do it exactly?

antonio_villar1
Participant

Hi,

I'm proceeding to share the steps I followed to install web server agent for nginx on linux:

So, after transfering the Appmon web server agent software to the nginx server, unpacking it and modiying the .ini file, and starting the master agent with a correct mapping to a system profile (all explained in the documentation), you have to insert the call to the agent every time the nginx service starts. In recent linux distros (I tried Ubuntu and redhat) the nginx service is defined and managed by the systemd config files, generally located in /lib/system/system or /etc/systemd/system. So, at the web server you should have an nginx.service file in one of those two directories. Follow these steps:

- Edit the nginx.service file, and add the following line in the [Service] section:

Environment="LD_PRELOAD=/opt/dynatrace-6.5/agent/lib64/libdtagent.so"

BE CAREFULL! the string "nginx" the documentation refers to should not be included. This is an example, so adjust the path and bitness to suit your installation.

- Save the file, reload the configuration with the command as root:

 systemctl daemon-reload

- Restart the service:

 systemctl restart nginx.service

- It should take a couple of seconds, and no errors should ocurr. Go to the dynatrace client, open the agents overview dashboard and you should have the master agent and a sub item associated with the nginx process we just started, but this item is shown with a warning (yellow or red). Click on it, open the Details option, and it instructs you to run a script and restart nginx (at least this happened to me in two different installations). This script is dinamically generated the first time the instrumented nginx is started. The command takes this form:

/opt/dynatrace-6.5/agent/conf/generate_offsets.sh -b <path to nginx binary> -d <path to debug symbols> -o /opt/dynatrace-6.5/agent/conf/dtnginx_self_generated_offsets.json

in my case was:

/opt/dynatrace-6.5/agent/conf/generate_offsets.sh -b /usr/sbin/nginx -o /opt/dynatrace-6.5/agent/conf/dtnginx_self_generated_offsets.json

The script installs all depended utilities needed automatically (calls yum or apt-get install), and creates the json file needed to instrument nginx.

- So, run the script and then restart the nginx service:

systemctl restart nginx.service

- Go back to the console and you should have the agents in green.

That's it and have fun with it.

Antonio V. (from Spain)

1 REPLY 1

eric_dechelle
Newcomer

I'm trying to use NGINX with cluster on 2 nodes (PCS) but the environment variable is not taken into account by the process launch

pcs resource create webserver ocf:heartbeat:nginx configfile=/etc/nginx/nginx.conf op monitor timeout="5s" interval="5s"