234cfds1 发表于 2015-9-8 09:13:42

RHEL 5.5 安装 Nagios 3.2.3

  安装好RHEL 5.5基础版后,我事先将光盘作为yum源,具体看本人之前随笔。相关rpm可在http://pkgs.repoforge.org/查找,个别缺失用google吧。
  监控主机HostA:


[*]#yum install httpd php gd
[*]#rpm -ivh nagios-3.2.3-3.el5.rf.i386.rpm nagios-plugins-1.4.9-1.el5.rf.i386.rpm nagios-plugins-nrpe-2.5.2-1.el5.rf.i386.rpm nagios-plugins-setuid-1.4.9-1.el5.rf.i386.rpm nginx-1.2.0-1.el5.ngx.i386.rpm perl-Crypt-DES-2.05-3.2.el5.rf.i386.rpm perl-Digest-HMAC-1.02-1.el5.rf.noarch.rpm perl-Digest-SHA1-2.13-1.el5.rfx.i386.rpm perl-Net-SNMP-5.2.0-1.2.el5.rf.noarch.rpm perl-Socket6-0.23-1.el5.rfx.i386.rpm
[*]#htpasswd -bc /etc/nagios/htpasswd.users nagiosadmin password
[*]#setenforce 0或者修改/etc/selinux/config使之永久有效
[*]#chkconfig --level 345 httpd on
[*]#chkconfig --level 345 nagios on
[*]#reboot
[*]#http://HostA/nagios
  被控Windows主机HostB:


[*]http://nsclient.org/nscp/downloads 下载最新NSClient++,并安装
[*]注意安装目录下NSC.ini中的

[*]

[*]allowed_hosts=
[*]password=


[*]

[*]port=5666




[*]#vi /etc/nagios/nagios.cfg

[*]cfg_file=/usr/local/nagios/etc/objects/windows.cfg


[*]windows.cfg

[*]修改主机对象 host_name,alias,address


[*]验证,重启nagios
  被控Linux主机HostC:


[*]# rpm -ivh nagios-nrpe-2.5.2-1.el5.rf.i386.rpm nagios-plugins-1.4.9-1.el5.rf.i386.rpm perl-Crypt-DES-2.05-3.2.el5.rf.i386.rpmperl-Digest-HMAC-1.02-1.el5.rf.noarch.rpm perl-Digest-SHA1-2.13-1.el5.rfx.i386.rpm perl-Net-SNMP-5.2.0-1.2.el5.rf.noarch.rpm perl-Socket6-0.23-1.el5.rfx.i386.rpm fping-2.4-1.b2.3.el5.rf.i386.rpm
[*] vi /etc/nagios/nrpe.cfg

[*]allowed_hosts=127.0.0.1,HostA_ip


[*]nrpe -c /etc/nagios/nrpe.cfg -d #运行nrpe
[*]vi /etc/sysconfig/iptables

[*]-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT


[*]netstat -an|grep 5666
[*]在HostA上执行

[*]#/usr/lib/nagios/plugins/check_nrpe-H 192.168.128.59
[*]返回NRPE v2.5.1,OK
[*]cp /etc/nagios/objects/localhost.cfg /etc/nagios/objects/linuxs.cfg
[*]vi /etc/nagios/objects/linuxs.cfg

[*]# Definitions for monitoring the Linux hosts
[*]cfg_file=/etc/nagios/objects/linuxs.cfg
[*]

View Code


◦###############################################################################
# LINUX.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
###############################################################################
# HOST DEFINITION
###############################################################################
define host{
use                     linux-server
host_name               iplat-builder
alias                   localhost
address               192.168.128.59
}
###############################################################################
# HOST GROUP DEFINITION
###############################################################################
define hostgroup {
hostgroup_namelinux-Hosts
alias         Linux Hosts
members         iplat-builder   ; Comma separated list of hosts that belong to this group
      }
###############################################################################
# SERVICE DEFINITIONS
###############################################################################
define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             PING
check_command            check_icmp!100.0,20%!500.0,60%
}
define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             Root Partition
check_command            check_local_disk!20%!10%!/
}
define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             Total Processes
check_command            check_local_procs!250!400!RSZDT
}
define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             Current Load
check_command            check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             Swap Usage
check_command            check_local_swap!20!10
}

define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             SSH
check_command            check_ssh
notifications_enabled      0
}
define service{
use                           local-service
hostgroup_name                  linux-Hosts
service_description             HTTP
check_command            check_http
notifications_enabled      0
}




[*]#chkconfig --level 345 nrpe on
  参考:


[*]http://www.nagios.org/
[*]http://smallfish01.blog.iyunv.com/3565/455092
[*]http://minitrue.googlecode.com/svn-history/r118/trunk/txt/ch13.txt
页: [1]
查看完整版本: RHEL 5.5 安装 Nagios 3.2.3