大綱php
1、前言html
2、Cacti 概述node
3、Cacti 工做流程mysql
4、Cacti 安裝 web
5、配置Cacti監控本機 sql
注,操做系統 CentOS 6.4 x86_84,軟件版本 Cacti-0.8.8b 目前最新版。 (說明:本博文的一些圖片自於開源社區與官方網站並非全部內容全是原創)數據庫
1、前言vim
在 前面的幾篇博客中咱們講解了,監控的概述、SNMP原理與實戰、RRDTool繪圖工具使用,這幾篇博文都是作爲鋪墊來爲咱們講解Cacti監控工具作準 備,經過上面博文的講解,咱們知道能夠經過snmp協議來收集遠程主機的系統狀態信息,如CPU使用率、內存的使用率、網卡流量、TCP鏈接數據等,而後 將收集的數據保存在RRD文件中,再經過RRTool複雜的命令行工具來繪圖。經過實際操做咱們會發現,雖然RRDTool繪圖工具功能很強大,可是使用 很是的複雜。還有如下缺點,瀏覽器
RRDTool只能存儲數據和畫圖,它沒有像MRTG中集成的數據採集功能,要手動收集數據或寫腳本收集數據。服務器
在命令行下的使用很是複雜,參數極多。
無用戶、圖像管理功能
而後咱們就會說了,有沒有什麼工具能補全以上缺點呢?答案是確定有的,下面咱們就來講一說咱們這篇博文的主角Cacti。
2、Cacti概述
Cacti 在英文中的意思是仙人掌的意思,Cacti是一套基於PHP、MySQL、SNMP及RRDTool開發的網絡流量監測圖形分析工具。它經過 snmpget來獲取數據,使用 RRDtool繪畫圖形,它的界面很是漂亮,能讓你根本無需明白rrdtool的參數能輕易的繪出漂亮的圖形。並且你徹底能夠不須要了解RRDtool復 雜的參數。它提供了很是強大的數據和用戶管理功能,能夠指定每個用戶能查看樹狀結 構、host以及任何一張圖,還能夠與LDAP結合進行用戶驗證,同時也能本身增長模板,讓你添加本身的snmp_query和script!功能很是強 大完善,界面友好。能夠說,Cacti將rrdtool的全部「缺點」都補足了!下圖是Cacti運行的主界面,
官方網站:http://www.cacti.net。好了,Cacti的簡單介紹咱們就說到這裏了,下面咱們來看一下Cacti的工做流程。
3、Cacti 工做流程
下面咱們來簡單的說明一下Cacti的工做流程,
步驟一,snmp協議收集遠程服務器的數據
步驟二,將snmp收集的數據內容保存到rrd數據庫中
步驟三,若用戶查看某臺設備上的流量或其它狀態信息
步驟四,在mysql數據庫中查找該設備對應的rra數據庫文件的名稱
步驟五,經過rrdtool命令進行繪圖便可
好了,在前面的幾篇博客中咱們講解了SNMP協議,也講解了RRDTool工具的使用,如今再來學習Cacti就很是的簡單了,下面咱們來安裝並使用Cacti。
4、Cacti 安裝
注,Cacti的運行是基於LAMP環境的首先咱們來安裝LAMP環境。(LAMP環境安裝有兩種方法,有時間的博友可使用源碼安裝,不想用源碼安裝的博友能夠參考個人安裝方法所有用yum安裝。)下面咱們來具體演示一下,
1.安裝yum源
1
2
3
4
|
[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
#我這邊已經安裝好了
|
2.同步時間
1
2
|
[root@node1 ~]
# ntpdate 202.120.2.101
12 Oct 11:03:56 ntpdate[13805]: adjust
time
server 202.120.2.101 offset 0.000661 sec
|
3.安裝LAMP環境
首先,用yum安裝相關軟件包,
1
|
[root@node1 ~]# yum install -y httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server gd gd-devel
|
設置開機自啓動並啓動服務,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@node1 ~]
# chkconfig httpd on
[root@node1 ~]
# service httpd start
正在啓動 httpd: [肯定]
[root@node1 ~]
# chkconfig mysqld on
[root@node1 ~]
# service mysqld start
正在啓動 mysqld: [肯定]
[root@node1 ~]
# netstat -ntulp
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 1045
/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1122
/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 13786
/sshd
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN 17820
/sshd
tcp 0 0 127.0.0.1:6013 0.0.0.0:* LISTEN 31664
/sshd
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 13017
/snmpd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 13375
/mysqld
tcp 0 0 :::80 :::* LISTEN 13917
/httpd
tcp 0 0 :::22 :::* LISTEN 1045
/sshd
tcp 0 0 ::1:25 :::* LISTEN 1122
/master
tcp 0 0 ::1:6010 :::* LISTEN 13786
/sshd
tcp 0 0 ::1:6012 :::* LISTEN 17820
/sshd
tcp 0 0 ::1:6013 :::* LISTEN 31664
/sshd
udp 0 0 0.0.0.0:161 0.0.0.0:* 13017
/snmpd
|
提供php頁面並測試php環境,
1
2
3
4
5
|
[root@node1 ~]
# cd /var/www/html/
[root@node1 html]
# vim index.php
<?php
phpinfo();
?>
|
好了,當你們看到這個頁面時,就說明咱們php環境安裝完成,下面咱們來測試mysql數據庫。
[
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環境就安裝完成了,下面咱們來安裝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 <tobi@oetiker.ch>
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
首先咱們去下載Cacti,
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環境運行的,下面咱們來爲Cacti配置虛擬主機,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@node1 ~]
# vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot
/web/vhosts/cacti
ServerName cacti.
test
.com
ErrorLog logs
/cacti
.
test
.com-error_log
CustomLog logs
/cacti
.
test
.com-access_log common
<Directory
"/web/vhosts/cacti"
>
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
: 已建立目錄
"/web"
mkdir
: 已建立目錄
"/web/vhosts"
mkdir
: 已建立目錄
"/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到全部表的語句,可是沒有建立數據庫的語句,因此下面咱們來配置一下Cacti數據庫,
1
2
|
[root@node1 cacti]
# mysqladmin create cactidb
[root@node1 cacti]
# mysql cactidb < cacti.sql
|
由於cacti要訪問數據庫,因此咱們得給cacti建立一個受權用戶,
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程序訪問路徑的
|
下面咱們來建立一個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:\Windows\System32\drivers\etc\hosts,新增一行:
1
|
192.168.18.201 cacti.
test
.com
|
下面咱們用瀏覽器訪問一下:http://cacti.test.com/install,會彈出cacti初始化界面,以下圖
咱們點擊」Next」繼續,
接下來讓你選擇全新安裝仍是升級安裝,咱們這裏確定選擇」New Install」,點擊「Next」繼續,
接下來會檢查全部配置選項,如有不符合要求的會用紅色標出,咱們這裏所有符合要求,點擊「Finish」繼續,
直接跳轉到cacti的登陸頁面,到這裏咱們cacti初始化就所有完成了,下面咱們登陸一下,默認用戶名和密碼都爲」admin」。
第一下次登陸時讓你修改默認的用戶名和密碼,本身設置一個便可。
好了,到這裏咱們已經能夠看cacti的配置界面了,下面咱們就來詳細的看一下。從上圖中咱們能夠看到最上面有兩個標籤一個是紅顏色的「console」控制檯標籤,另外一個是「graphs」圖像標籤,下面咱們點擊一下「graphs」標籤,以下圖:
你們能夠從圖上看到,因爲咱們還沒作任何配置,因此這裏沒有任何圖像。好了,下面咱們就來詳細說一說這兩個標籤中內容。先說,console 標籤。
你們先看左邊這一欄,從圖中咱們能夠看出,大體分爲七個大項和多個項目。下面咱們來的羅列一下,分別講解。
(1).Create 建立
New Graphs 添加新圖形
(2).Management 管理
Graph Management 圖形管理。能夠在此刪除、複製圖像,Cacti會自動建立圖像。不過若是咱們有特殊的須要,好比將幾張圖上的數據合併在一張圖像上的話也能夠在此手工新建圖像;
Graph Trees 圖形樹。在graphs界面裏,圖像或devices是樹狀結構顯示的,能夠在此設置樹的結構;
Data Sources 數據源。記要用來管理rrd文件的,通常無需修改,Cacti會本身建立rrd文件;
Devices 設備管理。這是咱們最常常須要修改的地方,能夠在此建立新的設備或修改其名稱等信息。
(3).Collection Methods 數據收集方法,通常咱們無需對這兩項進行修改。(很是重要在下面的內容中進行詳解)
Data Queries 數據查詢,
Data Input Methods 數據輸入方法
(4).Templates 模板,這些模板能夠導出、導入也能夠本身編寫,通常無需修改。
Graph Templates 圖形模板
Host Templates 主機模板
Data Templates 數據模板
(5).Import/Export 導入/導出,對上述模板的導入、導出。咱們能夠在Cacti的官方網站上找到這些模板,不過須要注意模板對於的Cacti的版本。
Import Templates 導入模板
Export Templates 導出模板
(6).Configuration 配置
Settings 系統設置,Cacti的主要配置菜單;能夠在此從新設置對應的程序的路徑、版本等信息。也能夠設置圖像的輸出方式(容許ftp)、顯示效果、登錄方式(容許使用LDAP)等。
Plugin Management 插件管理
(7).Utilities 工具
System Utilities 系統工具,顯示Cacti系統的一些cache和log信息,若是log文件太大建議直接到後臺查看;
User Management 用戶管理,能夠在此添加、刪除用戶,並對每一個用戶設置詳細的權限;
Logout User 用戶退出
裏面的具體內容請你們本身去看,下面咱們來說解一下第三大項收集方法,收集方法即數據收集方法。其中,有兩種方法:
數據查詢:xml格式數據收集方法
數據輸入方法:命令或腳本(比較經常使用)
注,腳本只須要指定如何獲取數據,而且獲取到的數據通過處理後要按元寶輸出。案例,
1
2
|
TAG:data TAG:data
input:30 output:40
|
好了,咱們用腳本定義了收集數據方法,也指定了數據輸出,那腳本多長時間執行一次呢?執行的時間是cacti程序設置的,下面咱們來配置cacti安裝的最重要的一步也是最後一步,設置cacti收集數據的默認的任務計劃。
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程序執行的,須要說明的是poller.php是由php寫的,單線程的功能相對較弱,爲此cacti官方單獨開發了一個多線程Spine工具,適合大規模監控應用。好了下面咱們就來配置一下任務計劃並查看。
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
|
爲了防止這個任務計劃不執行,咱們最好手動驗證一下,
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的時區設置的不對,下面咱們來修改一下php時區。
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
|
查看一下執行日誌,
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讓它來監控本機。
5、配置Cacti監控本機
首先咱們點擊一下「Devices」標籤,出下如下界面,你們從圖中能夠看出,默認的主機就是Localhost。
接下來咱們點擊一下「Localhost」主機,出現如下界面。
上圖是默認的配置,咱們只要修改一處便可,即是「SNMP Options」。以下圖,
只要選擇SNMP版本爲「Version2」,點擊下面的「Save」便可。效果圖以下,
接下來咱們選擇右上腳的「Create Graphs for this Host」(爲這個主機增長監控圖形),
咱們選擇監控本地主機的磁盤空間,點擊「Create」便可。下面咱們來點擊最上面的「Graph」標籤 。以下圖,
從圖中咱們能夠看到咱們新增長的監控磁盤空間的圖形尚未出圖,咱們得等個幾分鐘纔會出現圖形,請博友耐心等待。好了,過幾分鐘就會出現下面的效果圖,
再過幾分鐘就會出現最終效果圖,以下圖
好了,到這裏咱們配置Cacti監控localhost就所有完成了。在一下篇博文中咱們主要講解Cacti怎麼監控遠程主機與Cacti的高級應用。最後,但願你們有所收穫吧^_^……