溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

發(fā)布時(shí)間:2020-05-28 07:11:51 來(lái)源:網(wǎng)絡(luò) 閱讀:21203 作者:風(fēng)過(guò)_無(wú)痕 欄目:數(shù)據(jù)庫(kù)

一、原理介紹:

  1. SNMP簡(jiǎn)介      
  目前網(wǎng)絡(luò)中用得最廣泛的網(wǎng)絡(luò)管理協(xié)議是SNMP(Simple Network Management Protocol,簡(jiǎn)單網(wǎng)絡(luò)管理協(xié)議)。SNMP是被廣泛接受并投入使用的工業(yè)標(biāo)準(zhǔn),用于保證管理信息在網(wǎng)絡(luò)中任意兩點(diǎn)間傳送,便于網(wǎng)絡(luò)管理員在網(wǎng)絡(luò)上的任何節(jié)點(diǎn)檢索信息、修改信息、定位故障、完成故障診斷、進(jìn)行容量規(guī)劃和生成報(bào)告。    
SNMP采用輪詢(xún)機(jī)制,只提供最基本的功能集,特別適合在小型、快速和低價(jià)格的環(huán)境中使用。SNMP的實(shí)現(xiàn)基于無(wú)連接的傳輸層協(xié)議UDP,因此可以實(shí)現(xiàn)和眾多產(chǎn)品的無(wú)障礙連接。


  2. SNMP的工作機(jī)制      
SNMP分為NMS和Agent兩部分:    
NMS(Network Management Station,網(wǎng)絡(luò)管理站)是運(yùn)行客戶(hù)端程序的工作站,目前常用的網(wǎng)管平臺(tái)有QuidView、Sun NetManager和IBM NetView。    
Agent運(yùn)行在網(wǎng)絡(luò)設(shè)備上的服務(wù)器端軟件。    
NMS可以向Agent發(fā)出GetRequest、GetNextRequest和SetRequest報(bào)文,Agent接收到NMS的這些請(qǐng)求報(bào)文后,根據(jù)報(bào)文類(lèi)型進(jìn)行Read或Write操作,生成Response報(bào)文,并將報(bào)文返回給NMS。    
Agent在設(shè)備發(fā)生異常情況或狀態(tài)改變時(shí)(如設(shè)備重新啟動(dòng)),也會(huì)主動(dòng)向NMS發(fā)送Trap報(bào)文,向NMS匯報(bào)所發(fā)生的事件。


  3. SNMP的版本      
目前,設(shè)備中的SNMP Agent支持SNMP v3版本,兼容SNMP v1版本、SNMP v2C版本。    
SNMP v3采用用戶(hù)名和密碼認(rèn)證方式。    
SNMP v1、SNMP v2C采用團(tuán)體名(Community Name)認(rèn)證,非設(shè)備認(rèn)可團(tuán)體名的SNMP報(bào)文將被丟棄。SNMP團(tuán)體名用來(lái)定義SNMP NMS和SNMP Agent的關(guān)系。團(tuán)體名起到了類(lèi)似于密碼的作用,可以限制SNMP NMS訪問(wèn)設(shè)備上的SNMP Agent。用戶(hù)可以選擇指定以下一個(gè)或者多個(gè)與團(tuán)體名相關(guān)的特性:    
1.定義團(tuán)體名可以訪問(wèn)的MIB視圖。

2.設(shè)置團(tuán)體名對(duì)MIB對(duì)象的訪問(wèn)權(quán)限為讀寫(xiě)權(quán)限(write)或者只讀權(quán)限(read)。具有只讀權(quán)限的團(tuán)體名只能對(duì)設(shè)備信息進(jìn)行查詢(xún),而具有讀寫(xiě)權(quán)限的團(tuán)體名還可以對(duì)設(shè)備進(jìn)行配置。  
3.設(shè)置團(tuán)體名指定的基本訪問(wèn)控制列表。


  4. 設(shè)備支持的MIB      
在SNMP報(bào)文中用管理變量來(lái)描述設(shè)備中的管理對(duì)象。為了唯一標(biāo)識(shí)設(shè)備中的管理對(duì)象,SNMP用層次結(jié)構(gòu)命名方案來(lái)識(shí)別管理對(duì)象。整個(gè)層次結(jié)構(gòu)就像一棵樹(shù),樹(shù)的節(jié)點(diǎn)表示管理對(duì)象,如下圖1-1所示。每一個(gè)節(jié)點(diǎn),都可以用從根開(kāi)始的一條路徑唯一地標(biāo)識(shí)。

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

MIB(Management Information Base,管理信息庫(kù))的作用就是用來(lái)描述樹(shù)的層次結(jié)構(gòu),它是所監(jiān)控網(wǎng)絡(luò)設(shè)備的標(biāo)準(zhǔn)變量定義的集合。在圖1-1中,管理對(duì)象B可以用一串?dāng)?shù)字{1.2.1.1}唯一確定,這串?dāng)?shù)字是管理對(duì)象的對(duì)象標(biāo)識(shí)符(Object Identifier)。    
系統(tǒng)支持的常見(jiàn)MIB如下表1-1所示。

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti 


二、RRDtool安裝,分析及使用:

工作原理圖:

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

整個(gè)系統(tǒng)有四部分組成:

1、Cacti系統(tǒng)平臺(tái)用于用戶(hù)設(shè)置與查看圖表;Cacti需要LAMP環(huán)境的支持。

2、snmp用于采集數(shù)據(jù)給rrdtool繪制成圖,使用161.162端口,用MIB數(shù)據(jù)庫(kù)來(lái)保持?jǐn)?shù)據(jù)信息,根據(jù)OID定位數(shù)據(jù)(類(lèi)似1.3.6.1.2.1);Linux下使用net-snmp自帶的snmpget和snmpwalk等程序,Windows下使用php的snmp功能。

3、RRDTool繪圖引擎用于性能數(shù)據(jù)的存儲(chǔ)和繪畫(huà)圖像。

4、Mysql數(shù)據(jù)庫(kù)用來(lái)存儲(chǔ)RRDTool繪圖所需要的信息。


Cacti常見(jiàn)的監(jiān)測(cè)對(duì)象:

1、服務(wù)器資源:CPU、內(nèi)存、磁盤(pán)、進(jìn)程、連接數(shù)等

2、服務(wù)器類(lèi)型:WEB、MailFTP、數(shù)據(jù)庫(kù)

3、網(wǎng)絡(luò)接口:流量、轉(zhuǎn)發(fā)速度、丟包率


Cacti偏重于網(wǎng)絡(luò)流量,系統(tǒng)負(fù)載方面的監(jiān)控(網(wǎng)絡(luò)流量,cpu,硬盤(pán)使用率等)


1、安裝cacti基于lamp環(huán)境(apache+mysql+php+net-snmp+rrdtool)

1

yum install -y httpd httpd-devel mysql mysql-server mysql-devel

php php-devel php-mysql php-common php-gd php-mbstring php-xml

php-imap php-ldap php-odbc php-pear php-xmlrpc php-bcmath

gd gd-devel freetype freetype-devel libjpeg libjpeg-devel libpng

libpng-devel zlib zlib-devel libxml2 libxml2-devel libjpeg* libgcrypt

libgcrypt-devel libxslt libxslt-devel php-snmp net-snmp net-snmp-utils

perl-DBI rrdtool perl-rrdtool perl-DBD-MySQL net-snmp-libs lm_sensors

1
2
3
4
5
service httpd start
service mysqld start
chkconfig httpd on
chkconfig mysqld on
mysqladmin -u root password root   #設(shè)置mysql登錄密碼

2、安裝配置cacti

1)、安裝cacti

