Fork me on GitHub
Suzf  Blog

[译] SNMP Items with ZABBIX

SNMP Items with ZABBIX

原文:https://www.zabbix.com/wiki/howto/monitor/snmp/snmp

翻译不好的地方,欢迎大家指出.
设备

Cisco 3750X

例:系统运行时间

创建一个新的主机监控项

把监控项添加到主机(System Uptime)

描述:172.16.9.1(设备IP)

类型: SNMPv2 agent

SNMP community: public

SNMP OID: .1.3.6.1.2.1.1.3.0

SNMP port: 161

键: sysUpTimeInstance (必须唯一)

消息类型:数字整型

单位: s

使用乘法: .01

状态: 启用

存储类型: As is

保存监控项然后退到监控主机,对其进行监控

操作指南:

查找自己要监控的值或准确的名字:

[[email protected] ~]# snmpwalk -v 2c -c public 172.16.9.1|grep -i ifinoctet
IF-MIB::ifInOctets.1 = Counter32: 0
IF-MIB::ifInOctets.2 = Counter32: 567083598
IF-MIB::ifInOctets.10 = Counter32: 2070652319
IF-MIB::ifInOctets.5001 = Counter32: 3481469910
IF-MIB::ifInOctets.5002 = Counter32: 1027664073
IF-MIB::ifInOctets.5003 = Counter32: 3670716774
IF-MIB::ifInOctets.5004 = Counter32: 2533854585
IF-MIB::ifInOctets.5005 = Counter32: 1818187102
IF-MIB::ifInOctets.5006 = Counter32: 2940283312
IF-MIB::ifInOctets.5007 = Counter32: 3354906303
IF-MIB::ifInOctets.5008 = Counter32: 723189870
IF-MIB::ifInOctets.5009 = Counter32: 2780244569
IF-MIB::ifInOctets.5010 = Counter32: 941387180
IF-MIB::ifInOctets.5011 = Counter32: 559352509
IF-MIB::ifInOctets.5012 = Counter32: 1010474446
IF-MIB::ifInOctets.5013 = Counter32: 363032674
IF-MIB::ifInOctets.5014 = Counter32: 4357047
IF-MIB::ifInOctets.5015 = Counter32: 3049128451
IF-MIB::ifInOctets.5016 = Counter32: 1213051
IF-MIB::ifInOctets.5017 = Counter32: 0
IF-MIB::ifInOctets.5018 = Counter32: 0
IF-MIB::ifInOctets.5019 = Counter32: 0
IF-MIB::ifInOctets.5020 = Counter32: 0
IF-MIB::ifInOctets.5021 = Counter32: 0
IF-MIB::ifInOctets.5179 = Counter32: 0
IF-MIB::ifInOctets.5182 = Counter32: 0
IF-MIB::ifInOctets.10101 = Counter32: 3481469910
IF-MIB::ifInOctets.10102 = Counter32: 0
IF-MIB::ifInOctets.10103 = Counter32: 0
IF-MIB::ifInOctets.10104 = Counter32: 849803
IF-MIB::ifInOctets.10105 = Counter32: 4346
IF-MIB::ifInOctets.10106 = Counter32: 0
IF-MIB::ifInOctets.10107 = Counter32: 0
IF-MIB::ifInOctets.10108 = Counter32: 721814320
IF-MIB::ifInOctets.10109 = Counter32: 0
.....

查找你想要的OID:

[[email protected] ~]# snmpwalk -v 2c -c public -On 172.16.9.1 ifInOctets.1
.1.3.6.1.2.1.2.2.1.10.1 = Counter32: 0

监控流量

场景:

我们想要监控我们网关流出的流量

我们知道这个接口是 GigabitEthernet1/0/1

我们不知道这个 OID 是什么,但是我们知道一些常识。

解决:

得到我们想要的 OID

