AbramS
Basic Pleskian
I'm running Plesk 12 (latest build) on CentOs 6.6 with PHP as FastCGI. I've been using New Relic to monitor PHP and server activity since I started working with Plesk and it has always worked great, and it still does.
By default the New Relic config grabs all PHP activity as one 'Application' through the newrelic.appname variable that is set in /etc/php.d/newrelic.ini. The default appname is 'PHP Application'.
Now the awesome thing is, that you can specify a per domain AppName, allowing you to monitor server activity and per site activity for PHP. I've tested this through the 'PHP Additional Directives' feature in Plesk, which allows me to define newrelic.appname on a per domain basis. This works great, but locks that site from syncing with the subscription, as you're customising the setup. So: it works for NewRelic, but it makes managing subscriptions a pain in the ***.
Fortunately different Plesk users created a workaround for this by using custom service templates for Plesk. The solution for Plesk 11 is to create a file called php.php inside /usr/local/psa/admin/conf/templates/custom/service/ with the following content:
After creating that file one needs to run a httpdmng --reconfigure-all and from that moment on all domains should report to NewRelic with the Domain Name as the newrelic.appname.
For whatever reason, this does not work in Plesk 12.
I then went into the /usr/local/psa/admin/conf/templates/default/service/ directory and copied all PHP related files to the custom/service directory. These additional files are: php_over_cgi.php, php_over_fastcgi.php and mod_fastcgi.php
As I'm running PHP through FastCGI, I figured that adding the same modifications to the <IfModule> declarations in those files would allow me to get the preferred results.... But after running another httpdmng --reconfigure-all, nothing changed... I kept comparing phpinfo files on two separate domains with different subscriptions, but both kept displaying 'PHP Application' as the default newrelic.appname. Again: changing this in the PHP additional directives of the domain, instantly updated the value to display the correct app name!
Finally: adding this piece of code:
to the <IfModule fcgi> in custom/domain/domainVirtualHost.php does grab the correct local PHP value IF you run PHP as an Apache module. So the code does seem to work under some settings in Plesk 12, but not with the combination of Plesk 12 and PHP as Fast CGI. How does one get it to work?
So what am I missing here? Which files should I alter in Plesk 12 and how should I alter them if I wish to dynamically populate the newrelic.appname value based on the domain name while running PHP as FastCGI?
Alternatively: Is there maybe a trick to populate the 'PHP additional directives' with a dynamic php_value that allows me to keep the subscriptions in sync?
Thank you for taking the time to think along and help fix this!
By default the New Relic config grabs all PHP activity as one 'Application' through the newrelic.appname variable that is set in /etc/php.d/newrelic.ini. The default appname is 'PHP Application'.
Now the awesome thing is, that you can specify a per domain AppName, allowing you to monitor server activity and per site activity for PHP. I've tested this through the 'PHP Additional Directives' feature in Plesk, which allows me to define newrelic.appname on a per domain basis. This works great, but locks that site from syncing with the subscription, as you're customising the setup. So: it works for NewRelic, but it makes managing subscriptions a pain in the ***.
Fortunately different Plesk users created a workaround for this by using custom service templates for Plesk. The solution for Plesk 11 is to create a file called php.php inside /usr/local/psa/admin/conf/templates/custom/service/ with the following content:
Code:
<IfModule <?php echo $VAR->server->webserver->apache->php4ModuleName ?>>
<?php
if ($OPT['enabled']) {
echo "php_admin_flag engine on\n";
if (isset($OPT['settings'])) {
echo $OPT['settings'];
}
} else {
echo "php_admin_flag engine off\n";
}
?>
<?php
if (isset($VAR->domain))
{
echo "php_value newrelic.appname '".$VAR->domain->idnName."'\n";
}
?>
</IfModule>
<IfModule mod_php5.c>
<?php
if (array_key_exists('enabled', $OPT) && $OPT['enabled']) {
echo "php_admin_flag engine on\n";
if (isset($OPT['settings'])) {
echo $OPT['settings'];
}
} else {
echo "php_admin_flag engine off\n";
}
?>
<?php
if (isset($VAR->domain))
{
echo "php_value newrelic.appname '".$VAR->domain->idnName."'\n";
}
?>
</IfModule>
<IfModule mod_fcgid.c>
<?php
if (isset($VAR->domain))
{
echo "php_value newrelic.appname '".$VAR->domain->idnName."'\n";
}
?>
</IfModule>
After creating that file one needs to run a httpdmng --reconfigure-all and from that moment on all domains should report to NewRelic with the Domain Name as the newrelic.appname.
For whatever reason, this does not work in Plesk 12.
I then went into the /usr/local/psa/admin/conf/templates/default/service/ directory and copied all PHP related files to the custom/service directory. These additional files are: php_over_cgi.php, php_over_fastcgi.php and mod_fastcgi.php
As I'm running PHP through FastCGI, I figured that adding the same modifications to the <IfModule> declarations in those files would allow me to get the preferred results.... But after running another httpdmng --reconfigure-all, nothing changed... I kept comparing phpinfo files on two separate domains with different subscriptions, but both kept displaying 'PHP Application' as the default newrelic.appname. Again: changing this in the PHP additional directives of the domain, instantly updated the value to display the correct app name!
Finally: adding this piece of code:
Code:
<?php
if (isset($VAR->domain))
{
echo "php_value newrelic.appname '".$VAR->domain->idnName."'\n";
}
?>
to the <IfModule fcgi> in custom/domain/domainVirtualHost.php does grab the correct local PHP value IF you run PHP as an Apache module. So the code does seem to work under some settings in Plesk 12, but not with the combination of Plesk 12 and PHP as Fast CGI. How does one get it to work?
So what am I missing here? Which files should I alter in Plesk 12 and how should I alter them if I wish to dynamically populate the newrelic.appname value based on the domain name while running PHP as FastCGI?
Alternatively: Is there maybe a trick to populate the 'PHP additional directives' with a dynamic php_value that allows me to keep the subscriptions in sync?
Thank you for taking the time to think along and help fix this!
Last edited: