[prev in list] [next in list] [prev in thread] [next in thread] 

List:       net-snmp-coders
Subject:    Need help: AgentX callbacks not called
From:       "Ulrich Windl" <Ulrich.Windl () rz ! uni-regensburg ! de>
Date:       2015-09-08 9:27:35
Message-ID: 55EEC627020000A10001BCFF () gwsmtp1 ! uni-regensburg ! de
[Download RAW message or body]

Hi!

I need some help finding the missing link for my AgentX subagent:

I made an agentX that registers successfully with the master agent, and it registers \
the MIB object. However for some reason, the master agent seems to know nothing about \
the MIB, and the provided callback function are not called. I cannot find out why, so \
I'm asking for help.

On the test machine runs a regular (root) snmpd, and I run my test daemon with a \
different port and user (/usr/sbin/snmpd -M+. -m+NET-SNMP-MIB -m+IOTWatch-MIB -f -Lo \
-C --rocommunity="public .1" --rwcommunity=debug --master=agentx \
--agentXSocket=tcp:localhost:1705 udp:1161 -D).

My subagent is multi-threaded (most threads get the data and only one thread does the \
SNMP stuff, but data exchange is not done yet).

My MIB implements a table that should be changed dynamically, starting with an empty \
table (no objects created). The MIB starts like this: # +--netSnmpPlaypen(9999)
#    |
#    +--iotw(685032294)
#       |
#       +--iotwObjects(1)
#       |  |
#       |  +--iotwObjectTable(1)
#       |     |
#       |     +--iotwObjectEntry(1)
#       |        |  Index: iotwObjectIndex
#       |        |
#       |        +-- ---- Integer32 iotwObjectIndex(1)
#       |        |        Range: 1..2147483647
#       |        +-- CR-- EnumVal   iotwRowStatus(2)
#       |        |        Textual Convention: RowStatus
#       |        |        Values: active(1), notInService(2), notReady(3), crea\
teAndGo(4), createAndWait(5), destroy(6)
#       |        +-- -RW- String    iotwObjectName(3)
#       |        |        Size: 1..256
[...]

I switched on "-DALL" for the master and the subagent, but still I don't get it!

For me it seems the master is registering the subagent OK. Here are some log lines \
                from the master agent:
read_config: reading premib configuration tokens
trace: netsnmp_config_process_memory_list(): read_config.c, 648:
read_config: processing memory: rocommunity public .1
trace: netsnmp_config_process_memory_list(): read_config.c, 648:
read_config: processing memory: rwcommunity debug
trace: netsnmp_config_process_memory_list(): read_config.c, 648:
read_config: processing memory: master agentx
trace: netsnmp_config_process_memory_list(): read_config.c, 648:
read_config: processing memory: agentXSocket tcp:localhost:1705
trace: netsnmp_ds_set_boolean(): default_store.c, 205:
[...]
read_config: processing memory: master agentx
trace: run_config_handler(): read_config.c, 499:
read_config: Found a parser.  Calling it: master / agentx
Turning on AgentX master support.
trace: netsnmp_ds_set_boolean(): default_store.c, 205:
netsnmp_ds_set_boolean: Setting APP:3 = 1/True
trace: netsnmp_config_process_memory_list(): read_config.c, 648:
read_config: processing memory: agentXSocket tcp:localhost:1705
trace: run_config_handler(): read_config.c, 499:
read_config: Found a parser.  Calling it: agentXSocket / tcp:localhost:1705
trace: agentx_parse_agentx_socket(): mibgroup/agentx/agentx_config.c, 37:
agentx/config: port spec: tcp:localhost:1705
trace: netsnmp_ds_set_string(): default_store.c, 283:
[...]
agentx/master: initializing...
trace: netsnmp_tdomain_transport_full(): snmp_transport.c, 349:
tdomain: tdomain_transport_full("agentx", "tcp:localhost:1705", 1, "[NIL]", "[NIL]")
trace: find_tdomain(): snmp_transport.c, 322:
tdomain: Found domain "tcp" from specifier "tcp"
trace: netsnmp_lookup_default_target(): snmp_service.c, 388:
defaults: netsnmp_lookup_default_target("agentx", "tcp") -> ":705"
trace: netsnmp_tdomain_transport_full(): snmp_transport.c, 421:
tdomain: trying domain "tcp" address "localhost:1705" default address ":705"
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 799:
netsnmp_sockaddr_in: addr 0x7ffebc4639e0, inpeername "localhost:1705", default_target \
                ":705"
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 799:
netsnmp_sockaddr_in: addr 0x7ffebc4639e0, inpeername ":705", default_target "[NIL]"
[...]

