nagios3.5.1 server端源码编译安装方式

nagios目录结构如下:
主程序在/apps/svr/nagios目录;
配置文件/apps/conf/nagios

Nagios
1、解压
tar -xvzf nagios-3.5.1.tar.gz
2、编译
./configure -with-nagios-user=apps –with-nagios-group=apps –with-command-user=apps –with-command-group=apps –prefix=/apps/svr/nagios
make all
make install
make install-init (如果不需要service的方式运行,则不需要安装)
make install-config
make install-commandmode
make install-webconf(需要安装httpd之后才能运行它)

plugin
1、解压
tar -xvzf nagios-plugins-2.0.3.tar.gz
2、编译
./configure –with-nagios-use=apps –with-nagios-group=apps –prefix=/apps/svr/nagios
make
make install

NRPE(需要安装openssl-devel)
1、解压
tar -xvzf nrpe-2.15.tar.gz
2、
./configure –with-nrpe-user=apps –with-nrpe-group=apps –with-nagios-user=apps –with-nagios-group=apps –prefix=/apps/svr/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
3、修改nrpe.cfg
allowed_host 里面配置上server的地址。

插件安装
1、拷贝文件到libexec目录下
2、vi /apps/svr/nagios/etc/nrpe.cfg,添加如下两行
command[mycheck_disk_health]=/apps/svr/nagios/libexec/mycheck_disk_health.sh
command[mycheck_gmond]=/apps/svr/nagios/libexec/mycheck_gmond.sh
3(仅服务端需要)
vi /apps/svr/nagios/etc/objects/commands.cfg,添加:
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

配置监控主机
1、在objects下新建clients目录
2、在目录下添加以主机ip为名字的配置文件
vi 172.16.203.3.cfg
define host{
use linux-server
host_name 172.16.203.3
alias 172.16.203.3
address 172.16.203.3
#notifications_enabled 1
hostgroups 1
}
3、在nagios.cfg中增加如下一行:
cfg_dir=/apps/svr/nagios/etc/objects/clients

配置监控项
1、在objects目录下,增加services.cfg
define hostgroup{
hostgroup_name 1
alias 1
}
define service{
use local-service
hostgroup_name 1
service_description diskhealth
check_command check_nrpe!mycheck_disk_health (需要安装smartmontools)
}

define service{
use local-service
hostgroup_name 1
service_description gmond
check_command check_nrpe!mycheck_gmond
}

define service{
use local-service
hostgroup_name 1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
2、在nagios.cfg中增加一行
cfg_file=/apps/svr/nagios/etc/objects/services.cfg

连接cmagent
1、拷贝 submit_check_result.sh 文件到/apps/svr/nagios/libexec,并附执行权限。
2、vi submit_check_result.sh 修改其中的url
3、vi nagios.cfg 修改如下字段:
enable_notifications=0
obsess_over_services=1
ocsp_command=submit_check_result
4、vi /usr/local/nagios/etc/objects/commands.cfg添加命令submit_check_result
define command{
command_name submit_check_result
command_line /apps/svr/nagios/libexec/submit_check_result.sh ‘$HOSTADDRESS$’ ‘$SERVICEDESC$’ ‘$SERVICESTATE$’ ‘$SERVICEOUTPUT$’ ‘$HOSTGROUPNAME$’
}

页面访问:
1、yum -y install httpd php
htpasswd -c /apps/svr/nagios/etc/htpasswd.users nagiosadmin
2、make install-webconf(需要安装httpd之后才能运行它)
3、修改httpd.conf,将user和group配置成apps

运行nrpe
bin/nrpe -c etc/nrpe.cfg -d
检查是否正常运行
libexec/check_nrpe -H 172.16.203.3
报错:CHECK_NRPE: Error - Could not complete SSL handshake
nrpe.cfg中allowed_host未配置。

运行nagios
/apps/svr/nagios/bin/nagios -d /apps/svr/nagios/etc/nagios.cfg

1、Check result queue contained results for host’locahost’, but the host could not be found! Perhaps you forgot to define the host in yourconfig files?
启动了两个nagios,关掉一个即可
2、NRPE: Unable to read output
直接用运行nagios的用户执行那个脚本,发现报错,所以是那个脚本的问题。大多数情况下会是权限的问题

检查配置文件:
/apps/svr/nagios/bin/nagios -v /apps/svr/nagios/etc/nagios.cfg

定制化修改:
1、log
vi nagios.cfg
log_file=/apps/logs/nagios/nagios.log
2、pid
vi nagios.cfg
lock_file=/apps/run/nagios/nagios.lock
3、conf
ln -s /apps/svr/nagios/etc/* /apps/conf/nagios/

报错:
make all
make[1]: * No rule to make target ../include/locations.h', needed bybroker.o’. Stop.
yum -y install perl

页面访问报错:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
解决办法:
查看httpd的error日志,如果显示:
[authn_file:error] [pid 16158] (13)Permission denied: [client 172.16.207.38:64904] AH01620: Could not open password file: /apps/svr/nagios/etc/htpasswd.users
修改/apps/svr/nagios/etc/htpasswd.users权限
更改为777权限后,还是无法访问。切换到nagios用户,是可以访问这个文件的。很困惑。最后发现是selinux没有关闭。。

nagios页面,输入用户名密码之后看不到,因为默认启动httpd的是apache用户,而这个用户是没有权限访问nagios的
解决办法,修改httpd.conf
将user 和Gropu更改为对应的值

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值