Nagios监控linux服务器

Nagios监控linux服务器 一、客户端 安装所需的软件(nagios-plugins、nrpe) #wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz #wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz 1、安装nagios-plugins #增加一个用户 useradd nagios -s /sbin/nologin -M 解压并安装 #tar zvxf nagios-plugins-1.4.16.tar.gz && cd nagios-plugins-1.4.16 #./configure --with-nagios-user=nagios --with-nagios-group=nagios && make && make install #chown -R nagios:nagios /usr/local/nagios 2、安装nrpe #tar -zxvf nrpe-2.13.tar.gz && cd nrpe-2.13 #./configure --enable-ssl --with-ssl-lib (前提是已经安装了openssl与openssl-devel) #make all && make install-plugin && make install-daemon && make install-daemon-config 3、配置nrpe 配置nrpe信息 #vim /usr/local/nagios/etc/nrpe.cfg,查找并修改如下一行 allowed_hosts=172.16.17.223,127.0.0.1   #注意修改为nagios服务器的IP:172.16.17.223 #配置监控对象 说明:由监控原理可知被监控端做监控,然后将数据传给监控服务器绘总,设置监控详细参数主要是设置被监控端的nrpe.cfg文件,可以看到里面监控对象 vim /usr/local/nagios/etc/nrpe.cfg,查找并修改如下一行 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_disk]=/usr/local/nagios/libexec/check_disk -w 10% -c 5% 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 500 -c 550 command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10% command[check_ping]=/usr/local/nagios/libexec/check_ping -H 192.168.1.1 -w 100.0,20% -c 500.0,60% 后两行是自添加的 4、启动nrpe,并测试 #/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d #echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d &> /dev/null” >> /etc/rc.local #netstat -atulnp | grep nrpe tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      5201/nrpe            #/usr/local/nagios/libexec/check_nrpe -H localhost NRPE v2.13 二、服务器端 1、安装所需的软件(nagios、nagios-plugins、nrpe)下载后源码包安装,不赘述 wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz 安装完成后配置一下报警的邮箱 # grep email /usr/local/nagios/etc/objects/contacts.cfg         email                           minyongtao@innofidei.com        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** 2、配置 #在commands.cfg中定义nrpe这个外部构件 #vim /usr/local/nagios/etc/nagios.cfg,打开下面这一行 cfg_file=/usr/local/nagios/etc/objects/commands.cfg #vim /usr/local/nagios/etc/objects/commands.cfg,增加如下一行 check nrpe define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } 3、#配置要监控的linux主机 #cd /usr/local/nagios/etc/objects #mv localhost.cfg rhel5.cfg 更改如下 注意下面定义的check名字要与linux客户端/usr/local/nagios/etc/nrpe.cfg文件中的名字一致 #cat  rhel5.cfg # Define a host for the local machine define host{         use                     linux-server         host_name               rhel5         alias                   rhel5         address                 172.16.17.220         } # SERVICE DEFINITIONS # Define a service to "ping" the local machine define service{         use                             generic-service         ; Name of service template to use         host_name                       rhel5         service_description             PING         check_command                   check_nrpe!check_ping         } # Define a service to check the disk space of the root partition # on the local machine.  Warning if < 20% free, critical if # < 10% free space on partition. define service{         use                             generic-service         ; Name of service template to use         host_name                       rhel5         service_description             Root Partition         check_command                   check_nrpe!check_disk         } # Define a service to check the number of currently logged in # users on the local machine.  Warning if > 20 users, critical # if > 50 users. define service{         use                             generic-service         ; Name of service template to use         host_name                       rhel5         service_description             Current Users         check_command                   check_nrpe!check_users         } # Define a service to check the number of currently running procs # on the local machine.  Warning if > 250 processes, critical if # > 400 users. define service{         use                             generic-service         ; Name of service template to use         host_name                       rhel5         service_description             Total Processes         check_command                   check_nrpe!check_total_procs         } # Define a service to check the load on the local machine. define service{         use                             generic-service         ; Name of service template to use         host_name                       rhel5         service_description             Current Load         check_command                   check_nrpe!check_load         } # Define a service to check the swap usage the local machine. # Critical if less than 10% of swap is free, warning if less than 20% is free define service{         use                             generic-service         ; Name of service template to use         host_name                       rhel5         service_description             Swap Usage         check_command                   check_nrpe!check_swap         } 4、启动nrpc,并测试 #/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d #echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d &> /dev/null” >> /etc/rc.local #netstat -tulpn | grep nrpe tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      14371/nrpe           #/usr/local/nagios/libexec/check_nrpe -H 172.16.17.220  #linux客户端的IP地址:172.16.17.220 NRPE v2.13 #/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 测试都没有错误才是语法正确,哪里有错误会提示哪里改正之 Total Warnings: 0 Total Errors:   0 Things look okay - No serious problems were detected during the pre-flight check 5、重启服务 # service nagios restart Running configuration check...done. Stopping nagios: done. Starting nagios: done. 网页访问 http://ip/nagios

邮件如下

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏农夫安全

【原创】中间件测试方法总结---(1)

前言 之前讲了一些关于中间件的漏洞,本次来详细介绍一下对于常见中间件漏洞的测试,转载请说明来源,禁止用于非法和商业用途,多谢老铁支持 0x01 测试目...

49560
来自专栏杂烩

kafka-eagle1.1.9安装 原

源码地址https://github.com/smartloli/kafka-eagle

12310
来自专栏Hongten

python开发_email_读取邮件头信息

===========================================

73410
来自专栏浪淘沙

Redis学习笔记

    (*)前身:Memcached     (*)区别:支持持久化,RDB、AOF                 支持丰富的数据类型

14820
来自专栏V站

VIM不正常退出产生的swp文件将泄漏敏感信息

原理可参考此文章:https://blog.csdn.net/pwiling/article/details/51830781

40020
来自专栏weixuqin 的专栏

Nginx 安装配置教程

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #454545 }...

20810
来自专栏小狼的世界

Kubernetes基础:编排调度的那些Controllers

Kubernetes提供了很多Controller资源来管理、调度Pod,包括Replication Controller、ReplicaSet、Deploym...

19020
来自专栏Linyb极客之路

运维管理之防止"rm -rf /" 误删除

大概懂点linux的程序员都知道“rm -rf /”意味着擦除根路径“/”下挂载的所有内容而无需询问。以前一个主管说过,在你不充分了解某个工具的原理的时候,不要...

18940
来自专栏安全领域

物联网 MQTT 服务质量级别

原文地址:https://dzone.com/articles/internet-things-mqtt-quality

69070
来自专栏小李刀刀的专栏

再战子域共享Cookie问题

昨天贾宁旨光临寒舍,吃过晚饭回来后就跟他聊天,后来又玩了一会儿《Black Hawk Down》对战,到了大概晚上11点多,开始继续尝试用 Response.C...

50650

扫码关注云+社区

领取腾讯云代金券