1
2
3
wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
tar zxvf cacti-0.8.8b.tar.gz
mv cacti-0.8.8b/* /var/www/html

2)、導(dǎo)入數(shù)據(jù)庫(kù)結(jié)構(gòu)

1
2
3
mysql>create database cacti;
mysql>use cacti;
mysql>source /var/www/html/cacti.sql;

3)、配置cacti連接數(shù)據(jù)庫(kù):

1
2
3
4
5
6
7
8
9
vi /var/www/html/include/config.php
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "root";
$database_port = "3306";
$database_ssl = false;
$url_path = "/";  #去掉注釋?zhuān)薷穆窂綖楦?/code>

4)、圖形安裝cacti,輸入IP開(kāi)始安裝

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

默認(rèn)用戶(hù)、密碼都是admin,輸入后會(huì)讓你修改密碼用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti



5)、配置snmp監(jiān)控本地主機(jī)

1
2
3
4
5
vi /etc/snmp/snmpd.conf
com2sec notConfigUser 127.0.0.1 public
access notConfigGroup "" any noauth exact all none none
view all included .1 80
service snmpd restart

3、cacti其他配置

1)、php設(shè)置時(shí)區(qū)

1
2
3
vi /etc/php.ini
date.timezone = Asia/Shanghai
service httpd restart

2)、手動(dòng)運(yùn)行一次,生成初始圖像文件: (編繹安裝路徑/usr/local/apache/htdocs/)

1
/usr/bin/php /var/www/html/poller.php

3)、設(shè)置計(jì)劃任務(wù),每五分鐘生成一次圖表:

1
2
crontab -e
*/5 * * * * /usr/bin/php /var/www/html/poller.php

4)、修改cacti默認(rèn)設(shè)置:console->setting

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

rrdtool -v #查看rrdtool版本

snmp version :設(shè)置snmp版本,一般是version2

snmp community:設(shè)置共同體名,默認(rèn)是public

5)、設(shè)置權(quán)限:

1
2
3
4
chown -R apache.root /var/www/html/
chmod 775 -R /var/www/html
chmod 777 /var/www/html/rra /var/www/html/log
chown -R root.root /var/www/html/rra /var/www/html/log

6)、監(jiān)控本地主機(jī)

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

配置完后,查看localhost發(fā)現(xiàn)不出圖都是-nan:用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

解決:rrdtool fetch -r 300 localhost_mem_buffers_3.rrd AVERAGE #使用rrdtool獲取抓取的信息,結(jié)果都是-nan,現(xiàn)在看最后一個(gè)日期是1379679000,當(dāng)date +%s獲取的日期超過(guò)最后一個(gè),就該出圖了。

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti


4、監(jiān)控Linux主機(jī)

被監(jiān)控主機(jī)配置SNMP:

1
2
3
4
5
6
yum install -y net-snmp-*
vi /etc/snmp/snmpd.conf
com2sec notConfigUser 192.168.0.10 public #改為允許監(jiān)控主機(jī)的IP
access notConfigGroup "" any noauth exact all none none
view all included .1 80
service snmpd restart  #重啟snmp

監(jiān)控主機(jī)添加設(shè)備:

Console->Device->Add->create

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

添加到圖形樹(shù):

Console->Graph Trees->Add->Tree Item Type->Host->選擇主機(jī)->create


5、監(jiān)控Windows主機(jī)

  首先主機(jī)已經(jīng)添加snmp服務(wù)了,再安裝snmp-informant-std會(huì)在服務(wù)里面多出SNMP Trap,不需要配置,然后配置Snmp Service:

  開(kāi)始—運(yùn)行—services.msc,找到“snmp service”,右鍵打開(kāi)“屬性”,選擇“安全”,在“接受團(tuán)體名稱(chēng)”處,點(diǎn)“添加”,在“團(tuán)體名稱(chēng)”處寫(xiě)入你的cacti使用的community,選中“接受來(lái)自這些主機(jī)的snmp數(shù)據(jù)包”,默認(rèn)值為“l(fā)ocalhost”,點(diǎn)擊“編輯”,將“l(fā)ocalhost”改為cacti監(jiān)控服務(wù)器的實(shí)際 ip地址即可!


6、不出圖或不出數(shù)據(jù)以下入手解決

1.圖像沒(méi)有生成,運(yùn)行 #/usr/bin/php /var/www/html/poller.php

2.權(quán)限問(wèn)題,修改權(quán)限 #chmod 777 -R /var/www/html/rra /var/www/html/log/

3.snmp配置問(wèn)題,檢測(cè)是否有數(shù)據(jù)輸出 #snmpwalk -v2c -c public 127.0.0.1

