【Nagios】nagios服务器添加监控远程Linux主机

简介:

一、远程主机添加nagios用户

1
[root@yo ~] # useradd -s /sbin/nologin nagios


二、安装nagios-plugins插件

1
2
[root@yo nagios-plugins-2.1.1] # ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
[root@yo nagios-plugins-2.1.1] # make && make install

三、查看生成的目录文件

1
2
[root@yo nagios-plugins-2.1.1] # ls /usr/local/nagios/
include  libexec  share


四、安装nrpe

1
2
3
4
5
[root@yo nrpe-2.15] # ./configure 
[root@yo nrpe-2.15] # make all
[root@yo nrpe-2.15] # make install-daemon
[root@yo nrpe-2.15] # make install-daemon-config
[root@yo nrpe-2.15] # make install-plugin

五、安装nrpe守护进程的服务xinetd

1
2
[root@yo nrpe-2.15] # make install-xinetd
/usr/bin/install  -c -m 644 sample-config /nrpe .xinetd  /etc/xinetd .d /nrpe


六、打开/etc/xinetd.d/nrpe文件,修改添加服务端IP

1
  only_from       = 127.0.0.1 localhost 192.168.1.21

七、添加nrpe守护进程端口号

1
2
[root@yo nrpe-2.15] # vim /etc/services
nrpe            5666 /tcp                 #nrpe


八、安装xinetd软件包,并重启xinetd服务

1
2
3
4
[root@yo nrpe-2.15] # yum -y install xinetd
[root@yo nrpe-2.15] # /etc/init.d/xinetd restart
Stopping xinetd:                                           [FAILED]
Starting xinetd:                                           [  OK  ]


九、查看监听端口和nrpe进程有没有起来

1
2
[root@yo nrpe-2.15] # netstat -ntlp |grep 5666
tcp        0      0 :::5666                     :::*                        LISTEN      73351 /xinetd
1
2
[root@yo nrpe-2.15] # netstat -at | grep nrpe
tcp        0      0 *:nrpe                      *:*                         LISTEN


十、在远程主机运行check_nrpe测试有没有安装或配置成功

1
2
3
4
5
6
[root@yo nrpe-2.15] # /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 
NRPE v2.15
[root@yo nrpe-2.15] # /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_users
USERS OK - 5  users  currently logged  in  | users =5;5;10;0
[root@yo nrpe-2.15] # /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load
OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;
1
2
3
4
[root@yo nrpe-2.15] # /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.15
[root@yo nrpe-2.15] # /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
USERS OK - 5  users  currently logged  in  | users =5;5;10;0


十一、以下是在服务端测试

1
2
3
4
[root@www ~] # /usr/local/nagios/libexec/check_nrpe -H 192.168.1.250
NRPE v2.15
[root@www ~] # /usr/local/nagios/libexec/check_nrpe -H 192.168.1.250 -c check_users
USERS OK - 5  users  currently logged  in  | users =5;5;10;0


十二、服务端添加hosts.cfg和services.cfg两个文件,作为远程主机的监控配置文件

1
2
3
4
5
[root@www ~] # vim /etc/nagios/nagios.cfg 
cfg_file= /etc/nagios/objects/hosts .cfg
cfg_file= /etc/nagios/objects/services .cfg
[root@www ~] # touch /etc/nagios/objects/hosts.cfg
[root@www ~] # touch /etc/nagios/objects/services.cfg


十三、配置services.cfg文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
define service{
         use                     generic-service
         host_name               tecmint
         service_description     CPU Load
         check_command           check_nrpe!check_load
         }
define service{
         use                     generic-service
         host_name               tecmint
         service_description     Total Processes
         check_command           check_nrpe!check_total_procs
         }
define service{
         use                     generic-service
         host_name               tecmint
         service_description     Current Users
         check_command           check_nrpe!check_users
         }
define service{
         use                     generic-service
         host_name               tecmint
         service_description     SSH Monitoring
         check_command           check_nrpe!check_ssh
         }
