标签:
系统环境:
操作系统:CentOS-5.7 x86_64
Apache版本: Apache-2.2.22
Nagios版本: nagios-3.3.1
GD库: gd-2.0.33
2、安装前准备:
2.1、安装GD库
1
|
; html-script: false ]yum install -y gd.x86_64 gd-devel.x86_64
|
2.2、安装Apache
http://www.ttlsa.com/html/654.html
2.3、下载Nagios,Nagios-plugins,nrpe
官方网站
http://www.nagios.org/download/
截至2012.3.9在官网上的最新版本分别是
版本:nagios-3.3.1
1
|
; html-script: false ]wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz/download
|
版本:nagios-plugins-1.4.15
1
|
; html-script: false ]wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fplugins%2F&ts=1331283502&use_mirror=ncu
|
nrpe下载地址http://www.nagios.org/download/addons/
版本:nrpe-2.13
1
|
; html-script: false ]wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz?r=http%3A%2F%2Fexchange.nagios.org%2Fdirectory%2FAddons%2FMonitoring-Agents%2FNRPE--2D-Nagios-Remote-Plugin-Executor%2Fdetails&ts=1331283624&use_mirror=nchc
|
2.4、安装前注意事项:
Nagios,Nagios-plugins,nrpe安装在监控服务器上。
nrpe安装在Linux/Unix被监控端。
3、创建帐号及组
3.1、创建帐号
1
2
|
; html-script: false ]/usr/sbin/useradd -m nagios
passwd nagios
|
3.2、创建组
1
|
; html-script: false ]/usr/sbin/usermod -a -G nagios nobody
|
nobody为运行apache的帐号。
4、安装配置nagios
4.1、解压&安装
1
2
3
4
5
|
; html-script: false ]cd /usr/local/src/tarbag/
tar zxvf nagios-3.3.1.tar.gz -C ../software/
cd ../software/nagios/
./configure --prefix=/usr/local/nagios --with-command-group=nagios --with-gd-lib=/usr/lib64/ --with-gd-inc=/usr/lib64/
make all
|
# 使用make install来安装主程序,CGI和HTML文件
1
|
; html-script: false ]make install
|
# 使用make install-init在/etc/rc.d/init.d安装启动脚本
1
|
; html-script: false ]make install-init
|
# 使用make install-cofig来安装示例配置文件,安装的路径是/usr/local/nagios/etc.
1
|
; html-script: false ]make install-config
|
# 使用make install-commandmode来配置目录权限
1
|
; html-script: false ]make install-commandmode
|
注:
nagios目录功能的简要说明:
bin Nagios执行程序所在目录,nagios文件即为主程序
etc Nagios配置文件位置
sbin Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share Nagios网页文件所在的目录
var Nagios日志文件、spid 等文件所在的目录
var/archives 日志归档目录
var/rw 用来存放外部命令文件
4.2、配置apache
将下面行加入apache配置文件的alias模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
; html-script: false ]----------------------------------------
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
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">
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>
----------------------------------------
|
创建apache目录验证文件
1
2
3
4
|
; html-script: false ]htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: (输入密码)
Re-type new password: (再输入一次密码)
Adding password for user nagiosadmin
|
重启apache:
1
|
; html-script: false ]apachectl -k restart
|
配置nagios配置文件
1
|
; html-script: false ]vi /usr/local/nagios/etc/objects/contacts.cfg
|
将里面的email地址改为自己的email地址。
5、安装Nagios插件
1
2
3
4
5
|
; html-script: false ]tar zxvf nagios-plugins-1.4.15.tar.gz -C ../software/
cd ../software/nagios-plugins-1.4.15/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
|
6、启动Nagios
配置机器启动时自动启动Nagios
1
2
|
; html-script: false ]chkconfig --add nagios
chkconfig nagios on
|
检查Nagios配置文件
1
|
; html-script: false ]/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
# 启Nnagios
1
|
; html-script: false ]service nagios start
|
7、关闭SELinux及防火墙(切勿小视)
7.1、关闭SELinux
1
|
; html-script: false ]vi /etc/selinux/config
|
将下面行设为disabled
1
|
; html-script: false ]SELINUX=disabled
|
重启系统即可生效
或者使用setenforce关闭selinux
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
1
|
; html-script: false ]setenforce 0
|
这样就可以不用重启系统即可生效了
7.2、关闭防火墙
1
2
|
; html-script: false ]service iptables stop
chkconfig iptables off
|
如果开启防火墙,应该允许访问apache(一般为80端口)并允许nagios去抓取被监控机信息(一般nrpe为5666端口)。
8、访问Nagios服务器
http://IP/nagios/
输入用户名及密码登录。
9、安装nrpe插件
nrpe是用来监控Linux机器的插件
1
2
3
4
|
; html-script: false ]tar zxvf nrpe-2.13.tar.gz -C ../software/
cd ../software/nrpe-2.13
./configure
make all
|
在Nagios服务器端只要安装nrpe监控插件就行
1
|
; html-script: false ]make install-plugin
|
在/usr/local/nagios/etc/objects/commands.cfg中定义check_nrpe命令
1
|
; html-script: false ]vi /usr/local/nagios/etc/objects/commands.cfg
|
修改配置文件如下
1
2
3
4
5
6
7
8
9
10
11
|
; html-script: false ]########################################################################
#
# 2012.03.09 add by Tony
# NRPE COMMAND
#
########################################################################
# ‘check_nrpe ‘ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
|
标签:
原文地址:http://www.cnblogs.com/chenshoubiao/p/4782585.html