1. I have mentioned some nagios Server Installation and simple configuration. Now let's talk about the server's monitoring of multiple servers and the installation configuration of the monitored server.
2. configuration of nagios Server
(1). After the default installation, nagios creates a group and some services. This file is the localhost. cfg file. Now we want to create our own files
Comment out the definition localhost. cfg in nagios. cfg, and enable the hostgroup. cfg, host. cfg, services. cfg files. I put these three files
Put it in the conf directory for ease of management.
Note: These files and related directories are not originally available. You must create and authorize them by yourself.
(2) to create your own group, you must first set a contact in contacts. cfg.
Linux-servers is my own contact groups.
Note: If you do not create this contact and group, you cannot define your host team members in hostgroup. cfg.
(3) Now you can build your own monitoring host, Monitoring Service, and Monitoring Group.
First, let's talk about the relationship between the three. The Monitoring Group (hostgroup. cfg) includes the monitoring host (host. cfg) and the Monitoring Service (services. cfg)
Hostgroup. cfg-& gt; host. cfg-& gt; services. cfg
If one is absent, an error is returned.
Check whether the error message for the nagios. cfg file is
/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
You can see where your configuration is wrong. I also use this to troubleshoot the problem.
1. hostgroup. cfg
Define hostgroup {
Hostgroup_name Linux-servers
Alias Linux-servers
Members CentOS
}
2. host. cfg
Define host {
Host_name CentOS
Alias server, host-pnp
Address 192.168.1.8
Contact_groups Linux-servers
Check_command check-host-alive
Max_check_attempts 5
Icationication_interval 10
Icationication_period 24x7
Notification_options d, u, r
}
3. services. cfg
Define service {
Host_name CentOS
Use local-service, srv-pnp
Service_description CPU
Check_period 24x7
Max_check_attempts 4
Normal_check_interval 1
Retry_check_interval 1
Contact_groups Linux-servers
Icationication_interval 10
Icationication_period 24x7
Notification_options w, u, c, r
Check_command check_nrpe! Check_cpu
}
Define service {
Host_name CentOS
Use local-service, srv-pnp
Service_description CPU_load
Check_period 24x7
Max_check_attempts 4
Normal_check_interval 1
Retry_check_interval 1
Contact_groups Linux-servers
Icationication_interval 10
Icationication_period 24x7
Notification_options w, u, c, r
Check_command check_nrpe! Check_load
}
// Services. cfg only two items are provided here, and the others can be added as needed.
Restart nagios and check whether there are any errors. If not, restart it.
Service nagios restart
The figure above shows the result after I configured it. Now I want to configure the monitored end.
3. nagios monitoring configuration.
(1) install nagios-plugins
If the following configure does not check mysql, check whether mysql-devel is installed or not.
Tar-xvf nagios-plugins-1.4.15.tar.gz
Cd nagios-plugins-1.4.15
./Configure
Make & make install
(2) install nrpe
Tar-xvf nrpe-2.12.tar.gz
Cd nrpe-2.12
./Configure
Make all
Make install-plugin
Make install-daemon
Make install-daemon-config
Make install-xinetd // you can use xinetd to manage the startup and shutdown of nrpe.
(3) install some monitored software and install snmp to collect data. I have already mentioned installing and configuring net-snmp.
Configure the metric item (nrpe. cnf)
Log_facility = daemon
Pid_file =/var/run/nrpe. pid
Server_port = 5666
Nrpe_user = nagios
Nrpe_group = nagios
Allowed_hosts = 192.168.1.7
Dont_blame_nrpe = 1
Debug = 1
Command_timeout = 30
Connection_timeout = 300
Command [check_http] =/usr/local/nagios/libexec/check_http-I localhost-u/index. php-t 60
Command [check_disk] =/usr/local/nagios/libexec/check_disk-w 5%-c 3%-A-I '/dev/shm'
Command [check_traffic] =/usr/local/nagios/libexec/check_traffic.sh-V 2c-C nagios-H localhost-I 2-w 12, 30-c 15, 35-M-B-6
Command [check_cpu] =/usr/local/nagios/libexec/check_cpu.sh
Command [check_mem] =/usr/local/nagios/libexec/check_mem.sh
Command [check_ips] =/usr/local/nagios/libexec/ip_conn.sh 400 600
Command [check_load] =/usr/local/nagios/libexec/check_load-w 15,10, 8-c 30,25, 20
Command [check_ftp] =/usr/local/nagios/libexec/check_ftp 127.0.0.1-w 10-c 60
There are a few that do not need to be searched on the Internet, and then download them to/usr/local/nagios/libexec/and give the execution permission to the owner nagios. (Check_traffic.sh, check_cpu.sh,
Check_mem.sh, ip_conn.sh)
(4) To monitor mysql Databases and remote hosts, you also need to configure commands. cfg on the server.
Define command {
Command_name check_nrpe
Command_line $ USER1 $/check_nrpe-H $ HOSTADDRESS $-c $ ARG1 $
}
Define command {
Command_name check_mysql
Command_line $ USER1 $/check_mysql-H $ HOSTADDRESS $-unagdb-pwww-d nagdb
}
Define command {
Command_name check_mysql_health
Command_line $ USER1 $/check_mysql_health-hostname $ HOSTADDRESS $-username nagdb-password www-warning $ ARG1 $-critical $ ARG2 $-mode threads-connected
}
Just find a location and put it in the commands. cfg file.
Now the configuration is complete.
From the BLOG of HY_51CEO