This document provides answers to some of the most frequently asked questions about New Relic's PHP agent.
- What is the recommended environment for the agent?
- I am having trouble - what can I provide support for the quickest solution?
- How do I report multiple applications or virtual hosts?
- Why are there two daemon processes?
- Why do I still see uninstrumented time with detail=1?
- Why do INI changes not take effect immediately?
- Is there a version of the agent for Windows?
- What does a protocol mismatch error in my log files mean?
- Do I need root (superuser) access to use New Relic?
- Why are all my transactions named index.php?
What is the recommended environment for the agent?
Newer is almost always better. This is especially true with both the PHP engine and Apache. Both projects are actively maintained, and both are the frequent target of security attacks. The development teams of both products are constantly releasing updates that fix security issues or improve performance and fix bugs. Therefore, New Relic strongly recommends that you use the latest possible version in the stable branch of each of these products.
I am having trouble. What can I provide to Support for the quickest solution?
First, review New Relic's troubleshooting section to make sure that your issue isn't one of the more common ones with a known, quick solution. If that guide doesn't solve your issue, get support at support.newrelic.com.
Second, if the issue you are experiencing is repeatable, collect both agent and daemon logs at the
verbosedebug log level. For most problems, this is key to quickly diagnosing the problem. Use the logfile to troubleshoot the issue. If you need further assistance, get support at support.newrelic.com.
- Save aside your current logs in /var/log/newrelic.
cd /var/log/newrelic mv php_agent.log php_agent.log.old mv newrelic-daemon.log newrelic-daemon.log.old
/etc/newrelic/newrelic.cfgmake sure you set
loglevel=verbosedebug. If you are not using the
newrelic.cfgfile for configuring the daemon, set
newrelic.daemon.loglevel = "verbosedebug"in your INI file.
- In your PHP INI file set
- Restart your daemon. If you are using the external daemon mode use
/etc/init.d/newrelic-daemon restart. If you are using the automatic mode please kill any copies of the daemon before restarting your web server.
- Restart your web server.
- Let your web server run for a few minutes, long enough to reproduce the problem you are experiencing.
- Zip php_agent.log, newrelic-daemon.log and your Apache error log and attach the Zip file (or compressed tar file) with your bug report.
How do I report multiple applications or virtual hosts?
Frequently one single web server is used for supporting more than one application or multiple virtual hosts, and you need to report all of those applications or hosts separately so that you can judge individual performance. You thus need to change the "application name" and possibly other parameters on a host by host, or directory by directory basis. Exactly how this is achieved depends entirely on your actual web infrastructure, and is covered in detail in per directory settings.. Please read that section carefully.
Why are there two daemon processes?
The New Relic daemon is a vital component of the PHP agent. It acts as a proxy between the various copies of PHP inside your web server and the New Relic data collectors. It is the only entity that communicates with New Relic. Therefore, it is absolutely vital that this process is always running, else no data will be sent to New Relic and you will see empty graphs. In order to maintain this stability, when the daemon first starts up it spawns a copy of itself. The original process becomes a "watcher" process, and does almost no work whatsoever. The second one is the "worker" process that does the real work. In the event of either a failure or a special instruction from the RPM servers to reset, the worker process will terminate. The watcher process sees that this is an unnatural shutdown of the worker and immediately respawns a new worker process, thus ensuring that there is the absolute minimum amount of downtime. Only when the daemon is shut down in an orderly manner will the watcher not respawn a new worker, and will itself terminate.
Why do I still see uninstrumented time with detail=1?
There are two reasons why you may still see red blocks of uninstrumented time in a transaction trace. The first is if you have a function that is called frequently that is very quick, and below the default 2ms threshold for the top 100 list. The second, and most common cause is when a function takes a long time to execute but is written in C and is either an internal function or a function provided by an external module. The most frequent culprits are functions that send large blocks of data or large files to users. If the user is on a slow connection even sending small files, for example small images, could take a long time due to simple network latency. Since no internal or C extension functions are instrumented, the PHP agent has no-one to "blame" the time spent on, and this shows up in a transaction trace as uninstrumented time.
Why do INI changes not take effect immediately?
When Apache first starts up and initializes PHP, all of the INI settings are read, and the global defaults for any missing settings are set. Apache then creates a pool of "worker" processes to deal with requests. These worker processes inherit the settings set during initialization. You have no way of knowing exactly which worker process will deal with a given request. When you make INI file changes, there may still be hundreds of worker processes left with the old settings, and the main Apache process itself (which will periodically kill existing and spawn new worker processes) also has the original INI settings. Thus, until you restart your Apache server, most changes to your INI files will go un-noticed. The only exception to this is if you use PHP's "per-directory" setting mechanism using
.htaccess files. Such settings are rare. Therefore, after you have made changes to your INI settings, you need to restart your Apache (or whatever other product you use) web server.
Is there a version of the agent for Windows?
Not currently, no. However, it is not out of the question, it just hasn't been specifically planned for yet. If you are interested in a Windows port of the agent please contact technical support so that we can both gauge interest in such a port, and notify you if such a port becomes available.
What does a protocol mismatch error in my log files mean?
After upgrading your agent you may see errors in your daemon log file along the lines of
protocol mismatch: A.B != X.Y. There is only one possible reason you will ever see this message: your agent and daemon are out of sync with each other. The daemon and the actual agent (the PHP extension) are a very tightly coupled pair, and the daemon will only accept connections and commands from an agent that matches it. Sometimes the upgrade process will fail to kill the old daemon correctly and you may still have old daemon processes running, but more frequently this error is caused by not restarting your web server after an upgrade. If the daemon was upgraded correctly but your web server still contains older agents, you will see this error. The error itself points to which is the culprit for being out of date. If the number
A.B is less than the number
X.Y, it means that you have an out of date agent trying to communicate with a more modern daemon. However if the number
A.B is higher than the number
X.Y then it means that your daemon is out of date, and the most likely cause is that you have too many daemons running. In this case, kill all of the currently running
newrelic-daemon processes, and restart the daemon using
Do I need root (superuser) access to use New Relic?
For most use cases, you will need root access to install New Relic for PHP. This is because the installation process requires privileges only available to the root user. These privileges include:
- Read/write access to the PHP extensions directory
- Read/write access to PHP configuration data, either in the PHP configuration directory (preferred) or in php.ini.
- Ability to restart the web server or PHP process pool.
Running the agent does not require root access. The agent does need read/write access to the following files (the location of these files can be customized in the PHP agent settings):
- A file in which to store the agent's log files
- A file in which to store the agent's socket endpoint
- A file in which to record the agent's process ID
Why are all my transactions named index.php?
This is a symptom of using a framework that we do not explicitly support. Most frameworks use some form of "Model-View-Controller" or MVC architecture. In such systems, all requests actually are made to a single file; either using URL parameters, POST data or some other mechanism, that file will determine what action needs to be taken. As a trivial example, you may see a URL such as
http://foo.com/index.php?action=view&article=1234. Thus, although the URL looks like it is accessing index.php, internally that file will look at the parameters and route to view.php and deal with viewing the given article.
For frameworks that New Relic explicitly supports, we have code in the agent to "reach into" the framework code and determine a more appropriate transaction name automatically. In this case, we would call the transaction "view". If you are using a home-grown or closed source framework like vBulletin, we do not know how to name your transaction, and you will need to modify your framework yourself. You do this using the
newrelic_name_transaction() API call at some suitable point in your code when you know the action that needs to be taken. Please be sure to read the article on metric grouping issues for information on how best to name transactions and common pitfalls to avoid.