【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


相关文章
|
2天前
|
关系型数据库 应用服务中间件 Linux
Linux云服务器如何搭建LNMP环境
LNMP环境是Linux系统中常用的Web服务架构,由Linux、Nginx、MySQL/MariaDB和PHP组成,适用于高效托管动态网站。本文以CentOS 7为例,详细介绍了LNMP环境的搭建步骤,包括Nginx、MariaDB和PHP的安装与配置,以及最终通过创建`index.php`文件验证环境是否成功部署。具体操作涵盖配置YUM仓库、安装服务、编辑配置文件、启动服务等关键步骤,确保用户能够顺利搭建并运行LNMP环境。
25 1
Linux云服务器如何搭建LNMP环境
|
1月前
|
安全 大数据 Linux
云上体验最佳的服务器操作系统 - Alibaba Cloud Linux | 飞天技术沙龙-CentOS 迁移替换专场
本次方案的主题是云上体验最佳的服务器操作系统 - Alibaba Cloud Linux ,从 Alibaba Cloud Linux 的产生背景、产品优势以及云上用户使用它享受的技术红利等方面详细进行了介绍。同时,通过国内某社交平台、某快递企业、某手机客户大数据业务 3 大案例,成功助力客户实现弹性扩容能力提升、性能提升、降本增效。 1. 背景介绍 2. 产品介绍 3. 案例分享
|
2月前
|
Prometheus 监控 Cloud Native
Prometheus+Grafana监控Linux主机
通过本文的步骤,我们成功地在 Linux 主机上使用 Prometheus 和 Grafana 进行了监控配置。具体包括安装 Prometheus 和 Node Exporter,配置 Grafana 数据源,并导入预设的仪表盘来展示监控数据。通过这种方式,可以轻松实现对 Linux 主机的系统指标监控,帮助及时发现和处理潜在问题。
233 7
|
2月前
|
运维 监控 Linux
推荐几个不错的 Linux 服务器管理工具
推荐几个不错的 Linux 服务器管理工具
207 6
|
2月前
|
Prometheus 运维 监控
Prometheus+Grafana+NodeExporter:构建出色的Linux监控解决方案,让你的运维更轻松
本文介绍如何使用 Prometheus + Grafana + Node Exporter 搭建 Linux 主机监控系统。Prometheus 负责收集和存储指标数据,Grafana 用于可视化展示,Node Exporter 则采集主机的性能数据。通过 Docker 容器化部署,简化安装配置过程。完成安装后,配置 Prometheus 抓取节点数据,并在 Grafana 中添加数据源及导入仪表盘模板,实现对 Linux 主机的全面监控。整个过程简单易行,帮助运维人员轻松掌握系统状态。
330 3
|
2月前
|
存储 Oracle 安全
服务器数据恢复—LINUX系统删除/格式化的数据恢复流程
Linux操作系统是世界上流行的操作系统之一,被广泛用于服务器、个人电脑、移动设备和嵌入式系统。Linux系统下数据被误删除或者误格式化的问题非常普遍。下面北亚企安数据恢复工程师简单聊一下基于linux的文件系统(EXT2/EXT3/EXT4/Reiserfs/Xfs) 下删除或者格式化的数据恢复流程和可行性。
|
Linux C语言
Linux批量远程命令和上传下载工具
https://github.com/eyjian/mooon/releases/tag/mooon-tools mooon_ssh:批量远程命令工具,在多台机器上执行指定命令 mooon_upload:批量远程上传工具,上传单个或多个文件到单台或多台机器 mooon_download:批量远程下载工具,从指定机器下载一个或多个文件 mooon-tools-glibc2.
1095 0
|
18天前
|
Linux
Linux系统之whereis命令的基本使用
Linux系统之whereis命令的基本使用
54 23
Linux系统之whereis命令的基本使用
|
3月前
|
Linux 网络安全 数据安全/隐私保护
Linux 超级强大的十六进制 dump 工具:XXD 命令,我教你应该如何使用!
在 Linux 系统中,xxd 命令是一个强大的十六进制 dump 工具,可以将文件或数据以十六进制和 ASCII 字符形式显示,帮助用户深入了解和分析数据。本文详细介绍了 xxd 命令的基本用法、高级功能及实际应用案例,包括查看文件内容、指定输出格式、写入文件、数据比较、数据提取、数据转换和数据加密解密等。通过掌握这些技巧,用户可以更高效地处理各种数据问题。
384 8
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25