구성

구성

snmp를 통해 연결 유지 상태에 대한 정보를 쿼리할 수 없습니다. 다음 오류만 표시됩니다.

$ snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.9586.100.5
1.3.6.1.4.1.9586.100.5 = No Such Object available on this agent at this OID

또는 mib를 사용할 때:

$ snmpwalk -v 2c -c public 127.0.0.1 KEEPALIVED-MIB
KEEPALIVED-MIB: Unknown Object Identifier (Sub-id not found: (top) -> KEEPALIVED-MIB)

구성

SNMP- 데몬

snmpd는 버전 5.7.3입니다.

/etc/snmp/snmpd.conf

master agentx
agentaddress udp:127.0.0.1:161
rocommunity public 127.0.0.1

trapcommunity public 
trap2sink 127.0.0.1

연결 유지

Keepalived는 버전 1.3.2 빌드입니다.SNMP_V3_FOR_V2 SNMP SNMP_KEEPALIVED SNMP_CHECKER SNMP_RFC SNMP_RFCV2 SNMP_RFCV3

/etc/keepalived/keepalived.conf

# Managed by Puppet
global_defs {
  [...]

  snmp_socket udp:127.0.0.1:161
  enable_snmp_keepalived
  enable_traps
}

[...]

/etc/default/keepalived

DAEMON_ARGS="--snmp"

서비스

다음은 나에게 괜찮아 보이는 저널 출력입니다. 이는 다음의 결과입니다.systemctl start snmpd; systemctl restart keepalived

# Here snmpd is starting
Jun 07 18:12:42 vhrz1250 systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
Jun 07 18:12:42 vhrz1250 systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..
Jun 07 18:12:42 vhrz1250 snmpd[41254]: error on subcontainer 'ia_addr' insert (-1)
Jun 07 18:12:42 vhrz1250 snmpd[41254]: Turning on AgentX master support.
Jun 07 18:12:42 vhrz1250 snmpd[41254]: NET-SNMP version 5.7.3

# Here keepalived seems to be preparing for shutdown
Jun 07 18:12:56 vhrz1250 snmpd[41254]: Connection from UDP: [127.0.0.1]:58059->[127.0.0.1]:161
Jun 07 18:12:56 vhrz1250 snmpd[41254]: Connection from UDP: [127.0.0.1]:44178->[127.0.0.1]:161
Jun 07 18:13:05 vhrz1250 systemd[1]: Stopping Keepalive Daemon (LVS and VRRP)...
Jun 07 18:13:05 vhrz1250 Keepalived[38575]: Stopping
Jun 07 18:13:05 vhrz1250 Keepalived_healthcheckers[38576]: Stopped
Jun 07 18:13:05 vhrz1250 Keepalived_vrrp[38578]: VRRP_Instance(VI_10) sent 0 priority
Jun 07 18:13:06 vhrz1250 Keepalived_vrrp[38578]: Stopped
Jun 07 18:13:06 vhrz1250 Keepalived[38575]: Stopped Keepalived v1.3.2 (12/03,2016)
Jun 07 18:13:06 vhrz1250 systemd[1]: Stopped Keepalive Daemon (LVS and VRRP).

# Here keepalived stopped and spins back up again
Jun 07 18:13:06 vhrz1250 systemd[1]: Starting Keepalive Daemon (LVS and VRRP)...
Jun 07 18:13:06 vhrz1250 Keepalived[41293]: Starting Keepalived v1.3.2 (12/03,2016)
Jun 07 18:13:06 vhrz1250 Keepalived[41293]: Setting default script user to 'keepalived_script', uid:gid 1000:1000
Jun 07 18:13:06 vhrz1250 Keepalived[41293]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 07 18:13:06 vhrz1250 Keepalived[41295]: Starting Healthcheck child process, pid=41296
Jun 07 18:13:06 vhrz1250 Keepalived[41295]: Starting VRRP child process, pid=41297
Jun 07 18:13:06 vhrz1250 Keepalived_vrrp[41297]: Registering Kernel netlink reflector
Jun 07 18:13:06 vhrz1250 Keepalived_vrrp[41297]: Registering Kernel netlink command channel
Jun 07 18:13:06 vhrz1250 Keepalived_vrrp[41297]: Registering gratuitous ARP shared channel
Jun 07 18:13:06 vhrz1250 Keepalived_vrrp[41297]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 07 18:13:06 vhrz1250 systemd[1]: Started Keepalive Daemon (LVS and VRRP).
Jun 07 18:13:06 vhrz1250 Keepalived_healthcheckers[41296]: Initializing ipvs

# Here keepalived starts SNMP subagent for vrrp
Jun 07 18:13:06 vhrz1250 Keepalived_vrrp[41297]: Starting SNMP subagent
Jun 07 18:13:06 vhrz1250 snmpd[41254]: Connection from UDP: [127.0.0.1]:52941->[127.0.0.1]:161

# Keepalived continues starting up
Jun 07 18:13:06 vhrz1250 Keepalived_healthcheckers[41296]: Registering Kernel netlink reflector
Jun 07 18:13:06 vhrz1250 Keepalived_healthcheckers[41296]: Registering Kernel netlink command channel
Jun 07 18:13:06 vhrz1250 Keepalived_healthcheckers[41296]: Opening file '/etc/keepalived/keepalived.conf'.

# Here keepalived starts SNMP subagent for healthchecks
Jun 07 18:13:06 vhrz1250 Keepalived_healthcheckers[41296]: Starting SNMP subagent
Jun 07 18:13:06 vhrz1250 snmpd[41254]: Connection from UDP: [127.0.0.1]:53980->[127.0.0.1]:161

# Keepalived continues starting up
Jun 07 18:13:07 vhrz1250 Keepalived_healthcheckers[41296]: Using LinkWatch kernel netlink reflector...
Jun 07 18:13:07 vhrz1250 Keepalived_vrrp[41297]: Using LinkWatch kernel netlink reflector...
Jun 07 18:13:08 vhrz1250 Keepalived_vrrp[41297]: VRRP_Instance(VI_10) Transition to MASTER STATE
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: VRRP_Instance(VI_10) Entering MASTER STATE
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: Opening script file /usr/local/bin/keepalived_statechange
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: VRRP_Instance(VI_10): Sending SNMP notification
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: VRRP_Instance(VI_10): Sending SNMP notification vrrpTrapNewMaster
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: VRRP_Instance(VI_10): Sending SNMP notification vrrpv3NotifyNewMaster, reason 2
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: Remote SMTP server [137.248.1.36]:25 connected.
Jun 07 18:13:10 vhrz1250 Keepalived_vrrp[41297]: SMTP alert successfully sent.

# This might be connections from the VRRP instance snmp subagents
Jun 07 18:13:12 vhrz1250 snmpd[41254]: error on subcontainer 'ia_addr' insert (-1)
Jun 07 18:13:22 vhrz1250 snmpd[41254]: Connection from UDP: [127.0.0.1]:50917->[127.0.0.1]:161
Jun 07 18:13:22 vhrz1250 snmpd[41254]: Connection from UDP: [127.0.0.1]:38560->[127.0.0.1]:161

답변1

알겠습니다. 문제를 찾았습니다. 나는 항상 snmpd.conf스위치가 master agentx일반 에이전트와 동일한 주소에서 구현되는 AgentX 기능을 활성화한다고 생각했습니다(예: 에서 구성한 대로 agentaddress).

그러나 이는 사실이 아니며 agentXSocket대신 AgentX 주소/소켓이 제어됩니다.


따라서 최소 구성은 다음과 같아야 합니다.

/etc/snmp/snmpd.conf

rocommunity public
master agentx

# Note: This is the AgentX address/socket
agentXSocket tcp:127.0.0.1:700

# Note: This is the address/socket used for snmpwalk and such
# agentaddress udp:127.0.0.1:161

/etc/snmp/snmp.conf

# Note: This is optional!
#  To enable keepalived mib, download
#  https://github.com/acassen/keepalived/blob/master/doc/KEEPALIVED-MIB.txt
#  to /usr/share/snmp/mibs (keep the .txt extension) and enable
#  it with the following line
mibs +KEEPALIVED-MIB

/etc/keepalived/keepalived.conf

global_defs {
  [...]

  # Note: This is the AgentX address/socket
  snmp_socket tcp:127.0.0.1:700
}
[...]

/etc/default/keepalived

DAEMON_ARGS="--snmp"

관련 정보