Zabbix SNMP自定义OID监控存储

公司最近买了一个存储,snmp做的不是很完善,虽然提供了OID,但是OID只能用snmpwalk取得,不能用snmpget取得,联系厂商研发周期长,也需要花费很多时间来调试,
最后通过自定义OID,满足了我监控的要求。
snmp监控服务器,但是他有一个很明显的局限性:只能监控定义好的OID项目,假如我们想知道存储状态是否健康?在没有zabbix agent的情况下,我们该怎么做呢?
接下来就用这个实列来讲解自定义OID
过程如下:
一 查看存储上SNMP进程的信息和重启是否正常
#ps -ef | grep snmp
/opt/net-snmp/sbin/snmpd -LS0-6d -f -L -DdatatomModule,dlmod -c /etc/snmp/snmpd.conf
systemctl restart snmpd
二 增加自定义的OID
确认SNMP OID是否存在
首先我们需要找一个oid是否被系统暂用,比如.1.3.6.1.4.1.2021.5000
#snmpwalk -v 2c -c xxxxxxx 192.168.1.213 .1.3.6.1.4.1.2021.5000   
UCD-SNMP-MIB::ucdavis.5000 = No Such Object available on this agent at this OID
如上说明不存在
# vim /etc/snmp/snmpd.conf
extend .1.3.6.1.4.1.2021.5000 checkhealth /home/detuo/checkhealth.sh // 增加这一行
# vi /home/detuo/checkhealth.sh内容如下:
#!/bin/bash
IsHealth=`/usr/bin/ceph -s | grep health`
echo $IsHealth

------------------------

还可以增加其他,如检查磁盘空间(以T为单位)
[root@node01 detuo]# cat checkdiskspace.sh
#!/bin/bash
diskspace=`/usr/bin/df -B 1t | grep infinityfs1 | awk '{print $4}'`
echo $diskspace

#systemctl restart snmpd
三 测试自定义的OID是否正确
[root@zabbix backup]# snmpwalk -v 2c -c xxxxx 192.168.1.213 .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.104.101.97.108.116.104 = STRING: "/home/detuo/checkhealth.sh"
UCD-SNMP-MIB::ucdavis.5000.2.1.3.11.99.104.101.99.107.104.101.97.108.116.104 = ""
UCD-SNMP-MIB::ucdavis.5000.2.1.4.11.99.104.101.99.107.104.101.97.108.116.104 = ""
UCD-SNMP-MIB::ucdavis.5000.2.1.5.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.5000.2.1.6.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.2.1.7.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.2.1.20.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.5000.2.1.21.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.3.1.1.11.99.104.101.99.107.104.101.97.108.116.104 = STRING: "health: HEALTH_OK"
UCD-SNMP-MIB::ucdavis.5000.3.1.2.11.99.104.101.99.107.104.101.97.108.116.104 = STRING: "health: HEALTH_OK"
UCD-SNMP-MIB::ucdavis.5000.3.1.3.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.5000.3.1.4.11.99.104.101.99.107.104.101.97.108.116.104 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.5000.4.1.2.11.99.104.101.99.107.104.101.97.108.116.104.1 = STRING: "health: HEALTH_OK"
#snmpget -v 2c -c Jy_2020! 192.168.1.213 .1.3.6.1.4.1.2021.5000.4.1.2.11.99.104.101.99.107.104.101.97.108.116.104.1
UCD-SNMP-MIB::ucdavis.5000.4.1.2.11.99.104.101.99.107.104.101.97.108.116.104.1 = STRING: "health: HEALTH_OK"
上面的OID .1.3.6.1.4.1.2021.5000.4.1.2.11.99.104.101.99.107.104.101.97.108.116.104.1就是我要监控的项目。
四  创建snmp item

Zabbix SNMP自定义OID监控存储_第1张图片

五 配置告警

Zabbix SNMP自定义OID监控存储_第2张图片

六 zabbix目前只支持snmpget成功的OID,不支持snmpwalk成功的OID。

你可能感兴趣的:(zabbix)