等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)自2013年起到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設就選創(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原理與實戰(zhàn)、RRDTool繪圖工具使用,這幾篇博文都是做為鋪墊來為我們講解Cacti監(jiān)控工具做準 備,通過上面博文的講解,我們知道可以通過snmp協(xié)議來收集遠程主機的系統(tǒng)狀態(tài)信息,如CPU使用率、內(nèi)存的使用率、網(wǎng)卡流量、TCP連接數(shù)據(jù)等,然后 將收集的數(shù)據(jù)保存在RRD文件中,再通過RRTool復雜的命令行工具來繪圖。通過實際操作我們會發(fā)現(xiàn),雖然RRDTool繪圖工具功能很強大,但是使用 非常的復雜。還有以下缺點,
RRDTool只能存儲數(shù)據(jù)和畫圖,它沒有像MRTG中集成的數(shù)據(jù)采集功能,要手動收集數(shù)據(jù)或寫腳本收集數(shù)據(jù)。
Cacti 在英文中的意思是仙人掌的意思,Cacti是一套基于PHP、MySQL、SNMP及RRDTool開發(fā)的網(wǎng)絡流量監(jiān)測圖形分析工具。它通過 snmpget來獲取數(shù)據(jù),使用 RRDtool繪畫圖形,它的界面非常漂亮,能讓你根本無需明白rrdtool的參數(shù)能輕易的繪出漂亮的圖形。而且你完全可以不需要了解RRDtool復 雜的參數(shù)。它提供了非常強大的數(shù)據(jù)和用戶管理功能,可以指定每一個用戶能查看樹狀結 構、host以及任何一張圖,還可以與LDAP結合進行用戶驗證,同時也能自己增加模板,讓你添加自己的snmp_query和script!功能非常強 大完善,界面友好??梢哉f,Cacti將rrdtool的所有“缺點”都補足了!下圖是Cacti運行的主界面,
好了,在前面的幾篇博客中我們講解了SNMP協(xié)議,也講解了RRDTool工具的使用,現(xiàn)在再來學習Cacti就非常的簡單了,下面我們來安裝并使用Cacti。
注,Cacti的運行是基于LAMP環(huán)境的首先我們來安裝LAMP環(huán)境。(LAMP環(huán)境安裝有兩種方法,有時間的博友可以使用源碼安裝,不想用源碼安裝的博友可以參考我的安裝方法全部用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();
?>
好了,當大家看到這個頁面時,就說明我們php環(huán)境安裝完成,下面我們來測試mysql數(shù)據(jù)庫。
[
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
接下來啟動net-snmp并測試一下,
1
2
3
4
5
6
7
8
9
10
11
[root@node1 ~] # service snmpd start
正在啟動 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
下面來測試一下,
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)境準備就全部完成了,下面我們來安裝與配置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就是個PHP程序是基于LAMP環(huán)境運行的,下面我們來為Cacti配置虛擬主機,
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程序移動到/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ù)庫的語句,所以下面我們來配置一下Cacti數(shù)據(jù)庫,
1
2
[root@node1 cacti] # mysqladmin create cactidb
[root@node1 cacti] # mysql cactidb < cacti.sql
因為cacti要訪問數(shù)據(jù)庫,所以我們得給cacti創(chuàng)建一個授權用戶,
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 = "/" ; #這一行非常重要設置cacti程序訪問路徑的
下面我們來創(chuàng)建一個cacti用戶(安裝初始化cacti)并修改相關目錄權限,
1
2
3
[root@node1 ~] # cd /web/vhosts/cacti/
[root@node1 cacti] # useradd cactiuser
[root@node1 cacti] # chown -R cactiuser:cactiuser log/ rra/
接下來重新啟動一下httpd并初始化cacti,首先我們得修改 Win 7的hosts文件,C:WindowsSystem32driversetchosts,新增一行:
1
192.168.18.201 cacti. test .com
下面我們用瀏覽器訪問一下:http://cacti.test.com/install,會彈出cacti初始化界面,如下圖
我們點擊”Next”繼續(xù),
接下來讓你選擇全新安裝還是升級安裝,我們這里肯定選擇”New Install”,點擊“Next”繼續(xù),
接下來會檢查所有配置選項,若有不符合要求的會用紅色標出,我們這里全部符合要求,點擊“Finish”繼續(xù),
直接跳轉到cacti的登錄頁面,到這里我們cacti初始化就全部完成了,下面我們登錄一下,默認用戶名和密碼都為”admin”。
第一下次登錄時讓你修改默認的用戶名和密碼,自己設置一個即可。
好了,到這里我們已經(jīng)可以看cacti的配置界面了,下面我們就來詳細的看一下。從上圖中我們可以看到最上面有兩個標簽一個是紅顏色的“console”控制臺標簽,另一個是“graphs”圖像標簽,下面我們點擊一下“graphs”標簽,如下圖:
大家可以從圖上看到,由于我們還沒做任何配置,所以這里沒有任何圖像。好了,下面我們就來詳細說一說這兩個標簽中內(nèi)容。先說,console 標簽。
大家先看左邊這一欄,從圖中我們可以看出,大致分為七個大項和多個項目。下面我們來的羅列一下,分別講解。
(1).Create 創(chuàng)建
New Graphs 添加新圖形
(2).Management 管理
Graph Management 圖形管理。可以在此刪除、復制圖像,Cacti會自動創(chuàng)建圖像。不過如果我們有特殊的需要,比如將幾張圖上的數(shù)據(jù)合并在一張圖像上的話也可以在此手工新建圖像;
Graph Trees 圖形樹。在graphs界面里,圖像或devices是樹狀結構顯示的,可以在此設置樹的結構;
Data Sources 數(shù)據(jù)源。記要用來管理rrd文件的,一般無需修改,Cacti會自己創(chuàng)建rrd文件;
Devices 設備管理。這是我們最經(jīng)常需要修改的地方,可以在此創(chuàng)建新的設備或修改其名稱等信息。
(3).Collection Methods 數(shù)據(jù)收集方法,一般我們無需對這兩項進行修改。(非常重要在下面的內(nèi)容中進行詳解)
Data Queries 數(shù)據(jù)查詢,
Data Input Methods 數(shù)據(jù)輸入方法
(4).Templates 模板,這些模板可以導出、導入也可以自己編寫,一般無需修改。
Graph Templates 圖形模板
Host Templates 主機模板
Data Templates 數(shù)據(jù)模板
(5).Import/Export 導入/導出,對上述模板的導入、導出。我們可以在Cacti的官方網(wǎng)站上找到這些模板,不過需要注意模板對于的Cacti的版本。
Import Templates 導入模板
Export Templates 導出模板
(6).Configuration 配置
Settings 系統(tǒng)設置,Cacti的主要配置菜單;可以在此重新設置對應的程序的路徑、版本等信息。也可以設置圖像的輸出方式(允許ftp)、顯示效果、登陸方式(允許使用LDAP)等。
Plugin Management 插件管理
(7).Utilities 工具
System Utilities 系統(tǒng)工具,顯示Cacti系統(tǒng)的一些cache和log信息,如果log文件太大建議直接到后臺查看;
User Management 用戶管理,可以在此添加、刪除用戶,并對每個用戶設置詳細的權限;
Logout User 用戶退出
里面的具體內(nèi)容請大家自己去看,下面我們來講解一下第三大項收集方法,收集方法即數(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í)行一次呢?執(zhí)行的時間是cacti程序設置的,下面我們來配置cacti安裝的最重要的一步也是最后一步,設置cacti收集數(shù)據(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
這里任務計劃是由poller.php程序執(zhí)行的,需要說明的是poller.php是由php寫的,單線程的功能相對較弱,為此cacti官方單獨開發(fā)了一個多線程Spine工具,適合大規(guī)模監(jiān)控應用。好了下面我們就來配置一下任務計劃并查看。
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
為了防止這個任務計劃不執(zhí)行,我們最好手動驗證一下,
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 ~]$
大家可以看到上面報了一大堆錯,是什么錯誤喲?主要是因為我們php.ini的時區(qū)設置的不對,下面我們來修改一下php時區(qū)。
1
2
3
4
5
[root@node1 cacti] # vim /etc/php.ini
date .timezone = Asia /Shanghai
[root@node1 cacti] # service httpd restart
停止 httpd: [確定]
正在啟動 httpd: [確定]
接下來我們再來測試一下,
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)控本機。
五、配置Cacti監(jiān)控本機
首先我們點擊一下“Devices”標簽,出下以下界面,大家從圖中可以看出,默認的主機就是Localhost。
接下來我們點擊一下“Localhost”主機,出現(xiàn)以下界面。
上圖是默認的配置,我們只要修改一處即可,便是“SNMP Options”。如下圖,
只要選擇SNMP版本為“Version2”,點擊下面的“Save”即可。效果圖如下
接下來我們選擇右上腳的“Create Graphs for this Host”(為這個主機增加監(jiān)控圖形),
我們選擇監(jiān)控本地主機的磁盤空間,點擊“Create”即可。下面我們來點擊最上面的“Graph”標簽 。如下圖,
從圖中我們可以看到我們新增加的監(jiān)控磁盤空間的圖形還沒有出圖,我們得等個幾分鐘才會出現(xiàn)圖形,請博友耐心等待。好了,過幾分鐘就會出現(xiàn)下面的效果圖,
再過幾分鐘就會出現(xiàn)最終效果圖,如下圖
好了,到這里我們配置Cacti監(jiān)控localhost就全部完成了。在一下篇博文中我們主要講解Cacti怎么監(jiān)控遠程主機與Cacti的高級應用。最后,希望大家有所收獲吧^_^……