[[email protected] ~]# snmpwalk -v 2c -c public 172.16.9.1|grep GigabitEthernet1/0/1
IF-MIB::ifDescr.10101 = STRING: GigabitEthernet1/0/1
IF-MIB::ifDescr.10110 = STRING: GigabitEthernet1/0/10
IF-MIB::ifDescr.10111 = STRING: GigabitEthernet1/0/11
IF-MIB::ifDescr.10112 = STRING: GigabitEthernet1/0/12
IF-MIB::ifDescr.10113 = STRING: GigabitEthernet1/0/13
IF-MIB::ifDescr.10114 = STRING: GigabitEthernet1/0/14

现在我们可以得到OID相同的地方是IfDesscr 让我们试试“in”和“out”在这个接口上

我想“.10101”就是这个接口的结尾

[[email protected] ~]# snmpwalk -v 2c -c public 172.16.9.1|egrep -i 'if(in|out|101)'|less
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.10 = INTEGER: 10
IF-MIB::ifIndex.5001 = INTEGER: 5001
IF-MIB::ifIndex.5002 = INTEGER: 5002
IF-MIB::ifIndex.5003 = INTEGER: 5003
...
IF-MIB::ifIndex.10101 = INTEGER: 10101
IF-MIB::ifIndex.10102 = INTEGER: 10102
IF-MIB::ifIndex.10103 = INTEGER: 10103
IF-MIB::ifIndex.10104 = INTEGER: 10104

上面给出了这个项应该是 ifindex.num

创建一个zabbix 监控项

[[email protected] ~]# snmpwalk -v 2c -c zabbix.thtim.com 172.16.9.1 ifInOctets
IF-MIB::ifInOctets.1 = Counter32: 0
IF-MIB::ifInOctets.2 = Counter32: 567255108
IF-MIB::ifInOctets.10 = Counter32: 2075959402
IF-MIB::ifInOctets.5001 = Counter32: 3482669485
IF-MIB::ifInOctets.5002 = Counter32: 1030509076
IF-MIB::ifInOctets.5003 = Counter32: 3673853121
...
IF-MIB::ifInOctets.10101 = Counter32: 3482669485
IF-MIB::ifInOctets.10102 = Counter32: 0
IF-MIB::ifInOctets.10103 = Counter32: 0
...

啊哈 “ifInOctets” 和 “ifOutOctets” 与 索引10101 使我们要找的 。

即:ifInOctets.10101

让我来得到数字的OID

32位:

[[email protected] ~]# snmpwalk -v 2c -c public-On 172.16.9.1 ifInOctets.10101
.1.3.6.1.2.1.2.2.1.10.10101 = Counter32: 3482873659
[[email protected] ~]# snmpwalk -v 2c -c public -On 172.16.9.1 ifOutOctets.10101
.1.3.6.1.2.1.2.2.1.16.10101 = Counter32: 4031196606

64位
[[email protected] ~]# snmpwalk -v 2c -c pubic -On 172.16.9.1 ifHCInOctets.10101
.1.3.6.1.2.1.31.1.1.1.6.10101 = Counter64: 3482962709
[[email protected] ~]# snmpwalk -v 2c -c pulic -On 172.16.9.1 ifHCOutOctets.10101
.1.3.6.1.2.1.31.1.1.1.10.10101 = Counter64: 4031296146

好了, 现在我们来总结一下整个过程:

创建一个进接口的监控项

描述: 172.16.9.1(设备IP)

SNMP 版本: SNMPv2 agent

SNMP 团体名称: public

SNMP OID: .1.3.6.1.2.1.1.3.0

SNMP port: 161

键: sysUpTimeInstance (必须唯一)

消息类型:数字整型

单位: bps refer to the ZABBIX Manual and forums for more units

使用乘法: 8

状态: 启用

存储类型: Delta Speed per second # 流量是一个变化的值,我们不想看到是流量的总和

用同样的方法创建一个出接口的监控项