Chinaunix首页 | 论坛 | 博客
  • 博客访问: 140505
  • 博文数量: 68
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-28 20:01
文章分类

全部博文(68)

文章存档

2015年(68)

我的朋友

分类: 系统运维

2015-08-31 17:22:01

cacti 需要LAMP环境,网上很多LAMP的安装文档,这里就不说了

(1)建库

#mysql

mysql>create database cacti default character set utf8;

mysql>grant all privileges on cacti.* to cactiuser@localhost IDENTIFIED BY 'zxImusic';

mysql>flush privileges;

mysql>\q

 (2)安装cacti:

下载中文的cacti,解压到/var/www/cacti.后进入cacti的目录.导入cacti的数据结构

#cd /usr/local

下载0.8.7e

#wget http://blogimg.chinaunix.net/blog/upfile2/090815172648.gz

#tar -zxvf 090815172648.gz

#mv cacti-0.8.7e-cn-utf8 /data/apache/htdocs/cacti2

#cd  /data/apache/htdocs/cacti2

#mysql cacti < cacti.sql

或#mysql -ucactiuser -pchangzheng cacti < ./cacti.sql

下载对应版本的cacti-spine tar包,配置,安装。

wget 

#tar -zxvf cacti-spine-0.8.7e.tar.gz

#cd cacti-spine

#./configure --with-snmp=/usr/local/net-snmp

#make && make install

(3)修改配置文件

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

更改$database_password = "zxImusic";

#vi /usr/local/spine/etc/spine.conf

DB_Host         localhost

DB_Database     cacti

DB_User         cactiuser

DB_Pass         zxImusic

DB_Port         3306

(4)添加cacti用户

#groupadd cactiuser

#useradd -g cactiuser cactiuser -s /bin/false

#chown -R cactiuser /data/apache/htdocs/cacti2/rra 

#chown -R  cactiuser /data/apache/htdocs/cacti2/log

(5)配置httpd服务器的配置文件

#vi /etc/httpd/conf/httpd.conf

添加:

Alias /cacti /data/apache/htdocs/cacti2

<Directory /data/apache/htdocs/cacti2>

DirectoryIndex index.php

AllowOverride all

order deny,allow

deny from all

allow from all

AddType application/x-httpd-php .php

php_flag magic_quotes_gpc on

php_flag track_vars on

</Directory>

浏览器打开:

按提示安装,设置初始密码:admin/zxImusicxxxxx

收尾

#crontab -e

*/5 * * * * su cactiuser -c "/data/apache/php/bin/php /data/apache/htdocs/cacti2/poller.php >/dev/null 2>&1"

 (6)被监控主机snmp文件设置

将com2sec notConfigUser default public

改为

com2sec notConfigUser 127.0.0.1 public

将access notConfigGroup "" any noauth exact systemview none none

改为

access notConfigGroup "" any noauth exact all none none

#view all included .1 80

将前面的 # 注释 去掉。

保存退出

测试snmp是否正常

#snmpwalk -c public -v 2c localhost

#snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

IP-MIB::ipAdEntIfIndex.61.xxx.xxx.xxx = INTEGER: 2

IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.172.xxx.xxx.xxx = INTEGER: 3

也可以用snmpd -f -Le 命令查看当前有没有出什么错

 (7)插件的安装:

Cacti插件是对cacti的扩展。

要使用cacti插件必须先扩展cacti架构,来支持插件。

(7.1)安装cacti插件架构扩展

# wget http://blog.45639.com/soft/linux/cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff.gz

# gzip -d cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff.gz

# mv cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff /data/apache/htdocs/cacti

 

//备份cacti目录,以备插件扩展安装失败后能恢复到原状态

# cd /usr/local/apache/htdocs

# cp –r cacti ./cacti.bak

# cd ./cacti

//首先使用以下命令进行测试

# patch -p1 -N --dry-run < cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff.gz

//以上命令成功后,使用以下命令进行安装

# patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff.gz

(7.2)修改插件架构的MYSQL配置信息

vi /data/apache/htdocs/cacti/include/global.php

/* Default database settings*/

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "zxImusic";

$database_port = "3306";

 

安装后配置,首先查看你的cacti配置文件,看cacti相关的数据库信息是否被覆盖,如果被覆盖请直接从备份中拷贝一份到配置文件目录。

# cp ../include/config.php ./include/config.php

打开cacti配置文件,找到以下选项

$config['url_path'] = "/";

如过你的cacti能够在浏览器中使用以下方法直接访问,则不用修改cacti配置文件。

机器ip

如果cacti在浏览器中使用以下方法直接访问,

 机器ip/cacti

则$config['url_path'] = "/";必须被修改为$config['url_path'] = "/cacti/";

注意前后的/不能丢。

到此cacti插件结构的扩展完成,现在可以下载并安装你需要的cacti插件了。

 (8)安装Cacti插件

(8.1)settings插件安装

cd /data/apache/htdocs/cacti/plugins

wget 

tar zxvf settings-0.3.tar.gz

(8.2)Monitor插件安装

wget 

tar zxvf monitor-0.8.2.tar.gz

(8.3)thold插件安装

wget 

tar -zxvf thold-0.4.1.tar.gz

 vi /data/apache/htdocs/cacti/include/global.php

$plugins = array();

//$plugins[] = 'thold';

$plugins[] = 'settings'; //list first must is settings

$plugins[] = 'thold';

$plugins[] = 'monitor';

Settings插件负责一些基本的配置信息,为了更好使用其它的插件,Settings必需安排在$plugins的首行

 (9)cacti 插件使用权限

例给于admin所有插件使用权限:User Management :admin

阅读(352) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~