#找一台有apache的服务器,生成nagios页面的验证信息,不然很多页面没有权限访问 ./htpasswd -c nagios.htpasswd nagios New password: nagios Re-type new password: nagios Adding password for user nagios #将该文件放到/usr/local/nagios/etc/nagios.htpasswd #如果没有apache的机器,将如下内容保存为nagios.htpasswd,用户名密码都是nagios,弱口令哦,呵呵
nagios:e9hfl5LNHrFYo
vi /usr/local/nagios/etc/cgi.cfg #修改以下项的nagiosadmin为nagios authorized_for_all_host_commands=nagiosadmin authorized_for_all_hosts=nagiosadmin authorized_for_all_service_commands=nagiosadmin authorized_for_all_services=nagiosadmin authorized_for_configuration_information=nagiosadmin authorized_for_system_commands=nagiosadmin authorized_for_system_information=nagiosadmin 启动nagios:
/etc/init.d/nagios start
#==============至此,nagios安装完毕 , 可以访问 试试看了====================
############下面安装的ndoutils组件,可以将nagios的数据写入数据库,然后由Cacti的npc组件在Cacti的页面中展示,即所谓的整合,其实有些坑爹###############
tar -zxvf ndoutils-1.4b9.tar.gz cd ndoutils-1.4b9 ./configure --with-mysql=/usr/local/mysql --enable-mysql --with-ndo2db-user=web --with-ndo2db-group=web vi include/config.h #手动将261 262行,写上mysql头文件的绝对路径,前面的井号别删哈... #include </usr/local/mysql/include/mysql/mysql.h> #include </usr/local/mysql/include/mysql/errmsg.h>
make cd src/ cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/local/nagios/bin/ cd ../config cp ndo2db.cfg-sample ndo2db.cfg cp ndomod.cfg-sample ndomod.cfg
vi ndo2db.cfg #修改以下参数 db_name=cacti db_prefix=npc_ db_user=cactiuser db_pass=cactiuser #复制到nagios目录里 cp ndo2db.cfg ndomod.cfg /usr/local/nagios/etc/
vi /usr/local/nagios/etc/nagios.cfg #添加一行,使nagios能调用组件,将数据写入数据库 broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
vi /etc/init.d/nagios #使启动和关闭nagios的时候,组件一并启动或关闭 #在start函数结束前添加: /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg #在stop函数结束前添加: killall ndo2db-3x; rm -f /usr/local/nagios/var/ndo2db.lock; rm -f /usr/local/nagios/var/ndo.sock;