[AGENT++] AgentX++ master agent memory usage for shared tables

Frank Fock fock at agentpp.com
Wed Oct 6 20:58:23 CEST 2010


Hi Christopher,

1.
There can be several reasons why the master agent
memory increases, for example,

(1) the OS does not free used memory (linux),
(2) a subagent allocates indexes
(3) a session is not closed properly
...

2.
The index allocation fails most likely because a wrong
type has been chosen for the allocation. A multi-index
can be allocated as OID only. As INT32 only the first
sub-identifier is allocated.

3.
I do not fully understand where the problem is.
The IF-MIB implementation gets its information
from the OS.

Best regards,
Frank

On 06.10.2010 18:53, cjsajdak at rockwellcollins.com wrote:
> Hi All,
>
> I have a few questions about memory usage for the AgentX++ master agent
> (master.cpp) when an AgentX++ subagent implements shared tables (such as
> IF-MIB: if_mib.cpp and subagent.cpp).
>
> Thanks,
> Christopher Sajdak
>
> [Question 1]: I noticed that the AgentX++ master agent seems to grow in
> memory footprint each time I start/stop the subagent repeatedly. I have
> been running the AgentX++ examples which I compiled on my RedHat linux
> machine (agent++v3.5.30, snmp++v3.2.24, agentX++v1.4.17). I suspect that
> add_row() may be involved, but not sure how the master agent would be
> growing. Any ideas?
>
> $ ps -F -p 5735
> UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
> root      5735 27795  0 37137  4832   7 09:46 pts/17   00:00:00 ./master
> $ ps -F -p 5735
> UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
> root      5735 27795  0 37201  5144   7 09:46 pts/17   00:00:00 ./master
> $ ps -F -p 5735
> UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
> root      5735 27795  0 37265  5396   7 09:46 pts/17   00:00:00 ./master
> $ ps -F -p 5735
> UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
> root      5735 27795  0 37265  5400   7 09:46 pts/17   00:00:00 ./master
> $
>
> Example files mentioned:
> agentpp/agentX++/examples/master/src/master.cpp
> agentpp/agentX++/examples/subagent/src/subagent.cpp
> agentpp/agentX++/examples/subagent/src/if_mib.cpp
>
>
> NOTE:I modified the main loop in the subagent.cpp example to allow for a
> reconnection to the master agent. This allows me to stop and restart the
> master agent as well. See the code snippet here:
>
>     // Replace the main loop in
> agentpp/agentX++/examples/subagent/src/subagent.cpp with this:
>     // Main Loop
>     Request* req;
>     int retries;
>     do
>     {
>        while ((run)&&  (!mib->get_agentx()->quit()))
>        {
>
>           req = reqList->receive(40000);
>
>           if (req)
>           {
>              mib->process_request(req);
>           }
>           else
>           {
>              mib->cleanup();
>           }
>        }
>        mib->save_all(); // save persistent data to disk
>        retries = 0;
>        // Try to reconnect 10 times every 10 seconds
>        while ((run)&&  (retries++<  10)&&  (!mib->init()))
>        {
>           printf("Sleep for 10 sec during retry... \n");
>           sleep(10);
>        }
>     }
>     while ((run)&&  (retries<  10)); // stop after 10 consecutive failures
>
>
> [Question 2]: I have noticed when I try to use allocate_index() or
> init_row() for a shared table with multiple indices ("1.1", "1.2", "1.3",
> "2.1", "2.2", "2.3"), I get these errors (259 and 260) on some of the
> entries. Any tips?
>
> ./agentx_pp/agentx_def.h:#define AGENTX_INDEX_ALREADY_ALLOCATED 259
> ./agentx_pp/agentx_def.h:#define AGENTX_DUPLICATE_REGISTRATION  263
>
>
> allocate_index() ok on "1.1" and "2.2"
> allocate_index() fails on "1.2", "1.3", "1.4", "2.1", "2.3", "2.4"
>
> init_row() ok on "1.1" and "2.2"
> init_row() fails on "1.2", "1.3", "1.4", "2.1", "2.3", "2.4"
>
> (BTW, I noticed a thread:
> http://lists.agentpp.org/pipermail/agentpp/2008-January/004210.html that
> might be the same thing I am facing).
>
> Meanwhile these would all be handled by add_row(), but I think the master
> agent is consuming extra memory in the process.
>
> [Question 3]: When running the AgentX++ example subagent.cpp (implements
> IF-MIB), I see that there are several entries for each index. (see
> IF-MIB::ifIndex output from snmpwalk below). What is the purpose of these
> entries? Are they needed or can they be omitted somehow?
>
> $ snmpwalk -v3 -uunsecureUser localhost:4700 | grep IF-MIB
> IF-MIB::ifNumber.0 = INTEGER: 13
> IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
> IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
> IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
>
> (snip)
>
> IF-MIB::ifOutErrors.11 = Counter32: 0
> IF-MIB::ifOutErrors.12 = Counter32: 0
> IF-MIB::ifOutErrors.13 = Counter32: 0
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.118 = OID: IF-MIB::interfaces<---
> (AGENTX-MIB::agentxRegStart = .1.3.6.1.2.1.74.1.4.2.1.3)
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.131 = OID: IF-MIB::ifIndex.1<---
> are these entries added for each shared table index allocated?
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.138 = OID: IF-MIB::ifIndex.2
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.139 = OID: IF-MIB::ifIndex.6
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.141 = OID: IF-MIB::ifIndex.5
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.152 = OID: IF-MIB::ifIndex.7
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.158 = OID: IF-MIB::ifIndex.10
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.192 = OID: IF-MIB::ifIndex.8
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.204 = OID: IF-MIB::ifIndex.3
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.208 = OID: IF-MIB::ifIndex.9
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.217 = OID: IF-MIB::ifIndex.11
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.220 = OID: IF-MIB::ifIndex.4
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.221 = OID: IF-MIB::ifIndex.12
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.2.2.223 = OID: IF-MIB::ifIndex.13
>
> Now I stop the master agent and then restart it, I see that the
> IF-MIB::ifIndex entries are no longer there. Could these be contributing
> to master agent memory overhead?
>
> $ snmpwalk -v3 -uunsecureUser localhost:4700 | grep IF-MIB
> IF-MIB::ifNumber.0 = INTEGER: 13
> IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
> IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
> IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
>
> (snip)
>
> IF-MIB::ifOutErrors.11 = Counter32: 0
> IF-MIB::ifOutErrors.12 = Counter32: 0
> IF-MIB::ifOutErrors.13 = Counter32: 0
> SNMPv2-SMI::mib-2.74.1.4.2.1.3.1.1.1 = OID: IF-MIB::interfaces<--
> this time I don't see IF-MIB::ifIndex entries after master agent restart
> [cjsajdak at flexnetlab_backup ~]$
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/agentpp

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the AGENTPP mailing list