Re: question on AgentX sub-agent logging

"Steve S. Law" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Thanks

Compile OK now. I still have link error: 
"undefined reference to `setup_log'".

Here is what my Makefile looks like:


BUILDAGENTLIBS=`net-snmp-config --agent-libs`

sub-agent: $(OBJ)
        $(CC) -o sub-agent $(OBJ)  $(BUILDAGENTLIBS)

Am I missing some library in order to use setup_log?

Steve




--- "Anand R. Thillaivillagam"
<[email protected]> wrote:

> Replace SUBAGENT_LOGFILE with
> "/var/log/subagent.log"
> i.e.
> 
> logh->token = strdup("var/log/subagent.log");
> 
> Include  the following net-snmp header files:
> #include <net-snmp/net-snmp-config.h>
> #include <net-snmp/net-snmp-includes.h>
> #include <net-snmp/agent/net-snmp-agent-includes.h>
> 
> Also define
> netsnmp_log_handler *logh;
> in your C program.
> 
> Anand
> 
> Steve S. Law wrote:
> 
> >Hi,
> >Thanks for the info. I added the lines to my
> sub-agent
> >code but it won't compile (error is: "undeclared
> >SUBAGENT-LOGFILE"). If I commented out that line,
> then
> >the link failed ("undefined reference to
> >`setup_log'").
> >
> >What header file or/and library am I missing?
> >Thanks
> >Steve
> >Thillaivillagam" <[email protected]> wrote:
> >
> >  
> >
> >>Put the following lines of code in your subagent
> >>program:
> >>
> >>        logh =
>
>>netsnmp_register_loghandler(NETSNMP_LOGHANDLER_FILE,
> >>
> >>LOG_DEBUG);
> >>        if (logh)
> >>        {
> >>                logh->pri_max = LOG_EMERG;
> >>         
> >>        }
> >> 
> >>        setup_log(0, /* 1=Don't zero log, instead
> >>append to it */
> >>                          0, /* stderr_log */
> >>                          /var/log/subagent.log);
> /*
> >>*/
> >>
> >>The subagent will log to subagent.log.
> >>
> >>Anand
> >>
> >>
> >>Steve S. Law wrote:
> >>
> >>    
> >>
> >>>In my sub-agent program, I have
> >>>      
> >>>
> >>snmp_enable_calllog()
> >>    
> >>
> >>>and
> >>>several snmp_log()calls but nothing is being
> logged
> >>>      
> >>>
> >>in
> >>    
> >>
> >>>/var/log/snmpd.log file (default?). I thought
> >>>snmpd.log is only for AgentX master agent and not
> >>>      
> >>>
> >>for
> >>    
> >>
> >>>sub-agent?  Or even sub-agent will be logged to
> the
> >>>same file also? Clearly, I don't want my
> sub-agent
> >>>      
> >>>
> >>and
> >>    
> >>
> >>>master agent logging to the same file. I want to
> >>>      
> >>>
> >>have
> >>    
> >>
> >>>a log file for sub-agent separately. How do I do
> >>>      
> >>>
> >>it?
> >>    
> >>
> >>>I still have no luck in logging.
> >>>
> >>>Please help.
> >>>
> >>>Steve
> >>>
> >>>
> >>>--- Robert Story <[email protected]> wrote:
> >>>
> >>> 
> >>>
> >>>      
> >>>
> >>>>On Fri, 29 Jul 2005 15:07:11 -0700 (PDT) Steve
> >>>>wrote:
> >>>>SSL> So far I have been using printf statements
> in
> >>>>my
> >>>>SSL> sub-agent. I want to log them into a file
> >>>>instead, so
> >>>>SSL> in the sub-agent main program, I set
> 'syslog'
> >>>>to 1
> >>>>SSL> which invokes snmp_enable_callog().
> However,
> >>>>when I
> >>>>SSL> run it, I don't see any thing on the
> screean
> >>>>but I
> >>>>SSL> don't know where and if anything is being
> >>>>logged at
> >>>>SSL> all in any file.
> >>>>
> >>>>The default log file is /var/log/snmpd.log.
> >>>>
> >>>>SSL> Can you tell me what I should do? Do I need
> >>>>        
> >>>>
> >>to
> >>    
> >>
> >>>>write
> >>>>SSL> more code? what is DEBUGMSG for? I should
> use
> >>>>DEBUGMSG
> >>>>SSL> instead of printf in my code?
> >>>>
> >>>>If you always want to log, then snmp_log() is
> >>>>probably what you want. If it is
> >>>>really debug, and you only want to see it when
> the
> >>>>right debug flag is
> >>>>enabled, then use the DEBUG* macros.
> >>>>
> >>>>-- 
> >>>>NOTE: messages sent directly to me, instead of
> the
> >>>>lists, will be deleted
> >>>>     unless they are requests for paid
> consulting
> >>>>services.
> >>>>
> >>>>Robert Story; NET-SNMP Junkie
> >>>>Support: <http://www.net-snmp.org/>
> >>>><irc://irc.freenode.net/#net-snmp>  
> >>>>Archive:
> >>>>
> >>>>   
> >>>>
> >>>>        
> >>>>
>
>><http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-users>
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>You are lost in a twisty maze of little
> standards,
> >>>>all different. 
> >>>>
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>
> >>>      
> >>>
>
>>-------------------------------------------------------
> >>    
> >>
> >>>SF.Net email is Sponsored by the Better Software
> >>>      
> >>>
> 
=== message truncated ===



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.