Requirements Description :
After you install Nagios, you need to monitor your local resources, such as disk space usage, number of processes, swap space, and so on. These are not provided through the network,
Therefore, are local resources, can be implemented through the Nrpe plug-in data acquisition in the client, and then passed through the network to the monitoring server, by the monitoring server implementation of the pass over
The data to be judged.
Environment Description :
Operating system: RedHat6.6 x64
installation process :
----Client----
1. Turn off SELinux
sed ' s/selinux=.*/selinux=disabled/g ' /etc/selinux/~]# getenforcepermissive
2. Download, upload nagios-plugins plugin and Nrpe plugin
nagios-plugins:https://www.nagios.org/downloads/nagios-plugins/
Nrpe:https://github.com/nagiosenterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
ls -30801 root root 419695: nrpe-2.15. Tar . GZ 1 2728818 to : nagios-plugins- 2.2. 1. tar. gz
3. Install the Nrpe before installing the Nagios-plugins
3.1 Install the required packages
Yum Install GCC Make wget openssl-devel net-snmp net-snmp-utils
3.2 Unzip, compile, install
tar -zxf nagios-plugins-2.2. 1. Tar . gz [[email protected] software]# CD Nagios-plugins-2.2. 1 [email protected] Nagios-plugins-2.2. 1
[[email protected] nagios-plugins-2.2.1]# make
[[email protected] nagios-plugins-2.2.1]# make install
4. Create the Nagios user group and the user
[Email protected] nagios-plugins-2.2. 1 ]# groupadd nagios[[email protected] Nagios-plugins-2.2. 1] # Useradd-r-G Nagios Nagios
5. Unzip, compile, install Nrpe
tar zxf nrpe-2.15. Tar . gz [[email protected] software]# CD Nrpe-2.15[[email protected] Nrpe-2.15
[[email protected] nrpe-2.15]# make all
[email protected] nrpe-2.15]# make Install-daemon #安装nrpe命令.
[email protected] nrpe-2.15]# make Install-daemon-config #安装nrpe配置文件
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/etc
/usr/bin/install-c-M 644-o nagios-g Nagios sample-config/nrpe.cfg/usr/local/nagios/etc
6. Edit the Nrpe.cfg (/usr/local/nagios/etc/nrpe.cfg) configuration file to increase the address of the monitoring host
allowed_hosts=127.0. 0.1,192.168. 53.25 #找到allowed_hosts, increase the address of the monitoring host.
7. Add the Nrpe startup script to the/ETC/INIT.D directory and add it to the boot boot
[Email protected] etc]# cd/opt/software/nrpe-2.15[email protected] Nrpe-2.15]#CPinit-script/etc/init.d/Nrpe[[email protected] Nrpe-2.15]#chmod+x/etc/init.d/Nrpe [[email protected] Nrpe-2.15]# Chkconfig--add Nrpe[[email protected] Nrpe-2.15]# Chkconfig--list |grepNrpenrpe0: Off1: Off2: On3: On4: On5: On6: Off
8. Start the Nrpe service to see the port the program listens to
[Email protected] nrpe-2.15]# Service Nrpe startstarting Nrpe: [OK][[email protected] Nrpe-2.15]#PS-ef |grepNrpenagios23979 1 0 -: +?xx:xx:xx/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-Droot23982 1050 0 -: +pts/0 xx:xx:xx grepNrpe
[Email protected] nrpe-2.15]# NETSTAT-NTLP | grep Nrpe
TCP 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 23979/nrpe #nrpe监听端口是566 6
TCP 0 0::: 5666:::* LISTEN 23979/nrpe
----Monitoring Server----
1. Turn off SELinux
's/selinux=.*/selinux=disabled/g'/etc/selinux/config[[email protected] ~]# getenforcepermissive
2. Upload Nrpe package, unzip, compile, install
tar zxf nrpe-2.15. Tar . gz [[email protected] softwares]# CD Nrpe-2.15[[email protected] Nrpe-2.15
[[email protected] nrpe-2.15]# make all
[Email protected] nrpe-2.15]# make Install-plugin #安装check_nrpe插件而不是nrpe命令, be aware.
3. Check that the Nrpe_check plugin is properly installed
[Email protected] nrpe-2.15ls /usr/local/nagios/libexec//usr/local/nagios/libexec /check_nrpe
4. Add the Nrpe command to Nagios's commands.cfg
Define Command {
Command_name Check_nrpe
Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$
}
#特别注意不要有中文的中划线
5. Create a host configuration file and modify the permissions of the CFG file
Define host {
Use Linux-server
HOST_NAME 192.168.53.26
Address 192.168.53.26
}
Define Service {
Use Generic-service,graphed-service; Name of service template to use
HOST_NAME 192.168.53.26
Service_description System_load
Check_command Check_nrpe!check_load
}
Define Service {
Use Generic-service,graphed-service
HOST_NAME 192.168.53.26
Service_description Disk_usage
Check_command Check_nrpe!check_disk
}
[Email protected] objects]# chown Nagios:nagios 192.168.53.26.cfg
7. Create a directory of Nagios configuration files, categorize the configuration files
mkdir-p/usr/local/nagios/etc/objects/commandsmkdir-p/usr/local/nagios/etc/objects/Timeperiodsmkdir-p/usr/local/nagios/etc/objects/Contactsmkdir-p/usr/local/nagios/etc/objects/contactgroupsmkdir-p/usr/local/nagios/etc/objects/hostsmkdir-p/usr/local/nagios/etc/objects/hostgroupsmkdir-p/usr/local/nagios/etc/objects/Servicesmkdir-p/usr/local/nagios/etc/objects/servicegroupsmkdir-p/usr/local/nagios/etc/objects/Templatesmkdir-p/usr/local/nagios/etc/objects/others
Categorize the files into a specific path:
[Email protected] objects]# ls-ltr
Total 96
-rw-rw-r--. 1 Nagios nagios 1797 Jul 11:38 contacts.cfg
-rw-rw-r--. 1 Nagios nagios 3512 Jul 11:38 timeperiods.cfg
-rw-rw-r--. 1 Nagios nagios 4074 Jul 11:38 windows.cfg
-rw-rw-r--. 1 Nagios nagios 3001 Jul 11:38 printer.cfg
-rw-rw-r--. 1 Nagios nagios 3484 Jul 11:38 switch.cfg
-rw-rw-r--. 1 Nagios nagios 12869 Jul 14:44 templates.cfg
-rw-rw-r--. 1 Nagios nagios 4905 Jul 14:47 localhost.cfg
-rw-rw-r--. 1 Nagios nagios 7120 Jul 16:54 commands.cfg
-rw-r--r--. 1 nagios nagios 446 Jul 17:03 192.168.53.26.cfg
Drwxr-xr-x. 2 root root 4096 Jul 17:09 commands
Drwxr-xr-x. 2 root root 4096 Jul 17:09 timeperiods
Drwxr-xr-x. 2 root root 4096 Jul 17:09 contacts
Drwxr-xr-x. 2 root root 4096 Jul 17:09 contactgroups
Drwxr-xr-x. 2 root root 4096 Jul 17:09 hosts
Drwxr-xr-x. 2 root root 4096 Jul 17:09 hostgroups
Drwxr-xr-x. 2 root root 4096 Jul 17:09 Services
Drwxr-xr-x. 2 root root 4096 Jul 17:09 servicegroups
Drwxr-xr-x. 2 root root 4096 Jul 17:09 templates
Drwxr-xr-x. 2 root root 4096 Jul 17:09 others
[Email protected] objects]# MV 192.168.53.26.cfg hosts/
[Email protected] objects]# MV Localhost.cfg hosts/
[Email protected] objects]# MV COMMANDS.CFG commands
[Email protected] objects]# mv windows.cfg switch.cfg printer.cfg others/
[Email protected] objects]# MV Templates.cfg templates/
[Email protected] objects]# MV Timeperiods.cfg timeperiods/
[Email protected] objects]# mv contacts.cfg contacts
8. Modify the Nagios.cfg configuration file, add Cfg_dir configuration, comment out the Cfg_file
cfg_dir=/usr/local/nagios/etc/objects/commandscfg_dir =/usr/local/ Nagios/etc/objects/timeperiodscfg_dir =/usr/local/nagios/etc/objects/contactscfg_dir =/usr/local/nagios/etc/objects/ Contactgroupscfg_dir =/usr/local/nagios/etc/objects/hostscfg_dir =/ Usr/local/nagios/etc/objects/hostgroupscfg_dir =/usr/local/nagios/etc/ Objects/servicescfg_dir =/usr/local/nagios/etc/objects/ servicegroupscfg_dir =/usr/local/nagios/etc/objects/ templates #不配置others目录 in order to not monitor these other devices
# You can specify individual object config files as shown below:
#cfg_file =/usr/local/nagios/etc/objects/commands.cfg
#cfg_file =/usr/local/nagios/etc/objects/contacts.cfg
#cfg_file =/usr/local/nagios/etc/objects/timeperiods.cfg
#cfg_file =/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file =/usr/local/nagios/etc/objects/localhost.cfg
9. Restart Nagios
[email protected] objects]# service nagios restartrunning Configuration check ... Stopping Nagios:. Done done.
10. View the Monitoring page
Note: The system load has been checked properly. But Nrpe:command ' check_disk ' not defined, there was this error.
11.nrpe:command ' check_disk ' not defined processing, configuring Check_disk commands and alarms in the client's nrpe.cfg
Command[check_disk]=/usr/local/nagios/libexec/check_disk-w-P/C-W -p/boot #指定检查特定的分区, set the alarm, verify the percentage.
#command后面的中括号内, is the Nrpe command defined. This command is invoked on the server side, and then executed at the client, and it is understood that this command is a long string of aliases after the equals sign.
12. Restart the Nrpe of the client
[Email protected] etc]# service Nrpe restartshutting down Nrpe: [ OK ]starting Nrpe: [ OK ]
13. View the Nagios page
Note: You have been able to monitor remote disk space usage and set alarms, and other commands can simulate this. The specific dispatch commands are to be in the Libexec directory. or install plugins and commands yourself.
Other:
- Set the alarm value for disk space and check which directory is configured in the client's nrpe.cfg file. Other checks are also configured in the client alarm percentage
- Monitoring side, do not need to start the Nrpe process, the Nrpe process is only on the client start
Document creation time: July 31, 2018 18:05:31
Install the Nrpe plugin in a Linux environment to perform remote "local resource" checks? Nrpe installation?