转载:http://www.ttlsa.com/zabbix/snmp-custom-oid/
确认SNMP OID是否存在
首先我们需要找一个oid是否被系统暂用,比如.1.3.6.1.4.1.2021.5000
# snmpwalk -v 2c -c public www.ttlsa.com .1.3.6.1.4.1.2021.5000
UCD-SNMP-MIB::ucdavis.5000 = No Such Object available on this agent at this OID
如上说明不存在
增加自定SNMP OID
编写脚本
# cat /root/scripts/check_nginx.sh
#!/bin/bash
nginxNum=`/bin/ps aux | /bin/grep nginx | wc -l`
echo $nginxNum
修改配置
# vim /etc/snmp/snmpd.conf
extend .1.3.6.1.4.1.2021.5000 check_nginx /root/scripts/check_nginx.sh // 增加这一行
获取snmp信息
以下获取自定义的oid的所有数据,第一行便是我们需要获取的数据,那么在zabbix中写oid .1.3.6.1.4.1.2021.5000.4.1.2.11.99.104.101.99.107.95.110.103.105.110.120.1
# snmpwalk -v 1 -c public 173.219.255.122 .1.3.6.1.4.1.2021.5000
UCD-SNMP-MIB::ucdavis.5000.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.2.1.2.11.99.104.101.99.107.95.110.103.105.110.120 = STRING: "/root/scripts/check_nginx.sh"
UCD-SNMP-MIB::ucdavis.5000.2.1.3.11.99.104.101.99.107.95.110.103.105.110.120 = ""
UCD-SNMP-MIB::ucdavis.5000.2.1.4.11.99.104.101.99.107.95.110.103.105.110.120 = ""
UCD-SNMP-MIB::ucdavis.5000.2.1.5.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.5000.2.1.6.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.2.1.7.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.2.1.20.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.5000.2.1.21.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.3.1.1.11.99.104.101.99.107.95.110.103.105.110.120 = STRING: "6"
UCD-SNMP-MIB::ucdavis.5000.3.1.2.11.99.104.101.99.107.95.110.103.105.110.120 = STRING: "6"
UCD-SNMP-MIB::ucdavis.5000.3.1.3.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.3.1.4.11.99.104.101.99.107.95.110.103.105.110.120 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.5000.4.1.2.11.99.104.101.99.107.95.110.103.105.110.120.1 = STRING: "6"
创建snmp item
snmp-oid
获取最新数据
网友评论