I wonder whether the failure to initialize the "smux" is relevant here (I don't use \
                smux, I user AgentX):
mib_init: initializing: smux
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 799:
netsnmp_sockaddr_in: addr 0x7ffebc464080, inpeername "127.0.0.1", default_target \
                ":199"
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 799:
netsnmp_sockaddr_in: addr 0x7ffebc464080, inpeername ":199", default_target "[NIL]"
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 854:
netsnmp_sockaddr_in: check user service 199
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 962:
netsnmp_sockaddr_in: return { AF_INET, 0.0.0.0:199 }
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 854:
netsnmp_sockaddr_in: check user service 127.0.0.1
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 863:
netsnmp_sockaddr_in: servname not numeric, check if it really is a destination)trace: \
                netsnmp_sockaddr_in2(): snmpUDPDomain.c, 883:
netsnmp_sockaddr_in: check destination 127.0.0.1
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 906:
netsnmp_sockaddr_in: hostname (resolved okay)
trace: netsnmp_sockaddr_in2(): snmpUDPDomain.c, 962:
netsnmp_sockaddr_in: return { AF_INET, 127.0.0.1:199 }
[init_smux] bind failed: Permission denied
[...]

My test master agent also cannot write persistent config files:
snmp_agent: init_master_agent; "udp:1161" registered as an agent NSAP
trace: netsnmp_ds_set_string(): default_store.c, 283:
netsnmp_ds_set_string: Setting LIB:8 = "/var/lib/net-snmp"
trace: snmp_store(): snmp_api.c, 837:
snmp_store: storing stuff...
trace: snmp_save_persistent(): read_config.c, 1357:
snmp_save_persistent: saving snmpd files...
trace: snmp_save_persistent(): read_config.c, 1369:
snmp_save_persistent:  saving old config file: /var/lib/net-snmp/snmpd.conf -> \
/var/lib/net-snmp/snmpd.0.conf. Cannot rename /var/lib/net-snmp/snmpd.conf to \
/var/lib/net-snmp/snmpd.0.conf Cannot unlink /var/lib/net-snmp/snmpd.conf
read_config_store open failure on /var/lib/net-snmp/snmpd.conf
trace: _callback_lock(): callback.c, 130:
[...]
trace: snmp_call_callbacks(): callback.c, 322:
callback: START calling callbacks for maj=0 min=1
trace: snmp_call_callbacks(): callback.c, 336:
callback: calling a callback for maj=0 min=1
trace: snmp_call_callbacks(): callback.c, 336:
callback: calling a callback for maj=0 min=1
read_config_store open failure on /var/lib/net-snmp/snmpd.conf
read_config_store open failure on /var/lib/net-snmp/snmpd.conf
[...]
NET-SNMP version 5.4.2.1
trace: main(): snmpd.c, 1035:
snmpd/main: We're up.  Starting to process data.
[...]
dumpv_recv:          Range Sub-Id:      0
trace: agentx_parse(): mibgroup/agentx/protocol.c, 1666:
dumph_recv:       Registration OID
trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1118:
dumph_recv:         OID Header
dumpx_recv:          07 04 00 00
dumpv_recv:            # subids:        7 (0x07)
trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1122:
dumpv_recv:             prefix:         4 (0x04)
trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1125:
dumpv_recv:             inclusive:      0 (0x00)
trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1130:
dumph_recv:         OID Segments
  parse_oid
  sizeof(oid) = 8
dumpx_recv:          01 00 00 00
dumpv_recv:            Integer: 1 (0x01)
dumpx_recv:          88 1F 00 00
dumpv_recv:            Integer: 8072 (0x1F88)
dumpx_recv:          0F 27 00 00
dumpv_recv:            Integer: 9999 (0x270F)
dumpx_recv:          0F 27 00 00
dumpv_recv:            Integer: 9999 (0x270F)
dumpx_recv:          66 C3 D4 28
dumpv_recv:            Integer: 685032294 (0x28D4C366)
dumpx_recv:          01 00 00 00
dumpv_recv:            Integer: 1 (0x01)
dumpx_recv:          01 00 00 00
dumpv_recv:            Integer: 1 (0x01)
trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1205:
dumpv_recv:         OID: IOTWatch-MIB::iotwObjectTable
trace: init_agent_snmp_session(): snmp_agent.c, 1288:
snmp_agent: agent_sesion 0x7f6bc5449120 created
[...]
register_mib: registering "AgentX subagent 5, session 0x7f6bc54727c0, subsession \
                0x7f6bc5489320" at IOTWatch-MIB::iotwObjectTable with context \
                "(null)"
