Nagios监控安装手册Nagios监控安装手册
编制单位:高德软件有限公司
编制日期:2010年11月
编制人:杨聪广
目录
1. Nagios安装环境 (2)
2. 安装Nagios-3.2.3 (2)
3. nagios-plugins-1.4.15 插件安装 (4)
4. 配置apache (5)
5. 配置Nagios (7)
6. 客户机插件安装 (8)
7. PNP插件安装 (10)
1. Nagios安装环境
1、Nagios 安装操作系统:Centos 5.4 64bit
2、Nagios 环境需要的软件
1)Nagios-3.2.3 下载地址:
https://www.wendangku.net/doc/96923245.html,/projects/nagios/files/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz/download
2)nagios-plugins-1.4.15下载地址:
https://www.wendangku.net/doc/96923245.html,/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download
3)nrpe-2.12下载地址:
https://www.wendangku.net/doc/96923245.html,/projects/nagios/files/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz/download
4)apache2.x PHP5.x mysql5.x
2. 安装Nagios-
3.2.3
1.shell > tar -zxvf nagios-3.
2.
3.tar.gz
shell > ./configure --prefix=/usr/local/nagios
输出信息:
Shell >make all
输出
Shell > make install
输出:如下报错信息
从信息中可以看出是没有nagios用户造成的
Shell > useradd nagios
Shell >mkdir mkdir /usr/local/nagios
Shell > chown nagios.nagios /usr/local/nagios/ Shell >make install
输出:
Shell > make install-init
Shell > make install-commandmode
Shell > make install-config
2.验证安装的正确性
shell > ls /usr/local/nagios
bin etc libexec sbin share var
bin Nagios执行程序所在目录,nagios文件即为主程序
etc Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件sbin Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录Share Nagios网页文件所在的目录
Var Nagios日志文件、spid 等文件所在的目录
var/archives Empty directory for the archived logs
var/rw Empty directory for the external command file
3. nagios-plugins-1.
4.15 插件安装
1、Shell > tar –zxvf nagios-plugins-1.4.15.tar.gz
shell >./configure --prefix=/usr/local/nagios/
shell > make install
2、验证安装的正确性
shell >ls /usr/local/nagios/libexec/
4. 配置apache
1.配置Nagios虚拟目录
shell > vi /etc/httpd/conf/httpd.conf
################配置Nagios访问目录###########################
ScriptAlias /nagios/cgi-bin /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
Require valid-user
Alias /nagios /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
Require valid-user
2.增加验证用户
Shell > htpasswd -c /usr/local/nagios/etc/htpasswd nagios
3.启动apache
shell > service httpd start
4.访问Nagios http://
5.成功页面
5. 配置Nagios
1.修改nagios.cfg文件
Shell > vi /usr/local/nagios/etc/nagios.cfg
command_check_interval=-1改成15s
2.修改cgi.cfg
sehll > vi /usr/local/nagios/etc/cgi.cfg //修改default_user_name=nagios
3.配置邮件监控,编辑contacts.cfg
配置完重新加载配置文件service nagios reload
4.增加主机
说明:Nagios增加主机是以编辑文件的形式增加的,步骤可以分一下几步:
A. 新建一个以.cfg后缀名的文件(如:map.cfg)
B. 编辑map.cfg,这里边可以定义组,可以添加主机如:
C. 编辑ngios.cfg
D. 检查配置文件是否有错误
shell > /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
E. service nagios reload 重新加载配置文件
6. 客户机插件安装
1.在被监控主机上进安装nagios-plugins-1.4.15
A. 建立用户
shell > useradd nagios
B. 安装nagios-plugins-1.4.15
shell > tar –zxvf nagios-plugins-1.4.15.tar.gz
shell >cd nagios-plugins-1.4.15
shell > ./configure
shell > make && make install
C. 修改目录权限
shell > chown –R nagios:nagios /usr/local/nagios
2.安装nrpe-2.12
A. 安装nrpe-2.12
shell > tar –zxvf nrpe-2.12.tar.gz
shell > cd nrpe-2.12
shell > ./configure
shell > make all
shell > make install-plugin
shell > make install-deamo
shell > make install-daemon-config
shell >make install-xinetd
3. 编辑/etc/xinetd.d/nrpe
4. 重启服务service xinetd restart
5. 检查服务端口netstart –antup|grep 5666
7. PNP插件安装
1.下载pnp0.4.14安装包
shell > wget https://www.wendangku.net/doc/96923245.html,/project/pnp4nagios/PNP/pnp-0.4.14/pnp-0.4.14.tar.gz 2.安装pnp0.4.14
Shell >tar –zxvf /pnp-0.4.14.tar.gz
Shell >cd pnp-0.4.14
Shell >make all
Shell > make install
Shell >make install-init
3.修改配置文件
Sehll > cd /usr/local/nagios/etc/pnp/
shell > cp process_perfdata.cfg-sample process_perfdata.cfg
shell > cp npcd.cfg-sample npcd.cfg
shell > cp rra.cfg-sample rra.cfg
shell > chown -R nagios:nagios *
shell > vi process_perfdata.cfg
LOG_FILE = /usr/local/nagios/var/perfdata.log
# Loglevel 0=silent 1=normal 2=debug
LOG_LEVEL = 2 #先改为2,为debug模式
4.修改commands.cfg
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl //修改成自己的process_perfdata.pl 路径}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl//修改成自己的process_perfdata.pl 路径} 5.修改主机配置文件加小太阳
vi /usr/local/nagios/etc/nagios.cfg
#为这个主机增加小太阳标记
define host{
use linux-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
6.重新加载配置文件
service nagios reload