也谈cacti整合nagios(centos)
花了近一天的时间整合了cacti和nagios,cacti用来检测运行状态nagios主要用来预警。期间参考了很多网友的文章,在此感谢下!在这里记录一下配置过程,以备后忘。。说整合其实只是表面的,cacti和nagios还是以他们原来的方式进行工作,ndo负责将nagios收集的数据存在数据库中,cacti的npc插件会从数据库中取数据在cacti的npc标签中来展现。环境是cenos5.1+最小化安装+development tools
开始配置。。
vi /etc/yum.repos.d/Dag.repo###定义第三方源
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
http://rh-mirror.linux.iastate.edu/pub/dag/redhat/el$releasever/en/$basearch/dag
http://wftp.tu-chemnitz.de/pub/linux/dag/redhat/el$releasever/en/$basearch/dag
http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el$releasever/en/$basearch/dag
http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el$releasever/en/$basearch/dag
http://rpmfind.net/linux/dag/redhat/el$releasever/en/$basearch/dag
http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
http://mirrors.ircam.fr/pub/dag/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1
protect=0
gpgcheck=1
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
##################################################
vi utterramblings.repo ###定义php独立源
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
#########################################################################
一次性安装所需软件
yum -y install httpd mysql-server rrdtool mysql-devel php-devel net-snmp php php-mysql php-gd php-pdo php-snmp cacti nagios nagios-plugins
或者也可以直接安装centos官方推荐软件库:
下载rpm包
wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
安装DAG的PGP Key
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
验证下载包的完整性
rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm
安装包
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.*.rpm
参考网址:
http://doc.linuxpk.com/58083.html
安装php-json
wget http://www.aurore.net/projects/php-json/php-json-ext-1.2.0.tar.bz2
tar xvjf php-json-ext-1.2.0.tar.bz2
cd php-json-ext-1.2.0
###初始化PHP环境
phpize
./configure
make&&make install#####
(如果提示没有这个命令则首先要
yum -y install php-devel
如果还不行,说明你的编译工具有问题,安装一下就可以了
yum -y install autoconf
yum -y install automake
yum -y install libtool
)
查看有没有安装成功
find / -name '*json.so'
./usr/lib/php/modules/json.so
说明已经有了
vi /etc/php.ini
添加 include ('/etc/php.d/json.ini')
vi /etc/php.d/json.ini
内容如下:
extension=json.so
重启httpd
apachectl graceful
到此所需要的软件都安装完毕
开始配置cacti
修改cacti访问权限
vi /etc/httpd/conf.d/cacti.conf
如下:
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
#deny from all
#allow from 127.0.0.1
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
建立cacti数据库和授权
mysqladmin create cacti
mysql>grant all privileges on cacti.* to cacti@localhost identified by 'cacti';
mysql>flush privileges;
mysql>exit;
导入数据:
cd /var/www/cacti
mysql -ucacti -pcacti/dev/null 2>&1
重新启动apache
service httpd restart
访问http://yourserver/cacti/ 进行安装,用户名密码都是admin
下载cacti插件管理器
wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7d-PA-v2.4.zip
unzip cacti-plugin-0.8.7d-PA-v2.4.zip
cd files-0.8.7d
cp -rf * /var/www/cacti/
导入数据:
cd ..
mysql -ucacti -pcacti cacti UPDATE mysql.user SET Host='%' WHERE Host=' ' ;
mysql>GRANT ALL PRIVILEGES ON *.* TO root@"%";
mysql> FLUSH PRIVILEGES ;
mysql>exit
service mysqld restart
登陆成功。至于这个问题是如何引起的,还不明确,怀疑和主机名有关系,知道的高手们请指点下,小弟mysql超级菜鸟
其他问题一起交流
页:
[1]