一、cacti概述
二、cacti工作流程
三、cacti安装
四、配置cacti监控本机
环境:
操作系统:CentOS 6.4 x86_64
软件:Cacti-0.8.7e
官方网站:http://www.cacti.net
一、cacti概述
Cacti 在英文中的意思是仙人掌的意思,Cacti是一套基于PHP、MySQL、SNMP及RRDTool开发的网络流量监测图形分析工具。它通过snmpget来获取数据,使用 RRDtool绘画图形,它的界面非常漂亮,能让你根本无需明白rrdtool的参数能轻易的绘出漂亮的图形。而且你完全可以不需要了解RRDtool复杂的参数。它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结 构、host以及任何一张图,还可以与LDAP结合进行用户验证,同时也能自己增加模板,让你添加自己的snmp_query和script!功能非常强大完善,界面友好。可以说,Cacti将rrdtool的所有“缺点”都补足了!下图是Cacti运行的主界面,
二、cacti工作流程
下面我们来简单的说明一下Cacti的工作流程,
- 步骤一,snmp协议收集远程服务器的数据
- 步骤二,将snmp收集的数据内容保存到rrd数据库中
- 步骤三,若用户查看某台设备上的流量或其它状态信息
- 步骤四,在mysql数据库中查找该设备对应的rra数据库文件的名称
- 步骤五,通过rrdtool命令进行绘图即可
好了,在前面的几篇博客中我们讲解了SNMP协议,也讲解了RRDTool工具的使用,现在再来学习Cacti就非常的简单了,下面我们来安装并使用Cacti。
三、cacti安装
注,Cacti的运行是基于LAMP环境的首先我们来安装LAMP环境。(LAMP环境安装有两种方法,有时间的博友可以使用源码安装,不想用源码安装的博友可以参考我的安装方法全部用yum安装。)下面我们来具体演示一下,
1、更换系统默认的yum源
[[email protected] ~]# rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm Retrieving http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm warning: /var/tmp/rpm-tmp.1lW03k: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY Preparing... ########################################### [100%] 1:rpmforge-release ########################################### [100%] [[email protected] ~]# ll /etc/yum.repos.d/ total 24 -rw-r--r--. 1 root root 739 Mar 20 2013 mirrors-rpmforge -rw-r--r--. 1 root root 717 Mar 20 2013 mirrors-rpmforge-extras -rw-r--r--. 1 root root 728 Mar 20 2013 mirrors-rpmforge-testing drwxr-xr-x. 2 root root 4096 May 23 15:00 old -rw-r--r--. 1 root root 1128 Mar 20 2013 rpmforge.repo
2、时间同步
[[email protected] ~]# yum -y install ntp [[email protected] ~]# ntpdate -u asia.pool.ntp.org 4 Jun 10:25:26 ntpdate[1375]: step time server 202.73.36.32 offset -28799.877146 sec [[email protected] ~]# date Wed Jun 4 10:25:29 EDT 2014 [[email protected] ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime cp: overwrite `/etc/localtime‘? yes [[email protected] ~]# date Wed Jun 4 22:32:39 CST 2014 [[email protected] ~]# crontab -l */1 * * * * /usr/sbin/ntpdate -u asia.pool.ntp.org [[email protected] ~]# service crond restart Stopping crond: [ OK ] Starting crond: [ OK ]
3、安装lamp环境
[[email protected] ~]# yum install -y httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server gd gd-devel
设置开机自启动
[[email protected] ~]# service httpd start Starting httpd: [ OK ] [[email protected] ~]# chkconfig httpd on [[email protected] ~]# service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password ‘new-password‘ /usr/bin/mysqladmin -u root -h node1 password ‘new-password‘ Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ] [[email protected] ~]# chkconfig mysqld on [[email protected] ~]# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1048/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1124/master tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1625/mysqld tcp 0 0 :::80 :::* LISTEN 1425/httpd tcp 0 0 :::22 :::* LISTEN 1048/sshd tcp 0 0 ::1:25 :::* LISTEN 1124/master
测试phpinfo测试页面
[[email protected] ~]# cat >> /var/www/html/index.php <<EOF > <?php > phpinfo(); > ?> > EOF
测试php页面
好了!如果大家能看到这个phpinfo的页面,说明我们的apache和php是安装成功的
接着我们来测试我们的mysql数据是否成功
[[email protected] ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> \q Bye
好了,到这里Apache+PHP+MySQL就安装成功了。下面我们来看重点
net-snmp和RRDTool
4、安装net-snmp
[[email protected] ~]# yum install -y net-snmp net-snmp-utils
修改snmp的配置文件
[[email protected] ~]# cd /etc/snmp/ [[email protected] snmp]# cp snmpd.conf snmpd.conf.bak [[email protected] snmp]# vim snmpd.conf #修改55行view值 55 #view systemview included .1.3.6.1.2.1.1 56 view systemview included .1.3.6.1.2.1
接下来启动net-snmp服务并测试
[email protected] snmp]# service snmpd start Starting snmpd: [ OK ] [[email protected] snmp]# snmpnetstat -v 2c -c public -Ca -Cp tcp localhost Active Internet (tcp) Connections (including servers) Proto Local Address Remote Address (state) tcp *.ssh *.* LISTEN tcp *.mysql *.* LISTEN tcp localhost.smtp *.* LISTEN tcp localhost.smux *.* LISTEN tcp localhost.ssh localhost.52311 ESTABLISHED [[email protected] snmp]#
好了,到这里我们net-snmp安装完成,下面我们来安装RRDTool绘图工具。
5、安装RRDTool
[[email protected] ~]# yum -y install rrdtool
接下来测试RRDTool
[[email protected] ~]# rrdtool -v RRDtool 1.3.8 Copyright 1997-2009 by Tobias Oetiker <[email protected]> Compiled Aug 21 2010 10:57:18 Usage: rrdtool [options] command command_options Valid commands: create, update, updatev, graph, graphv, dump, restore, last, lastupdate, first, info, fetch, tune, resize, xport RRDtool is distributed under the Terms of the GNU General Public License Version 2. (www.gnu.org/copyleft/gpl.html) For more information read the RRD manpages
好了,到这里我们基本环境准备就全部完成了,下面我们来安装与配置Cacti。
6.安装与配置Cacti
6.1、 解压cacti压缩包并移动到指定的路径下
[[email protected] ~]# cd /usr/local/src/ [[email protected] src]# ls cacti-0.8.7e.tar.gz [[email protected] src]# tar xf cacti-0.8.7e.tar.gz -C /var/www/html/ [[email protected] src]# cd /var/www/html/ [[email protected] html]# ls cacti-0.8.7e index.php [[email protected] html]# ln -sv cacti-0.8.7e cacti `cacti‘ -> `cacti-0.8.7e‘
6.2、其中cacti.sql是保存了cacti到所有表的语句,但是没有创建数据库的语句,所以下面我们来配置一下Cacti数据库
[[email protected] ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> create database cactidb; mysql> use cactidb; mysql> source /var/www/html/cacti/cacti.sql mysql> \q Bye
6.3、因为cacti要访问数据库,所以我们得给cacti创建一个授权用户
[[email protected] ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> GRANT ALL ON cactidb.* TO [email protected] IDENTIFIED BY ‘cactiuser‘; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> \q Bye [[email protected] ~]# mysql -ucactiuser -pcactiuser Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cactidb | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> \q Bye
6.4、下面我们来修改cacti程序的配置文件
[[email protected] ~]# cd /var/www/html/cacti/include/ [[email protected] include]# cp config.php config.php.bak [[email protected] include]# vim config.php #需要修改的行 /* make sure these values refect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cactidb"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactiuser"; $database_port = "3306";
6.5、下面我们来创建一个cacti用户(安装初始化cacti)并修改相关目录权限,
[[email protected] ~]# cd /var/www/html/cacti [[email protected] cacti]# useradd cactiuser [[email protected] cacti]# chown -R cactiuser:cactiuser log/ rra/
6.6、浏览器访问cacti的初始化页面并安装cacti
cacti的初始化界面,如下图
点击【Next】继续
接下来让你选择全新安装还是升级安装,我们这里肯定选择【New Install】,点击【Next】继续,
接下来会检查所有配置选项,若有不符合要求的会用红色标出,我们这里全部符合要求,点击【Finish】继续,
直接跳转到cacti的登录页面,到这里我们cacti初始化就全部完成了,下面我们登录一下,默认用户名和密码都为”admin”
第一下次登录时让你修改默认的用户名和密码,自己设置一个即可。
首次登陆cacti的登陆界面,如下图
至此cacti的安装就完成了,接下来我们来配置cacti监控本地主机的硬件信息
设置cacti收集数据的默认的任务计划。
这里任务计划是由poller.php程序执行的,需要说明的是poller.php是由php写的,单线程的功能相对较弱,为此cacti官方单独开发了一个多线程Spine工具,适合大规模监控应用。好了下面我们就来配置一下任务计划并查看。
[[email protected] ~]# echo ‘*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php &>/dev/null‘ > /var/spool/cron/cactiuser [[email protected] ~]# crontab -u cactiuser -l */5 * * * * /usr/bin/php /var/www/html/cacti/poller.php &>/dev/null
为了防止这个任务计划不执行,首次我们最好手动验证一下
[[email protected] ~]# su cactiuser [[email protected] root]$ /usr/bin/php /var/www/html/cacti/poller.php PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 866 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 872 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1183 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1961 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3027 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3592 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3667 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3687 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 156 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 156 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 157 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 157 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 158 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 158 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 159 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 159 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 160 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 160 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 161 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 161 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 162 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_constants.php on line 162 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 621 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 621 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 622 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 622 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 623 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 623 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 624 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 624 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 625 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 625 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 626 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 626 PHP 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 627 PHP Warning: date(): 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 ‘America/New_York‘ for ‘EDT/-4.0/DST‘ instead in /var/www/html/cacti-0.8.7e/include/global_arrays.php on line 627 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/poller.php on line 77
大家可以看到上面报了一大堆错,是什么错误哟?主要是因为我们php.ini的时区设置的不对,下面我们来修改一下php时区。
[[email protected] ~]# vim /etc/php.ini ; Defines the default timezone used by the date functions ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone ;date.timezone = date.timezone = Asia/Shanghai [[email protected] ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
接下来我们在从新验证一下
[[email protected] ~]# su cactiuser [[email protected] root]$ /usr/bin/php /var/www/html/cacti/poller.php PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 866 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 872 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1183 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1961 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3027 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3592 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3667 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3687 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/poller.php on line 77 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/poller.php on line 178 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 866 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 872 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1183 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1961 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3027 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3592 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3667 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3687 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/cmd.php on line 60 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 866 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 872 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1183 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 1961 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3027 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3592 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3667 PHP Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/cacti-0.8.7e/lib/adodb/adodb.inc.php on line 3687 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/cmd.php on line 60 PHP Deprecated: Function ereg_replace() is deprecated in /var/www/html/cacti-0.8.7e/lib/rrd.php on line 29 PHP Deprecated: Function ereg_replace() is deprecated in /var/www/html/cacti-0.8.7e/lib/rrd.php on line 29 OK u:0.00 s:0.00 r:0.00 OK u:0.00 s:0.00 r:0.00 PHP Deprecated: Function ereg_replace() is deprecated in /var/www/html/cacti-0.8.7e/lib/rrd.php on line 29 OK u:0.00 s:0.00 r:1.00 PHP Deprecated: Function ereg_replace() is deprecated in /var/www/html/cacti-0.8.7e/lib/rrd.php on line 29 OK u:0.00 s:0.00 r:1.00 PHP Deprecated: Function ereg_replace() is deprecated in /var/www/html/cacti-0.8.7e/lib/rrd.php on line 29 OK u:0.00 s:0.00 r:1.00 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/poller.php on line 419 06/09/2014 07:59:36 AM - SYSTEM STATS: Time:1.2201 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5 PHP Deprecated: Function split() is deprecated in /var/www/html/cacti-0.8.7e/poller.php on line 387 [[email protected] root]$ cd /var/www/html/cacti [[email protected] cacti]$ chown -R cactiuser:cactiuser log/ rra/
查看一下执行日志
[[email protected] cacti]$ cd log [[email protected] log]$ tail -f cacti.log 06/08/2014 07:55:02 PM - SYSTEM STATS: Time:1.2324 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5 06/09/2014 07:59:36 AM - SYSTEM STATS: Time:1.2201 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
好了,到此我们的cacti就全部完成了;接下来我们来设置cacti来监控本机
四、配置cacti监控本机
首先我们点击一下“Devices”标签,出下以下界面,大家从图中可以看出,默认的主机就是Localhost
接下来我们点击一下“Localhost”主机,出现以下界面。
只要选择SNMP版本为“Version2”,点击下面的“Save”即可。效果图如下,
接下来我们选择右上脚的“Create Graphs for this Host”(为这个主机增加监控图形),
我们选择监控本地主机的磁盘空间,点击“Create”即可。下面我们来点击最上面的“Graph”标签 。如下图
监控本地主机的硬件信息
从图中我们可以看到我们新增加的监控磁盘空间的图形还没有出图,我们得等个几分钟才会出现图形,请博友耐心等待。好了,过几分钟就会出现下面的效果图
好了,到这里我们配置Cacti监控localhost就全部完成了。在一下篇博文中我们主要讲解Cacti怎么监控远程主机与Cacti的高级应用。最后,希望大家有所收获吧^_^……
谢谢好友Share your Knowledge
实战1 网络监控cacti的安装配置,布布扣,bubuko.com