设为首页 收藏本站
查看: 1828|回复: 0

监控利器--nagios

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-24 11:00:05 | 显示全部楼层 |阅读模式
                      Nagios安装   
基础环境   
[iyunv@m01 yum.repos.d]# cat /etc/redhat-release     
CentOS release 6.7 (Final)   
[iyunv@m01 yum.repos.d]# uname -r   
2.6.32-573.el6.x86_64   
[iyunv@m01 yum.repos.d]# uname -m   
x86_64
  1、准备3台服务器   
管理IP        角色        备注   
10.0.0.61    nagios        Nagios 服务器端   
10.0.0.8    web01        被监控的客户端服务器   
10.0.0.7    web02        被监控的客户端服务器
  2、设置yum安装源   
[iyunv@m01 ~]# ping www.baidu.com(确保可以上网)   
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.   
64 bytes from 61.135.169.121: icmp_seq=1 ttl=128 time=3.99 ms
  cd /etc/yum.repos.d/   
/bin/mv CentOS-Base.repo CentOS-Base.repo.oldboy.ori   
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos.repo
  3.解决Perl软件编译问题   
[iyunv@m01 yum.repos.d]# echo 'export LC_ALL=C'>>/etc/profile   
[iyunv@m01 yum.repos.d]# tail -1 /etc/profile   
export LC_ALL=C   
[iyunv@m01 yum.repos.d]# source /etc/profile   
[iyunv@m01 yum.repos.d]# echo $LC_ALL   
C   
[iyunv@m01 yum.repos.d]# cd ~
  4.关闭防火墙及selinux   
[iyunv@m01 ~]# /etc/init.d/iptables stop   
[iyunv@m01 ~]# /etc/init.d/iptables status   
iptables: Firewall is not running.   
[iyunv@m01 ~]# chkconfig iptables off   
[iyunv@m01 ~]# chkconfig --list iptables   
iptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off   
[iyunv@m01 ~]#sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config   
修改配置文件则永久生效,但是必须重启系统   
[iyunv@m01 ~]# getenforce   
Disabled
  5、解决系统时间同步问题   
[iyunv@m01 ~]# crontab -l   
#time sync by oldboy at 2010-2-1   
*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
  6、安装Nagios服务端所需安装包   
yum install gcc glibc glibc-common -y   
yum install gd gd-devel -y     
yum install mysql-server -y     
yum install httpd php php-gd -y
  [iyunv@m01 ~]# rpm -qa mysql httpd php   
httpd-2.2.15-47.el6.centos.4.x86_64   
php-5.3.3-46.el6_7.1.x86_64   
mysql-5.1.73-5.el6_7.1.x86_64
  7、创建Nagios服务器端需要的用户及组   
[iyunv@m01 ~]# /usr/sbin/useradd nagios   
[iyunv@m01 ~]# /usr/sbin/useradd apache -M -s /sbin/nologin   
useradd: user 'apache' already exists   
[iyunv@m01 ~]# /usr/sbin/groupadd nagcmd                  
[iyunv@m01 ~]# /usr/sbin/usermod -a -G nagcmd nagios   
[iyunv@m01 ~]# /usr/sbin/usermod -a -G nagcmd apache   
[iyunv@m01 ~]# id -n -G nagios      
nagios nagcmd   
[iyunv@m01 ~]# id -n -G apache     
apache nagcmd
  8、上传软件包到指定目录或通过URL下载   
mkdir -p /home/oldboy/tools/nagios   
cd /home/oldboy/tools/nagios     
rz
  ====================================================   
安装Nagios服务器端   
tar xf nagios-3.5.1.tar.gz     
cd nagios   
./configure --with-command-group=nagcmd     
make all     
make install     
make install-init     
make install-config     
make install-commandmode
  1、安装Nagios Web配置文件及创建登录用户   
make install-webconf   
htpasswd -bc /usr/local/nagios/etc/htpasswd.users oldboy 123456   
cat /usr/local/nagios/etc/htpasswd.users   
/etc/init.d/httpd reload
  2、添加监控报警信息接受的Email地址   