4.刪除rra下所有文件,清除緩存 #system utilities –>Rebuild poller cache

5.系統(tǒng)時(shí)間不準(zhǔn)確,重新設(shè)置時(shí)間 date.timezone = PRC

6.數(shù)據(jù)庫(kù)表有損壞,修復(fù) #mysqlcheck -ao cacti -auto-repair -uroot -p

7.不顯示圖片也不顯示數(shù)據(jù)  #service snmpd restart

7.嘗試重啟snmpd服務(wù) #service snmpd restart


到此安裝完畢?。?!



7、相關(guān)詳細(xì)配制1 --- 以下為通過(guò)RRDtool命令查看數(shù)據(jù)

[root@localhost ~]# yum install net-snmp

[root@localhost ~]# yum install net-snmp-utils

[root@localhost ~]# snmpwalk -v 2c -c public localhost host
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (1618864) 4:29:48.64
HOST-RESOURCES-MIB::hrSystemUptime.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
[root@localhost ~]# snmpwalk -v 2c -c public localhost

SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-164.el5PAE #1 SMP Tue Aug 18 15:59:11 EDT 2009 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (745096) 2:04:10.96
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (13) 0:00:00.13
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for ma

[root@localhost ~]# vi /etc/snmp/snmpd.conf

# First, map the community name "public" into a "security name"
#       sec.name        source          community
#com2sec notConfigUser   default         public
com2sec notConfigUser  127.0.0.1        mypublic
com2sec notConfigUser  10.109.0.0/16    mypublic

# Second, map the security name into a group name:
#       groupName       securityModel   securityName
group   notConfigGroup  v1              notConfigUser
group   notConfigGroup  v2c             notConfigUser

[root@localhost ~]# service snmpd restart

[root@localhost ~]# snmpwalk -v 2c -c mypublic  10.109.131.198
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-164.el5PAE #1 SMP Tue Aug 18 15:59:11 EDT 2009 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (15379) 0:02:33.79
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
... ...

[root@localhost ~]# chkconfig snmpd on
[root@localhost ~]# chkconfig --list snmpd
snmpd              0:off    1:off    2:on    3:on    4:on    5:on    6:off

[root@localhost ~]# yum install ruby

...

Downloading Packages:
(1/2): ruby-libs-1.8.5-5.el5_3.7.i386.rpm      | 1.6 MB     00:00     
(2/2): ruby-1.8.5-5.el5_3.7.i386.rpm         | 274 kB     00:00

...

[root@localhost ~]# rpm -ivh rrdtool-1.2.27-4.el5.i386.rpm
[root@localhost ~]# rpm -ivh rrdtool-perl-1.2.27-4.el5.i386.rpm
[root@localhost ~]#
rrdtool create test.rrd --step 5 --start -1 DS:testds:GAUGE:8:0:U RRA:AVERAGE:0.5:1:17280 RRA:AVERAGE:0.5:10:3456 RRA:AVERAGE:0.5:100:1210
[root@localhost ~]# ll -h test.rrd
-rw-r--r--  1 root root  173K Feb 22 16:14 test.rrd
[root@localhost ~]# rrdtool info test.rrd
filename = "test.rrd"
rrd_version = "0003"
step = 5
last_update = 1487751267
ds[testds].type = "GAUGE"
ds[testds].minimal_heartbeat = 8
ds[testds].min = 0.0000000000e+00
ds[testds].max = NaN
ds[testds].last_ds = "UNKN"
...

[root@localhost ~]# cat insert.sh
#!/bin/bash
#
for I in {1..200000}; do
    mysql -e "INSERT INTO testdb.tb1(NAME) VALUES ('stu$I')"
    mysql -e "SELECT * FROM testdb.tb1" &> /dev/null
done

[root@localhost ~]# cat   getselect.sh

#!/bin/bash
#
while true; do
    SELECT=`mysql --batch -e "SHOW GLOBAL STATUS LIKE 'com_select'" | awk '/Com_select/{print $2}'`
    rrdtool update mysql.rrd N:$SELECT
    sleep 3
