发布时间:2014-09-05 16:58:39作者:知识屋
通过整合pnp4nagios,ndoutils,nconf提供了关于nagios的一套完整的配置方案
操作系统Centos5.5,目前最新版本的nagios3.3.1,装上之后界面变化了太难看,所以这里我还用3.2.3的版本来安装
首先把编译环境准备好,我们这里把开发库先都装上
yum groupinstall "Development Libraries" "Development Tools" "Legacy Software Development" "X Software Development" -y
#########################################################################
naigos安装配置:
安装需要的软件包
yum install mysql perl mysql-server perl-DBI perl-DBD-MySQL httpd gcc glibc glibc-common gd gd-devel ruby ruby-devel2 ruby-devel mysql-devel
yum install php53-* yum默认安装的是5.1版本的php,但是pnp4nagios-0.6.6需要5.2以上版本的php,我们这里就装5.3的
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
useradd -m nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G apache nagios
tar zxf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
输入密码并记住,因为这个同时也是网页访问nagios时要输入的密码。
chkconfig --add nagios
chkconfig nagios on
chkconfig httpd on
chkconfig mysqld on
tar nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
service nagios start
service httpd start
service mysqld start
使用http://localhost/nagios/来访问
##########################################################################
pnp4nagios的安装和配置
接下来我们来配置pnp4nagios,能够把nagios捕获到的数据绘制成图片
rrdtool依赖众多,这里我选择下载rrdtool的rpm包
rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm rrdtool-devel-1.4.4-1.el5.wrl.i386.rpm rrdtool-1.4.4-1.el5.wrl.i386.rpm
rpm -ivh rrdtool-*
tar -xvf pnp4nagios-0.6.6.tar.gz
cd pnp4nagios-0.6.6
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install
make install-webconf
make install-config
make isntall-init
make fullinstall
pnp4nagios官方提供了三种配置方法,我这里选取一种
vi /usr/local/nagios/etc/nagios.cfg
process_performance_data=1
#
# service performance data
#
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA/tTIMET::$TIMET$/tHOSTNAME::$HOSTNAME$/tSERVICEDESC::$SERVICEDESC$/tSERVICEPERFDATA::$SERVICEPERFDATA$/tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$/tHOSTSTATE::$HOSTSTATE$/tHOSTSTATETYPE::$HOSTSTATETYPE$/tSERVICESTATE::$SERVICESTATE$/tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
#
# host performance data starting with Nagios 3.0
#
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA/tTIMET::$TIMET$/tHOSTNAME::$HOSTNAME$/tHOSTPERFDATA::$HOSTPERFDATA$/tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$/tHOSTSTATE::$HOSTSTATE$/tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
vi /usr/local/nagios/etc/objects/commands.cfg 修改最后两行为
define command{
command_name process-service-perfdata-file
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata-file
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}
cd /usr/local/pnp4nagios/share
mv install.php install.php.bak
访问测试 http://localhost/pnp4nagios
让nagios显示小太阳图标
在pnp4nagios的源码包下面执行
cp contrib/ssi/* /usr/local/nagios/share/ssi/
然后在服务或者主机定义里面添加action_url
define service{
use local-service ; Name of service template to use
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
}
define host{
use linux-server
host_name localhost
alias localhost
address 127.0.0.1
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
}
效果如下:
###########################################################################
安装nconf实现nagios的图形化配置
tar -xvf nconf-1.2.6-0.tgz -C /var/www/html/
chown -R apache:apache /var/www/html/nconf
为nconf创建数据库
mysql -u root -p
create database nconf;
grant all privileges on 数据库名称.* to '用户名'@'localhost' identified by '密码' with grant option;
然后通过浏览器访问: http://localhost/nconf
根据提示进行安装 然后删除 INSTALL/ INSTALL.php UPDATE/ UPDATE.php重新刷新页面就可以使用了!
这里使用刚才建立的数据库
这里使用默认配置就好了
下面是安装完成后的界面
##############################################################################
安装配置ndoutils把nagios的数据导入mysql数据库
mysql -u root -p
mysql>CREATE DATABASE nagios;
mysql>GRANT ALL ON nagios.* TO nagios@localhost IDENTIFIED BY ‘nagios’ 授权nagios用户,密码为 Nagios
mysql>FLUSH PRIVILEGES;
wget http://prdownloads.sourceforge.net/sourceforge/nagios/ndoutils-1.4b9.tar.gz
wget http://svn.centreon.com/trunk/ndoutils-patch/ndoutils1.4b9_light.patch
tar -xvf ndoutils-1.4b9.tar.gz
cd ndoutils
patch -p1 -N < ../ndoutils1.4b9_light.patch
./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql /
--with-ndo2db-user=nagios --with-ndo2db-group=nagios
make
cd db
./installdb ./installdb -u root -p 数据库密码 -d nagios
mysql -u root -p
mysql>USE nagios;
mysql>SHOW TABLES; 验证表已经生成
cd ndoutils-1.4b9
cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
cp ./src/ndo2db-3x /usr/local/nagios/bin/ndo2db
cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
cp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
chmod 774 /usr/local/nagios/bin/ndo*
chown nagios:nagios /usr/local/nagios/bin/ndo*
chown nagios:nagios /usr/local/nagios/etc/ndo*
vi ndo2db.cfg
db_name=nagios
db_user=nagios
db_pass=nagios
vi /usr/local/nagios/etc/nagios.cfg
添加以下两行
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
修改
event_broker_options=-1 //我设置为1,测试也可以
cp ./daemon-init /etc/init.d/ndo2db
chmod +x /etc/init.d/ndo2db
chkconfig --add ndo2db
service nagios restart
service ndo2db start
tail -f /usr/log/nagios/var/nagios.log
作者“成长全记录”
linux一键安装web环境全攻略 在linux系统中怎么一键安装web环境方法
Linux网络基本网络配置方法介绍 如何配置Linux系统的网络方法
Linux下DNS服务器搭建详解 Linux下搭建DNS服务器和配置文件
对Linux进行详细的性能监控的方法 Linux 系统性能监控命令详解
linux系统root密码忘了怎么办 linux忘记root密码后找回密码的方法
Linux基本命令有哪些 Linux系统常用操作命令有哪些
Linux必学的网络操作命令 linux网络操作相关命令汇总
linux系统从入侵到提权的详细过程 linux入侵提权服务器方法技巧
linux系统怎么用命令切换用户登录 Linux切换用户的命令是什么
在linux中添加普通新用户登录 如何在Linux中添加一个新的用户
2012-07-10
CentOS 6.3安装(详细图解教程)
Linux怎么查看网卡驱动?Linux下查看网卡的驱动程序
centos修改主机名命令
Ubuntu或UbuntuKyKin14.04Unity桌面风格与Gnome桌面风格的切换
FEDORA 17中设置TIGERVNC远程访问
StartOS 5.0相关介绍,新型的Linux系统!
解决vSphere Client登录linux版vCenter失败
LINUX最新提权 Exploits Linux Kernel <= 2.6.37
nginx在网站中的7层转发功能