cp /usr/local/nagios/etc/objects/contacts.cfg{,.ori}   
sed -i 's#nagios@localhost#976199267@qq.com#g' /usr/local/nagios/etc/objects/contacts.cfg   
使用第三方邮件服务商提供的邮箱,把下列一行添加达到/etc/mail.rc里   
[iyunv@m01 tools]# tail -1 /etc/mail.rc  
set from=18516688992@163.com smtp=smtp.163.com smtp-auth-user=18516688992 smtp-auth-password=tian123 smtp-auth=login
  3、配置Apache服务并加入系统开机自启动   
[iyunv@m01 tools]# /etc/init.d/httpd start   
Starting httpd:     
[iyunv@m01 tools]# /etc/init.d/httpd restart   
Stopping httpd:                                            [  OK  ]   
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 172.16.1.61 for ServerName   
                                                           [  OK  ]   
[iyunv@m01 tools]# chkconfig httpd on   
[iyunv@m01 tools]# netstat -lntup|grep httpd     
tcp        0      0 :::80                       :::*                        LISTEN      53291/httpd   
  在浏览器登录   
10.0.0.61/nagios   
输入用户名和密码   
oldboy   
123456   
显示nagios core就正常了
  4、安装Nagios插件软件包   
安装基础依赖包   
yum install perl-devel openssl-devel -y   
安装Nagiospluginx插件包   
wget https://nagios-plugins.org/download/nagios-plugins-1.4.16.tar.gz   
[iyunv@m01 tools]# ls nagios-plugins-1.4.16.tar.gz     
nagios-plugins-1.4.16.tar.gz   
[iyunv@m01 tools]# tar xf nagios-plugins-1.4.16.tar.gz   
[iyunv@m01 tools]# cd nagios-plugins-1.4.16   
[iyunv@m01 nagios-plugins-1.4.16]# ./configure  --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules --with-mysql   
[iyunv@m01 nagios-plugins-1.4.16]# make   
[iyunv@m01 nagios-plugins-1.4.16]# make install
  5、安装nrpe软件   
ls /usr/local/nagios/libexec/check_nrpe     
[iyunv@m01 nagios-plugins-1.4.16]# cd ..   
tar xf nrpe-2.12.tar.gz     
cd nrpe-2.12     
./configure   
make all   
make install -plugin     
make install -daemon   
make install -daemon-config   
[iyunv@m01 nrpe-2.12]# ls /usr/local/nagios/libexec/|wc -l   
60
  检查check_nrpe插件   
[iyunv@m01 tools]# ls /usr/local/nagios/libexec/check_nrpe     
/usr/local/nagios/libexec/check_nrpe   
[iyunv@m01 nrpe-2.12]# ls /usr/local/nagios/libexec/|wc -l   
60     
到此为止Nagios服务器端的软件安装部分就配置完成了
  6、配置并启动Nagios服务   
添加Nagios服务到开机自启动   
[iyunv@m01 tools]# chkconfig nagios on   
[iyunv@m01 tools]# chkconfig --list nagios      
nagios          0:off   1:off   2:on    3:on    4:on    5:on    6:off   
更好的办法   
[iyunv@m01 tools]# echo "/etc/init.d/nagios start">>/etc/rc.local     
[iyunv@m01 tools]# tail -1 /etc/rc.local   
/etc/init.d/nagios start   
检查语法   
[iyunv@m01 tools]# /etc/init.d/nagios checkconfig   
Running configuration check... OK.   
启动Nagios服务   
[iyunv@m01 tools]# /etc/init.d/nagios start   
Starting nagios: done.   
检查Nagios服务器端进程及端口   
[iyunv@m01 tools]# ps -ef |grep nagios|grep -v grep   
nagios   15895     1  0 16:41 ?        00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg   
[iyunv@m01 tools]# netstat -lntup|grep nagios
  ===============================================   
