NagiosThe process of monitoring a Linux server is as follows:
Client Configuration:
User Creation:
Useradd nagios can modify the shell of this account in/etc/password to/sbin/nologin)
Passwd nagios
Install plug-ins:
- tar zxvf nagios-plugins-1.4.11.tar.gz
-
- cd nagios-plugins-1.4.11
-
- ./configure--prefix=/usr/local/nagios --enable-redhat-pthread-workaround
-
- make all
-
- make install
Modify permissions:
Chown nagios: nagios/usr/local/nagios-R
Install the Nrpe service:
- Tar zxvf nrpe-2.8.1.tar.gz
-
- Cd nrpe-2.8.1
-
- ./Configure-prefix =/usr/local/nagios [./configure -- enable-ssl -- enable-command-args]
-
- Make all (Compilation)
-
- Make install-plugin install plug-in)
-
- Make install-daemon install nrpe daemon)
-
- Make install-daemon-config install the configuration file)
-
- Make install-xinetd install the xinetd script file)
Add Server IP Address:
Vi/etc/xinetd. d/nrpe
Only_from = 127.0.0.1 192.168.0.108
Add nrpe service:
Vi/etc/services
Nrpe 5666/tcp # nrpe
Restart the Xinetd service:
Service xinetd restart
Check whether the Nrpe service is enabled:
Netstat-ant | grep 5666
Test whether Nrpe works properly:
/Usr/local/nagios/libexec/check_nrpe-H localhost
NRPE v2.8.1 indicates that it is normal to connect nrpe daemon locally with check_nrpe)
Server Configuration:
A. Copy the localhost. cfg template file to monitor 192.168.112.101:
Cp/usr/local/nagios/etc/localhost. cfg/usr/local/nagios/etc/192.168.112.101.cfg
Vi 192.168.112.101.cfg
Modify the host name, IP address, and alias of the Configuration)
B. Add 192.168.112.101.cfg to the main configuration file of nagios:
Vi/usr/local/nagios/etc/nagios. cfg
Export _file =/usr/local/nagios/etc/objects/192.168.112.101.cfg
C. Verify that the configuration file is correct and restart:
/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/object/nagios. cfg
Service nagios restart (restart nagios to make the configuration take effect)
D. Check the naigios monitoring page and find that the host has been added normally.
It is not required to add monitoring services to the server ):
Add the check_nrpe function to the Command. cfg file:
- vi /usr/local/nagios/etc/commands.cfg
-
- define command{
-
- command_name check_nrpe
-
- command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
-
- }
Note:: The $ ARG1 $ parameter after-c is the detection command sent to nrpe daemon. It should be used when check_nrpe is used in services. cfg! With this parameter.
Additional knowledge points:
Vi/usr/local/nagios/etc/nrpe. cfg
Find the following content:
- # The following examples use hardcoded command arguments...
-
- command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
-
- command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
-
- command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
-
- command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
-
- command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
[] Is the command name, that is, the-c parameter of check_nrpe can be connected to, = followed by the actually executed plug-in program commands. the format of commands defined in cfg is very similar, but it is written in a line. that is to say, check_users is the abbreviation of/usr/local/nagios/libexec/check_users-w 5-c 10 after the equal sign.
We can easily know that the commands defined in the above five lines are the number of login users, cpu load, hda1 capacity, zombie processes, and the total number of processes. usage :. /check_load -- help, because-c can only be followed by nrpe. the command defined in cfg, that is, we can only use the Five Commands defined above.
For other nagios configurations, please read:
Install and configure nagios, modify Apache configuration, configure initial Nagios 3.0 installation, monitor Windows servers, and solve ten Nagios faults