Nagios Configuration and use

Source: Internet
Author: User

First, install Nagios


Yum Install-y epel-release

Yum install-y httpd nagios nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe


(where httpd as the web-side interface for Nagios)


You can also use the HTTPD tool to generate Nagios login passwords:


Htpasswd-c/etc/nagios/passwd Nagiosadmin


Detecting a configuration file for problems:


Nagios-v/etc/nagios/nagios.cfg


Start the service:


Service httpd Start

Service Nagios Start


Browser access:


Httpd://ip/nagios



Two, Nagios monitoring client


The Nagios service needs to be installed on the client machine:


Yum Install-y epel-release

Yum install-y nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe


Open configuration file/etc/nagios/nrpe.cfg


Find "allowed_hosts=127.0.0.1" to "allowed_hosts=127.0.0.1,192.168.1.11" followed by IP for service-side IP


Find "dont_blame_nrpe=0" and Change to "dont_blame_nrpe=1"


Start the service:


Service Nrpe Start



Third, Nagios server configuration


Open the file/etc/nagios/nagios.cfg, find "Cfg_dir", this is the storage directory to define the monitoring file, we can define a number of directories, and later put the new host information files all here.


Under our defined directory, create a sub-configuration file and add the monitored host information:


cd/etc/nagios/conf.d/

Vim 192.168.1.12.cfg


Define Host{

Use Linux-server
HOST_NAME 192.168.1.12
Alias 192.168.1.12
Address 192.168.1.12
}
Define Service{
Use Generic-service
HOST_NAME 192.168.1.12
Service_description check_ping
Check_command check_ping!100.0,20%!200.0,50%
Max_check_attempts 5
Normal_check_interval 1
}
Define Service{
Use Generic-service
HOST_NAME 192.168.1.12
Service_description Check_ssh
Check_command Check_ssh
Max_check_attempts 5
Normal_check_interval 1
}
Define Service{
Use Generic-service
HOST_NAME 192.168.1.12
Service_description check_http
Check_command check_http
Max_check_attempts 5
Normal_check_interval 1
}


# #注, the IP here is client-side IP, monitoring the project has three ping, ssh, http. In fact, the scripts used for these three projects are local scripts, which means that even if the remote host does not have Nagios and Nrpe, they can also be monitored. But if you want to monitor load,disk, and so on, you need to get through the Nrpe service, the reason is very simple, load and disk need to log on to the remote host to obtain information, and ping,ssh,http are not required. The process of obtaining relevant information from the remote host is done by Nrpe. If your client does not start the Nrpe service then we are unable to obtain information such as load and disk from the remote host. The following article configures the use of Nrpe to monitor remote host related projects.


Edit/etc/nagios/objects/commands.cfg on server side


Add a line at the end of the file:


Define Command{

Command_name Check_nrpe

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

}



Continue to modify child configuration files


cd/etc/nagios/conf.d/

Vim 192.168.1.12.cfg #添加如下内容


Define Service{

Use Generic-service
HOST_NAME 192.168.1.12
Service_description Check_load
Check_command Check_nrpe!check_load
Max_check_attempts 5
Normal_check_interval 1
}

Define Service{
Use Generic-service
HOST_NAME 192.168.1.12
Service_description check_disk_hda1
Check_command check_nrpe!check_hda1
Max_check_attempts 5
Normal_check_interval 1
}

Define Service{
Use Generic-service
HOST_NAME 192.168.1.12
Service_description Check_disk_hda2
Check_command Check_nrpe!check_hda2
Max_check_attempts 5
Normal_check_interval 1
}



# #这里需要解释一下相关的 "Check_command", first look at this "check_nrpe!check_load" here Check_nrpe is the above/usr/local/nagios/etc/objects/ Just defined in Commands.cfg, the following check_load is a command script defined on the remote host. Specifically where the definition is described later. Why add a "!" in the middle, this is the specific form of nagios, without concern. The following need to go to the remote host to define the script used above.


Service End multiplicity Start service:

Service Nagios Restart


Client Restart Service:

Service Nrpe Restart



Iv. in Nagios client custom script monitoring


After the monitoring script has been written, copy to the/usr/lib64/nagios/plugins/directory, of course, this directory is defined in the configuration file/etc/nrpe.d/check_log2s3.cfg.


Vim/etc/nrpe.d/check_log2s3.cfg


command[check_log2s3]=sudo/usr/lib64/nagios/plugins/logmonitoring.sh


# #当然, these can be written directly into/etc/nagios/nrpe.cfg, but not easily managed, so we can separate the services for each monitoring script in the/etc/nrpe.d/directory.


To restart the client service:


Service Nrpe Restart


Add the appropriate service to the server:


Vim 192.168.1.12.cfg


# #加入如下内容


Define Service{
Use Generic-service
HOST_NAME 192.168.1.12
Service_description CHECK_LOGS3
Check_command CHECK_NRPE!CHECK_LOGS3
Max_check_attempts 5
Normal_check_interval 1
}


To restart the service-side service:


Service Nagios Restart







This article is from "The Miracle Teenager" blog, please be sure to keep this source http://raffaelexr.blog.51cto.com/8555551/1853676

Nagios Configuration and use

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.