Newrelic

From wiki.mikejung.biz
Jump to: navigation, search

Liquidweb 728x90.jpg

How to restart newrelic php agent

If you notice that NewRelic APM data is no longer updating and are not sure, I suggest tailing the php agent log on your server to see what the issue might be. If the agent gets an update, or your server software gets updated the PHP agent may not restart correctly, or may not run at all, to tell what is going on view the logs below

tail -f /var/log/newrelic/php_agent.log

In my case, I noticed tons of newrelic errors that mentioned warning: daemon connect (fd=6 uds=/tmp/.newrelic.sock). This error was gathered on a VPS running CentOS 6.6

2015-02-20 13:12:53.712 (14939 14939) warning: daemon connect(fd=6 uds=/tmp/.newrelic.sock) returned -1 errno=ENOENT. Failed to connect to the newrelic-daemon. Please make sure that there is a properly configured newrelic-daemon running. For additional assistance, please see: https://newrelic.com/docs/php/newrelic-daemon-startup-modes

To resolve this issue you can simply restart the newrelic-daemon which seemed to resolve the error above.

/usr/bin/newrelic-daemon restart

Newrelic nrsysmond and newrelic-daemon Memory Usage

I like to use this simple bash script to determine approximate memory usage for whatever process I pass as the option.

#!/bin/bash
ps -C $1 -O rss | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =",count; print "Memory usage per process =",sum/1024/count, "MB"; print "Total memory usage =", sum/1024, "MB" ;};'

The newrelic server agent, or nrsysmond runs a total of two process, each using about 3MB of RAM each, or a total of just 6MB. This is pretty low for an agent, so if you are worried about this agent wasting RAM, there's no need to be worried.

./mem.sh nrsysmond

Number of processes = 2
Memory usage per process = 2.92969 MB
Total memory usage = 5.85938 MB

The newrelic php agent is also pretty tiny in terms of memory usage. I have both the PHP agent and server agent installed and they use about 10MB of RAM total.

./mem.sh newrelic-daemon

Number of processes = 2
Memory usage per process = 1.6582 MB
Total memory usage = 3.31641 MB


How to start and restart newrelic server agent (newrelic-sysmond)

If you use NewRelic and sometimes see "No data reporting for this server" under the servers tab, odds are you need to start the server agent, (newrelic-sysmond). I'm not sure why sysmond decides to stop itself, but I've noticed this happens a few times a month.

To start newrelic-sysmond use this command

/etc/init.d/newrelic-sysmond start

To restart newrelic-sysmond use this command

/etc/init.d/newrelic-sysmond restart

How remove newrelic server agent (newrelic-sysmond) with yum

If you want to remove sysmond from CentOS you can simply use yum to remove it. If you used RPM to install newrelic then you may not be able to use yum to remove the agent.

yum remove newrelic-sysmond

How remove newrelic server agent (newrelic-sysmond) with rpm

If yum isn't doing what you want then try removing packages with rpm. -e means erase.

rpm -e newrelic-sysmond