德克云技术联盟

会员中心
发新帖
打印 上一主题 下一主题

部署cacti+nagios
发布人: 史东杰 发布时间:2015-09-04 浏览:4142

参考:



操作系统:centos6.6 64位

安装包位置:/soft

主要软件版本:

nagios-4.1.1

nagios plugins 2.1.1

cacti-0.8.8f.tar.gz

ndoutils-2.0.0.tar.gz



相关下载:






关闭防火墙


安装必要软件

#yum -y install http* mysql-devel mysql-server php-* net-snmp-* gd gd-devel perl-libwww-perl

#yum -y install gcc gcc-c++ unzip wget

#yum -y install rrdtool*

#yum -y install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

#yum -y install patch



创建nagios文件夹

#mkdir /var/www/html/nagios


1. 安装nagios


#cd /soft

#tar zxvf nagios-4.1.1.tar.gz

#cd nagios-4.1.1

#./configure --prefix=/var/www/html/nagios

#make all

#useradd nagios

#make install && make install-init && make install-commandmode && make install-config && make install-webconf


增加nagios登录认证文件

#htpasswd -c /var/www/html/nagios/etc/htpasswd.users control


安装nagios plugins

#cd /soft

#tar zxvf nagios-plugins-2.1.1.tar.gz

#cd nagios-plugins-2.1.1

#./configure --prefix=/var/www/html/nagios/

#make && make install


给用户apache添加组nagios

#chmod -G nagios apache


修改nagios文件夹的所属权

#chown nagios.nagios /var/www/html/nagios/ -R


启动

#/etc/init.d/httpd start

#chkconfig httpd on

#/etc/init.d/nagios start


2. 安装cacti


#/etc/init.d/mysqld start

#vi /etc/snmp/snmpd.conf

com2sec notConfigUser  default       public

改为

com2sec notConfigUser  10.0.3.221       public


access  notConfigGroup ""      any       noauth    exact  all(此处改为all) none none


