免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3705 | 回复: 0
打印 上一主题 下一主题

[Web] 很详细的cacti 暗转监控。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-14 13:59 |只看该作者 |倒序浏览
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel

需要的文件 以后打包上传。现在没有时间弄。。。。

二 安装

1.安装mysql

tar zxvf  mysql-5.0.92.tar.gz

cd  mysql-5.0.92

./configure --prefix=/usr/local/mysql --sysconfdir=/etc --with-unix-socket-path=/usr/local/mysql/var/mysql/mysql.sock --without-debug --enable-isam --with-mysqld-user=mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
make && make install
useradd mysql
/usr/local/mysql/bin/mysql_install_db
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chown -R mysql.mysql /usr/local/mysql/var
/etc/rc.d/init.d/mysqld start
cd..




2.安装apache

tar zxvf  httpd-2.2.17.tar.gz

cd  httpd-2.2.17

./configure --prefix=/usr/local/http --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-deflate --enable-expires --enable-rewrite --enable-authn-dbm=shared --enable-ssl --with-ssl
make && make install
cp /usr/local/http/bin/apachectl /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
/etc/rc.d/init.d/httpd start
在地址栏输入IP,可以看到
IT works
说明apache正常启动





3.安装php
tar zxvf php-5.2.17.tar.gz
cd php-5.2.17
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/http/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mode --enable-zip --with-bz2 --with-jpeg-dir --with-png-dir --with-freetype-dir --without-iconv --with-libxml-dir --with-zlib-dir --with-xmlrpc --with-gd --with-curl --with-curlwrappers --with-xsl --enable-sockets --disable-rpath --disable-debug
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
vi /usr/local/http/conf/httpd.conf

找到AddType application/x-gzip .gz .tgz 在下行填加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到index.html 在后边加空格,填加
index.php

4.填加PHP测试页
vi /usr/http/htdocs/index.php
填写代码
<?php
phpinfo()
?>

5.重启apache
service httpd restart

6.在地址栏输入
ip:/index.php
可以看到测试页,说明PHP正常启动




1.   cacti安装:
tar -xzvf  cacti-0.8.7g.tar.gz

cd cacti-0.8.7g

2.   mv cacti-0.8.7g  /usr/local/http/htdocs/cacti  (apache默认www目录)

3.   cd   /usr/local/http/htdocs/cacti

chmod 777  rra
chmod 777 log
chmod 777 poller.php

4.   vi /usr/local/http/htdocs/include/config.php
修改下面设置
$database_type = "mysql";               
$database_default = "cacti";                     #(连接cacti库)
$database_hostname = "127.0.0.1";           #(连接到那个地址)
$database_username = "cacti";                  #(使用的数据库名)
$database_password = "";                          #(密码)
$database_port = "3306";

5.   然后登录数据库;
mysql> create database cacti;
mysql> use mysql;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option;
mysql> grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti' with grant option;
mysql> update user set password=password("") where user="cacti";                  
mysql> flush privileges;
mysql> use cacti;
mysql> source  /usr/local/http/htdocs/cacti.sql;                          #(导入数据库)


6.   浏览器下配置
#用浏览器打开 http://ip/cacti ,会显示 cacti的安装指南,设置好就不会再出现了。
#点击 “Next”
#选择“New Install”,点击“Next”
#指定 rrdtool、 php、 snmp 工具的 Binary 文件路径,确保所有的路径都是显示“ FOUND”,没有 “NOT FOUND”的,点击 Finish 完成安装。
#Cacti 默认的用户名与密码是 admin,输入用户名与密码,点击 login
#php路径改为 /usr/local/php/bin/php ( 上面php配置安装的时候已经安装到这里了)
#为了安全的原因,第一次登录成功后,cacti 会强制要求你更改一个新的 password ,输入新密码并确认密码,点击 save ,进入 cacti 控制台界面:
#点击 graphs ,查看cacti 监控本机的图表:


7.   crontab -e
*/5 * * * * root /usr/local/php/bin/php /usr/local/http/htdocs/cacti/poller.php > /dev/null 2>&1

8.   vi /etc/crontab
*/5 * * * * root /usr/local/php/bin/php /usr/local/http/htdocs/cacti/poller.php > /dev/null 2>&1




安装rrdtool包:
yun install   perl-rrdtool-1.2.30-1.el5.rf.i386.rpm   rrdtool-1.2.30-1.el5.rf.i386.rpm    rrdtool-devel-1.2.30-1.el5.rf.i386.rpm  #(这三个包一定要同时安装,要不然会报错。)




snmp安装配置:
使用 Cacti 监控 Linux 主机
#在被监控的linux主机上安装net-snmp

1.  yum install net-snmp*
vi /etc/snmp/snmp.conf
#将下边这行中的default

com2secnotConfigUser default public

#改为

com2secnotConfigUser 127.0.0.1 public

#将下边这行中的systemview

access notConfigGroup "" any noauth exact systemview none none

#改为all

access notConfigGroup "" any noauth exact all none none

#将下边这行的注释“#”号去掉

#view all included .1 80

#重启snmpd服务

service snmpd restart


注意:
如果出现问题请注意一下snmp协议的版本,都用version 1是一种解决方法
如果都用version 1,需要把所有监控机和被监控机的snmpd.conf改一下
#vi /etc/snmp/snmpd.conf
#将下边这行

view systemview included .1.3.6.1.2.1.1#改为

view systemview included .1.3.6.1.2.1



运行./poller.php 出现如下问题。
./poller.php: line 1: ?php: 没有那个文件或目录
./poller.php: line 2: /bin: is a directory
./poller.php: line 3: +-------------------------------------------------------------------------+: command not found
./poller.php: line 4: syntax error near unexpected token `|'
./poller.php: line 4: ` | Copyright (C) 2004-2010 The Cacti Group     

需要vi poller.php文件最顶 一行加入  #!/usr/bin/php -q  即可
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP