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?
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.