使用 snmp 监控 keeplived 虚拟 IP

使用 snmp 监控 keeplived 虚拟 IP

我正在尝试使用 snmp 监控 keepalived VIP。我在两台服务器上运行了 keepalived。我们遇到的情况是 VIP 突然出现在两台服务器上,这是一个大问题,因为这些服务器是虚拟网关。我的目标是通过 check_mk 插件使用 python 脚本监控两台服务器上的 keepalived。现在我可以获得主服务器和备份服务器,但我想知道 VIP 分配给了哪台服务器。

我可以获得所有 keepalived OID:

snmpwalk -v 2c -c public keepalived.server KEEPALIVED
snmpwalk -v 2c -c public keepalived.server KEEPALIVED-MIB::keepalived
snmpwalk -v 2c -c public keepalived.server KEEPALIVED-MIB::vrrp
snmpwalk -v 2c -c public keepalived.server VRRP-MIB::vrrpMIB
snmpwalk -v 2c -c public keepalived.server VRRPV3-MIB::vrrpv3MIB

但是当我运行以下命令时出现错误:

# snmpwalk -v2c -c public keepalived.server KEEPALIVED-MIB::virtualServerAddress
KEEPALIVED-MIB::virtualServerAddress = No Such Object available on this agent at this OID

我对 snmp 和 keepalived 不太熟悉。我该如何让它工作呢?显然它的工作方式如下这里

此外我还有一个问题:

也应该snmp-mibs-downloader安装在 keepalived 服务器上,还是安装在监控服务器上就足够了,因为当没有安装 keepalived 服务器时,我会在 keepalived 服务器上收到以下日志:

# less /var/log/syslog 
Sep 18 10:41:11 snmpd[16695]: MIB search path: /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/
mibs/site:/usr/s/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp 
Sep 18 10:41:11 snmpd[16695]: Cannot find module (SNMPv2-MIB): At line 0 in (none)
Sep 18 10:41:11 snmpd[16695]: Cannot find module (IF-MIB): At line 0 in (none) 
Sep 18 10:41:11 snmpd[16695]: Cannot find module (IP-MIB): At line 0 in (none) 
Sep 18 10:41:11 snmpd[16695]: Cannot find module (TCP-MIB): At line 0 in (none)
Sep 18 10:41:11 snmpd[16695]: Cannot find module (UDP-MIB): At line 0 in (none)
Sep 18 10:41:11 snmpd[16695]: Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none) 
Sep 18 10:41:11 snmpd[16695]: Cannot find module (NOTIFICATION-LOG-MIB): At line 0 in (none)
Sep 18 10:41:11 snmpd[16695]: Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none)
Sep 18 10:41:11 snmpd[16695]: Cannot find module (DISMAN-SCHEDULE-MIB): At line 0 in (none) 
Sep 18 10:41:11 snmpd[16695]: Cannot find module (HOST-RESOURCES-TYPES): At line 0 in (none)
Sep 18 10:41:11 snmpd[16695]: Cannot find module (MTA-MIB): At line 0 in (none)
................
................
................

simlint 在监控服务器上没有任何输出:

# smilint /usr/share/snmp/mibs/KEEPALIVED-MIB.txt
# 

但针对目录运行它:

# smilint /usr/share/snmp/mibs/*
/usr/share/snmp/mibs/GNOME-SMI.txt:88: warning: module name `GNOME-SMI' should match `*-MIB'
/usr/share/snmp/mibs/IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt:151: enumeration name `mplsTpPseudowireEndpointIdentifier' longer than 32 characters
/usr/share/snmp/mibs/IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt:62: warning: current type `AddressFamilyNumbers' is not referenced in this module
/usr/share/snmp/mibs/IANAifType-MIB.txt:462: warning: named number `if-gsn' must not include a hyphen in SMIv2
/usr/share/snmp/mibs/IANAifType-MIB.txt:279: warning: identifier `IANAifType' differs from `ianaifType' only in case
/usr/share/snmp/mibs/IANAifType-MIB.txt:7: info: previous definition of `ianaifType'
/usr/share/snmp/mibs/IANAifType-MIB.txt:279: warning: current type `IANAifType' is not referenced in this module
/usr/share/snmp/mibs/IANAifType-MIB.txt:600: warning: current type `IANAtunnelType' is not referenced in this module
/usr/share/snmp/mibs/IANA-RTPROTO-MIB.txt:42: warning: current type `IANAipRouteProtocol' is not referenced in this module
/usr/share/snmp/mibs/IANA-RTPROTO-MIB.txt:74: warning: current type `IANAipMRouteProtocol' is not referenced in this module
/usr/share/snmp/mibs/LM-SENSORS-MIB.txt:17: failed to locate MIB module `UCD-SNMP-MIB'`
...............
...............
...............

我不知道这是否是 snmp 问题或 keepalived 问题,或者缺少我需要安装的 MIB。

感谢您的帮助。

答案1

来自 acassen/keepalived 的 pqarmitage 回答了这个问题这里

运行snmpwalk -v2c -c public keepalived.server KEEPALIVED-MIB::virtualServerAddress我得到的结果与您使用上述配置的结果完全相同,但这是正确的,因为没有配置虚拟服务器(虚拟服务器是 IPVS/healthchecker 配置的一部分,与 vrrp_instances 无关)。

如果我在配置中添加几个虚拟服务器,地址分别为 10.0.1.4 和 10.0.2.4,则会snmpwalk -v2c -c public keepalived.server KEEPALIVED-MIB::virtualServerAddress产生:

KEEPALIVED-MIB::virtualServerAddress.1 = Hex-STRING: 0A 00 01 04
KEEPALIVED-MIB::virtualServerAddress.2 = Hex-STRING: 0A 00 02 04

谢谢

相关内容