三、部署nagios监控系统
1、安装nagios系统
(1)创建nagios用户和组
# groupadd -g 1000 nagios
# useradd -g nagios -u 1000 nagios
(2)安装nagios
# ./configure --prefix=/usr/local/nagios --enable-event-broker --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios --with-httpd-conf=/etc/httpd/conf.d --with-temp-dir=/tmp --with-init-dir=/etc/init.d/
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf
(3)安装nagios-plugins插件
# yum install perl perl-devel openssl openssl-devel
# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr --with-mysql=/usr/local/mysql/ --with-openssl=/usr --enable-perl-modules
# make
# make install
(4)安装NRPE通信协议软件
# ./configure --prefix=/usr/local/nagios --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d \\启动nrpe
# /usr/local/nagios/libexec/check_nrpe -H localhost
(5)安装ndoutils数据库通信软件
# ./configure --prefix=/usr/local/nagios --enable-mysql --with-init-dir=/etc/init.d --with-ndo2db-user=nagios --with-ndo2db-group=nagios --with-mysql=/usr/local/mysql
# make
# make install
# make install-config
# make install-init
------------------------------------------------------------------ 安装ndoutils出现错误 一般是数据库的错误
删除安装文件,重新解压缩,重新configure,然后
# vi include/config.h
将
#include <mysql/mysql.h>
#include <mysql/errmsg.h>
修改为
#include </usr/local/mysql/include/mysql/mysql.h>
#include </usr/local/mysql/include/mysql/errmsg.h>
然后进行make
# cd /var/ftp/pub/nagios/ndoutils-2.0.0/db (这个就是自己指定的目录 你自己装在哪里 你就放在哪里)
# ./installdb -u nagios -paixocm -h 172.17.10.252 -d nagios 这个是数据库的 必须先在数据库中创建 然后在去条件 而且要有权限
# cd /usr/local/nagios/etc
# mv ndo2db.cfg-sample ndo2db.cfg
# mv ndomod.cfg-sample ndomod.cfg
2、配置nagios系统
# chown nagios:nagios nagios -R
(1)配置nagios主配置文件/usr/local/nagios/etc/nagios.cfg
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
(2)配置/usr/local/nagios/etc/ndo2db.cfg文件,用于nagios和ndo2db及数据库通信的相关信息
lock_file=/usr/local/nagios/var/ndo2db.lock
ndo2db_user=nagios
ndo2db_group=nagios
socket_type=unix
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
use_ssl=0
db_servertype=mysql
db_host=172.17.10.252
db_port=3306
db_name=nagios
db_prefix=nagios_
db_user=nagios
db_pass=aixocm
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
max_externalcommands_age=44640
max_notifications_age=44640
max_contactnotifications=44640
max_contactnotificationmethods=44640
max_logentries_age=129600
max_acknowledgements_age=44640
debug_level=0
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
(3)配置/usr/local/nagios/etc/ndomod.cfg
(4)配置/usr/local/nagios/etc/nrpe.cfg客户端配置文件
3、启动nagios的各项服务
# service nagios start
# service nrpe start cp init-script /etc/init.d/nrpe (要启动 必须要将在安装目录下的文件复制过去)chmod +x /etc/init.d/nrpe(加上可执行权限)
# service ndo2db start (要将自己mysql/lib的文件添加到vi /etc/ld.so.conf文件中 并且用ldconfig重新去读
)
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
将cgi的一个配置文件更改下
use_authentication=0
要安装php 与perl安装包