trace: netsnmp_subtree_find_first(): agent_registry.c, 156:
subtree: looking for subtree for context: ""
trace: netsnmp_subtree_find_first(): agent_registry.c, 160:
subtree: found one for: ""
trace: netsnmp_subtree_find_first(): agent_registry.c, 156:
subtree: looking for subtree for context: ""
trace: netsnmp_subtree_find_first(): agent_registry.c, 160:
subtree: found one for: ""
trace: netsnmp_subtree_find_prev(): agent_registry.c, 1518:
wtest: oid in: IOTWatch-MIB::iotwObjectTable
trace: netsnmp_subtree_find_prev(): agent_registry.c, 1529:
[...]
agentx/master: registered ok
[...]
dumph_send:   Get* Variable List
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 400:
dumph_send:     VarBind
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 401:
dumph_send:       type
dumpx_send:        05 00
dumpv_send:          Short:     5 (0x05)
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 447:
dumph_send:       name
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 224:
dumpv_send:         OID: IOTWatch-MIB::iotwObjectTable
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 265:
dumph_send:         OID Header
dumpx_send:          07 04 00 00
dumpv_send:            # subids:        7 (0x07)
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 269:
dumpv_send:             prefix: 4 (0x04)
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 271:
dumpv_send:             inclusive:      0 (0x00)
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 275:
dumph_send:         OID Segments
dumpx_send:          01 00 00 00
dumpv_send:            Integer: 1 (0x01)
dumpx_send:          88 1F 00 00
dumpv_send:            Integer: 8072 (0x1F88)
dumpx_send:          0F 27 00 00
dumpv_send:            Integer: 9999 (0x270F)
dumpx_send:          0F 27 00 00
dumpv_send:            Integer: 9999 (0x270F)
dumpx_send:          66 C3 D4 28
dumpv_send:            Integer: 685032294 (0x28D4C366)
dumpx_send:          01 00 00 00
dumpv_send:            Integer: 1 (0x01)
dumpx_send:          01 00 00 00
dumpv_send:            Integer: 1 (0x01)
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 456:
dumph_send:       value
dumpx_send:2C 00 00 00
dumpv_send:  Integer:   44 (0x2C)
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 1006:
agentx_build: packet built okay
trace: free_agent_snmp_session(): snmp_agent.c, 1314:
snmp_agent: agent_session 0x7f6bc5449120 released
trace: free_agent_snmp_session(): snmp_agent.c, 1319:
verbose:asp: asp 0x7f6bc5449120 reqinfo 0x7f6bc5449310 freed
[...]
register_mib: registering "AgentX subagent 5, session 0x7f6bc54727c0, subsession \
0x7f6bc5489320" at IOTWatch-MIB::iotwObjectTable with context "(null)" [...]
trace: netsnmp_subtree_find_prev(): agent_registry.c, 1529:
wtest: oid cmp: IOTWatch-MIB::iotwObjectTable  --- off = 8, in off = 8 test = 1
trace: netsnmp_subtree_find_prev(): agent_registry.c, 1529:
wtest: oid cmp: IOTWatch-MIB::iotwObjects.2  --- off = 12, in off = 13 test = 1
netsnmp_assert !"registration != duplicate" failed agent_registry.c:536 \
                netsnmp_subtree_load()