view all    included  .1                               80(取消此行的注释符号#)


#/etc/init.d/snmpd start


#cd /soft

#wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz


#tar zxvf cacti-0.8.8f.tar.gz

#mv cacti-0.8.8f /var/www/html/cacti


配置mysql

mysql>create database cacti;

mysql>grant all privileges on cacti.* to cacti@localhost identified by 'net.shan.2014' with grant option;

mysql>grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'net.shan.2014' with grant option;

mysql>use cacti;

mysql>source /var/www/html/cacti/cacti.sql;

mysql> flush privileges;

mysql> \q


配置cacti以连接数据库,修改两个php文件,修改内容相同

#vim /var/www/html/cacti/include/config.php


#vim /var/www/html/cacti/include/global.php



$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "net.shan.2014";

$database_port = "3306";

$database_ssl = false;


cacti默认是以美国的时间为准的,修改为本地时区:

vi /var/www/html/cacti/include/global.php

文件,在里面加入一行


date_default_timezone_set(‘Asia/Chongqing’);



添加cacti账号

#useradd -r -M cacti


更改cacti程序文件的所属权

#chown -R cacti /var/www/html/cacti/poller.php


#chown -R cacti /var/www/html/cacti/rra


#chown -R cacti /var/www/html/cacti/log


创建计划任务,来自动画图

#su cacti

bash-4.1$ crontab -e

*/2 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1


修改/etc/php.ini

#vim /etc/php.ini

在[date]里添加date.timezone="Asia/Chongqing"


继续安装cacti

在浏览器里输入http://IP/cacti

选择New Install点击Next

选择RRDTool 1.4.x,点击finish

登录用户名:admin,密码:admin

首次登录修改admin的密码;




3. 整合cacti和nagios


下载并安装ndoutils

#cd /soft

#tar zxvf ndoutils-2.0.0.tar.gz

# cd ndoutils-2.0.0

# ./configure --prefix=/var/www/html/nagios/ --enable-mysql --disable-pgsql --with-mysql-inc=/usr/include/

#make

#cd /soft/ndoutils-2.0.0/src

#cp -v src/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} /var/www/html/nagios/bin

#cd /soft/ndoutils-2.0.0/db

#./installdb -ucacti -pnet.shan.2014 -hlocalhost -dcacti

#cd /soft/ndoutils-2.0.0

#cp -v config/{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

#chmod 644 /var/www/html/nagios/etc/ndo*

#chown nagios:nagios /var/www/html/nagios/etc/*

#chown nagios:nagios /var/www/html/nagios/bin/*


修改nagios.cfg

#vim /var/www/html/nagios/etc/nagios.cfg

在#broker_module后面添加一行

broker_module=/var/www/html/nagios/bin/ndomod-3x.o      config_file=/var/www/html/nagios/etc/ndomod.cfg


修改ndo2db.cfg

#vim /var/www/html/nagios/etc/ndo2db.cfg

确保下列内容为唯一项

socket_type=tcp

db_servertype=mysql

db_host=127.0.0.1

db_port=3306

db_name=cacti

db_prefix=npc_

db_user=cacti

db_pass=cacti


修改ndomod.cfg

#vim /var/www/html/nagios/etc/ndomod.cfg

确保下列项的唯一内容为

output_type=tcpsocket  

output=127.0.0.1  

#output=/var/www/html/nagios/var/ndo.sock(这行一定要注释掉)


为ndo2db添加启动进程

#cp /soft/ndoutils-2.0.0/daemon-init  /etc/init.d/ndo2db


#vim /etc/init.d/ndo2db

检查里面的路径确保不会出现“//",并将Ndo2dbBin修改成下面的值:

Ndo2dbBin=/var/www/html/nagios/bin/ndo2db-3x

Ndo2dbCfgFile=/var/www/html/nagios/etc/ndo2db.cfg

Ndo2dbVarDir=/var/www/html/nagios/var



#chmod +x /etc/init.d/ndo2db   


启动守护进程与nagios

# /var/www/html/nagios/bin/ndo2db-3x -c /var/www/html/nagios/etc/ndo2db.cfg

# service nagios restart



安装npc,在cacti界面中显示nagios

安装cacti扩展模块

#cd /soft


# tar zxvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz

#cp -R cacti-plugin-arch/* /var/www/html/cacti/

# cd /var/www/html/cacti/

# mysql -ucacti -pnet.shan.2014 cacti < pa.sql

#patch -p1 -N <cacti-plugin-0.8.7h-PA-v3.0.diff


修改/var/www/html/cacti/include/config.php

新增$url_path="/cacti/";


在cacti控制台,打开Console - User Management - admin - realm permissions,勾选Plugin Management,点击save

在控制台Configuration下多了一个Plugin Management选项卡,则cacti架构扩展完成。


cacti安装npc

#cd /soft

#tar zxvf npc-2.0.4.tar.gz

# mv npc /var/www/html/cacti/plugins/

# vim /var/www/html/cacti/include/config.php

添加:

$plugins[] = 'npc';


#service ndo2db restart

#service nagios restart


在Web上配置NPC以使之正常读取工作。

在Settings->npc中 ,勾上Remote Commands

然后在console----settings-----NPC填入以下

Nagios Command File Path= /var/www/html/nagios/var/rw/nagiosNaNd

Nagios URL=你的地址(http://localhost/nagios/)  


由于之前新建了htpasswd的用户,需给该用户查查nagios的一些状态信息

/var/www/html/nagios/etc/cgi.cfg 所有nagiosadmin后面都加上你添加的新用户







分类浏览
关于我们
联系我们
技术联盟
云服务
云技术
云合作
帮助中心
发帖规则
QQ客服
内部通道
企业邮箱
企业论坛
版本选择
手机版
电脑版
用手机扫描下方二维码查看手机版页面

版权所有 西安云联电子科技有限公司
Copyright @ 2011-2022 | decoclouds.com All Rig
陕ICP备13002202号-1

快速回复 返回顶部 返回列表