done


  573  rrdtool fetch -r 5  mysql.rrd AVERAGE
  574  rrdtool fetch -r 30  mysql.rrd AVERAGE
  575  rrdtool fetch -r 30  mysql.rrd max
  576  rrdtool fetch -r 30  mysql.rrd MAX
  577  rrdtool fetch -r 30  mysql.rrd LAST

  580  rrdtool graph mysql.png -s 1487747370 -t "mysql select" -v "select/3" DEF:select3=mysql.rrd:myselect:AVERAGE:step=3 LINE1:select3#FF0000:"SELECT"
  581  rrdtool graph mysql.png -s 1487747370 -t "mysql select" -v "select/30" DEF:select3=mysql.rrd:myselect:AVERAGE:step=30 LINE1:select3#FF0000:"SELECT"
  583  rrdtool graph mysql2.png -s 1487747370 -t "mysql select" -v "select/3" DEF:select3=mysql.rrd:myselect:AVERAGE:step=30 DEF:max30=mysql.rrd:myselect:MAX:step=30 DEF:last30=mysql.rrd:myselect:LAST:step=30 LINE1:select3#FF0000:"SELECT"
  584  rrdtool graph mysql3.png -s 1487747370 -t "mysql select" -v "select/30" DEF:select3=mysql.rrd:myselect:AVERAGE:step=30 DEF:max30=mysql.rrd:myselect:MAX:step=30 DEF:last30=mysql.rrd:myselect:LAST:step=30 LINE1:select3#FF0000:"SELECT"
  589  rrdtool graph mysql4.png -s 1487747370 -t "mysql select" -v "select/30" DEF:select3=mysql.rrd:myselect:AVERAGE:step=30 DEF:max30=mysql.rrd:myselect:MAX:sep=30 DEF:last30=mysql.rrd:myselect:LAST:step=30 LINE1:select3#FF0000:"SELECT" GPRINT:last30:LAST:"CURRENT\: %10.21f" GPRINT:max30:MAX:"MAXIMUM\:%6.21f"


8、相關(guān)詳細(xì)配制2 --- 創(chuàng)建HTTP虛擬主機(jī)及手動(dòng)查看

[root@localhost ~]# vi /etc/httpd/extra/httpd-vhosts.conf

<VirtualHost *:80>
    ServerName cacti.jacktest.com
    DocumentRoot "/web/vhosts/cacti"
    <Directory "/web/vhosts/cacti">
        Options Indexes
        AllowOverride none
        Require all granted
    </Directory>
    ErrorLog "logs/cacti-error_log"
    CustomLog "logs/cacti-access_log" common
</VirtualHost>

[root@localhost ~]# mkdir /web
[root@localhost ~]# mkdir /web/vhosts
[root@localhost ~]# ls /web/vhosts
[root@localhost ~]# tar xf cacti-0.8.8a.tar.gz -C /web/vhosts/
[root@localhost ~]# cd /web/vhosts/
[root@localhost vhosts]# ll
lrwxrwxrwx  1 root root    12 02-23 09:26 cacti -> cacti-0.8.8a
drwxr-xr-x 13 1000 users 4096 2012-04-23 cacti-0.8.8a

[root@localhost vhosts]# service httpd restart


[root@localhost cacti]# mysqladmin create cactidb
[root@localhost cacti]# mysql cactidb < cacti.sql
[root@localhost cacti]# mysql -e "GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'"
[root@localhost cacti]# mysqladmin flush-privileges
[root@localhost cacti]# mysql -ucactiuser -p

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cactidb            |
| test               |
+--------------------+
3 rows in set (0.01 sec)

[root@localhost cacti]# vi config.php

$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
$database_ssl = false;
/*
   Edit this to point to the default URL of your Cacti install
   ex: if your cacti install as at http://serverip/cacti/ this
   would be set to /cacti/
*/
//$url_path = "/cacti/";
$url_path = "/";

[root@localhost include]# useradd cactiuser

[root@localhost cacti]# pwd
/web/vhosts/cacti

[root@localhost cacti]# chown -R cactiuser:cactiuser rra/ log


poller.php  --===>>  Spine

[root@localhost cacti]# echo '*/5 * * * * /usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php &>/dev/null' > /var/spool/cron/cactiuser    #自動(dòng)5分鐘執(zhí)行一次poller.php
[root@localhost cacti]# crontab -u cactiuser -e