define service{
         use                     generic-service
         host_name               tecmint
         service_description     FTP Monitoring
         check_command           check_nrpe!check_ftp
         }


十四、配置hosts.cfg文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
## Default Linux Host Template ##
define host{
name                            linux-box               ; Name of this template
use                             generic-host            ; Inherit default values
check_period                    24x7
check_interval                  5
retry_interval                  1
max_check_attempts              10
check_command                   check-host-alive
notification_period             24x7
notification_interval           30
notification_options            d,r
contact_groups                  admins
register                        0                       ; DONT REGISTER THIS - ITS A TEMPLATE
}
## Default
define host{
use                             linux-box               ; Inherit default values from a template
host_name                       tecmint                 ; The name we're giving to this server
alias                            CentOS 6.5                ; A longer name  for  the server
address                         192.168.1.250            ; IP address of Remote Linux host


十五、检查配置并重启nagios

1
2
3
4
[root@www ~] # /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg 
Total Warnings: 0
Total Errors:   0
[root@www ~] # service nagios restart

十六、在web页面上查看结果

wKioL1aWTwrTYbBtAAKNLqV2vXA284.jpg


本文转自 HMLinux 51CTO博客,原文链接:http://blog.51cto.com/7424593/1734791


相关文章
|
9天前
|
Java Linux
Springboot 解决linux服务器下获取不到项目Resources下资源
Springboot 解决linux服务器下获取不到项目Resources下资源
|
12天前
|
Linux
linux下搭建tftp服务器教程
在Linux中搭建TFTP服务器,需安装`tftp-server`(如`tftpd-hpa`)。步骤包括:更新软件包列表,安装`tftpd-hpa`,启动并设置开机自启,配置服务器(编辑`/etc/default/tftpd-hpa`),添加选项,然后重启服务。完成后,可用`tftp`命令进行文件传输。例如,从IP`192.168.1.100`下载`file.txt`: ``` tftp 192.168.1.100 <<EOF binary put file.txt quit EOF ```
27 4
|
27天前
|
监控 网络协议 Shell
【Shell 命令集合 网络通讯 】Linux 监控和记录网络中ARP(Address Resolution Protocol)活动 arpwatch命令 使用指南
【Shell 命令集合 网络通讯 】Linux 监控和记录网络中ARP(Address Resolution Protocol)活动 arpwatch命令 使用指南
33 0
|
27天前
|
监控 安全 Shell
【Shell 命令集合 文件传输 】Linux 将文件传送到远端的UUCP主机 uuto命令使用指南
【Shell 命令集合 文件传输 】Linux 将文件传送到远端的UUCP主机 uuto命令使用指南
30 0
|
27天前
|
网络协议 Shell Linux
【Shell 命令集合 网络通讯 】⭐⭐⭐Linux 测试与目标主机之间的网络连接ping 命令 使用指南
【Shell 命令集合 网络通讯 】⭐⭐⭐Linux 测试与目标主机之间的网络连接ping 命令 使用指南
41 1
|
27天前
|
Linux Shell 网络安全
【Shell 命令集合 网络通讯 】Linux 与SMB服务器进行交互 smbclient命令 使用指南
【Shell 命令集合 网络通讯 】Linux 与SMB服务器进行交互 smbclient命令 使用指南
40 1
|
5天前
|
Linux 数据安全/隐私保护
Linux基础与服务器架构综合小实践
【4月更文挑战第9天】Linux基础与服务器架构综合小实践
1041 6
|
17天前
|
Ubuntu Linux 虚拟化
【Linux】ubuntu安装samba服务器
【Linux】ubuntu安装samba服务器
|
17天前
|
Linux
Linux安装bind9搭建自己的域名服务器
Linux安装bind9搭建自己的域名服务器
11 0
|
20天前
|
网络协议 Linux 网络安全
Linux服务器DNS服务器配置实现bind的正向解释和反向解释
Linux服务器DNS服务器配置实现bind的正向解释和反向解释
17 0