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