Cacti安裝磁碟IO監控
平臺
CentOS5.4
cacti-0.8.7e(cacti-0.8.7g已經測試安裝正常)
snmpdiskio-0.9.6
安裝
安裝cacti平臺就不提了,網上多得是,今天主要是如何新增disk io監控的模板.
1. 將下載的snmpdiskio-0.9.4.tar.gz上傳到cacit伺服器上,解壓縮,將partition.xml拷貝resource/snmp_queries下.
tar zxvf snmpdiskio-0.9.4.tar.gz
cp snmpdiskio-0.9.4 /usr/local/apache2/htdocs/cacti/resource/snmp_queries/
2. 在cacti伺服器的web介面下匯入cacti_data_query_snmp_disk_statistics.xml和cacti_graph_template_disk_io_bytessec.xml
3. 將下載的snmpdiskio-0.9.4.tar.gz上傳到被監控機上,解壓縮,將目錄下可執行檔案snmpdisk拷貝/usr/local/bin/下.
tar zxvf snmpdiskio-0.9.4.tar.gz
install -m 0755 -o root -g root -p -v snmpdiskio /usr/local/bin/,
由於9.4太老不支援2.6核心,需要修改,出自http://forums.cacti.net/viewtopic.php?p=124793#124793 中dverlaeckt 的“code”
Vim snmpdiskio # $Id: snmpdiskio,v 1.5 2008/01/31 21:19:50 dverlaeckt Exp $ # snmpdiskio v0.9.6 (c) 2008 Dieter Verlaeckt <dieter.verlaeckt@gmail.com> # snmpdiskio v0.9.5 (c) 2007 Pablo Destefanis <pdestefanis@gmail.com> # snmpdiskio v0.9.4 (c) 2006 Mikael Fridh <mikael@meanstreak.se>
# Fields in /proc/partitions (kernel 2.4) # major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
# Fields in /proc/diskstats (kernel 2.6) for disks (i.e. hda) # major minor name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
# Fields in /proc/diskstats (kernel 2.6) for partitions (i.e. hda1) # major minor name rio rsect wio wsect
# InBlocks = sectors written to disk # OutBlocks = sectors read from disk
# Set default procfile for kernel 2.4 PROCFILE="/proc/partitions" MODE="linux24"
# Probably kernel 2.6: if [ -f /proc/diskstats ]; then PROCFILE=/proc/diskstats MODE="linux26" fi
function hdNum() { awk ' BEGIN { num=0 } $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ { num++ } END { print num } ' $PROCFILE }
function hdIndex() { awk ' BEGIN { num=0 } $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ { num++; print num } ' $PROCFILE }
function hdDescr() { if [ "$MODE" = "linux26" ]; then awk ' $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ { printf "%s/n", $3 }' $PROCFILE else awk ' $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ { printf "%s/n", $4 }' $PROCFILE fi }
function hdInBlocks() { if [ "$MODE" = "linux26" ]; then awk ' $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ && NF == 7 { printf "%.0f/n", $7 * 512 } $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ && NF == 14 { printf "%.0f/n", $10 * 512 } ' $PROCFILE else awk ' $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ && NF == 15 { printf "%.0f/n", $11 * 512 } ' $PROCFILE fi }
function hdOutBlocks() { if [ "$MODE" = "linux26" ]; then awk ' $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ && NF == 7 { printf "%.0f/n", $5 * 512 } $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ && NF == 14 { printf "%.0f/n", $6 * 512 } ' $PROCFILE else awk ' $1 ~ /[0-9]+/ && $2 ~ /[0-9]+/ && NF == 15 { printf "%.0f/n", $7 * 512 } ' $PROCFILE fi }
function usage() { cat <<-EOUSAGE Usage: $0 <hdNum|hdIndex|hdDescr|hdInBlocks|hdOutBlocks> EOUSAGE }
if [ 1 -ne $# ]; then usage exit 1 fi
case $1 in hdNum|hdIndex|hdDescr|hdInBlocks|hdOutBlocks) $1 ;; 'hdNum') hdNum ;; 'hdIndex') hdIndex ;; 'hdDescr') hdDescr ;; 'hdInBlocks') hdInBlocks ;; 'hdOutBlocks') hdOutBlocks ;; *) usage exit 1 ;; esac
exit 0 |
4. 修改被監控機的snmpd.conf,在檔案的結尾新增如下:
exec .1.3.6.1.4.1.2021.54 hdNum /bin/sh /usr/local/bin/snmpdiskio hdNum
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
這裡增加了/bin/sh,我在網上搜尋了許多,都沒有加上這個,我測試就是不成功.
Service snmpd restart
測試
snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.2021.58
[root@localhost ~]# 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: "390659584" UCD-SNMP-MIB::ucdavis.58.101.18 = STRING: "823808" UCD-SNMP-MIB::ucdavis.58.101.19 = STRING: "386556928" UCD-SNMP-MIB::ucdavis.58.101.20 = STRING: "827904" UCD-SNMP-MIB::ucdavis.58.101.21 = STRING: "5120" UCD-SNMP-MIB::ucdavis.58.101.22 = STRING: "2224640" UCD-SNMP-MIB::ucdavis.58.101.23 = STRING: "0" UCD-SNMP-MIB::ucdavis.58.101.24 = STRING: "0" UCD-SNMP-MIB::ucdavis.58.101.25 = STRING: "0" UCD-SNMP-MIB::ucdavis.58.102.1 = INTEGER: 0 UCD-SNMP-MIB::ucdavis.58.103.1 = "" |
出現如下資料,表示正常.
5.在cacti的devicesà Associated Data Queries新增SNMP - Disk Statistics
Create Graphs for this Host選擇
你會發現要選擇的硬碟太多,你可以用iostat命令,照這裡新增
avg-cpu: %user %nice %system %iowait %steal %idle 1.11 0.28 1.61 0.55 0.00 96.45
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn sda 2.70 23.93 38.02 763647 1213086 sda1 0.00 0.05 0.00 1609 14 sda2 2.69 23.68 38.01 755634 1212824 sda3 0.00 0.05 0.00 1617 0 sda4 0.00 0.00 0.00 10 0 sda5 0.01 0.14 0.01 4345 248 |
我使用虛擬機器測試的
排錯
如果出現
snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.2021.58 |
你先執行snmpwalk -v 2c -c public localhost,看看是否正常,如不正常,說明snmpd.conf其他配置有問題,如正常,說明剛才新增exec有問題,請檢查.
Snmp.conf提前設定
40 # sec.name source community 41 com2sec notConfigUser default mynetsnmp
61 # group context sec.model sec.level prefix read write notif 62 access notConfigGroup "" any noauth exact all none none
77 ## group.name sec.model sec.name 78 group MyRWGroup v1 local 79 group MyRWGroup v2c local 80 group MyRWGroup usm local
86 ## incl/excl subtree mask 87 view all included .1 80 |
參考: http://upfelix.blogbus.com/logs/7
相關文章
- cacti監控(2)正式安裝rrdtoolcacti
- cacti監控(1)基礎安裝apachemysqlphpApacheMySqlPHP
- 轉載 使用Cacti監控你的網路(二)- Cacti的安裝
- Windows下安裝Cacti流量與系統資訊監控Windows
- Linux下常用監控cacti的安裝和配置Linux
- 搭建Cacti監控
- cacti監控mysqlMySql
- 磁碟IO效能監控(Linux 和 Windows)LinuxWindows
- zabbix監控linux磁碟io的模板Linux
- ZABBIX安裝以及監控磁碟、mysql、oracle配置MySqlOracle
- 配置CACTI監控MySQL資料庫狀態(2)安裝cacti相關軟體包MySql資料庫
- cacti監控lighttpdhttpd
- cacti監控tcpconnectionTCP
- cacti批量新增監控
- nagios監控linux磁碟io的bugiOSLinux
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(3)-監控nginx,php,memcache,Low-level discovery磁碟IO分散式NginxPHP
- Cacti0.8.8a監控mysqlMySql
- Cacti 監控 AIX 系統AI
- cacti監控windows伺服器Windows伺服器
- cacti自定義監控指令碼指令碼
- 【監控】Zabbix安裝
- 配置CACTI監控MySQL資料庫狀態(4)配置cactiMySql資料庫
- Centos使用Cacti監控你的網路CentOS
- Zabbix監控安裝部署
- cacti安裝紀實
- 配置CACTI監控MySQL資料庫狀態(5)增加MySQL監控模板MySql資料庫
- Cacti+Nagios監控平臺完美整合iOS
- linux下cacti監控平臺的搭建Linux
- stap監控IO指令碼指令碼
- 整理了cacti安裝和plugin安裝Plugin
- 【shell】磁碟監控指令碼指令碼
- Cacti的安裝之CentOSCentOS
- Ubuntu安裝cacti步驟Ubuntu
- ubuntu下cacti安裝配置Ubuntu
- Nagios+Cacti監控平臺完美整合部署iOS
- 使用 SNMP 和 Cacti 監控 Linux 伺服器Linux伺服器
- Redis安裝+叢集+效能監控Redis
- Munin監控的安裝與配置