[root@localhost vhosts]# vi /etc/php.ini

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = PRC

[root@localhost vhosts]# service httpd restart

[cactiuser@localhost ~]$ /usr/local/php/bin/php /web/vhosts/cacti/poller.php
02/24/2017 09:44:13 AM - SYSTEM STATS: Time:0.1567 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:0 RRDsProcessed:0

[root@localhost log]# vi  /usr/local/apache/htdocs/cacti/log/cacti.log

02/24/2017 09:40:01 AM - SYSTEM STATS: Time:0.1457 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:0 RRDsProcessed:0
[root@localhost rra]# ls  /usr/local/apache/htdocs/cacti/rra/
localhost_load_1min_5.rrd    localhost_mem_swap_4.rrd  localhost_users_6.rrd
localhost_mem_buffers_3.rrd  localhost_proc_7.rrd


9、相關(guān)詳細(xì)配制3 -- 手動(dòng)查看監(jiān)控文檔

1. 測(cè)試收集命令:

[cactiuser@localhost ~]$ snmpnetstat -v 2c -c public -Can -Cp tcp 10.109.131.144

2. 顯示一個(gè)結(jié)果

[root@localhost htdocs]# vim   /usr/local/apache/htdocs/scripts/tcpconn.sh

#!/bin/bash
#
# $1: hostname or ip
# $2: snmp comunity
SNMPNETSTAT=/usr/bin/snmpnetstat
ESTABLISHED=`$SNMPNETSTAT -v 2c -c $2 -Can -Cp tcp $1 | grep -i 'established' |wc -l`
echo -n "established:$ESTABLISHED"

執(zhí)行結(jié)果:established:19

3. 顯示多個(gè)結(jié)果

#!/bin/bash
#
# $1: hostname or ip
# $2: snmp comunity
SNMPNETSTAT=/usr/bin/snmpnetstat
TEMPFILE=`mktemp /tmp/$1_tcpconn.XXXXXXXX`

$SNMPNETSTAT -v 2c -c $2 -Can -Cp tcp $1 > $TEMPFILE
ESTABLISHED=` grep -i '$ESTABLISHED' $TEMPFILE  |wc -l `
TIMEWAIT=` grep -i '$TIMEWAIT' $TEMPFILE  |wc -l `
SYNRECEIVED=` grep -i '$SYNRECEIVED' $TEMPFILE  |wc -l `

echo -n "established:$ESTABLISHED timewait:$TIMEWAIT synreceived:$SYNRECEIVED"


用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti

用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti


用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti




用SNMP對(duì)大型網(wǎng)絡(luò)管理-cacti




10、相關(guān)下載


1) rrdtool 下載:

https://mirrors.tuna.tsinghua.edu.cn/epel//5/i386/ 


2) cacti-0.8.8a 下載:

http://vdisk.weibo.com/s/ukAFmeXH43dKX


3) cacti-spine-0.8.8a 下載:

http://www.cacti.net/downloads/spine/


4) monitor-v1.3-1.tgz 下載:

http://docs.cacti.net/plugin:monitor


5) Cacti0.8.8a (Spine-Monitor-Setting-thold)安裝與優(yōu)化

http://damondeng.blog.51cto.com/1038075/1226857


6) thold-v0.5.0.tgz 下載:   http://docs.cacti.net/plugin:thold#download

settings-v0.71-1.tgz  下載: http://docs.cacti.net/plugin:thold#download

monitor-v1.3-1.tgz 下載: http://docs.cacti.net/plugin:monitor

7) Cacti 使用第三方模版監(jiān)控windows主機(jī)
http://www.cactifans.org/category/cacti%E8%A7%86%E9%A2%91

8) cacti模板大全:
http://csevan.blog.163.com/blog/static/117971266201071292318877/

9) 用Webmin輕松管理linux服務(wù)


http://guojiping.blog.51cto.com/5635432/987817


10) Cnyunwei-Cacti+Nagios最新版本 V11發(fā)布,安裝完成即使用。

http://www.cnyunwei.com/thread-5714-1-1.html

---end---
 

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI