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