Nagios客户端安装   
1、基础环境   
[iyunv@m01 yum.repos.d]# cat /etc/redhat-release     
CentOS release 6.7 (Final)   
[iyunv@m01 yum.repos.d]# uname -r   
2.6.32-573.el6.x86_64   
[iyunv@m01 yum.repos.d]# uname -m   
x86_64
  2、准备2台服务器   
管理IP        角色        备注   
10.0.0.8    web01        被监控的客户端服务器   
10.0.0.7    web02        被监控的客户端服务器
  3.解决Perl软件编译问题   
[iyunv@m01 yum.repos.d]# echo 'export LC_ALL=C'>>/etc/profile   
[iyunv@m01 yum.repos.d]# tail -1 /etc/profile   
export LC_ALL=C   
[iyunv@m01 yum.repos.d]# source /etc/profile   
[iyunv@m01 yum.repos.d]# echo $LC_ALL
  4.关闭防火墙及selinux   
[iyunv@m01 ~]# /etc/init.d/iptables stop   
[iyunv@m01 ~]# /etc/init.d/iptables status   
iptables: Firewall is not running.   
[iyunv@m01 ~]# chkconfig iptables off   
[iyunv@m01 ~]# chkconfig --list iptables   
iptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off   
[iyunv@m01 ~]#sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config   
修改配置文件则永久生效,但是必须重启系统   
[iyunv@m01 ~]# getenforce   
Disabled
  5、解决系统时间同步问题   
[iyunv@m01 ~]# crontab -l   
#time sync by oldboy at 2010-2-1   
*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
  =============================================   
正式安装   
1、安装基础系统软件   
yum install gcc glibc glibc-common -y   
yum install mysql-server -y
  [iyunv@m01 ~]# rpm -qa mysql   
mysql-5.1.73-5.el6_7.1.x86_64
     
2、上传软件包到指定目录或通过URL下载   
mkdir -p /home/oldboy/tools/nagios   
cd /home/oldboy/tools/nagios     
rz
  unzip -q oldboy_training_nagios_soft.zip
  3、添加Nagios用户   
[iyunv@web01 nagios]# useradd nagios -M -s /sbin/nologin   
[iyunv@web01 nagios]# id nagios   
uid=508(nagios) gid=508(nagios) groups=508(nagios)
  4、安装nagios-plugins插件   
[iyunv@web02 nagios]# yum install perl-devel perl-CPAN openssl-devel -y   
[iyunv@web02 nagios]# tar xf nagios-plugins-1.4.16.tar.gz     
[iyunv@web02 nagios]# cd nagios-plugins-1.4.16   
[iyunv@web02 nagios-plugins-1.4.16]# ./configure  --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules --with-mysql   
检查插件数   
[iyunv@web01 nagios]# ls /usr/local/nagios/libexec/|wc -l   
61
  5、安装nrpe软件   
[iyunv@m01 nagios-plugins-1.4.16]# cd ..   
ls /usr/local/nagios/libexec/check_nrpe     
tar xf nrpe-2.12.tar.gz     
cd nrpe-2.12     
./configure   
make all   
make install -plugin     
下面两个会报错   
make install -daemon   
make install -daemon-config   
[iyunv@m01 nrpe-2.12]# ls /usr/local/nagios/libexec/|wc -l   
60
  检查check_nrpe插件   
[iyunv@m01 tools]# ls /usr/local/nagios/libexec/check_nrpe     
/usr/local/nagios/libexec/check_nrpe   
[iyunv@m01 nrpe-2.12]# ls /usr/local/nagios/libexec/|wc -l   
60
  6、安装其他相关的插件   
