Nagios Installation and configuration (personal note)

Source: Internet
Author: User

Nagios is an open source free network monitoring tool, can effectively monitor Windows,Linux and Unix host status, switch routers and other network settings, printers and so on. Send mail or SMS alarm when the system or service status is abnormal the first time to notify the site operators, after the status of the resumption of normal mail or SMS notification.

Nagios What's the difference with cacti ? In short, cacti mainly monitor traffic, Server Status page display;Nagios main monitoring services, mail and SMS alarm lights, of course, there is a simple flow monitoring interface, the combination of the use of better results. (with Nagios working simple logic diagram)

Nagios monitoring client needs to use plug-in and NRPE software to implement,NRPE as the intermediary agent, receive the Nagios server side of the request, the other end on the remote host to specify the relevant monitoring information.

About Nagios configuration and how to use it
The installed Nagios has five directories such as etc, bin, sbin, share, Var, if present, indicating that the program is properly installed on the system. Nagios Various directory uses are described below:
directory where the bin Nagios executable program resides
The directory where the ETC Nagios configuration files are located
The directory where the Sbin Nagios CGI files are located, that is, the files required to execute external commands
The directory where the share Nagios Web page file resides
Libexec Nagios External plug-in directory
The directory where the Var Nagios log files, lock, and other files reside
Var/archives Nagios Log Auto Archive directory
VAR/RW the directory used to store external command files

1. Monitoring end Installation Steps (ip:192.168.77.133)

(1)


    1. Installing Nagios dependent yum install -y gcc glibc glibc-common gdgd-devel xinetd  openssl-devel php.x86_64 perl; yum install  httpd  mysql    mysql-server    php   php-mysql  -y  Create Nagiso users and related paths     mkdir /usr/local/nagioschown -r nagios:nagios/usr/local/nagiosuseradd  nagios  Compile Download Install NAGIOSWGET HTTP://SOURCEFORGE.NET/PROJECTS/NAGIOS/FILES/NAGIOS-3.X/NAGIOS-3.2.1/ nagios-3.2.1.tar.gz/downloadhttp://down1.chinaunix.net/distfiles/nagios-plugins-1.4.14.tar.gz http:// nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gzuseraddnagiostar zxvf  nagios-3.2.1.tar.gzcd  nagios-3.2.1./configure  --prefix=/usr/local/nagios  -- with-command-group=nagiosmake allmakeinstall //to install the main program, CGI and HTML files makeinstall-init //in/etc/rc.d/ INIT.D Install the startup script makeinstall-config //to install the sample configuration file, the installation path is/usr/local/nagios/etcmakeinstall-commandmode //to configure directory permissions makeinstall-webconf //   Configure Nagios to integrate with Apache make all ; make install; make install-init;make  install-config;make install-commadnmode;make install-webconf;

(2) Installation Nagios-plugins

Tar zxvfnagios-plugins-1.4.14.tar.gz cdnagios-plugins-1.4.14./configure--prefix=/usr/local/nagios--with-nagios-u Ser=nagios--with-nagios-group=nagios make&& make install

(3) Plug-in Nrpe installation

TAR-XZF nrpe-2.14.tar.gz && cd nrpe-2.14&&./configure--enable-ssl--with-ssl-lib &&make All & Amp;&make install-plugin && make Install-daemon && makeinstall-daemon-config

(4)Nagios access control settings and testing

Htpasswd-c/usr/local/nagios/etc/htpasswd.users Nagiosadmin

Enter the password two times, the login page will use this password.

Restart Nagios,/etc/init.d/nagios restart;/etc/init.d/httpd restart;

http://192.168.77.133/nagios/such as 650) this.width=650; "title=" 9.jpg "alt=" wkiom1woxpdafczeaan6fansv24673.jpg "src=" Http://s3.51cto.com/wyfs02/M01/6F/02/wKiom1WOxPDAfCZEAAN6fAnsV24673.jpg "/>

(4) installed on the monitored side (ip:192.168.77.166)

Useradd Nagios; tar-xzf nagios-plugins-1.4.14.tar.gz &&CD Nagios-plugins-1.4.14&&./configure–prefix =/usr/local/nagios&&make &&make installtar-xzf nrpe-2.14.tar.gz && cd nrpe-2.14&&./ Configure--enable-ssl--with-ssl-lib &&make all &&make install-plugin && make Install-daemon & amp;& makeinstall-daemon-config chown-r nagios:nagios/usr/local/nagios/start Nrpe client command:/usr/local/nagios/bin/n Rpe-c/usr/local/nagios/etc/nrpe.cfg-d

