Dear Dave:
Thanks a lot.
But I don't realize how to use DEBUGMSG( ) correct.
For example:
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include<net-snmp/agent/debug_handler.h>
#include "ucdSnmpTutorialMIB.h"
#include<stdio.h>
#include<string.h>
void
init_ucdSnmpTutorialMIB(void)
{
static oid ustSSSimpleString_oid[] =
{ 1, 3, 6, 1, 4, 1, 2021, 13, 4242, 1, 1, 1 };
static oid ustSSSecondsSinceChanged_oid[] =
{ 1, 3, 6, 1, 4, 1, 2021, 13, 4242, 1, 1, 2 };
DEBUGMSG("ucdSnmpTutorialMIB Initializing", "\n"));
......}
The message after compiler will show that too few argument to function
debugmsg, and error : macro "DEBUGMSG" pass two arguments, but take
as just 1.
I don' know how to use that, can you instruct me how to apply DEBUGMSG,
thanks a lot.
Best Regards,
Clement Hsu
2007/1/8, Dave Shield <[EMAIL PROTECTED]>:
On 26/12/06, Clement Hsu <[EMAIL PROTECTED]> wrote:
> I meet a problem of how to debug snmp codes
> the following is my code...
> void
> init_ustScalarSet(void)
> {
>
> DEBUGMSGTL(("ustScalarSet", "Initializing\n"));
>
> REGISTER_MIB("ustScalarSet", ustScalarSet_variables, variable4,
> ustScalarSet_variables_oid);
[snip]
That would be activated by running the agent using
snmpd -DustScalarSet -f -Le
(The '-f -Le' isn;t strictly necessary, but it often helps to see debug
output
if the agent is run directly on the command line).
> unsigned char *
> var_ustScalarSet(struct variable *vp,
> oid * name,
> size_t *length,
> int exact, size_t *var_len, WriteMethod **
write_method)
> {
I'd probably have some debug code here, to tell if the routine is called
at all.
> if (header_generic(vp, name, length, exact, var_len, write_method)
> == MATCH_FAILED)
> return NULL;
>
> switch (vp->magic) {
> case USTSSSIMPLESTRING:
> *write_method = write_ustSSSimpleString;
>
> printf("check some thing");
I'd use the same DEBUGMSG() style code - rather than direct print
statements.
That way it works even when the agent is run as a daemon.
>
> return (u_char *);
But return what?
I wouldn't expect this code to even compile!
> case USTSSSECONDSSINCECHANGED:
>
> printf("check error , this is snmpget");
Again, use DEBUGMSG()
> After I give the command as belowed:
>
> gcc -I/usr/local/include -fPIC -shared –c –o ustScalarSet.c
ustScalarSet.o
> gcc -I/usr/local/include -fPIC -shared –o ustScalarSet.so
ustScalarSet.o
>
>
> and add a line to snmpd.conf :
> dlmod ustScalarSet /usr/local/temp/ustScalarSet.so
>
> After I pass the gcc compile, when I use snmpget, the message show
there
> doesn't exist such objet, I don't know why, and how to give the exact
command to
> debug the above codes and how to find out the problem where it is
Please see the FAQ entry
" I've added my code to this template and it still doesn't work. Why
not?"
(http://net-snmp.sourceforge.net/wiki/index.php/FAQ:Coding_13)
That gives you a checklist of things to work through.
Dave
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders