1、snmp配置自定义OID
/etc/snmp/snmpd.conf
com2sec notConfigUser default public group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser view systemview included .1 access notConfigGroup "" any noauth exact systemview none none syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) dontLogTCPWrappersConnects yes extend .1.3.6.1.4.1.2021.50 zabbix_agent /bin/bash /root/zabbix_check.sh extend .1.3.6.1.4.1.2021.51 hadoop_QuorumPeerMain_check /bin/bash /root/hadoop_QuorumPeerMain_check.sh
添加OID内容:
extend .1.3.6.1.4.1.2021.50 zabbix_agent /root/zabbix_check.sh
extend:扩展OID
.1.3.6.1.4.1.2021.50:.1.3.6.1.4.1.2021不可变,表示用户自定义OID前缀,50用户自定义
zabbix_agent:标示、名称。用于区分不同扩展项目
/bin/bash /root/zabbix_check.sh:运行脚本,脚本的绝对路径
2、zabbix_check.sh内容
#!/bin/bash echo `netstat -tnlp|grep -v tcp6|grep zabbix_agent|wc -l`
2、zabbix服务端查看
snmpwalk -v 2c -c public 192.168.8.47 .1.3.6.1.4.1.2021.50
内容如下:
UCD-SNMP-MIB::ucdavis.50.1.0 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.50.2.1.2.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = STRING: "/bin/bash" UCD-SNMP-MIB::ucdavis.50.2.1.3.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = STRING: "/home/monitor/zabbix/app_connection_db.sh" UCD-SNMP-MIB::ucdavis.50.2.1.4.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = "" UCD-SNMP-MIB::ucdavis.50.2.1.5.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 5 UCD-SNMP-MIB::ucdavis.50.2.1.6.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.50.2.1.7.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.50.2.1.20.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 4 UCD-SNMP-MIB::ucdavis.50.2.1.21.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.50.3.1.1.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = STRING: "600" UCD-SNMP-MIB::ucdavis.50.3.1.2.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = STRING: "600" UCD-SNMP-MIB::ucdavis.50.3.1.3.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.50.3.1.4.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98 = INTEGER: 0 UCD-SNMP-MIB::ucdavis.50.4.1.2.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98.1 = STRING: "600"
完整UUID:
ucdavis.50.3.1.2.17.97.112.112.95.99.111.110.110.101.99.116.105.111.110.95.100.98