【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


相关文章
|
6月前
|
运维 监控 中间件
Linux运维笔记 - 如何使用WGCLOUD监控交换机的流量
WGCLOUD是一款开源免费的通用主机监控工具,安装使用都非常简单,它可以监控主机、服务器的cpu、内存、磁盘、流量等数据,也可以监控数据库、中间件、网络设备
|
7月前
|
Ubuntu Linux 网络安全
如何在Linux中更改主机名?修改主机名最新方法
本期教程将指导您如何在Linux系统中更改主机名。主机名是Linux系统的常用功能,用于识别服务器,帮助区分不同服务器,并与网络进程和其他应用程序协同工作。教程涵盖显示当前主机名的方法(通过`hostname`命令),以及在CentOS 7、Debian 9和Ubuntu 16.04及以上版本中更改主机名的步骤(使用`hostnamectl set-hostname`命令)。对于其他Linux版本,可编辑`/etc/hostname`文件实现更改。记得重启相关服务或服务器以使更改生效!
1876 12
|
11月前
|
Prometheus 监控 Cloud Native
Prometheus+Grafana监控Linux主机
通过本文的步骤,我们成功地在 Linux 主机上使用 Prometheus 和 Grafana 进行了监控配置。具体包括安装 Prometheus 和 Node Exporter,配置 Grafana 数据源,并导入预设的仪表盘来展示监控数据。通过这种方式,可以轻松实现对 Linux 主机的系统指标监控,帮助及时发现和处理潜在问题。
978 7
|
11月前
|
Prometheus 运维 监控
Prometheus+Grafana+NodeExporter:构建出色的Linux监控解决方案,让你的运维更轻松
本文介绍如何使用 Prometheus + Grafana + Node Exporter 搭建 Linux 主机监控系统。Prometheus 负责收集和存储指标数据,Grafana 用于可视化展示,Node Exporter 则采集主机的性能数据。通过 Docker 容器化部署,简化安装配置过程。完成安装后,配置 Prometheus 抓取节点数据,并在 Grafana 中添加数据源及导入仪表盘模板,实现对 Linux 主机的全面监控。整个过程简单易行,帮助运维人员轻松掌握系统状态。
1649 3
|
运维 监控 Unix
服务器监控软件Nagios
【10月更文挑战第19天】
287 2
|
Linux 网络安全
Linux虚拟机与主机和Xshell的连接问题解决
Linux虚拟机与主机和Xshell的连接问题解决
490 1
|
监控 安全 Linux
使用NRPE和Nagios监控Linux系统资源的方法
通过遵循以上步骤,可以有效地使用NRPE和Nagios监控Linux系统资源,确保系统运行稳定,并及时响应任何潜在的问题。这种方法提供了高度的可定制性和灵活性,适用于从小型环境到大型分布式系统的各种监控需求。
246 2
|
弹性计算 Linux
[转]ECS之初体验(Linux)
服务商: 阿里云 操作系统:Linux 64位 Ubantu 20.04 64位
172 0
|
28天前
|
弹性计算 运维 安全
阿里云轻量应用服务器与云服务器ECS啥区别?新手帮助教程
阿里云轻量应用服务器适合个人开发者搭建博客、测试环境等低流量场景,操作简单、成本低;ECS适用于企业级高负载业务,功能强大、灵活可扩展。二者在性能、网络、镜像及运维管理上差异显著,用户应根据实际需求选择。
197 10

热门文章

最新文章