[iyunv@web01 nrpe-2.12]# cd ..   
[iyunv@web01 nagios]#     
#----------Dear,我是分隔符---------------------   
tar zxf Params-Validate-0.91.tar.gz     
cd Params-Validate-0.91   
perl Makefile.PL   
make   
make install   
cd ..   
#----------Dear,我是分隔符---------------------   
tar zxf Class-Accessor-0.31.tar.gz     
cd Class-Accessor-0.31   
perl Makefile.PL   
make   
make install   
cd ..   
#----------Dear,我是分隔符---------------------   
tar zxf Config-Tiny-2.12.tar.gz   
cd Config-Tiny-2.12   
perl Makefile.PL   
make   
make install   
cd ..   
#----------Dear,我是分隔符---------------------   
tar zxf Math-Calc-Units-1.07.tar.gz     
cd Math-Calc-Units-1.07   
perl Makefile.PL   
make   
make install   
cd ..   
#----------Dear,我是分隔符---------------------   
tar zxf Regexp-Common-2010010201.tar.gz   
cd Regexp-Common-2010010201   
perl Makefile.PL   
make   
make install   
cd ..   
#----------Dear,我是分隔符---------------------   
tar zxf Nagios-Plugin-0.34.tar.gz     
cd Nagios-Plugin-0.34   
perl Makefile.PL   
make   
make install   
cd ..   
#----------Dear,我是分隔符---------------------   
#yum install sysstat -y
  如果报错就是前面的perl环境变量没提前设置好
  7、配置监控内存、磁盘I/O脚本插件   
yum install dos2UNIX -y   
/bin/cp /home/oldboy/tools/nagios/check_memory.pl  /usr/local/nagios/libexec/   
/bin/cp /home/oldboy/tools/nagios/check_iostat  /usr/local/nagios/libexec/   
chmod 755 /usr/local/nagios/libexec/check_memory.pl     
chmod 755 /usr/local/nagios/libexec/check_iostat     
dos2unix /usr/local/nagios/libexec/check_memory.pl   
dos2unix /usr/local/nagios/libexec/check_iostat
  8、配置Nagios客户端nrpe服务   
cd /usr/local/nagios/etc/   
[iyunv@web02 etc]# sed -n '79p' nrpe.cfg     
allowed_hosts=127.0.0.1   
[iyunv@web01 etc]# sed -i 's#allowed_hosts=127.0.0.1#allowed_hosts=127.0.0.1,10.0.0.61#g' nrpe.cfg  
[iyunv@web01 etc]# sed -n '79p' nrpe.cfg     
allowed_hosts=127.0.0.1,10.0.0.61
  9、然后在命令模式下执行shift+g命令道结尾。并进行如下操作   
第一步,注释掉199-203行   
#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_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1   
#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 150 -c 200     
第二步,在下面新添加要监控的内容:   
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20   
command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 10% -c 3%   
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 15% -c 7% -p /   
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%   
command[check_iostat]=/usr/local/nagios/libexec/check_iostat -w 6 -c 10   
10、启动Nagios client nrpe守护进程   
[iyunv@web02 etc]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d   
检查启动结果   
[iyunv@web02 etc]# netstat -lntup|grep nrpe   
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      24505/nrpe         
[iyunv@web02 etc]# ps -ef |grep nrpe |grep -v grep   
nagios   24505     1  0 19:56 ?        00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
  重启技巧(这里不用重启)   
#pkill nrpe   
#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
  11、加入开机自启   
[iyunv@web01 etc]# echo "#nagios nrpe process cmd by wangtian 2016-5-22">>/etc/rc.local     
[iyunv@web01 etc]# echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d">>/etc/rc.local     
检查     
[iyunv@web01 etc]# tail -2 /etc/rc.local     
#nagios nrpe process cmd by wangtian 2016-5-22   
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
     
===============================================================================   
Nagios服务器端监控   
修改主配置文件(新手不需要,需要的话自己加上去书上582页)   
[iyunv@m01 tools]#cp /usr/local/nagios/etc/nagios.cfg{,.ori}   
[iyunv@m01 tools]# vim /usr/local/nagios/etc/nagios.cfg +34   
增加如下主机和服务的配置文件   
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg   
cfg_file=/usr/local/nagios/etc/objects/services.cfg   
cfg_dir=/usr/local/nagios/etc/objects/services/   
然后注释下列   
# Definitions for monitoring the local (Linux) host   
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
  根据已有数据生成hosts.cfg   
