Agent Installation for PHP

Cavisson PHP Agent (APM) is a PHP based agent for instrumenting a PHP application. It is similar to Cavisson NetDiagnostics NodeJS Agent, which is used for instrumenting Node.js application, and BCI agent, which is used to instrument Java-based enterprise application.

Terminologies Used

AbbreviationDescription
ndHomeThe Home directory of ND
Example: /opt/cavisson/netdiagnostics

Installation Prerequisites

This section describes all the prerequisites of the server where PHP Agent is to be installed:

  1. Platform requirements
    • Linux
  1. Storage requirements
    • Minimum disk space of 256 Megabytes (4 Mb installation files plus logs)
  1. PHP requirements
    • PHP supported version is 5.4 and later.
    • PHP-FPM should be installed on the server (optional). PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. 
  1. Other requirements
    • Apache Portable Runtime (APR) libraries, such as lib-apr and lib-apr-util should be installed on the server.

Agent Installation for PHP Programming Framework

Enable PHP Agent for Monitoring Application

A. Installing both Agent (.so) and proxy on the same Server

1. Keep the build file (the file with .so extension) within the php home directory.

Example:
php home: /usr/lib/php/20151012
Build File:cavPhpAgent.4.1.14.33.so

2. Keep the proxy binary at ndHome directory.

Example: 
NDHOME=/opt/cavisson/netdiagnostics
Proxy Binary: proxyControl.4.1.14.33

3. Add extension at php.ini files at the last.

Example:
/etc/php/7.0/apache2/php.ini
/etc/php/7.0/cli/php.ini
extension=cavPhpAgent.4.1.14.33.so 

Copy the service control files controlService and cavNdproxy at the following path:

Path: /etc/init.d/

4. Make following entries within the ndsettings.conf and proxysetting.conf files at ndHome directory.

root@Cav-30-48:/opt/cavisson/netdiagnostics/config# ls -ltr
-rwxrwxr-x 1 root root   30 Feb  6 12:41 proxysetting.conf
-rwxr-xr-x 1 root root  145 Feb 11 16:23 ndsettings.conf

/opt/cavisson/netdiagnostics/config/ndsettings.conf
tier=<Tier Name>
server= <Application Server IP>
instance= <Application Instance name>
ndcHost= <ndc host>
ndcPort= < ndc port>
proxyIP= <proxy server>
proxyPort= <proxy port>
proxyConType=0
proxyMode=1
root@Cav-30-48:/opt/cavisson/netdiagnostics/config# cat proxysetting.conf
proxyPort= <proxy port>
proxyConType=0

Example:

/opt/cavisson/netdiagnostics/config/ndsettings.conf
root@Cav-30-48:/opt/cavisson/netdiagnostics/config# cat ndsettings.conf
tier=PhpApp
server=10.10.30.48
instance=Instance1
ndcHost=10.10.30.29
ndcPort=9999
proxyIP=10.10.30.48
proxyPort=1111
proxyConType=0
proxyMode=1

root@Cav-30-48:/opt/cavisson/netdiagnostics/config# cat proxysetting.conf
proxyPort=1111
proxyConType=0

5. Restart the proxy.

/etc/init.d/cavNdproxy restart

6. Restart the agent (apache2).

/etc/init.d/apache2 restart

B. Installing Agent (.so) and proxy on different Servers

Configuration at Application Side

  1. Keep the build file (the file with .so extension) within the php home directory.

Example:

php home: /usr/lib/php/20151012
Build File:cavPhpAgent.4.1.14.33.so

  1. Add extension at php.ini files at the last.

Example:

/etc/php/7.0/apache2/php.ini /etc/php/7.0/cli/php.ini extension=cavPhpAgent.4.1.14.33.so

  1. Make the following entries within the ndsettings.conf files at ndHome/config directory.

root@Cav-30-48:/opt/cavisson/netdiagnostics/config# ls -ltr -rwxr-xr-x 1 root root  145 Feb 11 16:23 ndsettings.conf

/opt/cavisson/netdiagnostics/config/ndsettings.conf
tier=<Tier Name>
server= <Application Server IP>
instance= <Application Instance name>
ndcHost= <ndc host>
ndcPort= < ndc port>
proxyIP= <proxy server>
proxyPort= <proxy port>
proxyConType=0
proxyMode=1

Example:

/opt/cavisson/netdiagnostics/config/ndsettings.conf
root@Cav-30-48:/opt/cavisson/netdiagnostics/config# cat ndsettings.conf
tier=PhpApp
server=10.10.30.48
instance=Instance1
ndcHost=10.10.30.29
ndcPort=9999
proxyIP=10.10.30.29
proxyPort=1111
proxyConType=0
proxyMode=1 

Configuration of proxy on other server:

  1. Keep the proxy binary at ndHome directory.

Example: 

NDHOME=/opt/cavisson/netdiagnostics
Proxy Binary: proxyControl.4.1.14.33

  1. Copy the service control files controlService and cavNdproxy at the following path:

Path: /etc/init.d/

  1. Make the following entries within the ndsettings.conf andproxysetting.conf files at ndHome directory.

root@Cav-30-29:/opt/cavisson/netdiagnostics/config# ls -ltr
-rwxrwxr-x 1 root root   30 Feb  6 12:41 proxysetting.conf
-rwxr-xr-x 1 root root  145 Feb 11 16:23 ndsettings.conf

 /opt/cavisson/netdiagnostics/config/ndsettings.conf
ndcHost= <ndc host>
ndcPort= < ndc port>
proxyConType=0
proxyMode=1

root@Cav-30-29:/opt/cavisson/netdiagnostics/config# cat proxysetting.conf
proxyPort= <proxy port>
proxyConType=0 

Example:

/opt/cavisson/netdiagnostics/config/ndsettings.conf
root@Cav-30-29:/opt/cavisson/netdiagnostics/config# cat ndsettings.conf
ndcHost=10.10.30.29
ndcPort=9999
proxyConType=0
proxyMode=1

root@Cav-30-29:/opt/cavisson/netdiagnostics/config# cat proxysetting.conf
proxyPort=1111
proxyConType=0

  1. Restart the proxy.

/etc/init.d/cavNdproxy restart

  1. Restart the agent (apache2).

/etc/init.d/apache2 restart

Verification of Successful Installation

  1. Check the successful installation using the netstat command:

netstat -natp | grep <ndcPort>

  1. This displays the creation of three connections (Control / Data / Autosensor) to verify the successful installation of PHP agent:

root@Cav-30-48:/opt/cavisson/netdiagnostics/config# netstat -natp | grep 9999
tcp 46  0 10.10.30.48:6574  10.10.30.29:9999 ESTABLISHED 7210/proxyControl.4
tcp 26  0 10.10.30.48:6572  10.10.30.29:9999 ESTABLISHED 7210/proxyControl.4
tcp 0   0 10.10.30.48:6518  10.10.30.29:9999 ESTABLISHED 7210/proxyControl.4

Un-Installation / Rollback

To un-install, the PHP agent, revert the installation process, restart apache2, and stop the proxy servers.