How To Monitor PHP-FPM and Nginx With Zabbix

This is another quick tutorial, this time I’ll show you how to configure your server to allow zabbix to monitor Nginx and PHP-FPM. This tutorial assumes you’ve already installed zabbix on your monitoring server and also the server to be monitored. For simplicity sake, let’s call your zabbix server (the one doing the monitoring) zabbix_mon and let’s call the server you would like to monitor, server1. Zabbix is an open source monitoring solution available here, Nginx is an httpd and reverse proxy server, found here and php-fpm is an alternative PHP FastCGI found here.
Ok, with that out of the way, let set this up.

1. First, assuming you already have both Nginx and PHP-FPM installed and configured on server1, enable php-fpm status page in php-fpm config file (just make sure this line exists and it is not commented out):

sudo vim /etc/php-fpm.d/www.conf

pm.status_path = /phpfpm-status

2. restart php-fpm

sudo /etc/init.d/php-fpm restart

Now allow nginx to server both php-fpm and nginx status pages. Create 2 separate config files, one for nginx status and another for php-fpm status:

3. Create a new config file under /etc/nginx/virtual.d/ for php-fpm status

sudo vim /etc/nginx/virtual.d/fpmstatus.conf


#
# Enable php-fpm status
#
server {
    listen       55888;

    location /phpfpm-status {
        fastcgi_pass   unix:/tmp/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        allow 127.0.0.1;
        allow 111.111.111.111;    # Put your zabbix_mon zabbix monitoring server here
        deny all;
    }
}

4. Create a new config file under /etc/nginx/virtual.d/ for nginx status

sudo vim /etc/nginx/virtual.d/nginxstatus.conf

# Enable nginx status
server {

   listen 55777;

   location /nginx-status {
        stub_status on;
        access_log   off;
        allow 127.0.0.1;
        allow 111.111.111.111;    # Put your zabbix_mon zabbix monitoring server here
        deny all;
        }
}

5. Reload nginx

sudo /etc/init.d/nginx reload

6. Test both status pages:

curl http://127.0.0.1:55888/phpfpm-status

pool:                 www
process manager:      dynamic
start time:           18/Dec/2012:13:26:29 -0600
start since:          867269
accepted conn:        902240
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       19
active processes:     1
total processes:      20
max active processes: 121
max children reached: 30


curl http://127.0.0.1:55777/nginx-status
Active connections: 1 
server accepts handled requests
 474931 474931 474995 
Reading: 0 Writing: 1 Waiting: 0 

7. Install perl(LWP::UserAgent)

sudo yum install perl-libwww-perl

8. Create a script for zabbix:

sudo vim /usr/local/zabbix/plugins/php-fpm_status.pl

#!/usr/bin/perl
#
# Boris HUISGEN <bhuisgen@hbis.fr>

use LWP::UserAgent;

my $URL = "http://127.0.0.1:55888/phpfpm-status";

#
# DO NOT MODIFY AFTER THIS LINE
#

my $ua = LWP::UserAgent->new(timeout => 15);
my $response = $ua->request(HTTP::Request->new('GET', $URL));

my $conn = 0;
my $idle = 0;
my $active = 0;
my $total = 0;
my $maxchildren = 0;

foreach (split(/\n/, $response->content)) {
 $conn = $1 if (/^accepted conn:\s+(\d+)/);
 $idle = $1 if (/^idle processes:\s+(\d+)/);
 $active = $1 if (/^active processes:\s+(\d+)/);
 $total = $1 if (/^total processes:\s+(\d+)/);
 $maxchildren = $1 if (/^max children reached:\s+(\d+)/);
  }

 print "Accepted conn: $conn\tIdle proc: $idle\tActive proc: $active\tTotal proc: $total\tMax children: $maxchildren\n";

9. Create the file with zabbix parameters (this file calls the file above)

sudo vim /usr/local/etc/zabbix_agentd.conf.d/php_fpm

UserParameter=php.conn,/usr/local/zabbix/plugins/php-fpm_status.pl|cut -f1|cut -d" " -f3
UserParameter=php.idle,/usr/local/zabbix/plugins/php-fpm_status.pl|cut -f2|cut -d" " -f3
UserParameter=php.active,/usr/local/zabbix/plugins/php-fpm_status.pl|cut -f3|cut -d" " -f3
UserParameter=php.total,/usr/local/zabbix/plugins/php-fpm_status.pl|cut -f4|cut -d" " -f3
UserParameter=php.maxchildren,/usr/local/zabbix/plugins/php-fpm_status.pl|cut -f5|cut -d" " -f3

10. Also create the monitor for nginx

sudo vim /usr/local/etc/zabbix_agentd.conf.d/nginx_monitor

UserParameter=nginx.active[*],wget -O- -q http://localhost:55777/nginx-status | grep 'Active' | awk '{print $NF}'
UserParameter=nginx.reading[*],wget -O- -q http://localhost:55777/nginx-status | grep 'Reading' | awk '{print $$2}'
UserParameter=nginx.writing[*],wget -O- -q http://localhost:55777/nginx-status | grep 'Writing' | awk '{print $$4}'
UserParameter=nginx.waiting[*],wget -O- -q http://localhost:55777/nginx-status | grep 'Waiting' | awk '{print $$6}'
UserParameter=nginx.accepted[*],wget -O- -q http://localhost:55777/nginx-status | awk NR==3 | awk '{print $$1}'
UserParameter=nginx.handled[*],wget -O- -q http://localhost:55777/nginx-status | awk NR==3 | awk '{print $$2}'
UserParameter=nginx.requests[*],wget -O- -q http://localhost:55777/nginx-status | awk NR==3 | awk '{print $$3}'

11. Change permissions on both files (assuming your zabbix user and group is called zabbix):

sudo chown zabbix.zabbix /usr/local/etc/zabbix_agentd.conf.d/php_fpm
sudo chmod 775 /usr/local/etc/zabbix_agentd.conf.d/php_fpm
sudo chown zabbix.zabbix /usr/local/zabbix/plugins/php-fpm_status.pl
sudo chmod 775 /usr/local/zabbix/plugins/php-fpm_status.pl

12. Add the new files to zabbix config so it loads the parameters

sudo vim /usr/local/etc/zabbix_agentd.conf

Include=/usr/local/etc/zabbix_agentd.conf.d/php_fpm
Include=/usr/local/etc/zabbix_agentd.conf.d/nginx_monitor

13. Restart zabbix to load the new parameters

sudo /etc/init.d/zabbix_agentd stop
sudo /etc/init.d/zabbix_agentd start

14. Load the templates below to zabbix_mon and apply the templates to the servers you’d like to monitor (using the zabbix web page for your zabbix_mon server):

php-fpm-zabbix-template.xml

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2012-12-28T20:30:14Z</date>
    <groups>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template_PHP_FPM</template>
            <name>Template PHP FPM</name>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>PHP FPM</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>PHP - number of active processes</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>php.active</key>
                    <delay>15</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>PHP FPM</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>PHP - number of idle processes</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>php.idle</key>
                    <delay>15</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>PHP FPM</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>PHP - number of max children reached</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>php.maxchildren</key>
                    <delay>15</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>PHP FPM</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>PHP - number of total accepted connections</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>php.conn</key>
                    <delay>15</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>PHP FPM</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>PHP - number of total processes</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>php.total</key>
                    <delay>15</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>PHP FPM</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
            </items>
            <discovery_rules/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <graphs>
        <graph>
            <name>PHP FPM Scoreboard</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>0</show_work_period>
            <show_triggers>0</show_triggers>
            <type>0</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>1</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>1</drawtype>
                    <color>009900</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_PHP_FPM</host>
                        <key>php.conn</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>5</drawtype>
                    <color>888800</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_PHP_FPM</host>
                        <key>php.total</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>5</drawtype>
                    <color>FFA500</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_PHP_FPM</host>
                        <key>php.idle</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>5</drawtype>
                    <color>EEEE00</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_PHP_FPM</host>
                        <key>php.active</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <drawtype>5</drawtype>
                    <color>DD0000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_PHP_FPM</host>
                        <key>php.maxchildren</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
</zabbix_export>

nginx-zabbix-template.xml

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2012-12-28T20:29:03Z</date>
    <groups>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Tpl_Nginx_Monitor</template>
            <name>Template Nginx Monitor</name>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Nginx</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Nginx Accepted</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.accepted[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx Active</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.active[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx Handled</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.handled[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx Reading</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.reading[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx Requests</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.requests[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx Waiting</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.waiting[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx Writing</name>
                    <type>0</type>
                    <snmp_community></snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid></snmp_oid>
                    <key>nginx.writing[]</key>
                    <delay>30</delay>
                    <history>60</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts></allowed_hosts>
                    <units></units>
                    <delta>0</delta>
                    <snmpv3_securityname></snmpv3_securityname>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase></snmpv3_authpassphrase>
                    <snmpv3_privpassphrase></snmpv3_privpassphrase>
                    <formula>1</formula>
                    <delay_flex></delay_flex>
                    <params></params>
                    <ipmi_sensor></ipmi_sensor>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username></username>
                    <password></password>
                    <publickey></publickey>
                    <privatekey></privatekey>
                    <port></port>
                    <description></description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
            </items>
            <discovery_rules/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <graphs>
        <graph>
            <name>Nginx Scoreboard</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>1</show_work_period>
            <show_triggers>0</show_triggers>
            <type>0</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>0</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>5</drawtype>
                    <color>555555</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.requests[]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>5</drawtype>
                    <color>CCFFFF</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.handled[]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>1</drawtype>
                    <color>009900</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.accepted[]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>1</drawtype>
                    <color>CCCCCC</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.active[]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <drawtype>1</drawtype>
                    <color>FFA500</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.writing[]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <drawtype>1</drawtype>
                    <color>EEEE00</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.reading[]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>6</sortorder>
                    <drawtype>1</drawtype>
                    <color>DD0000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Tpl_Nginx_Monitor</host>
                        <key>nginx.waiting[]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
</zabbix_export>

That’s it, now you will be able to monitor both nginx and php-fpm from zabbix, just remember to import both templates above into your zabbix server and apply them to each of the servers you’d like to monitor. Thanks for stopping by once again and remember, share with others, after all, code should be free.foscode.com | because code should be free

One thought on “How To Monitor PHP-FPM and Nginx With Zabbix

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>