[iyunv@m01 tools]# cd /usr/local/nagios/etc/objects/     
[iyunv@m01 objects]# head -51 localhost.cfg >hosts.cfg   
[iyunv@m01 objects]# chown nagios.nagios /usr/local/nagios/etc/objects/hosts.cfg
  然后生成新的空services.cfg服务文件   
[iyunv@m01 objects]# touch services.cfg   
[iyunv@m01 objects]# chown nagios.nagios /usr/local/nagios/etc/objects/services.cfg     
最后,生成服务的配置文件目录   
[iyunv@m01 objects]# mkdir services     
[iyunv@m01 objects]# chown -R nagios.nagios /usr/local/nagios/etc/objects/services     
检查   
[iyunv@m01 objects]# ls -lrt   
total 60   
-rw-rw-r-- 1 nagios nagios 10812 May 22 15:14 templates.cfg   
-rw-rw-r-- 1 nagios nagios  7716 May 22 15:14 commands.cfg   
-rw-rw-r-- 1 nagios nagios  3208 May 22 15:14 timeperiods.cfg   
-rw-rw-r-- 1 nagios nagios  5403 May 22 15:14 localhost.cfg   
-rw-rw-r-- 1 nagios nagios  4019 May 22 15:14 windows.cfg   
-rw-rw-r-- 1 nagios nagios  3124 May 22 15:14 printer.cfg   
-rw-rw-r-- 1 nagios nagios  3293 May 22 15:14 switch.cfg   
-rw-r--r-- 1 root   root    2166 May 22 15:26 contacts.cfg.ori   
-rw-rw-r-- 1 nagios nagios  2166 May 22 15:28 contacts.cfg   
-rw-r--r-- 1 nagios nagios  1870 May 22 20:36 hosts.cfg   
-rw-r--r-- 1 nagios nagios     0 May 22 20:38 services.cfg   
drwxr-xr-x 2 nagios nagios  4096 May 22 20:39 services
  ====================================================================
  配置Nagios服务器端监控项   
1、定义要监控的Nagios客户端主机   
[iyunv@m01 objects]# cd /usr/local/nagios/etc/objects/   
[iyunv@m01 objects]# cp hosts.cfg.ori{,.1}   
[iyunv@m01 objects]# egrep -v "#|^$" hosts.cfg.ori >hosts.cfg   
[iyunv@m01 objects]# vim hosts.cfg   
检查   
[iyunv@m01 objects]# cat hosts.cfg   
define host{   
        use                     linux-server            
        host_name               web01   
        alias                   web01   
        address                 10.0.0.8   
        }   
define host{   
        use                     linux-server            
        host_name               web02   
        alias                   web02   
        address                 10.0.0.7   
        }   
define hostgroup{   
        hostgroup_name  linux-servers     
        alias           Linux Servers     
        members         web01,web02     
        }
  2、配置services.cfg,定义要监控的资源服务   
[iyunv@m01 objects]#cp services.cfg{,.ori}   
[iyunv@m01 objects]#vim services.cfg     
[iyunv@m01 objects]# cat services.cfg                           
define service {   
        use                         generic-service            
        host_name                   web01,web02   
        service_description         Disk Partition   
        check_command               check_nrpe!check_disk   
        }   
define service {   
        use                         generic-service            
        host_name                   web01,web02   
        service_description         Swap Useage     
        check_command               check_nrpe!check_swap   
        }   
define service {   
        use                         generic-service            
        host_name                   web01,web02   
        service_description         MEM Useage   
        check_command               check_nrpe!check_mem   
        }   
define service {   
        use                         generic-service            
        host_name                   web01,web02   
        service_description         Current Load   
        check_command               check_nrpe!check_load   
        }   
define service {   
        use                         generic-service            
        host_name                   web01,web02   
        service_description         Disk Iostat   
        check_command               check_nrpe!check_iostat!5!11   
        }   
define service {   
        use                         generic-service            
        host_name                   web01,web02   
        service_description         PING   
        check_command               check_ping!100.0,20%!500.0,60%   
        }   
        
3、调试hosts.cfg和service.cfg的所有配置   
[iyunv@m01 objects]# cp commands.cfg{,.ori}   
[iyunv@m01 objects]#  vim commands.cfg   
[iyunv@m01 objects]# tail -5 commands.cfg   
# 'check_nrpe' command definition   
define command{   
        command_name    check_nrpe   
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$   
        }
  4、检查语法   
/etc/init.d/nagios checkconfig   
出现OK就可以启动了   
/etc/init.d/nagios start   
如果已经启动了,就执行/etc/init.d/nagios reload
  在网页输入服务器端IP/Nagios就可以看到结果啦
  =====================================================================================   
配置报警(前面已经修改过邮箱报警,需要其他报警的自行扩展)   
配置报警就是配置contacts.cfg文件。可以将公司所有的运维人员都加入到这个文件中,如果有需要还可以分组。
  配置报警的步骤:   
(1)    添加联系人及联系组contacts.cfg;   
define contact{   
    contact_name    oldboy-pager   
    use                generic-contact   
    alias            Nagios users   
    email            18901398229   
    }   
(2)    添加报警的命令commands.cfg     
define command {   
    command_name    notify-host-by-pager   
    command_line    $USER1$/sms_send "$HOSTSTATE$ alert for $HOSTNAME$" $CONTACTOAGER$   
    }   
define command {   
    command_name    notify-service-by-pager   
    command_line    $USER1$/sms_send "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTOAGER$   
    }   
(3)    调整联系人模板,添加报警的命令(来自于commands.cfg):   
define contact{   
    name                            generic-contact   
    service_notification_period     24x7   
    host_notification_period        24x7   
    service_notification_options    w,u,c,r,f,s   
    host_notification_options       d,u,r,f,s   
    service_notification_commands   notify-service-by-email,notify-service-by-pager   
    host_notification_commands      notify-host-by-email,notify-host-by-pager   
    register                        0   
    }   
(4)    在hosts.cfg和service.cfg配置文件中添加报警联系人及组,或者在模板中添加   
contact_groups          admins,group1,group2,user1
  
  
  一些排错的思路  (1) 客户端获取值失败:
  [iyunv@client1 ~]# /usr/local/nagios/libexec/check_nrpe -H 10.0.0.2 -c check_disk
  CHECK_NRPE: Error - Could not complete SSL handshake. # 握手失败
  # 这种问题的解决办法很简单,只需要执行下面这条命令即可:
  [iyunv@client1 ~]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_disk
  # 如果能够获得值,那就是没有添加网卡地址,在nrpe.cfg中修改allowed_hosts=127.0.0.1这一行
  (2) 状态为CRITICAL
  # 这种问题就是连接失败,要么是服务没起,要么就是防火墙没关。我们可以现在本地执行:
  /usr/local/nagios/libexec/check_nrpe -H 10.0.0.2 -c check_disk
  # 当然ip和参数都可以改,通过该命令就能得到答案,因为改命令就是Nagios获取监控值的过程
  (3) 命令行执行能够获取数值,但是web界面去获取不到。
  define service {
  use generic-service
  host_name 02-client1,01-nagios
  service_description Disk Partition
  check_command check_nrpe!check_disk # 肯定是这个参数定义错了
  }
  (4) Unable to read output
  # 出现这种问题的原因就是获取值的插件没有执行权限,或者是这插件就是有问题的,总之就是插件的错。
  command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 6% -c 3% # check_memory.pl就是插件
  [iyunv@nagios libexec]# chmod +x check_memory.pl # 执行该命令,如果还是不行,那就是插件本身的问题了
  总结,当web界面显示出现问题时:
  (1) Nagios自身和配置文件;
  (2) 在服务器端执行:
  /usr/local/nagios/libexec/check_nrpe -H 被监控主机地址 -c 获取值的命令
  (3) 在客户端本地执行:
  /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c 获取值的命令
  (4) 执行nrpe.cfg配置文件中的获取值的命令:
  command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 8% -p / # 执行该命令
                   


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-221077-1-1.html 上篇帖子: nagios 的配置总结 下篇帖子: CentOS 7 中自定义nagios 插件脚本 监控
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表