您的位置:首页 > 运维架构 > Linux

Nagios监控linux主机以及硬件信息

2017-07-27 15:07 429 查看

Nagios监控linux主机

以下步骤都是命令,目录选择自行思考

安装Nagios XI Linux agent 

wget https://assets.nagios.com/downloads/nagiosxi/agents/linux-nrpe-agent.tar.gz

Tar xzf linux-nrpe-agent.tar.gz

cd linux-nrpe-agent.tar.gz

./fullinstall

 

安装NRPE插件

yum install -y gcc glibc glibc-common openssl-devel perl wget

Wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.0.tar.gz

tar xzf nrpe.tar.gz

cd /tmp/nrpe-nrpe-3.2.0/

./configure --enable-command-args

make all

make install-groups-users

make install

make install-config

 

echo >> /etc/services

echo '# Nagios services' >> /etc/services

echo 'nrpe    5666/tcp' >> /etc/services

 

make install-init

cd /usr/local/nagios/etc/

vim nrpe.cfg

 

 

 

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 #原本不能进入

/usr/local/nagios/libexec/check_nrpe -H 192.168.56.63 #使用更新后ip

 

start nrpe

stop nrpe

restart nrpe

status nrpe

安装之后在/usr/local/nagios/etc/objects下新建你缩需要金控主机的.cfg文件,然后进去进行配置,在这个文件中添加你所需要监控主机的服务,其中服务在/usr/local/nagios/libexec下查看由哪些可以监控的服务,下面以监控linux主机192.168.56.64中的PING命令为例进行说明

 

在监控端63

cd /usr/local/nagios/etc/objects

vim 192.168.56.64.cfg  #输入以下内容,监控主机,ping,硬盘,cpu等

define host{

        use                    linux-server           ; Name of host template to use,这个use名字在templates.cfg中查找进行设置

                                                        ; This host definition will inherit all variables that are defined

                                                        ; in (or inherited by) the linux-server host template definition.

        host_name               test64

        alias                   test64

        address                 192.168.56.64

        }

define service{

        use                             local-service         ; Name of service template to use

        host_name                       test64

        service_description             PING

        check_command                   check_ping!100.0,20%!500.0,60%

        }

        host_name test64

        service_description Current Users

        check_command check_nrpe!check_users

        contact_groups admins

}

#The following service will monitor the free drive space on /dev/sda1 on the remote host.  

define service{

        use local-service

        host_name test64

        service_description /dev/sda1 Free Space

        check_command check_nrpe!check_sda1

        contact_groups admins

}

#The following service will monitor the total number of processes on the remote host.  

define service{

        use local-service

        host_name test64

        service_description Total PProcesses

        check_command check_nrpe!check_total_procs

        contact_groups admins

}

#The following service will monitor the number of zombie processes on the remote host.  

define service{

        use local-service

        host_name test64

        service_description Zombie Processes

        check_command check_nrpe!check_zombie_procs

        contact_groups admins

}

#  monitoring the swap usage on the remote host  

define service{

        use local-service

        host_name test64

        service_description Swap Usage

        check_command check_nrpe!check_swap

        contact_groups admins

}

"192.168.56.64.cfg" 93L, 3168C                                                         81,2-9       底端

 

配置/usr/local/nagios/etc/nagios.cfg

添加行cfg_file=/usr/local/nagios/etc/objects/192.168.56.64.cfg

 

 

遇到的错误

 

错误解决办法,user名称要与templates.cfg中的相对应,
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nagios linux nrpe 监控