trace: register_agentx_list(): mibgroup/agentx/master_admin.c, 259:
agentx/master: duplicate registration
trace: handle_master_agentx_packet(): mibgroup/agentx/master_admin.c, 591:
agentx/master: send response, stat 263 (req=0x4c19098c,trans=0x0,sess=0x5)
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 613:
dumph_send: AgentX Header
dumpx_send:  01 12 00 00
dumpv_send:    Version: 1
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 616:
dumpv_send:     Command:        18 (Response)
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 619:
dumpv_send:     Flags:  00
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 622:
dumph_send:   Session ID
dumpx_send:    05 00 00 00
dumpv_send:      Integer:       5 (0x05)
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 631:
dumph_send:   Transaction ID
dumpx_send:    00 00 00 00
dumpv_send:      Integer:       0 (0x00)
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 640:
dumph_send:   Request ID
dumpx_send:    8C 09 19 4C
dumpv_send:      Integer:       1276709260 (0x4C19098C)
trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 649:
dumph_send:   Dummy Length :-(
dumpx_send:    00 00 00 00
dumpv_send:      Integer:       0 (0x00)
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 716:
dumph_send: AgentX Payload
dumpx_send:  4A 43 00 00
dumpv_send:    Integer: 17226 (0x434A)
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 903:
dumph_send:   Response
dumpx_send:    4A 43 00 00
dumpv_send:      sysUpTime:     17226
dumpx_send:  07 01
dumpv_send:    Short:   263 (0x107)
dumpx_send:  00 00
dumpv_send:    Short:   0 (0x00)
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 919:
dumph_send:   Response errors
dumpx_send:    07 01 00 00
dumpv_send:      errstat:       263
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 922:
dumpv_send:       errindex:     0
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 934:
dumph_send:   Get* Variable List
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 400:
dumph_send:     VarBind
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 401:
dumph_send:       type
dumpx_send:        05 00
dumpv_send:          Short:     5 (0x05)
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 447:
dumph_send:       name
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 224:
dumpv_send:         OID: IOTWatch-MIB::iotwObjectTable
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 265:
dumph_send:         OID Header
dumpx_send:          07 04 00 00
dumpv_send:            # subids:        7 (0x07)
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 269:
dumpv_send:             prefix: 4 (0x04)
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 271:
dumpv_send:             inclusive:      0 (0x00)
trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 275:
dumph_send:         OID Segments
dumpx_send:          01 00 00 00
dumpv_send:            Integer: 1 (0x01)
dumpx_send:          88 1F 00 00
dumpv_send:            Integer: 8072 (0x1F88)
dumpx_send:          0F 27 00 00
dumpv_send:            Integer: 9999 (0x270F)
dumpx_send:          0F 27 00 00
dumpv_send:            Integer: 9999 (0x270F)
dumpx_send:          66 C3 D4 28
dumpv_send:            Integer: 685032294 (0x28D4C366)
dumpx_send:          01 00 00 00
dumpv_send:            Integer: 1 (0x01)
dumpx_send:          01 00 00 00
dumpv_send:            Integer: 1 (0x01)
trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 456:
dumph_send:       value
dumpx_send:2C 00 00 00
dumpv_send:  Integer:   44 (0x2C)
trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 1006:
agentx_build: packet built okay
trace: free_agent_snmp_session(): snmp_agent.c, 1314:
snmp_agent: agent_session 0x7f6bc5449120 released
trace: free_agent_snmp_session(): snmp_agent.c, 1319:
verbose:asp: asp 0x7f6bc5449120 reqinfo 0x7f6bc544e5e0 freed

On the subagent I see these messages:
[...]
read_config: /etc/snmp/iotwatch.conf:5 examining: debugTokens agentx/config \
agentx/master agentx/subagent agentx_build agentx_build_varbind agent_handler \
agent_registry agent_set initialize_table_iotwObjectTable [...]
NET-SNMP version 5.4.2.1 AgentX subagent connected
[...]
agentx/subagent: registering: NET-SNMP-MIB::netSnmpPlaypen.685032294.1.1
[...]
dumpv_recv:           OID: NET-SNMP-MIB::netSnmpPlaypen.685032294.1.1
[...]

In the subsequent output I do not see my OID anywhere!

Could the problem be "netsnmp_assert !"registration != duplicate" failed \
agent_registry.c:536 netsnmp_subtree_load()"?

My agent uses this sequence to register and process requests:
                if ( netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
                                            NETSNMP_DS_AGENT_ROLE, 1)
                     != SNMPERR_SUCCESS )
                {
                        result = 2;
                }
                SOCK_STARTUP;           /* initialize TCP/IP, if necessary */
                /* initialize the agent library */
                if ( init_agent(snmp_agent_name) != 0 )
                {
                        result = 2;
                }
                init_iotwObjectTable(); /* initialize MIB module */
                init_snmp(snmp_agent_name);
                while ( stop_requests == 0 ) {
                        time(&MIB_vars.dummy);
                        agent_check_and_process(1); /* 0 == don't block */
                }

                /* at shutdown time */
                snmp_shutdown(snmp_agent_name);
                SOCK_CLEANUP;

The objects I register are these:
# define iotwObjectTable_TABLE_OID 1,3,6,1,4,1,8072,9999,9999,685032294,1,1
initialize_table_iotwObjectTable(); /* in init_iotwObjectTable() */

Is it OK that I skip over some undefined nodes, i.e. I register 685032294,1,1 at \
1,3,6,1,4,1,8072,9999,9999, but that's a subtree of height 3 (and not one).

I'd really appreciate if someone could help me finding the problem!

Regards,
Ulrich


------------------------------------------------------------------------------
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic