此监控模板以iostat命令为数据源,需先安装cacti和sysstat组件。
yum -y install systat unzip
wget https://www.haiyun.me/download/cacti-iostat.zip
unzip cacti-iostat.zip
cd markround-Cacti-iostat-templates-7394c7b/
复制iostat.pl到被监控服务器目录:
cp scripts/iostat.pl /usr/local/bin/iostat.pl
被监控服务器snmp配置文件添加:
echo "pass .1.3.6.1.3.1 /usr/bin/perl /usr/local/bin/iostat.pl" >> /etc/snmp/snmpd.conf
service snmpd restart
复制iostat.xml至Cacti安装目录:
cp snmp_queries/linux/iostat.xml /cactipath/resource/snmp_queries/
#新版本cacti如果无法采集数据需删除ioName字段
#sed -i 's/:ioName//g' cactipath/resource/snmp_queries/iostat.xml
添加计划任务,用于采集数据。
cat > /etc/cron.d/iostat <<EOF
*/5 * * * * root cd /tmp && iostat -xkd 2 2 | sed 's/,/\./g' > io.tmp && mv io.tmp iostat.cache
EOF
测试数据采集是否正常:
snmpwalk -v1 -c public www.haiyun.me .1.3.6.1.3.1.2
SNMPv2-SMI::experimental.1.2.1 = STRING: "sda"
SNMPv2-SMI::experimental.1.2.2 = STRING: "sda1"
SNMPv2-SMI::experimental.1.2.3 = STRING: "sda2"
SNMPv2-SMI::experimental.1.2.4 = STRING: "dm-0"
SNMPv2-SMI::experimental.1.2.5 = STRING: "dm-1"
SNMPv2-SMI::experimental.1.2.6 = STRING: "hdc"
Cacti界面导入templates/linux目录下模板:
然后在新建设备时添加相应的模板,效果图如下: