分类: LINUX
2009-04-07 16:47:34
官方站点
安装笔记
1.下载并安装相关软件
1)下载相关软件
apache #
GD库(1.63以上) #
zlib #
pnglib #
jpeglib #
basic icons #http://prdownloads.sourceforge.net/nagios/imagepak-base.tar.gz
#gd,zlib,pnglib,jpeglib这些正常安装即可, ./configure && make && make install
nagios #
nagios-plugins #
nrpe #
2)安装部分
#apache自己装
#gd,zlib,pnglib,jpeglib这些正常安装即可, ./configure && make && make install
#安装nagios
# adduser nagios
#usermod apache -G nagios
wget
tar zxf nagios-2.5.tar.gz
cd nagios-2.5
./configure –prefix=/app/nagios –with-gd-lib=/usr/local/lib –with-gd-inc=/usr/local/include
make all
make install
make install-init
make install-commandmode
make install-config
安装nagios-plugin
# tar zxvf nagios-plugins-xxx.tar.gz
#cd nagios-plugis-xxx
#./configure -prefix=/app/nagios-plugins
# –enable-redhat-pthread-workaround 这个参数可以在出现checking for redhat spopen problem… 错误时使用
#make
#make install
安装完成后/app/nagios-plugins会产生一个libexec的目录,将该目录全部移动到/app/nagios/目录下
安装imagepak-base.tar.gz
tar –xvzf imagepak-base.tar.gz
mv base/ /usr/local/nagios/share/images/logos/
2.开始配置
(1)配置apache
在apache的配置文件httpd.conf中追加
ScriptAlias /nagios/cgi-bin/ /app/nagios/sbin/
AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
Alias /nagios/ /app/nagios/share/
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
(2)设置访问权限
a. 在/app/nagios/share目录下
vi .htaccess
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /app/nagios/etc/.htpasswd
require valid-user
b. 在/app/nagios/sbin目录下
vi .htpasswd
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /app/nagios/etc/.htpasswd
require valid-user
c. /app/apache/bin/htpasswd –c /app/nagios/etc/.htpasswd nagios
3、配置nagios
/app/nagios/etc下是nagios的配置模板文件nagios/cgi/resource/minimal/.cfg-sample,把改名,把后面的-sample去掉.
另外还需要修改cgi.cfg
#use_authentication=0
这时启动nagios和apache就可以访问nagios的管理页面了
4.NRPE的安装.及监按指令的布署
nrpe 安装与使用
安装nrpe与配置
#./configure
#make all
#vi sample-config/nrpe.cfg
改成你允许的IP
allowed_hosts=127.0.0.1,192.168.0.57(57是nagios服务器)
改成你准备监视的服务command
[check_disk]=/usr/local/nagios/libexec/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
检查磁盘,当 / 剩余$ARG1$%报警(浅黄色),剩余$ARG2$%“出错”(红色)-p 后为指定分区
#还需要注意libexec的命令路径,如果自定义安装,那路径可能是不对的
#启动nrpe,端口为5666
src/nrpe -c sample-config/nrpe.cfg -d
2、服务器上的配置
安装nrpe(主要是使用check_nrpe模块)
#./configure
#make all
#cp src/check_nrpe /app/nagios/libexec
nagios文件的配置
vi commands.cfg
#定义check_nrpe命令
# ‘check_nrep’ command definition
define command{
command_name check_nrpe
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#定义服务时 可以参考如下命令
#check_command check_nrpe!check_disk!20%!10%
其它远程调用例子:
#../libexec/check_by_ssh -H 192.168.1.100 -C “/app/nagios/libexec/check_disk -w 10% -c 5% -p /”
#注意ssh可以直接登录,另外nagios是以nagios用户来启动的,可以在部分命令后加-u username来识别
后补充:Windows服务器客户端安装步骤
1. 从下载nrpe_nt.0.8b-bin-NoSSL.zip 并解压
2. 从%2F2131.html;d=1下载nrpe_nt_plugins.zip,并放于C:\nrpe_nt\plugins\目录
3. 解压后,运行NRPE_NT.exe -i -n安装服务
4. 编辑nrpe.cfg,大概内容如下
server_port=5666
allowed_hosts=192.168.0.2
dont_blame_nrpe=0
debug=1
command_timeout=30
loglevel=4
use_win_metachars=1
command[check_cmd]=e:\NRPE_NT\test.cmd
command[nt_check_disk_c]=C:\nrpe_nt\plugins\diskspace_nrpe_nt.exe c: 70 90
command[nt_check_disk_d]=C:\nrpe_nt\plugins\diskspace_nrpe_nt.exe d: 70 90
command[nt_check_disk_e]=C:\nrpe_nt\plugins\diskspace_nrpe_nt.exe e: 70 90
command[nt_cpuload]=C:\nrpe_nt\plugins\cpuload_nrpe_nt.exe 50 80
command[nt_memload]=C:\nrpe_nt\plugins\memload_nrpe_nt.exe 70 90
command[nt_service]=C:\nrpe_nt\plugins\service_nrpe_nt.exe “Event Log,DNS Client”
command[nt_eventlog]=C:\nrpe_nt\plugins\eventlog_nrpe_nt.exe -m 7200 -s “Service Control
Manager”
5. 找相关目录里面启动服务即可.如果有防火墙也要开放5666
FAQ:
现象:The scripts outputs “Can’t locate Net/SNMP.pm in @INC…..”
There are 2 ways of doing this
1) By CPAN (best)
on command line, as root :
[your_host]# perl -MCPAN -e shell
cpan> install Net::SNMP
2) “By hand”
Get the folowings modules (tar.gz format) on