所需軟體:此軟體網上并不是太好找,建議大家好好收藏
snmpdiskio-0.9.6.zip
下載下傳點http://www.colderboy.com/wp-content/uploads/2011/08/snmpdiskio.rar
1.把解壓之後檔案夾下的snmpdiskio檔案上傳到被監控伺服器的/usr/local/bin目錄下;
由于9.4太老不支援2.6核心,需要修改, 這裡下載下傳的包我已經更新過已經支援2.6核心.
2.把解壓之後檔案夾下的 partition.xml上傳到cacti監控伺服器的
/www/cacti/resource/snmp_queries/目錄下,這裡我的CACTI的
目錄檔案為以上,大家可以根據實際情況修改。
且分别導入2個模闆:
cacti_graph_template_disk_io_bytessec.xml
cacti_data_query_snmp_disk_statistics.xml
3修改snmp配置檔案/etc/snmp/snmpd.conf
#----------------------------------------------------------------------------------
com2sec local localhost public
com2sec local 監控IP 位址 public
com2sec mynetwork NETWORK/24 COMMUNITY
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
group MyROGroup usm mynetwork
view all included .1 80
access MyROGroup "" any noauth exact all none none
access MyRWGroup "" any noauth exact all all none
syslocation etiantian.org
syscontact Me <[email protected]>
proc mountd
proc ntalkd 4
proc sendmail 10 1
proc httpd 10 1
exec echotest /bin/echo hello world
exec disk_used_shell /bin/sh /root/current_disk_used.sh
exec httpd_proc /bin/sh /root/current_httpd_proc.sh
disk / 10000
disk /boot 10000
load 12 14 14
#以下五行是我添加的内容
<a>exec .1.3.6.1.4.1.2021.54 hdNum /bin/sh /usr/local/bin/snmpdiskio hdNum</a>
exec .1.3.6.1.4.1.2021.55 hdIndex /bin/sh /usr/local/bin/snmpdiskio hdIndex
exec .1.3.6.1.4.1.2021.56 hdDescr /bin/sh /usr/local/bin/snmpdiskio hdDescr
exec .1.3.6.1.4.1.2021.57 hdInBlocks /bin/sh /usr/local/bin/snmpdiskio hdInBlocks
exec .1.3.6.1.4.1.2021.58 hdOutBlocks /bin/sh /usr/local/bin/snmpdiskio hdOutBlocks
4重新開機snmpd服務
/etc/init.d/snmpd restart
五:在cacti監控主機上測試
yum install -y net-snmp-utils*
[root@mail ~]# snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.2021.58
UCD-SNMP-MIB::ucdavis.58.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.58.2.1 = STRING: "hdOutBlocks"
UCD-SNMP-MIB::ucdavis.58.3.1 = STRING: "/bin/sh /usr/local/bin/snmpdiskio hdOutBlocks"
UCD-SNMP-MIB::ucdavis.58.100.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.58.101.1 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.2 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.3 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.4 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.5 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.6 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.7 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.8 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.9 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.10 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.11 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.12 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.13 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.14 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.15 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.16 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.17 = STRING: "641941504"
UCD-SNMP-MIB::ucdavis.58.101.18 = STRING: "701440"
UCD-SNMP-MIB::ucdavis.58.101.19 = STRING: "224997888"
UCD-SNMP-MIB::ucdavis.58.101.20 = STRING: "297335296"
UCD-SNMP-MIB::ucdavis.58.101.21 = STRING: "2048"
UCD-SNMP-MIB::ucdavis.58.101.22 = STRING: "66200576"
UCD-SNMP-MIB::ucdavis.58.101.23 = STRING: "659456"
UCD-SNMP-MIB::ucdavis.58.101.24 = STRING: "51835904"
UCD-SNMP-MIB::ucdavis.58.101.25 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.101.26 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.102.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.58.103.1 = ""
看到以上内容說配置成功.
5.CACTI模版配置,這裡有點小難度,需要特别注意
找到Templates-->Host Templates-->找到又上方的Add添加一個主機模版
點開add之後輸入建立的主機模版的名字例如:LINUX-disk-io點選create 進入下一步配置
在Associated Graph Templates選擇Disk-I/O (bytes/sec)點選Add添加
在Associated Data Queries選擇SNMP-Disk Statistics點選 Add 添加
最後點選 Save 儲存完成。
6.為主機建立Graphs
Devices --> 選擇 一個主機 --> Host Template 選擇剛剛建立的linux-disk-io 點選儲存
點選上方的 *Create Graphs for this Host在下面就能看到Data Query [SNMP - Disk Statistics]
這樣清單,清單内顯示你硬碟的資訊。選擇你需要監控的磁盤點選建立完成。
本文轉自 houzaicunsky 51CTO部落格,原文連結:http://blog.51cto.com/hzcsky/480000