标签:http ar os 使用 sp strong on 数据 div
前面的文章我们已经讲过zabbix如何使用snmp监控服务器,但是他有一个很明显的局限性:只能监控定义好的OID项目,假如我们想知道nginx进程是否在运行?在没有zabbix agent的情况下,我们该怎么做呢?接下来就用这个实力来讲解自定义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 |
如上说明不存在
编写脚本
# cat /root/scripts/check_nginx.sh |
#!/bin/bash |
nginxNum=`/bin/psaux | /bin/grepnginx |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 // 增加这一行 |
以下获取自定义的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" |
接下来创建触发器以及报警,我就不多说了,大家可以参考《zabbix触发器》
zabbix snmp自定义OID nginx监控实例(55)
标签:http ar os 使用 sp strong on 数据 div
原文地址:http://my.oschina.net/766/blog/353763