BOSCO 蜻蜓点水,一点一滴

On a new journey……

RHEL 5.4下nagios的安装

 

# 挂载系统光盘或系统ISO镜像

[root@AS5 ~]# mount /dev/hdc /mnt

mount: block device /dev/hdc is write-protected, mounting read-only

# 创建yum仓库

[root@AS5 ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo

修改为:

[rhel-debuginfo]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///mnt/Server

enabled=1

gpgcheck=0

# 清缓存

[root@AS5 ~]# yum clean all

Loaded plugins: rhnplugin, security

Cleaning up Everything

# 安装相关软件包

[root@AS5 ~]# yum -y install httpd gcc glibc glibc-common php *gd*

# 检查SElinux是否关闭

[root@AS5 ~]# getenforce

Disabled

# 创建组及用户

[root@AS5 ~]# groupadd nagcmd

[root@AS5 ~]# useradd -m nagios

[root@AS5 ~]# passwd nagios

[root@AS5 ~]# usermod -G nagcmd nagios

[root@AS5 ~]# usermod -G nagcmd apache

[root@AS5 ~]# id nagios

uid=500(nagios) gid=501(nagios) groups=501(nagios),500(nagcmd)

[root@AS5 ~]# id apache

uid=48(apache) gid=48(apache) groups=48(apache),500(nagcmd)

[root@AS5 ~]# ll

total 11952

-rw------- 1 root root    1171 Mar 17 05:08 anaconda-ks.cfg

drwxr-xr-x 2 root root    4096 Mar 17 05:18 Desktop

-rw-r--r-- 1 root root   37174 Mar 17 05:08 install.log

-rw-r--r-- 1 root root    4062 Mar 17 05:07 install.log.syslog

-rw-r--r-- 1 root root 9638175 Aug 12 11:17 nagios-cn-3.2.3.tar.bz2

-rw-r--r-- 1 root root 2095419 Aug 12 11:17 nagios-plugins-1.4.15.tar.gz

-rw-r--r-- 1 root root  405725 Aug 12 11:17 nrpe-2.12.tar.gz

[root@AS5 ~]# mkdir /usr/local/nagios

[root@AS5 ~]# chown -R nagios:nagios /usr/local/nagios/

[root@AS5 ~]# chmod -R 775 /usr/local/nagios/

# 安装nagios包

[root@AS5 ~]# tar xvjf nagios-cn-3.2.3.tar.bz2

[root@AS5 ~]# cd nagios-cn-3.2.3

[root@AS5 nagios-cn-3.2.3]# ./configure --with-command-group=nagcmd --enable-event-broker --prefix=/usr/local/nagios

[root@AS5 nagios-cn-3.2.3]# make all && make install

[root@AS5 nagios-cn-3.2.3]# make install-init && make install-config && make install-commandmode && make install-webconf

 

[root@AS5 ~]# cd

[root@AS5 ~]# vi .bashrc

# 为方便后面操作,这里添加检查nagios配置的正确性的别名

alias ck_nagios='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'

PATH=$PATH:/usr/local/nagios/bin

[root@AS5 ~]# source .bashrc

[root@AS5 ~]# ck_nagios

 

Total Warnings: 0

Total Errors:   0

 

[root@AS5 ~]# echo $PATH

/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nagios/bin

 

[root@AS5 ~]# cat /etc/httpd/conf.d/nagios.conf

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER

# Last Modified: 11-26-2005

#

# This file contains examples of entries that need

# to be incorporated into your Apache web server

# configuration file.  Customize the paths, etc. as

# needed to fit your system.

 

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

 

<Directory "/usr/local/nagios/sbin">

#  SSLRequireSSL

   Options ExecCGI

   AllowOverride None

   Order allow,deny

   Allow from all

#  Order deny,allow

#  Deny from all

#  Allow from 127.0.0.1

   AuthName "Nagios Access"

   AuthType Basic

   AuthUserFile /usr/local/nagios/etc/htpasswd.users

   Require valid-user

</Directory>

 

Alias /nagios "/usr/local/nagios/share"

 

<Directory "/usr/local/nagios/share">

#  SSLRequireSSL

   Options None

   AllowOverride None

   Order allow,deny

   Allow from all

#  Order deny,allow

#  Deny from all

#  Allow from 127.0.0.1

   AuthName "Nagios Access"

   AuthType Basic

   AuthUserFile /usr/local/nagios/etc/htpasswd.users

   Require valid-user

</Directory>

 

#给中文在线帮助文档显示用的一个虚拟目录路径

Alias /pub/images "/usr/local/nagios/share/docs/images"

<Directory "/usr/local/nagios/share/docs/images">

   Options None

   AllowOverride None

   Order allow,deny

   Allow from all

   AuthName "Nagios Access"

   AuthType Basic

   AuthUserFile /usr/local/nagios/etc/htpasswd.users

   Require valid-user

</Directory>

 

[root@AS5 ~]# /usr/local/nagios/etc/

[root@AS5 etc]# ls

cgi.cfg  nagios.cfg  nagiosgraph.cfg  objects  resource.cfg

 

[root@AS5 etc]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password:

Re-type new password:

Adding password for user nagiosadmin

[root@AS5 etc]# cat htpasswd.users 

nagiosadmin:IbIG.EOXGxbAY

[root@AS5 etc]# service httpd restart

Stopping httpd: [FAILED]

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.200.100 for ServerName

[  OK  ]

[root@AS5 etc]# cd

[root@AS5 ~]# ls

anaconda-ks.cfg  install.log         nagios-cn-3.2.3          nagios-plugins-1.4.15.tar.gz

Desktop          install.log.syslog  nagios-cn-3.2.3.tar.bz2  nrpe-2.12.tar.gz

[root@AS5 ~]# tar xvzf nagios-plugins-1.4.15.tar.gz

[root@AS5 nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios

 

[root@AS5 nagios-plugins-1.4.15]# make && make install

[root@AS5 nagios-plugins-1.4.15]# cd

[root@AS5 ~]# chkconfig --add nagios

[root@AS5 ~]# chkconfig nagios on

[root@AS5 ~]# alias

alias ck_nagios='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

[root@AS5 ~]# ck_nagios

 

Total Warnings: 0

Total Errors:   0

 

Things look okay - No serious problems were detected during the pre-flight check

[root@AS5 ~]# service nagios start

Starting nagios: done.

 

此时就可以用web访问nagios界面了。

 

[root@AS5 ~]# ls

anaconda-ks.cfg  install.log.syslog       nagios-plugins-1.4.15

Desktop          nagios-cn-3.2.3          nagios-plugins-1.4.15.tar.gz

install.log      nagios-cn-3.2.3.tar.bz2  nrpe-2.12.tar.gz

[root@AS5 ~]# tar xvzf nrpe-2.12.tar.gz

[root@AS5 ~]# cd nrpe-2.12

[root@AS5 nrpe-2.12]# ls

Changelog     configure.in  init-script.debian.in  LEGAL        README.SSL     subst.in

config.guess  contrib       init-script.in         Makefile.in  sample-config  update-version

config.sub    docs          init-script.suse.in    nrpe.spec    SECURITY

configure     include       install-sh             README       src

[root@AS5 nrpe-2.12]# ./configure

 

--注:

--如果这一步报错:checking for SSL headers... configure: error: Cannot find ssl headers

--解决办法:安装openssl和openssl-devel包即可。

 

[root@AS5 nrpe-2.12]# make all

[root@AS5 nrpe-2.12]# make install-plugin

[root@AS5 nrpe-2.12]# make install-daemon

[root@AS5 nrpe-2.12]# make install-daemon-config

[root@AS5 nrpe-2.12]# make install-xinetd

 

[root@AS5 nrpe-2.12]# cd

 

[root@AS5 ~]# /usr/local/nagios/bin/nrpe -i /usr/local/nagios/etc/nrpe.cfg

 

[root@AS5 ~]# service xinetd restart

Stopping xinetd: [  OK  ]

Starting xinetd: [  OK  ]

[root@AS5 ~]# chkconfig --list | grep nrpe

       nrpe:             on

 

[root@AS5 ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

 

[root@AS5 ~]# vi /etc/xinetd.d/nrpe

 

[root@AS5 ~]# vi /etc/services

--添加

nrpe    5666/tcp                       #nrpe

 

[root@AS5 nrpe-2.12]# /etc/init.d/xinetd restart

Stopping xinetd: [  OK  ]

Starting xinetd: [  OK  ]

[root@AS5 nrpe-2.12]# netstat -an | grep 5666

tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      

 

[root@AS5 ~]# /usr/local/nagios/libexec/check_nrpe -H AS5

NRPE v2.12

[root@AS5 ~]# /usr/local/nagios/libexec/check_nrpe -H localhost

NRPE v2.12

 

 

阅读更多
版权声明:本文为博主hw_libo原创文章,未经博主允许不得转载。 https://blog.csdn.net/HW_LiBo/article/details/6881820
个人分类: RHEL
想对作者说点什么? 我来说一句

Nagios with NRPE detail configure

2011年07月20日 1.62MB 下载

CentOS 5.4版本全下载(包括5.4

2010年04月27日 188B 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