Nagios Monitor nginx status (check_nginx_status.pl)

Source: Internet
Author: User

1. Install the required components

Yum Install Perl perl-devel perl-cpan bc-y

Perl-mcpan-eshell & cpan> install BUNDLE::LWP

Compile and install Nrpe (refer to Tutorial: http://2860664.blog.51cto.com/2850664/1559056 )



The following are the monitored side settings

2. Download check_nginx_status.pl Script

: Https://codeload.github.com/regilero/check_nginx_status/zip/master

After extracting the files, upload check_nginx_status.pl to/usr/local/nagios/libexec

chmod +x check_nginx_status.pl

Chown Nagios.nagcmd check_nginx_status.pl

3. Test script on monitored side

Cd/usr/local/nagios/libexec

./check_nginx_status.pl-h 192.168.1.247 -S www.xxx.com -P 80

NGINX OK-0.067 sec. Response time, active:1 (writing:1 reading:0 waiting:0) reqpersec:0.111 connpersec:0.111 REQP erconn:1.000| writing=1;;;; reading=0;;;; waiting=0;;;; active=1;;;; reqpersec=0.111111;;;; connpersec=0.111111;;;; reqperconn=1.000000;;;;

Where red is the IP address of the Nginx server, and green is the website URL that needs to be monitored.

4,vi/usr/local/nagios/etc/nrpe.cfg Add

Command[check_nginx]=/usr/local/nagios/libexec/check_nginx_status.pl-h 192.168.1.247 -S www.xxx.com -P 80

5. Delete the 192.168.1.247_CHECK_NGINX_STATUS8D727909E5ACE94DC547C3AF50AF6CB9 generated by/TMP or the following error! Prompt failed to generate file.

rm/tmp/192.168.1.247_check_nginx_status8d727909e5ace94dc547c3af50af6cb9

The following are the settings for the Nagios host

5. Server-Side testing

/usr/local/nagios/libexec/check_nrpe-h 192.168.1.247-c Check_nginx

NGINX OK-0.065 sec. Response time, active:1 (writing:1 reading:0 waiting:0) reqpersec:0.020 connpersec:0.020 REQP erconn:1.000| writing=1;;;; reading=0;;;; waiting=0;;;; active=1;;;; reqpersec=0.020000;;;; connpersec=0.020000;;;; reqperconn=1.000000;;;;


Vi/usr/local/nagios/etc/nagios.cfg add

cfg_file=/usr/local/nagios/etc/objects/nginx.cfg

6, Touch/usr/local/nagios/etc/objects/nginx.cfg

Vi/usr/local/nagios/etc/objects/nginx.cfg (Note to modify the IP on the monitored side) the content is as follows  

**************************************** I'm a split line ************************************

define host{           use              linux-server           host_name     nginx           alias         nginx           address        Monitored end ip         }define service{        use                        generic-service        host_name              nginx         service_description     check-swap        check_command         check_nrpe!check_swap                }define service{         use                       generic-service        host_name              nginx         service_description     check-load        check_command         check_nrpe!check_load                }define service {        use                       generic-service        host_name              nginx        service_description     check-disk        check_command        check_nrpe!check_sda1                }define service{         use                       generic-service         host_name              nginx       service_description     check-users        check_command        check_nrpe!check_users                }define service{         use                     generic-service         host_name           nginx         service_description  otal_procs         check_command     check_nrpe!check_total_procs}define service{         use                              generic-service          ; name of service template to use         host_name                        nginx         service_description              PING        check_command                    check_ping! 100.0,20%!500.0,60%        }define service{     use                      generic-service    host_name                nginx    service_description     nginx_status     check_command           check_ nrpe!check_nginx!        notifications_enabled            0        }

I'm also a split line ************************************

Error message

7. Nagios Server Error

NGINX unknown-unable to write temporary data in:/tmp/192.168.1.247_check_nginx_ Status8d727909e5ace94dc547c3af50af6cb9

Workaround: Delete the files under the monitored host/tmp 192.168.1.247_CHECK_NGINX_STATUS8D727909E5ACE94DC547C3AF50AF6CB9

rm/tmp/192.168.1.247_check_nginx_status8d727909e5ace94dc547c3af50af6cb9

This article is from the "Linux related sharing" blog, make sure to keep this source http://2860664.blog.51cto.com/2850664/1564225

Nagios Monitor nginx status (check_nginx_status.pl)

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.