when to call module_init is important


I would like to check if it is important if module_init(mib) must be called before *init(mib, engineId) function in agenpro?
The reason I am asking is that I compiled agent+±4.3.1 as it is and I could not obtain the snmpFrameworkMIBObjects ->snmpEngine ( It would always return zeros for all OID from this subtree.
After some investigation (comparing atm-mib example with agenpro) find out that module_init is actually embedded in init() function in atm-mib example. I then make changes in the agenpro main function to call module_init before init() and I got it working: I could get snmpFrameworkMIBObjects.

Can you please, let me know you opinion about it?


Hi Safet,

Most likely, the error was to add the SNMP-FRAMEWORK-MIB to the MIB modules configured to be generated by AgenPro.

Those generated stubs (without instrumentation and thus 0 values) overwrite the AGENT++ built-in implementation of that MIB when module_init(mib) is called. When you move that initialisation before init(..) of the main agent (which is not recommended), then the built-in implementation overwrites the generated one. That’s why you then see some values.

As a general rule of thumb, generate only MIB modules with AgenPro which are not yet implemented by the AGENT++ framework. Otherwise you will get conflicts or need to implement instrumentation code, that has already implemented in the framework.

Hope this helps.

Best regards,

Hello Frank,

I understood, when I stared using AgenPro to generate the code for the Agent, that all modules I want to be supported I have to add them plus my own MIBs.
After your mention the rules for the inclusion of MIBs I removed the standards MIB, initialized users modules with module_init(mib), after the initialization of standard supported modules init(..) and now there is no issues.
Thank you for your help. Appreciate it very much.