Nagios monitors Nginx and PHP-FPM

Source: Internet
Author: User

The online use of Nagios monitoring, version is 4.0.8

Nginx is the latest version of Tengine, PHP is version 5.5


Nginx Plugin

Https://exchange.nagios.org/directory/Plugins/Web-Servers/nginx/check_nginx_status-2Epl/details

PHP-FPM Plug-in

Https://github.com/regilero/check_phpfpm_status


Unzip the file inside.

Get 2 files

check_nginx_status.pl

check_phpfpm_status.pl

Put these 2 files under the/usr/local/nagios/libexec directory

Set permissions

cd/usr/local/nagios/libexec/

chmod 755 check_nginx_status.pl check_phpfpm_status.pl

chmod Nagios:nagios check_nginx_status.pl check_phpfpm_status.pl


Installing components required to run PL plug-ins

Yum Install-y perl-time-hires


The following settings are required on the monitored side

modifying Nginx configuration Files

Vi/usr/local/nginx/conf/vhosts/dts.conf

Add Blue Section

server {

Listen 10.168.45.10:80;

server_name dts.xx.com;

root/www/dts/web/www;

Index index.php index.html index.htm;


#nagios查看nginx信息

Location/nginx_status {

Stub_status on;

#allow 10.252.12.7;

#deny all;

}

#nagios查看php信息

Location =/status {

Include Fastcgi_params;

Fastcgi_param script_filename $document _root$fastcgi_script_name;

Fastcgi_index index.php;

Fastcgi_pass 127.0.0.1:9000;

#allow 10.252.12.7;

#deny all;

}


Location/{


}


Location ~ \.php$ {

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param script_filename $document _root$fastcgi_script_name;

Include Fastcgi_params;

}


}


Reboot load Nginx Configuration

/usr/local/nginx/sbin/nginx-s Reload


Modifying the PHP-FPM configuration file

Vi/usr/local/php/etc/php-fpm.conf

Remove the semicolon from the following line to turn on view status

Pm.status_path =/status


Reload PHP-FPM

/ETC/INIT.D/PHP-FPM Reload

The configuration of the client ends here.


Start testing on the server side

[Email protected] libexec]# cd/usr/local/nagios/libexec/

[Email protected] libexec]# /check_nginx_status.pl-h 10.168.45.10

NGINX OK-0.054 sec. Response time, active:11 (writing:11 reading:0 waiting:0) reqpersec:0.000 connpersec:0.000 Re qperconn:0.000| writing=11;;;; reading=0;;;; waiting=0;;;; active=11;;;; reqpersec=0.000000;;;; connpersec=0.000000;;;; reqperconn=0.000000;;;;

[Email protected] libexec]# /check_phpfpm_status.pl-h 10.168.45.10-u/status?full

PHP-FPM Ok-www, 0.073 sec. Response time, Busy/idle 12/1298, (max:34, reached:0), reqpersec 90.1, Queue 0 (len:128, R eached:0) | idle=1298 busy=12 maxprocesses=34 maxprocessesreach=0 queue=0 maxqueuereach=0 queuelen=128 ReqPerSec=90.084746


Modify a file

Vi/usr/local/nagios/etc/objects/commands.cfg

Last line add


# check Nginx

Define Command {

Command_name Check_nginx_status

Command_line $USER 1$/check_nginx_status.pl-h $HOSTADDRESS $

}


# Check PHPFPM

Define Command {

Command_name Check_phpfpm_status

Command_line $USER 1$/check_phpfpm_status.pl-h $HOSTADDRESS $-u/status?full

}


Modify the Hosts file to add the following content


Define Service{

Use Generic-service

HOST_NAME app_1

Service_description Nginx_status

Check_command Check_nginx_status

}

Define Service{

Use Generic-service

HOST_NAME app_1

Service_description Phpfpm_status

Check_command Check_phpfpm_status

}


Restart Nagios

/etc/init.d/nagios restart


View Page


The first time you view the page, you will find a red message indicating

/tmp/10.168.45.10_check_nginx_status3b462c1ca9852cf74bb3c8c3c6a10872

/tmp/10.168.45.10_check_phpfpm_status3b683c1ca9817cf74ff3c7c3c6a10884

Cannot write

The solution is to delete the file, wait a few minutes, and it will turn green.


If the installation path for Nagios is not/usr/local/nagios

Then when viewing Phpfpm_status, you are prompted not to find the load utils.pm file

The workaround is to modify the check_phpfpm_status.pl file

Use Lib "/usr/local/nagios/libexec";

Modify the path for your own installation

The view will turn green in a few minutes.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/34/wKioL1WU3g_wWh5TAACDpuygeJI727.jpg "title=" Qq20150702143728.png "alt=" wkiol1wu3g_wwh5taacdpuygeji727.jpg "/>650" this.width=650; "src=" http://s3.51cto.com /wyfs02/m02/6f/37/wkiom1wu3ftiu2ifaab2jmbpqmc787.jpg "title=" Qq20150702143738.png "alt=" Wkiom1wu3ftiu2ifaab2jmbpqmc787.jpg "/>


This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1670142

Nagios monitors Nginx and PHP-FPM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.