Dear Sir,

I am writing to thank you for your letter and say,

On Sat, Jan 15, 2005 at 08:00:08PM +0000, Nick Ing-Simmons wrote:

  [snip]
 
> >that the fault is in either the FreeBSD Perl or the 
> >embedding support (the use of the Perl API hasn't changed between 1.2 
> >and 2.0, nor has the Perl shim that is called by Nagios).
> 
> If Nagios without perl doesn't leak (and I assume given its use 
> people would notice) that seems reasonable.
> 
> However the perl API for a threaded perl is slightly different,
> so if use hasn't changed with a move to threaded perl that _may_ 
> be the problem. If Nagios is itself "thread hot", then there may be 
> some house keeping additions so that each new Nagios thread that calls
> perl allocates and cleans up correctly.
> 
> >
> >Instrumenting the Perl shim (copied from perlembed) that determines 
> >whether the Perl service check program is feasable as is any amount of 
> >testbedding. 
> 
> Can I/we see the shim?
> 

The shim is viewable at

http://cvs.sourceforge.net/viewcvs.py/nagios/nagios/p1.pl?only_with_tag=HEAD&view=markup

(yes, it needs rethinking and there seem to be some problems with the 
logging that I thought had been dealt with).

( BTW, the leak rate is <= 600kB/hour not 1-2 MB/hour. Here are some 
recent mem sizes

tsitc> tail -20  restart_on_image-size_threshold.log
WARNING (VSZ>-1): 21144 21144 21144 21144 21144 21144 21144 21144 21260 
21144
Sun Jan 16 11:40:02 EST 2005: No restart necessary.
Sun Jan 16 12:00:00 EST 2005: Checking if memory size of Nagios process 
>= 40000 kB.
WARNING (VSZ>-1): 21336 21336 21336 21336 21336 21336 21336 21336 21452 
21336 21336 21336
Sun Jan 16 12:00:01 EST 2005: No restart necessary.
Sun Jan 16 12:20:00 EST 2005: Checking if memory size of Nagios process 
>= 40000 kB.
WARNING (VSZ>-1): 21208 21208 21208 21208 21208 21208 21208 21208 21324 
21208
Sun Jan 16 12:20:02 EST 2005: No restart necessary.
Sun Jan 16 12:40:01 EST 2005: Checking if memory size of Nagios process 
>= 40000 kB.
WARNING (VSZ>-1): 21408 21408 21408 21408 21408 21408 21408 21408 21524 
21408
Sun Jan 16 12:40:02 EST 2005: No restart necessary.
Sun Jan 16 13:00:00 EST 2005: Checking if memory size of Nagios process 
>= 40000 kB.
WARNING (VSZ>-1): 21620 21620 21620 21620 21620 21620 21620 21620 21736 
21620 21620 21620
Sun Jan 16 13:00:02 EST 2005: No restart necessary.
Sun Jan 16 13:20:01 EST 2005: Checking if memory size of Nagios process 
>= 40000 kB.
WARNING (VSZ>-1): 21476 21476 21476 21476 21476 21476 21476 21476 21592 
21476
Sun Jan 16 13:20:02 EST 2005: No restart necessary.
Sun Jan 16 13:40:00 EST 2005: Checking if memory size of Nagios process 
>= 40000 kB.
WARNING (VSZ>-1): 21688 21688 21688 21688 21688 21688 21688 21688 21804 
21688
Sun Jan 16 13:40:02 EST 2005: No restart necessary.
)

The call to Perl is mainly at

http://cvs.sourceforge.net/viewcvs.py/nagios/nagios/base/checks.c?rev=1.73&only_with_tag=HEAD&view=markup

Or here are what I think are the relvant bits  (from checks.c)

#ifdef EMBEDDEDPERL
        if(isperl){
 
                SV *plugin_out_sv ;
                char *perl_plugin_output ;
                int count ;
 
                /* execute our previously compiled script - from 
perl_call_argv("Embed::Persistent::eval_file",..) */
                ENTER;
                SAVETMPS;
                PUSHMARK(SP);
                XPUSHs(sv_2mortal(newSVpv(args[0],0)));
                XPUSHs(sv_2mortal(newSVpv(args[1],0)));
                XPUSHs(sv_2mortal(newSVpv(args[2],0)));
                XPUSHs(sv_2mortal(newSVpv(args[3],0)));
                PUTBACK;
                count = perl_call_pv("Embed::Persistent::run_package", 
G_EVAL | G_ARRAY);
                SPAGAIN;
                plugin_out_sv = POPs;
                perl_plugin_output = SvPOK(plugin_out_sv) && 
(SvCUR(plugin_out_sv) > 0) ? savepv(SvPVX(plugin_out_sv))
                                                                                
        
: savepv("(No output!)\n") ;
                strncpy(plugin_output, perl_plugin_output, 
sizeof(plugin_output));
                /* The Perl scalar corresponding to pclose_result could 
contain string or integer.
                   It is better to let POPi do the dirty work (SvPVOK or 
SvIOK could be true).
                 */
                pclose_result = POPi ;
                PUTBACK;
                FREETMPS;
                LEAVE;
 
                /* check return status  */
                if(SvTRUE(ERRSV)){
                        pclose_result=-2;
#ifdef DEBUG1
                        printf("embedded perl ran %s with error 
%s\n",fname,SvPV(ERRSV,PL_na));
#endif
                        }
 
                strip(plugin_output);
 
#ifdef DEBUG1
                printf("embedded perl plugin output was 
%d,%s\n",pclose_result, plugin_output);
#endif

and here is the init (from utils.c)

int init_embedded_perl(void){
#ifdef EMBEDDEDPERL
        char *embedding[] = { "", "" };
        int exitstatus = 0;
        char buffer[MAX_INPUT_BUFFER];

        embedding[1]=p1_file;

        use_embedded_perl=TRUE;

        if((my_perl=perl_alloc())==NULL){
                use_embedded_perl=FALSE;
                snprintf(buffer,sizeof(buffer),"Error: Could not 
allocate memory for embedded Perl interpreter!\n");
                buffer[sizeof(buffer)-1]='\x0';
                
write_to_logs_and_console(buffer,NSLOG_RUNTIME_ERROR,TRUE);
                return ERROR;
                }

        perl_construct(my_perl);
        exitstatus=perl_parse(my_perl,xs_init,2,embedding,NULL);
        if(!exitstatus)
                exitstatus=perl_run(my_perl);

#endif
        return OK;
        }

Thank you for your encouraging words.

Yours sincerely.

-- 
Stanley Hopcroft

IP Australia
Ph: (02) 6283 3189  Fax: (02) 6281 1353
PO Box 200 Woden  ACT 2606
http://www.ipaustralia.gov.au
--
This message contains privileged and confidential information only 
for use by the intended recipient.  If you are not the intended 
recipient of this message, you must not disseminate, copy or use 
it in any manner.  If you have received this message in error, 
please advise the sender by reply e-mail.  Please ensure all 
e-mail attachments are scanned for viruses prior to opening or 
using.

Reply via email to