1

I am trying to write a snmp subagent that using agentX, which is supported by net-snmp. At first, I used the example codes from net-snmp FAQ:

http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_Subagent

And from the example codes (example-demon.c,nstAgentSubagentObject.c,nstAgentSubagentObject.h), I build a subagent which can use agentX to perform snmpget and snmpset.

My question is: From the code in nstAgentSubagentObject.c, there are many trace codes such as follows:

DEBUGMSGTL(("nstAgentSubagentObject",
                "Initializing the nstAgentSubagentObject module\n"));

But I can't see the log anywhere.

I tried to start snmpd (demon of snmp) by snmpd -f -DnstAgentSubagentObject -Lf /tmp/snmp.log.

But I still can't see the log. Could anyone tell me how to see the log of DEBUGMSGTL?

zhaojing
  • 585
  • 3
  • 11
  • 33

3 Answers3

2

i can just set flag :

-Dverbose

or if you want to see all logs :

-Dall
Mapedd
  • 702
  • 7
  • 16
1

Instead of starting snmpd with -D nstAgentSubagentObject you want to pass that command-line option to your subagent when you start it.

In the tutorial it suggests starting the subagent with the following command:

% ./mysubagent &

To enable the more debug messages, try starting it with the following command instead:

% ./mysubagent -D nstAgentSubagentObject

If I remember correctly, that should print out the debug output to the console. You can combine it with the -L option if you'd prefer it written to a file.

lostriebo
  • 1,483
  • 1
  • 16
  • 25
1

FYI, you can also put the following into a snmp.conf file and twiddle the options there too:

debugTokens nstAgentSubagentObject
doDebugging 1

But, the other answer is spot on: you need to turn on debugging where the code will be hit, which is in the subagent (the snmp.conf file will be read by both).

Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69