共计 12295 个字符,预计需要花费 31 分钟才能阅读完成。
1、cacti 简介
1)、cacti 是用 php 语言实现的一个软件,它的主要功能是用 snmp 服务获取数据,然后用 rrdtool 储存和更新数据,当用户需要查看数据的时候用 rrdtool 生成图表呈现给用户。因此,snmp 和 rrdtool 是 cacti 的关键。Snmp 关系着数据的收集,rrdtool 关系着数据存储和图表的生成。
2)、mysql 配合 PHP 程序存储一些变量数据并对变量数据进行调用,如:主机名、主机 ip、snmp 团体名、端口号、模板信息等变量。
3)、snmp 抓到数据不是存储在 mysql 中,而是存在 rrdtool 生成的 rrd 文件中(在 cacti 根目录的 rra 文件夹下)。rrdtool 对数据的更新和存储就是对 rrd 文件的处理,rrd 文件是大小固定的档案文件(Round Robin Archive),它能够存储的数据笔数在创建时就已经定义。
2、软件包准备
————————————– 分割线 ————————————–
cacti-0.8.8b.tar.gz
httpd-2.2.23.tar.gz
php-5.4.10.tar.gz
cmake-2.8.11.2.tar.gz
mysql-5.5.28.tar.gz
rrdtool-1.4.8.tar.gz
net-snmp-5.7.2.1.tar.gz
Python-2.7.6.tgz
libxml2-2.9.1.tar.gz
zlib-1.2.8.tar.gz
jpegsrc.v9a.tar.gz
libpng-1.6.12.tar.gz
freetype-2.5.3.tar.gz
libart_lgpl-2.3.21.tar.gz
gettext-0.19.2.tar.xz
libgd-2.1.0.tar.gz
curl-7.37.1.tar.gz
————————————– 分割线 ————————————–
RHEL6.4 中使用 Cacti+Spine 监控主机实现发送邮件报警 http://www.linuxidc.com/Linux/2013-11/92795.htm
RHEL6.4 中使用 Cacti+Spine 监控远程主机 http://www.linuxidc.com/Linux/2013-11/92796.htm
CentOS 5.5 完整安装 Cacti+Spine http://www.linuxidc.com/Linux/2011-12/49701.htm
CentOS 6 下 Cacti 搭建文档 http://www.linuxidc.com/Linux/2013-06/86595.htm
RHEL5.9 下 Cacti 监控部署详解 http://www.linuxidc.com/Linux/2013-06/85427.htm
CentOS 6.3 下 Cacti 安装详解 http://www.linuxidc.com/Linux/2013-05/84279.htm
CentOS Linux 下快速安装配置 Cacti 中文版 http://www.linuxidc.com/Linux/2013-03/81627.htm
3、apache 安装配置
# tar zxvf httpd-2.2.23.tar.gz
# cd httpd-2.2.23
# ./configure –prefix=/usr/local/apache2 –enable-so
# make && make install
# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
4、mysql 安装配置
# tar zxvf cmake-2.8.11.2.tar.gz
# cd cmake-2.8.11.2
# ./configure
# make && make install
# groupadd mysql
# useradd mysql
# tar zxvf mysql-5.5.28.tar.gz
# cd mysql-5.5.28
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0
# make && make install
# vim /root/.bashrc
PATH=/usr/local/mysql/bin:${PATH}
export PATH
# source /root/.bashrc
# cp support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# chmod 755 /usr/local/src/mysql-5.5.28/scripts/mysql_install_db
# ./scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data
# chown -R mysql.mysql /usr/local/mysql/data
# service mysqld start
# mysqladmin -uroot password 123456
# mysqladmin –user=root -p create cacti
# mysql -uroot -p cacti<cacti.sql
mysql>GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactipassword’;
mysql>flush privileges;
5、GD 安装配置
1)、安装 libxml2
# tar zxvf Python-2.7.6.tgz #貌似只能是这个版本,否则编译 libxml2 时会报错
# cd Python-2.7.6
# ./configure –prefix=/usr/local/python
# make && make install
# tar zxvf libxml2-2.9.1.tar.gz
# cd libxml2-2.9.1
# ./configure –prefix=/usr/local/libxml2
# make && make install
2)、安装 zlib
# tar zxvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure –prefix=/usr/local/zlib2
# make && make install
# yum install -y zlib-devel
3)、安装 jpegsrc
# tar zxvf jpegsrc.v9a.tar.gz
# cd jpeg-9a
# ./configure –prefix=/usr/local/jpegsrc9
# make && make install
4)、安装 libpng
# tar zxvf libpng-1.6.12.tar.gz
# cd libpng-1.6.12
# ./configure –prefix=/usr/local/libpng2
# make && make install
5)、安装 freetype
# tar zxvf freetype-2.5.3.tar.gz
# cd freetype-2.5.3
# ./configure –prefix=/usr/local/freetype2
# make && make install
6)、安装 libart_lgpl
# tar zxvf libart_lgpl-2.3.21.tar.gz
# cd libart_lgpl-2.3.21
# ./configure –prefix=/usr/local/libart
# make && make install
7)、安装 gettext
# xz -d gettext-0.19.2.tar.xz
# tar xvf gettext-0.19.2.tar
# cd gettext-0.19.2
# ./configure –prefix=/usr/local/gettext
# make && make install
8)、安装 GD
# tar zxvf libgd-2.1.0.tar.gz
# cd libgd-2.1.0
9)、安装 curl
# tar zxvf curl-7.37.1.tar.gz
# cd curl-7.37.1
# ./configure –prefix=/usr/local/curl
# make && make install
6、php 安装配置
# yum install -y libxml2-devel freetype-devel
# tar zxvf php-5.4.10.tar.gz
# cd php-5.4.10
# ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-jpeg-dir=/usr/local/jpeg9/ –with-png-dir=/usr/local/libpng2/ –with-gd –with-freetype-dir=/usr/local/freetype2/ –with-zlib-dir=/usr/local/zlib2/ –with-mysql=/usr/local/mysql –with-curl=/usr/local/curl –with-gettext=/usr/local/gettext –enable-sockets
# make && make install
# cp php.ini-development /usr/local/php/lib/php.ini
# ln -s /usr/local/php/bin/php /usr/bin
# vim /usr/local/apache2/conf/httpd.conf
在 #AddType application/x-tar.tgz 后追加:AddType application/x-httpd-php .php
在 #LoadModule foo_module modules/mod_foo.so 后追加:LoadModule php5_module modules/libphp5.so
在 DirectoryIndexindex.html 后面追加 index.php
更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2014-09/106582p2.htm
7、rrdtool 安装配置
# yum install -y freetype-devel libart_lgpl-devel gd-devel cairo cairo-devel pango pango-devel
# tar zxvf rrdtool-1.4.8.tar.gz
# cd rrdtool-1.4.8
# ./configure –prefix=/usr/local/rrdtool
# make && make install
# ln -s /usr/local/rrdtool/bin/rrdtool /usr/bin
8、net-snmp 安装配置
# tar zxvf net-snmp-5.7.2.1.tar.gz
# cd net-snmp-5.7.2.1
# ./configure –prefix=/usr/local/net-snmp
# make && make install
# ln –s /usr/local/net-snmp/bin/* /usr/local/bin/
# cp /usr/local/src/net-snmp-5.7.2.1/EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
# vim /usr/local/net-snmp/share/snmp/snmpd.conf
添加以下内容
view all included .1
view systemview included .1.3.6.1.2.1.2
# /usr/local/net-snmp/sbin/snmpd
# lsof -i:161
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
snmpd 41107 root 8u IPv4 616363 0t0 UDP localhost:snmp
# snmpwalk -v 1 -c public localhost system
# vim /etc/rc.d/rc.local
追加以下内容,开机自启动
/usr/local/net-snmp/sbin/snmpd
# 关于 snmpd.conf 的内容还可以引用以下配置
com2sec notConfigUser default test
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view all included .1
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.2
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup “” any noauth exact all none none
com2sec local localhost test
com2sec mynetwork 10.0.2.0/24 test
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
9、cacti 安装配置
# tar zxvf cacti-0.8.8b.tar.gz
# mv cacti-0.8.8b /usr/local/cacti
# vim /usr/local/apache2/conf/httpd.conf
DocumentRoot “/usr/local/apache2/htdocs” => DocumentRoot “/usr/local/cacti”
<Directory “/usr/local/apache2/htdocs”> => <Directory “/usr/local/cacti”>
# vim /usr/local/cacti/include/config.php
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cactipassword”;
$database_port = “3306”;
$database_ssl = false;
/* load up old style plugins here */ #enable plugins
$plugins = array();
//$plugins[] = ‘thold’;
# useradd cactiuser
# chown -R cactiuser.cactiuser ./rra ./log
# service httpd restart
# rrdtool fetch localhost_users_6.rrd AVERAGE|MAX# 查看 rrd 文件是否有数据
10、被监控机安装 snmp 服务
# yum install -y net-snmp*
# vim /etc/snmp/snmpd.conf
view all included .1
view systemview included .1.3.6.1.2.1.2
# service snmpd start
# lsof -i:161
11、问题汇总
问题 1:
Warning: strtotime(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in /usr/local/apache2/htdocs/cacti/include/global_constants.php on line 165
解决方法:
# vim /usr/local/php/lib/php.ini
修改
date.timezone = PRC
并取消注释
问题 2:
PHP Strict Standards: Only variables should be passed by reference in /usr/local/nginx/html/cacti/lib/ping.php on line 382
解决方法:
socket_select($r = array($this->socket), $w = NULL, $f = NULL, $to_sec, $to_usec){
=> 修改为
$r = array($this->socket);
$w = NULL;
$f = NULL;
switch(socket_select($r, $w, $f, $to_sec, $to_usec)){
问题 3:
WARNING: Cron is out of sync with the Poller Interval! The Poller Interval is ‘300’ seconds, with a maximum of a ‘300’ second Cron, but 2135 seconds have passed since the last poll!
解决方法:
*/1 * * * * /usr/bin/php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1
1、cacti 简介
1)、cacti 是用 php 语言实现的一个软件,它的主要功能是用 snmp 服务获取数据,然后用 rrdtool 储存和更新数据,当用户需要查看数据的时候用 rrdtool 生成图表呈现给用户。因此,snmp 和 rrdtool 是 cacti 的关键。Snmp 关系着数据的收集,rrdtool 关系着数据存储和图表的生成。
2)、mysql 配合 PHP 程序存储一些变量数据并对变量数据进行调用,如:主机名、主机 ip、snmp 团体名、端口号、模板信息等变量。
3)、snmp 抓到数据不是存储在 mysql 中,而是存在 rrdtool 生成的 rrd 文件中(在 cacti 根目录的 rra 文件夹下)。rrdtool 对数据的更新和存储就是对 rrd 文件的处理,rrd 文件是大小固定的档案文件(Round Robin Archive),它能够存储的数据笔数在创建时就已经定义。
2、软件包准备
————————————– 分割线 ————————————–
cacti-0.8.8b.tar.gz
httpd-2.2.23.tar.gz
php-5.4.10.tar.gz
cmake-2.8.11.2.tar.gz
mysql-5.5.28.tar.gz
rrdtool-1.4.8.tar.gz
net-snmp-5.7.2.1.tar.gz
Python-2.7.6.tgz
libxml2-2.9.1.tar.gz
zlib-1.2.8.tar.gz
jpegsrc.v9a.tar.gz
libpng-1.6.12.tar.gz
freetype-2.5.3.tar.gz
libart_lgpl-2.3.21.tar.gz
gettext-0.19.2.tar.xz
libgd-2.1.0.tar.gz
curl-7.37.1.tar.gz
————————————– 分割线 ————————————–
RHEL6.4 中使用 Cacti+Spine 监控主机实现发送邮件报警 http://www.linuxidc.com/Linux/2013-11/92795.htm
RHEL6.4 中使用 Cacti+Spine 监控远程主机 http://www.linuxidc.com/Linux/2013-11/92796.htm
CentOS 5.5 完整安装 Cacti+Spine http://www.linuxidc.com/Linux/2011-12/49701.htm
CentOS 6 下 Cacti 搭建文档 http://www.linuxidc.com/Linux/2013-06/86595.htm
RHEL5.9 下 Cacti 监控部署详解 http://www.linuxidc.com/Linux/2013-06/85427.htm
CentOS 6.3 下 Cacti 安装详解 http://www.linuxidc.com/Linux/2013-05/84279.htm
CentOS Linux 下快速安装配置 Cacti 中文版 http://www.linuxidc.com/Linux/2013-03/81627.htm
3、apache 安装配置
# tar zxvf httpd-2.2.23.tar.gz
# cd httpd-2.2.23
# ./configure –prefix=/usr/local/apache2 –enable-so
# make && make install
# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
4、mysql 安装配置
# tar zxvf cmake-2.8.11.2.tar.gz
# cd cmake-2.8.11.2
# ./configure
# make && make install
# groupadd mysql
# useradd mysql
# tar zxvf mysql-5.5.28.tar.gz
# cd mysql-5.5.28
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0
# make && make install
# vim /root/.bashrc
PATH=/usr/local/mysql/bin:${PATH}
export PATH
# source /root/.bashrc
# cp support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# chmod 755 /usr/local/src/mysql-5.5.28/scripts/mysql_install_db
# ./scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data
# chown -R mysql.mysql /usr/local/mysql/data
# service mysqld start
# mysqladmin -uroot password 123456
# mysqladmin –user=root -p create cacti
# mysql -uroot -p cacti<cacti.sql
mysql>GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactipassword’;
mysql>flush privileges;
5、GD 安装配置
1)、安装 libxml2
# tar zxvf Python-2.7.6.tgz #貌似只能是这个版本,否则编译 libxml2 时会报错
# cd Python-2.7.6
# ./configure –prefix=/usr/local/python
# make && make install
# tar zxvf libxml2-2.9.1.tar.gz
# cd libxml2-2.9.1
# ./configure –prefix=/usr/local/libxml2
# make && make install
2)、安装 zlib
# tar zxvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure –prefix=/usr/local/zlib2
# make && make install
# yum install -y zlib-devel
3)、安装 jpegsrc
# tar zxvf jpegsrc.v9a.tar.gz
# cd jpeg-9a
# ./configure –prefix=/usr/local/jpegsrc9
# make && make install
4)、安装 libpng
# tar zxvf libpng-1.6.12.tar.gz
# cd libpng-1.6.12
# ./configure –prefix=/usr/local/libpng2
# make && make install
5)、安装 freetype
# tar zxvf freetype-2.5.3.tar.gz
# cd freetype-2.5.3
# ./configure –prefix=/usr/local/freetype2
# make && make install
6)、安装 libart_lgpl
# tar zxvf libart_lgpl-2.3.21.tar.gz
# cd libart_lgpl-2.3.21
# ./configure –prefix=/usr/local/libart
# make && make install
7)、安装 gettext
# xz -d gettext-0.19.2.tar.xz
# tar xvf gettext-0.19.2.tar
# cd gettext-0.19.2
# ./configure –prefix=/usr/local/gettext
# make && make install
8)、安装 GD
# tar zxvf libgd-2.1.0.tar.gz
# cd libgd-2.1.0
9)、安装 curl
# tar zxvf curl-7.37.1.tar.gz
# cd curl-7.37.1
# ./configure –prefix=/usr/local/curl
# make && make install
6、php 安装配置
# yum install -y libxml2-devel freetype-devel
# tar zxvf php-5.4.10.tar.gz
# cd php-5.4.10
# ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-jpeg-dir=/usr/local/jpeg9/ –with-png-dir=/usr/local/libpng2/ –with-gd –with-freetype-dir=/usr/local/freetype2/ –with-zlib-dir=/usr/local/zlib2/ –with-mysql=/usr/local/mysql –with-curl=/usr/local/curl –with-gettext=/usr/local/gettext –enable-sockets
# make && make install
# cp php.ini-development /usr/local/php/lib/php.ini
# ln -s /usr/local/php/bin/php /usr/bin
# vim /usr/local/apache2/conf/httpd.conf
在 #AddType application/x-tar.tgz 后追加:AddType application/x-httpd-php .php
在 #LoadModule foo_module modules/mod_foo.so 后追加:LoadModule php5_module modules/libphp5.so
在 DirectoryIndexindex.html 后面追加 index.php
更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2014-09/106582p2.htm