原始出处:http://www.weiyan.me/2012/05/130根据该文增加注释
软件打包的下载地址如下http://down.51cto.com/data/629144
yuminstall-yhttp*
yuminstall-ymysql*
yuminstall-yphp-*
yuminstall-ynet-snmp*
yuminstall-yhttpdgccglibcglibc-commongdgd-develphpphp-gdntpruby*
wgethttp://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz
tarzxfnagios-3.3.1.tar.gz
cdnagios
./configure�Cprefix=/var/www/html/nagios
makeall
useraddnagios
makeinstall&&makeinstall-init&&makeinstall-commandmode&&makeinstall-config&&makeinstall-webconf
htpasswd-c/var/www/html/nagios/etc/htpasswd.usersnagiosadmin
wgethttp://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
tar-zvxfnagios-plugins-1.4.15.tar.gz
cdnagios-plugins-1.4.15
./configure�Cprefix=/var/www/html/nagios/
make
makeinstall
usermod-Gnagiosapache##将apache用户加到nagios组。
chownnagios.nagios/var/www/html/nagios/-R
servicehttpdrestart
chkconfighttpdon
/etc/init.d/nagiosstart
在这里没有提供rrdtool的工具,需要下载可以去这里下载上述的3个软件包
rrdtool、rrdtool-devel的地址: http://packages.express.org/rrdtool/
rrdtool-php的地址: http://pkgs.org/download/rrdtool-php
注意,rrdtool的组件和附加组件版本尽量一致,而由于rrdtool-php这个包非常稀有,所以,尽量请以rrdtool-php的版本来决定rrdtool以及rrdtool-devel的版本。
还有一定要对应环境,别安装成了fedora的版本了=。=
|
yumlocalinstall-y�Cnogpgcheckrrdtool-*
servicemysqldstart
vim/etc/snmp/snmpd.conf
#修改3项127.0.0.1、all、启用项(修改的内容详见我Cacti的安装文档,上面有非常详细的内容介绍)
servicesnmpdrestart
wgethttp://www.cacti.net/downloads/cacti-0.8.7h.tar.gz
tarzxvfcacti-0.8.7h.tar.gz
mvcacti-0.8.7h/var/www/html/cacti
mysql>createdatabasecacti;
mysql>grantalloncacti.*to‘cacti’@‘localhost’identifiedby‘cacti’;
mysql>flushprivileges;
cd/var/www/html/cacti
mysql-ucacti-pcacticacti</var/www/html/cacti/cacti.sql
vim/var/www/html/cacti/include/config.php
vim/var/www/html/cacti/include/global.php
$database_default=“cacti”;//默认数据库名
$database_hostname=“localhost”;//主机名
$database_username=“cacti”;//登陆数据库用户名
$database_password=“cacti”;//登陆数据库密码
$database_port=“3306″;
|
useradd�Cr�CMcacti
chown�CRcacti/var/www/html/cacti/rra/
chown�CRcacti/var/www/html/cacti/log/
sucacti
crontab�Ce
*/5****php/var/www/html/cacti/poller.php>/dev/null2>&1
php/var/www/html/cacti/poller.php>/dev/null2>&1
exit
wgethttp://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz/download
tarzxvfndoutils-1.4b9.tar.gz
cdndoutils-1.4b9
./configure�Cprefix=/var/www/html/nagios�Cenable-mysql�Cdisable-pgsql�Cwith-mysql-inc=/usr/include/mysql�Cwith-mysql-lib=/usr/lib/mysql
make
cp-vsrc/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo}/var/www/html/nagios/bin
cddb
./installdb-ucacti-pcacti-hlocalhost-dcacti
cd..
cp-vconfig/{ndo2db.cfg-sample,ndomod.cfg-sample}/var/www/html/nagios/etc
mv/var/www/html/nagios/etc/ndo2db.cfg-sample/var/www/html/nagios/etc/ndo2db.cfg
mv/var/www/html/nagios/etc/ndomod.cfg-sample/var/www/html/nagios/etc/ndomod.cfg
chmod644/var/www/html/nagios/etc/ndo*
chownnagios:nagios/var/www/html/nagios/etc/*
chownnagios:nagios/var/www/html/nagios/bin/*
vim/var/www/html/nagios/etc/nagios.cfg
#在文件中添加:
broker_module=/var/www/html/nagios/bin/ndomod-3x.oconfig_file=/var/www/html/nagios/etc/ndomod.cfg
#检查
event_broker_options=-1##为Nagios开启eventbroker
vim/var/www/html/nagios/etc/ndo2db.cfg
#确保下列内容为唯一项
socket_type=tcp
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=cacti
db_prefix=nagios_
db_user=cacti
db_pass=cacti
vim/var/www/html/nagios/etc/ndomod.cfg
#确保下列项的唯一内容为
output_type=tcpsocket
output=127.0.0.1
cp./daemon-init/etc/init.d/ndo2db
vim/etc/init.d/ndo2db
#检查里面的路径确保不会出现“//”,并将Ndo2dbBin修改成下面的值:
Ndo2dbBin=/var/www/html/nagios/bin/ndo2db-3x
chmod+x/etc/init.d/ndo2db
servicendo2dbstart
tail-20/var/log/messages##查看其中是否有错误出现。如无报错请继续
servicenagiosstart
wgethttp://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
tarxvfcacti-plugin-0.8.7h-PA-v3.0.tar.gz
cp-Rcacti-plugin-arch/*/var/www/html/cacti/
cd/var/www/html/cacti/
mysql-ucacti-pcacticacti<pa.sql
patch-p1-N<cacti-plugin-0.8.7h-PA-v3.0.diff
##为cacti配置文件打补丁的时候注意在为include/config.php打补丁的时候有可能它将include/config.php.dist给打补丁了,我们只需要手动加入下面的内容即可。
viminclude/config.php
#修改(或新加入)为
$url_path=“/cacti/”;
tarzxvfnpc-2.0.4.tar.gz
mvnpc/var/www/html/cacti/plugins/
vim/var/www/html/cacti/include/config.php
#加入:
$plugins[]=‘npc’;
wgethttp://pkgs.fedoraproject.org/repo/pkgs/php-pecl-json/json-1.2.1.tgz/d8904d2f004ceec85eeacf524cd25539/json-1.2.1.tgz
tarzxvfjson-1.2.1.tgz
cdjson-1.2.1
phpize##如果发现没有Phpize文件,则是因为php-devel包没有安装导致的
./configure
make&&makeinstall
php-i|grepphp.ini##查看是否有导入信息
vim/etc/php.ini
#添加
extension=json.so
vim/etc/httpd/conf/httpd.conf
#添加一行:
AddTypeapplication/x-httpd-php.php.phtml
#修改原DirectoryIndex内容为:
DirectoryIndexindex.htmlindex.html.varindex.php
usermod-Gcactiapache
servicehttpdrestart##重启apache以让php生效
php-m##查看是否有json被加载
vim/var/www/html/nagios/etc/ndo2db.cfg
db_prefix=npc_
./mysql-ucacti-pcacti
mysql>usecacti;
mysql>altertablenpc_eventhandlersaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_hostchecksaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_hoststatusaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_notificationsaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_servicechecksaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_servicestatusaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_statehistoryaddlong_outputTEXTNOTNULLdefault”afteroutput;
mysql>altertablenpc_systemcommandsaddlong_outputTEXTNOTNULLdefault”afteroutput;
servicendo2dbrestart
servicenagiosrestart
#进入mysql数据库
mysql>createdatabasenconf;
#创建nconf数据库
mysql>grantallprivilegesonnconf.*tonconf@localhostidentifiedby‘nconf’;
#创建nconf用户并赋权
mysql>flushprivileges;
#刷新特权表
mysql>quit
wgethttp://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz/download
tar-zxfnconf-1.2.6-0.tgz-C/var/www/html/
cd/var/www/html/nconf
chown-Rapache.apacheconfig/temp/static_cfg/output/
rm-rfINSTALLINSTALL.phpUPDATEUPDATE.php
#删除安装所需的初始化文件
ln-s/var/www/html/nagios/bin/nagiosbin/nagios
chmod+x/var/www/html/nconf/bin/generate_config.pl
chown-Rapache.apachebin
chmod+x/var/www/html/nagios/bin/nagios
chmod+x/var/www/html/nconf/ADD-ONS/deploy_local.sh
vim/var/www/html/nconf/ADD-ONS/deploy_local.sh
修改里面的Nagios路径为/var/www/html/nagios/etc/
/var/www/html/nconf/ADD-ONS/deploy_local.sh
vim/var/www/html/nagios/etc/nagios.cfg
#将其中cfg_file=*******字段全部注释,并加入
cfg_dir=/var/www/html/nagios/etc/Default_collector
cfg_dir=/var/www/html/nagios/etc/global
servicenagiosreload
#重载nagios配置文件使之生效
六:错误总结:
tail-f/var/www/html/nagios/var/nagios.log要经常看这个日志。根据提示来对号入座
ndomod:Couldnotopendatasink!I’llkeeptrying,butsomeoutputmaygetlost…
解决办法:
检查/nagios/etc目录的权限是否足够的大
确保/var/www/html/nagios/etc/nagios.cfg中有如下行出现,否则,请自行添加:
event_broker_options=-1
检查ndo2db.cfg中的配置,确保使用tcp连接
socket_type=tcp
检查ndomod.cfg中的配置,确保使用tcp套接字
output_type=tcpsocket
|
2.在npc安装过程中进行表操作时报错
mysql>altertablenpc_eventhandlersaddlong_outputTEXTNOTNULLdefault”afteroutput;ERROR1146(42S02):Table‘cacti.npc_eventhandlers’doesn’texist 解决办法:要先在cacti页面下正确的启用npc插件,正确的启用~一个向上的箭头和一个向右的箭头都要开启才行~ |
3.在应用nconf的时候报错
点nconf�C>GenerateNagiosconfig�C>报错了。ErroraccessingorexecutingNagios/Icingabinary‘/var/www/html/nconf/bin/nagios’. Cannotrunthemandatorysyntaxcheck. 解决办法: 检查你的/var/www/html/nconf/bin/nagios这个文件所链接的那个原始文件的权限,确保是777或者775 |
4….当然还没有发现错误,如果有,将会继续补充,欢迎网友在安装部署的过程中发现错误将错误积极交流,我将一一添加……
七:最后的样式