(5) Monitoring configuration

A. Monitoring-side configuration:

CP Localhost.cfg 192.168.77.166.cfg

Replace the Locahost, 127.0.0.1, and check_local in the default configuration file with the latest

Add cfg_file=/usr/local/nagios/etc/objects/192.168.77.166.cfg after nagios.cfg 36 rows

Last execution:/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg no error can be

Define the Nrpe command, I am here to monitor MySQL master and slave, the HTTP keyword needs to define the command in COMMANDS.CFG:

Define command{        command_name    check_ nrpe        command_line     $USER 1$/check_nrpe  -H  $HOSTADDRESS $ -c  $ARG 1$        }define  command{        command_name    check_mysql         command_line     $USER 1$/check_mysql -h   $HOSTADDRESS $ -s -uroot -p123456           }define command{        command_name     check_http_word        command_line    $ user1$/check_http -i  $HOSTADDRESS $ -u  $ARG 1$ -p  $ARG 2$ -s  $ARG 3$           } 

Then define the services you want to monitor in 192.168.77.166.cfg:

Define Service{
Use Local-service
HOST_NAME 192.168.77.166
Service_description Sda1_monitor
Check_command check_nrpe!check_sda1
Notifications_enabled 1
}
Define Service{
Use Local-service
HOST_NAME 192.168.77.166
Service_description Sda2_monitor
Check_command Check_nrpe!check_sda2
Notifications_enabled 1
}
Define Service{
Use Local-service
HOST_NAME 192.168.77.166
Service_description Sda5_monitor
Check_command Check_nrpe!check_sda5
Notifications_enabled 1
}
Define Service {
Use Local-service
HOST_NAME 192.168.77.166
Service_description Check_mysql_slave
Check_command Check_mysql
}

Define Service {
Use Local-service
HOST_NAME 192.168.77.166
Service_description monitor_discuz_ Forum
Check_command check_http_word!/index.php!80! Forum
}

Then define the monitoring command on the monitored side:

Command[check_mysql]=/usr/local/nagios/libexec/check_mysqlcommand[check_users]=/usr/local/nagios/libexec/check _users-w 5-c command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5-c 30,25,20command[check_sda1]=/ Usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sda1command[check_sda2]=/usr/local/nagios/libexec/check_ Disk-w 20%-C 10%-p/dev/sda2command[check_sda5]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sda5

Last boot Nrpe:

/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d/usr/local/nagios/libexec/check_nrpe- Hlocalhost is monitored to verify/usr/local/nagios/libexec/check_nrpe-hlocalhost-c check_users Test command

B.

5 Steps to monitor a client:

1. Install Nrpe on both server side and client, install Nagios-plugins on client

2, in the client-defined monitoring of the specific project, modify allow allowed IP (server IP)

3. Start the client and server Nrpe respectively.

4. Define the Check_nrpe command in server-side commands.cfg:

Define Command{

Command_name Check_nrpe

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$

}

5, in the server-side corresponding IP configuration file, add the items that need to be monitored:

Define Service{

Use Local-service

HOST_NAME 192.168.77.166

Service_description Sda1_monitor

Check_command Check_nrpe!check_u

Notifications_enabled 1

       }

(6)

    1. Nagios Mail and SMS alarm

Use Nagios Alarm, previously can send alarm with fetion, but since Fetion changed the interface, it is not convenient, then we have to send SMS alarm how to do it, we can 139 mailbox, the mechanism is nagios to 139 mailbox send information, then the information will be automatically sent to our binding mobile phone. Bind your phone in 139 in advance. In addition, you can use the SMS cat (charge) device to send an alarm.

The default command.cfg has been configured in the Mail alarm settings, you can use the default configuration, using the system default mail to send mail, you can also define the content sent by the format and send the mail SMTP server-side software. You need to define the e-mail address you want to accept in vi/usr/local/nagios/etc/objects/contacts.cfg.



Since then, the Nagios-related configuration has ended, and further research will continue to be updated






This article is from the "Fluffy Duck" blog, please be sure to keep this source http://woshitieren.blog.51cto.com/2466034/1668679

Nagios Installation and configuration (personal note)

Related Article

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.