哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、
等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)自2013年起到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
注,操作系統(tǒng) CentOS 6.4 x86_84,軟件版本 Cacti-0.8.8b 目前最新版。 (說明:本博文的一些圖片自于開源社區(qū)與官方網(wǎng)站并不是所有內(nèi)容全是原創(chuàng))
在 前面的幾篇博客中我們講解了,監(jiān)控的概述、SNMP原理與實(shí)戰(zhàn)、RRDTool繪圖工具使用,這幾篇博文都是做為鋪墊來為我們講解Cacti監(jiān)控工具做準(zhǔn) 備,通過上面博文的講解,我們知道可以通過snmp協(xié)議來收集遠(yuǎn)程主機(jī)的系統(tǒng)狀態(tài)信息,如CPU使用率、內(nèi)存的使用率、網(wǎng)卡流量、TCP連接數(shù)據(jù)等,然后 將收集的數(shù)據(jù)保存在RRD文件中,再通過RRTool復(fù)雜的命令行工具來繪圖。通過實(shí)際操作我們會(huì)發(fā)現(xiàn),雖然RRDTool繪圖工具功能很強(qiáng)大,但是使用 非常的復(fù)雜。還有以下缺點(diǎn),
RRDTool只能存儲(chǔ)數(shù)據(jù)和畫圖,它沒有像MRTG中集成的數(shù)據(jù)采集功能,要手動(dòng)收集數(shù)據(jù)或?qū)懩_本收集數(shù)據(jù)。
Cacti 在英文中的意思是仙人掌的意思,Cacti是一套基于PHP、MySQL、SNMP及RRDTool開發(fā)的網(wǎng)絡(luò)流量監(jiān)測(cè)圖形分析工具。它通過 snmpget來獲取數(shù)據(jù),使用 RRDtool繪畫圖形,它的界面非常漂亮,能讓你根本無需明白rrdtool的參數(shù)能輕易的繪出漂亮的圖形。而且你完全可以不需要了解RRDtool復(fù) 雜的參數(shù)。它提供了非常強(qiáng)大的數(shù)據(jù)和用戶管理功能,可以指定每一個(gè)用戶能查看樹狀結(jié) 構(gòu)、host以及任何一張圖,還可以與LDAP結(jié)合進(jìn)行用戶驗(yàn)證,同時(shí)也能自己增加模板,讓你添加自己的snmp_query和script!功能非常強(qiáng) 大完善,界面友好??梢哉f,Cacti將rrdtool的所有“缺點(diǎn)”都補(bǔ)足了!下圖是Cacti運(yùn)行的主界面,
好了,在前面的幾篇博客中我們講解了SNMP協(xié)議,也講解了RRDTool工具的使用,現(xiàn)在再來學(xué)習(xí)Cacti就非常的簡(jiǎn)單了,下面我們來安裝并使用Cacti。
注,Cacti的運(yùn)行是基于LAMP環(huán)境的首先我們來安裝LAMP環(huán)境。(LAMP環(huán)境安裝有兩種方法,有時(shí)間的博友可以使用源碼安裝,不想用源碼安裝的博友可以參考我的安裝方法全部用yum安裝。)下面我們來具體演示一下,
[root@node1 ~] # 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
Preparing... ########################################### [100%]
package rpmforge-release-0.5.3-1.el6.rf.x86_64 is already installed #我這邊已經(jīng)安裝好了
12 Oct 11:03:56 ntpdate[13805]: adjust time server 202.120.2.101 offset 0.000661 sec
[root@node1 ~]# yum install -y httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server gd gd-devel
Proto Recv-Q Send-Q Local Address Foreign Address State PID /Program name
phpinfo();
?>
好了,當(dāng)大家看到這個(gè)頁(yè)面時(shí),就說明我們php環(huán)境安裝完成,下面我們來測(cè)試mysql數(shù)據(jù)庫(kù)。
[
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root@node1 ~] # mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 96186
Server version: 5.1.69 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 |
| testdb |
+--------------------+
4 rows in set (0.08 sec)
mysql>
好了,到這里我們LAMP環(huán)境就安裝完成了,下面我們來安裝net-snmp與RRDTool。
4.安裝net-snmp
1
[root@node1 ~] # yum install -y net-snmp net-snmp-utils
下面我們來修改一下配置文件,
1
2
3
4
5
[root@node1 ~] # vim /etc/snmp/snmpd.conf
修改前,
view systemview included .1.3.6.1.2.1.1
修改后,
view systemview included .1.3.6.1.2.1
接下來啟動(dòng)net-snmp并測(cè)試一下,
1
2
3
4
5
6
7
8
9
10
11
[root@node1 ~] # service snmpd start
正在啟動(dòng) snmpd: [確定]
[root@node1 ~] # 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.x11- ssh - *.* LISTEN
tcp 192.168.18.201. ssh 192.168.18.138.61353 ESTABLISHED
好了,到這里我們net-snmp安裝完成,下面我們來安裝RRDTool繪圖工具。
5.安裝RRDTool
1
[root@node1 ~] # yum install -y rrdtool
下面來測(cè)試一下,
1
2
3
4
5
6
7
8
9
10
[root@node1 ~] # rrdtool -v
RRDtool 1.3.8 Copyright 1997-2009 by Tobias Oetiker
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
好了,到這里我們基本環(huán)境準(zhǔn)備就全部完成了,下面我們來安裝與配置Cacti。
6.安裝與配置Cacti
首先我們?nèi)ハ螺dCacti,
1
2
3
4
5
6
7
8
9
10
11
12
[root@node1 ~] # wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
[root@node1 ~] # ll -h
總用量 2.8M
-rw-------. 1 root root 970 8月 17 18:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 2.2M 8月 7 09:42 cacti-0.8.8b. tar .gz
-rw-r--r-- 1 root root 176 10月 11 16:06 getselect.sh
-rw-r--r-- 1 root root 152 10月 11 16:15 insert.sh
-rw-r--r--. 1 root root 16K 8月 17 18:50 install .log
-rw-r--r--. 1 root root 4.1K 8月 17 18:48 install .log.syslog
-rw-r--r-- 1 root root 11K 10月 11 16:23 mysql.png
-rw-r--r-- 1 root root 294K 10月 11 16:47 mysql.rrd
-rw-r--r-- 1 root root 294K 10月 10 21:53 rrdtool-1.3.8-6.el6.x86_64.rpm
大家都知道Cacti就是個(gè)PHP程序是基于LAMP環(huán)境運(yùn)行的,下面我們來為Cacti配置虛擬主機(jī),
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@node1 ~] # vim /etc/httpd/conf/httpd.conf
DocumentRoot /web/vhosts/cacti
ServerName cacti. test .com
ErrorLog logs /cacti . test .com-error_log
CustomLog logs /cacti . test .com-access_log common
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html index.htm
AllowOverride None
Order allow,deny
Allow from all
< /Directory >
< /VirtualHost >
下面我們來建立Cacti文檔目錄,
1
2
3
4
[root@node1 ~] # mkdir -pv /web/vhosts/cacti
mkdir : 已創(chuàng)建目錄 "/web"
mkdir : 已創(chuàng)建目錄 "/web/vhosts"
mkdir : 已創(chuàng)建目錄 "/web/vhosts/cacti"
接下來我們來解壓剛才下載的Cacti壓縮包并將Cacti程序移動(dòng)到/web/vhosts/cacti下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@node1 ~] # tar xf cacti-0.8.8b.tar.gz
[root@node1 ~] # cd cacti-0.8.8b
[root@node1 cacti-0.8.8b] # mv * /web/vhosts/cacti/
[root@node1 cacti-0.8.8b] # cd /web/vhosts/cacti/
[root@node1 cacti] # ls
about.php data_templates.php graph_templates.php log scripts
auth_changepassword.php docs graph_view.php logout .php script_server.php
auth_login.php gprint_presets.php graph_xport.php plugins script_server.pl
cacti.sql graph_image.php host.php plugins.php settings.php
cdef.php graph.php host_templates.php poller_commands.php templates_export.php
cli graph_settings.php images poller_export.php templates_import.php
cmd.php graphs_items.php include poller.php tree.php
color.php graphs_new.php index.php README user_admin.php
data_input.php graphs.php install resource utilities.php
data_queries.php graph_templates_inputs.php lib rra
data_sources.php graph_templates_items.php LICENSE rra.php
其中cacti.sql是保存了cacti到所有表的語句,但是沒有創(chuàng)建數(shù)據(jù)庫(kù)的語句,所以下面我們來配置一下Cacti數(shù)據(jù)庫(kù),
1
2
[root@node1 cacti] # mysqladmin create cactidb
[root@node1 cacti] # mysql cactidb < cacti.sql
因?yàn)閏acti要訪問數(shù)據(jù)庫(kù),所以我們得給cacti創(chuàng)建一個(gè)授權(quán)用戶,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@node1 cacti] # mysql -e "GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY \'cactiuser\'"
[root@node1 cacti] # mysqladmin flush-privileges
[root@node1 cacti] # mysql -ucactiuser -pcactiuser
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 96192
Server version: 5.1.69 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.02 sec)
mysql>
下面我們來修改cacti程序的配置文件,
1
2
3
4
5
6
7
8
9
10
11
12
[root@node1 ~] # cd /web/vhosts/cacti/
[root@node1 cacti] # cd include/
[root@node1 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" ;
$database_ssl = false ;
$url_path = "/" ; #這一行非常重要設(shè)置cacti程序訪問路徑的
下面我們來創(chuàng)建一個(gè)cacti用戶(安裝初始化cacti)并修改相關(guān)目錄權(quán)限,
1
2
3
[root@node1 ~] # cd /web/vhosts/cacti/
[root@node1 cacti] # useradd cactiuser
[root@node1 cacti] # chown -R cactiuser:cactiuser log/ rra/
接下來重新啟動(dòng)一下httpd并初始化cacti,首先我們得修改 Win 7的hosts文件,C:WindowsSystem32driversetchosts,新增一行:
1
192.168.18.201 cacti. test .com
下面我們用瀏覽器訪問一下:http://cacti.test.com/install,會(huì)彈出cacti初始化界面,如下圖
我們點(diǎn)擊”Next”繼續(xù),
接下來讓你選擇全新安裝還是升級(jí)安裝,我們這里肯定選擇”New Install”,點(diǎn)擊“Next”繼續(xù),
接下來會(huì)檢查所有配置選項(xiàng),若有不符合要求的會(huì)用紅色標(biāo)出,我們這里全部符合要求,點(diǎn)擊“Finish”繼續(xù),
直接跳轉(zhuǎn)到cacti的登錄頁(yè)面,到這里我們cacti初始化就全部完成了,下面我們登錄一下,默認(rèn)用戶名和密碼都為”admin”。
第一下次登錄時(shí)讓你修改默認(rèn)的用戶名和密碼,自己設(shè)置一個(gè)即可。
好了,到這里我們已經(jīng)可以看cacti的配置界面了,下面我們就來詳細(xì)的看一下。從上圖中我們可以看到最上面有兩個(gè)標(biāo)簽一個(gè)是紅顏色的“console”控制臺(tái)標(biāo)簽,另一個(gè)是“graphs”圖像標(biāo)簽,下面我們點(diǎn)擊一下“graphs”標(biāo)簽,如下圖:
大家可以從圖上看到,由于我們還沒做任何配置,所以這里沒有任何圖像。好了,下面我們就來詳細(xì)說一說這兩個(gè)標(biāo)簽中內(nèi)容。先說,console 標(biāo)簽。
大家先看左邊這一欄,從圖中我們可以看出,大致分為七個(gè)大項(xiàng)和多個(gè)項(xiàng)目。下面我們來的羅列一下,分別講解。
(1).Create 創(chuàng)建
New Graphs 添加新圖形
(2).Management 管理
Graph Management 圖形管理。可以在此刪除、復(fù)制圖像,Cacti會(huì)自動(dòng)創(chuàng)建圖像。不過如果我們有特殊的需要,比如將幾張圖上的數(shù)據(jù)合并在一張圖像上的話也可以在此手工新建圖像;
Graph Trees 圖形樹。在graphs界面里,圖像或devices是樹狀結(jié)構(gòu)顯示的,可以在此設(shè)置樹的結(jié)構(gòu);
Data Sources 數(shù)據(jù)源。記要用來管理rrd文件的,一般無需修改,Cacti會(huì)自己創(chuàng)建rrd文件;
Devices 設(shè)備管理。這是我們最經(jīng)常需要修改的地方,可以在此創(chuàng)建新的設(shè)備或修改其名稱等信息。
(3).Collection Methods 數(shù)據(jù)收集方法,一般我們無需對(duì)這兩項(xiàng)進(jìn)行修改。(非常重要在下面的內(nèi)容中進(jìn)行詳解)
Data Queries 數(shù)據(jù)查詢,
Data Input Methods 數(shù)據(jù)輸入方法
(4).Templates 模板,這些模板可以導(dǎo)出、導(dǎo)入也可以自己編寫,一般無需修改。
Graph Templates 圖形模板
Host Templates 主機(jī)模板
Data Templates 數(shù)據(jù)模板
(5).Import/Export 導(dǎo)入/導(dǎo)出,對(duì)上述模板的導(dǎo)入、導(dǎo)出。我們可以在Cacti的官方網(wǎng)站上找到這些模板,不過需要注意模板對(duì)于的Cacti的版本。
Import Templates 導(dǎo)入模板
Export Templates 導(dǎo)出模板
(6).Configuration 配置
Settings 系統(tǒng)設(shè)置,Cacti的主要配置菜單;可以在此重新設(shè)置對(duì)應(yīng)的程序的路徑、版本等信息。也可以設(shè)置圖像的輸出方式(允許ftp)、顯示效果、登陸方式(允許使用LDAP)等。
Plugin Management 插件管理
(7).Utilities 工具
System Utilities 系統(tǒng)工具,顯示Cacti系統(tǒng)的一些cache和log信息,如果log文件太大建議直接到后臺(tái)查看;
User Management 用戶管理,可以在此添加、刪除用戶,并對(duì)每個(gè)用戶設(shè)置詳細(xì)的權(quán)限;
Logout User 用戶退出
里面的具體內(nèi)容請(qǐng)大家自己去看,下面我們來講解一下第三大項(xiàng)收集方法,收集方法即數(shù)據(jù)收集方法。其中,有兩種方法:
數(shù)據(jù)查詢:xml格式數(shù)據(jù)收集方法
數(shù)據(jù)輸入方法:命令或腳本(比較常用)
注,腳本只需要指定如何獲取數(shù)據(jù),并且獲取到的數(shù)據(jù)經(jīng)過處理后要按元寶輸出。案例,
1
2
TAG:data TAG:data
input:30 output:40
好了,我們用腳本定義了收集數(shù)據(jù)方法,也指定了數(shù)據(jù)輸出,那腳本多長(zhǎng)時(shí)間執(zhí)行一次呢?執(zhí)行的時(shí)間是cacti程序設(shè)置的,下面我們來配置cacti安裝的最重要的一步也是最后一步,設(shè)置cacti收集數(shù)據(jù)的默認(rèn)的任務(wù)計(jì)劃。
1
2
3
4
5
6
7
8
9
10
11
12
[root@node1 cacti] # ls
about.php data_templates.php graph_templates.php log scripts
auth_changepassword.php docs graph_view.php logout .php script_server.php
auth_login.php gprint_presets.php graph_xport.php plugins script_server.pl
cacti.sql graph_image.php host.php plugins.php settings.php
cdef.php graph.php host_templates.php poller_commands.php templates_export.php
cli graph_settings.php images poller_export.php templates_import.php
cmd.php graphs_items.php include poller.php tree.php
color.php graphs_new.php index.php README user_admin.php
data_input.php graphs.php install resource utilities.php
data_queries.php graph_templates_inputs.php lib rra
data_sources.php graph_templates_items.php LICENSE rra.php
這里任務(wù)計(jì)劃是由poller.php程序執(zhí)行的,需要說明的是poller.php是由php寫的,單線程的功能相對(duì)較弱,為此cacti官方單獨(dú)開發(fā)了一個(gè)多線程Spine工具,適合大規(guī)模監(jiān)控應(yīng)用。好了下面我們就來配置一下任務(wù)計(jì)劃并查看。
1
2
3
[root@node1 cacti] # echo \'*/5 * * * * /usr/bin/php /web/vhosts/cacti/poller.php &>/dev/null\' > /var/spool/cron/cactiuser
[root@node1 cacti] # crontab -u cactiuser -l
* /5 * * * * /usr/bin/php /web/vhosts/cacti/poller .php &> /dev/null
為了防止這個(gè)任務(wù)計(jì)劃不執(zhí)行,我們最好手動(dòng)驗(yàn)證一下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[root@node1 cacti] # su - cactiuser
[cactiuser@node1 ~]$ /usr/bin/php /web/vhosts/cacti/poller .php
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 165
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 165
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 166
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 166
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 167
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 167
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 168
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 168
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 169
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 169
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 170
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 170
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 171
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_constants .php on line 171
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 671
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 671
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 672
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 672
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 673
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 673
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 674
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 674
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 675
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 675
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 676
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 676
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 677
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 \' Asia /Chongqing \' for \' CST /8 .0 /no DST\' instead in /web/vhosts/cacti/include/global_arrays .php on line 677
[cactiuser@node1 ~]$
大家可以看到上面報(bào)了一大堆錯(cuò),是什么錯(cuò)誤喲?主要是因?yàn)槲覀僷hp.ini的時(shí)區(qū)設(shè)置的不對(duì),下面我們來修改一下php時(shí)區(qū)。
1
2
3
4
5
[root@node1 cacti] # vim /etc/php.ini
date .timezone = Asia /Shanghai
[root@node1 cacti] # service httpd restart
停止 httpd: [確定]
正在啟動(dòng) httpd: [確定]
接下來我們?cè)賮頊y(cè)試一下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@node1 cacti] # su - cactiuser
[cactiuser@node1 ~]$ /usr/bin/php /web/vhosts/cacti/poller .php
[root@node1 cacti] # chown -R cactiuser:cactiuser log/ rra/ #修改一下cacti程序中的log和rra目錄的所屬者與所屬組
[cactiuser@node1 cacti]$ /usr/bin/php /web/vhosts/cacti/poller .php
10 /12/2013 04:18:26 PM - SYSTEM STATS: Time:0.2288 Method:cmd.php Processes:1 Threads:N /A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
OK u:0.00 s:0.00 r:0.14
OK u:0.00 s:0.00 r:0.14
OK u:0.00 s:0.00 r:0.14
OK u:0.00 s:0.00 r:0.14
OK u:0.00 s:0.01 r:0.15
OK u:0.00 s:0.01 r:0.15
OK u:0.00 s:0.01 r:0.15
OK u:0.00 s:0.01 r:0.15
OK u:0.00 s:0.01 r:0.16
OK u:0.00 s:0.01 r:0.16
查看一下執(zhí)行日志,
1
2
3
[cactiuser@node1 cacti]$ cd log
[cactiuser@node1 log]$ tail cacti.log
10 /12/2013 04:18:26 PM - SYSTEM STATS: Time:0.2288 Method:cmd.php Processes:1 Threads:N /A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
好的,Cacti安裝到這里就全部完成了,下面我們來配置Cacti讓它來監(jiān)控本機(jī)。
五、配置Cacti監(jiān)控本機(jī)
首先我們點(diǎn)擊一下“Devices”標(biāo)簽,出下以下界面,大家從圖中可以看出,默認(rèn)的主機(jī)就是Localhost。
接下來我們點(diǎn)擊一下“Localhost”主機(jī),出現(xiàn)以下界面。
上圖是默認(rèn)的配置,我們只要修改一處即可,便是“SNMP Options”。如下圖,
只要選擇SNMP版本為“Version2”,點(diǎn)擊下面的“Save”即可。效果圖如下
接下來我們選擇右上腳的“Create Graphs for this Host”(為這個(gè)主機(jī)增加監(jiān)控圖形),
我們選擇監(jiān)控本地主機(jī)的磁盤空間,點(diǎn)擊“Create”即可。下面我們來點(diǎn)擊最上面的“Graph”標(biāo)簽 。如下圖,
從圖中我們可以看到我們新增加的監(jiān)控磁盤空間的圖形還沒有出圖,我們得等個(gè)幾分鐘才會(huì)出現(xiàn)圖形,請(qǐng)博友耐心等待。好了,過幾分鐘就會(huì)出現(xiàn)下面的效果圖,
再過幾分鐘就會(huì)出現(xiàn)最終效果圖,如下圖
好了,到這里我們配置Cacti監(jiān)控localhost就全部完成了。在一下篇博文中我們主要講解Cacti怎么監(jiān)控遠(yuǎn)程主機(jī)與Cacti的高級(jí)應(yīng)用。最后,希望大家有所收獲吧^_^……
網(wǎng)站欄目:Cacti安裝配置Cacti監(jiān)控本機(jī)