New Relic monitoring for Server, Virtual Host PHP and WordPress

New Relic offers completely free server monitoring (CPU, RAM, Network I/O etc) and limited (24 hour retention) PHP application performance monitoring (detailed error logs, PHP vs MySQL load times etc). Its far better than monitoring tools I’ve seen and very useful for trying to figure out any problems with WordPress which can be quite heavy in different areas CPU vs RAM vs Database.

Server monitoring

New Relic have excellent docs on the server installation, but this is a summary of the commands, N.B. the YOUR_LICENCE_KEY needs to be changed:

sudo sh -c 'echo deb http://apt.newrelic.com/debian/ newrelic non-free > /etc/apt/sources.list.d/newrelic.list'
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install newrelic-sysmond
nrsysmond-config --set license_key=YOUR_LICENCE_KEY
/etc/init.d/newrelic-sysmond start

PHP monitoring

There’s again useful New Relic installation notes:

sudo sh -c 'echo deb http://apt.newrelic.com/debian/ newrelic non-free > /etc/apt/sources.list.d/newrelic.list'
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update

This is all repeated from the Server section, so the only actual line required is:

sudo apt-get install newrelic-php5

This asks you to give an Application Name – the best format to use is [vhost domain];[server domain] where the server domain is used as a kind of parent filter for all vhost domains.

PHP vhosts applications

This doesn’t quite work for Plesk installations as we want a per-directory application performance indicator. This assumes that we’re using the Apache php mod rather than FastCGI as we’re putting PHP ini settings in apache config files.

Plesk

This guide (http://blogs.reliablepenguin.com/2015/02/11/plesk-new-relic) was the perfect starting point. The application names they suggest are really useful e.g.

[vhost domain];[server domain]

Changing the application name

If you make a mistake with the application name you can change it. Just follow this document (https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications).

Apache Virtual Hosts

I have a manual setup on a dev server – so I needed to modify the /etc/php5/conf.d/newrelic.ini file to comment out the appname.

I could then add the variables into the /etc/apache2/sites-available/* apache config files with

php_value newrelic.appname "vhost.example.com;server.example.com"

WordPress W3 Total Cache

W3 Total Cache offers a basic integration with New Relic through its API.

There’s a couple of links for this:

W3 Total Cache assumes that you’ve setup the PHP application. What is non-obvious is that you need an API key and not your licence key. Via a WordPress SE answer, you can then enable API access (Select (account name) > Account settings > Integrations > Data sharing > API access) and use the generated API key in WordPress Admin > W3 Total Cache > General Settings > Monitoring section (wp-admin/admin.php?page=w3tc_general#monitoring).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s