首先下载snmpdiskio-0.9.6.zip,文件不好找,我已经放在本文章的附件里面。

解压snmpdiskio-0.9.6.zip复制partition.xml到cacti/resource/snmp_queries/下面

[root@test]# cp partition.xml /home/wwwroot/default/cacti/resource/snmp_queries/

分别导入模板文件:

cacti_data_query_snmp_disk_statistics.xml

cacti_graph_template_disk_io_bytessec.xml

cacti添加I/O监控_disk

cacti添加I/O监控_ IO _02

 

Cacti has imported the following items:

GPRINT Preset

[success] Normal [update]

Data Input Method

[success] Get SNMP Data (Indexed) [update]

Data Template

[success] Disk - I/O [update]

Graph Template

[success] Disk - I/O (bytes/sec) [update]

在被监控端的/etc/snmp/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

cacti添加I/O监控_ IO _03

安装snmpdiskio到usr/local/bin下面并且给予执行权限

[root@node7]# install -m 0755 -o root -g root -p -v snmpdiskio /usr/local/bin/
`snmpdiskio’ -> `/usr/local/bin/snmpdiskio’

重启snmpd服务

[root@node7 bin]# service snmpd restart
Stopping snmpd:                                            [  OK  ]
Starting snmpd:                                            [  OK  ]

查看日志

[root@node7 log]# pwd
/var/log

[root@node7 log]# cat messages

如果报错:

Dec 18 14:54:39 node7 snmpd[6887]: /etc/snmp/snmpd.conf: line 462: Error: ERROR: This output format has been deprecated - Please use the ’extend’ directive instead
Dec 18 14:54:39 node7 snmpd[6887]: /etc/snmp/snmpd.conf: line 463: Error: ERROR: This output format has been deprecated - Please use the ’extend’ directive instead
Dec 18 14:54:39 node7 snmpd[6887]: /etc/snmp/snmpd.conf: line 464: Error: ERROR: This output format has been deprecated - Please use the ’extend’ directive instead
Dec 18 14:54:39 node7 snmpd[6887]: /etc/snmp/snmpd.conf: line 465: Error: ERROR: This output format has been deprecated - Please use the ’extend’ directive instead
Dec 18 14:54:39 node7 snmpd[6887]: /etc/snmp/snmpd.conf: line 466: Error: ERROR: This output format has been deprecated - Please use the ’extend’ directive instead

因为snmp V5版本不支持exec所以要把exec改为extend

extend .1.3.6.1.4.1.2021.54 hdNum /bin/sh /usr/local/bin/snmpdiskio hdNum
extend .1.3.6.1.4.1.2021.55 hdIndex /bin/sh /usr/local/bin/snmpdiskio hdIndex
extend .1.3.6.1.4.1.2021.56 hdDescr /bin/sh /usr/local/bin/snmpdiskio hdDescr
extend .1.3.6.1.4.1.2021.57 hdInBlocks /bin/sh /usr/local/bin/snmpdiskio hdInBlocks
extend .1.3.6.1.4.1.2021.58 hdOutBlocks /bin/sh /usr/local/bin/snmpdiskio hdOutBlocks

测试是否出数据:

[root@node7 log]# snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.2021.58
UCD-SNMP-MIB::ucdavis.58.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.58.2.1.2.11.104.100.79.117.116.66.108.111.99.107.115 = STRING: "/bin/sh"
UCD-SNMP-MIB::ucdavis.58.2.1.3.11.104.100.79.117.116.66.108.111.99.107.115 = STRING: "/usr/local/bin/snmpdiskio hdOutBlocks"
UCD-SNMP-MIB::ucdavis.58.2.1.4.11.104.100.79.117.116.66.108.111.99.107.115 = ""
UCD-SNMP-MIB::ucdavis.58.2.1.5.11.104.100.79.117.116.66.108.111.99.107.115 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.58.2.1.6.11.104.100.79.117.116.66.108.111.99.107.115 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.58.2.1.7.11.104.100.79.117.116.66.108.111.99.107.115 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.58.2.1.20.11.104.100.79.117.116.66.108.111.99.107.115 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.58.2.1.21.11.104.100.79.117.116.66.108.111.99.107.115 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.58.3.1.1.11.104.100.79.117.116.66.108.111.99.107.115 = STRING: "0"
UCD-SNMP-MIB::ucdavis.58.3.1.2.11.104.100.79.117.116.66.108.111.99.107.115 = STRING: "0

完全没有问题,下面就可以在cacti上面添加监控:

cacti添加I/O监控_ IO _04

 

  • Created graph: 10.1.60.155 - Disk I/O (bytes/sec) - sda


  • Created graph: 10.1.60.155 - Disk I/O (bytes/sec) - sda1


  • Created graph: 10.1.60.155 - Disk I/O (bytes/sec) - sda2

 cacti添加I/O监控_cacti_05

 

 snmpdiskio-0.9.6.rar