Mailing List Archive

Please help: resource limit for running Perl under Apache?
Hi, I've a Perl script that does following:

- Ssh to a device and get information, e.g.: open(DEV, "/usr/bin/ssh -v statuser\@192.168.11.1 sh get client list| ");

- Loop through the result and display as html.

The Perl script can complete without problem when run in bash or in Apache 2.2.

However, when I put it on a new Apache 2.4 server, the script can't display all output - the output table expected to be 1000 lines now ends at ~300. Checked that it seems the ssh command terminated prematurely. The "while (<DEV>)" loop exists as there is no more input data. The Perl can also complete without problem when run in bash on the same server running Apache 2.4.

I wonder if there is any resource limit for CGI/Perl when running under Apache 2.4. Default OS resource limit looks alright:

stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 15014
virtual memory (kbytes, -v) unlimited

Sorry that I'm not web admin and don't have access to Apache logs.

Would anyone please help? Thanks a lot.

Regards
Re: Please help: resource limit for running Perl under Apache? [ In reply to ]
Hi.

It sounds like what you need to do is :
add some logging directly in your perl script, to a separate logfile.
(And maybe re-open STDERR to that same logfile).
Then you will see exactly where and why the perl script crashes under Apache.
Do not forget that when the perl script runs under Apache, it runs under the same user-id
as the Apache webserver.

On 22.05.2017 12:40, ST Wong (ITSC) wrote:
> Hi, I?ve a Perl script that does following:
>
> -Ssh to a device and get information, e.g.: open(DEV, ?/usr/bin/ssh -v
> statuser\@192.168.11.1 sh get client list| ");
>
> -Loop through the result and display as html.
>
> The Perl script can complete without problem when run in bash or in Apache 2.2.
>
> However, when I put it on a new Apache 2.4 server, the script can?t display all output ?
> the output table expected to be 1000 lines now ends at ~300. Checked that it seems the
> ssh command terminated prematurely. The ?while (<DEV>)? loop exists as there is no more
> input data. The Perl can also complete without problem when run in bash on the same
> server running Apache 2.4.
>
> I wonder if there is any resource limit for CGI/Perl when running under Apache 2.4.
> Default OS resource limit looks alright:
>
> stack size (kbytes, -s) 8192
>
> cpu time (seconds, -t) unlimited
>
> max user processes (-u) 15014
>
> virtual memory (kbytes, -v) unlimited
>
> Sorry that I?m not web admin and don?t have access to Apache logs.
>
> Would anyone please help? Thanks a lot.
>
> Regards
>
RE: Please help: resource limit for running Perl under Apache? [ In reply to ]
Hi,

Thanks for your advice.
We've done before by writing data read from ssh command to separate log file. The output simply ends somewhere. Then the Perl script continues with the rest of the code, e.g. the Perl script prints some headings, then a table containing lines from the ssh command, and print some footnotes at the end of script. The output html looks 'normal' except there are fewer lines in the table. It's unlikely the Perl script aborted.

Will ask web admin to check Apache log for any hint.

Thanks again.

-----Original Message-----
From: Andr? Warnier (tomcat) [mailto:aw@ice-sa.com]
Sent: Monday, May 22, 2017 7:35 PM
To: modperl@perl.apache.org
Subject: Re: Please help: resource limit for running Perl under Apache?

Hi.

It sounds like what you need to do is :
add some logging directly in your perl script, to a separate logfile.
(And maybe re-open STDERR to that same logfile).
Then you will see exactly where and why the perl script crashes under Apache.
Do not forget that when the perl script runs under Apache, it runs under the same user-id as the Apache webserver.

On 22.05.2017 12:40, ST Wong (ITSC) wrote:
> Hi, I've a Perl script that does following:
>
> -Ssh to a device and get information, e.g.: open(DEV, "/usr/bin/ssh
> -v
> statuser\@192.168.11.1 sh get client list| ");
>
> -Loop through the result and display as html.
>
> The Perl script can complete without problem when run in bash or in Apache 2.2.
>
> However, when I put it on a new Apache 2.4 server, the script can't display all output -
> the output table expected to be 1000 lines now ends at ~300. Checked that it seems the
> ssh command terminated prematurely. The "while (<DEV>)" loop exists as there is no more
> input data. The Perl can also complete without problem when run in bash on the same
> server running Apache 2.4.
>
> I wonder if there is any resource limit for CGI/Perl when running under Apache 2.4.
> Default OS resource limit looks alright:
>
> stack size (kbytes, -s) 8192
>
> cpu time (seconds, -t) unlimited
>
> max user processes (-u) 15014
>
> virtual memory (kbytes, -v) unlimited
>
> Sorry that I'm not web admin and don't have access to Apache logs.
>
> Would anyone please help? Thanks a lot.
>
> Regards
>
Re: Please help: resource limit for running Perl under Apache? [ In reply to ]
You could try checking dmesg. Sometimes I see things like this in ours:

[4585112.266794] Out of memory: Kill process 18584 (perl) score 937 or
sacrifice child

[4585112.266842] Killed process 18584 (perl) total-vm:53547100kB,
anon-rss:47902052kB, file-rss:0kB

On Mon, May 22, 2017 at 9:13 PM, ST Wong (ITSC) <ST@itsc.cuhk.edu.hk> wrote:

> Hi,
>
> Thanks for your advice.
> We've done before by writing data read from ssh command to separate log
> file. The output simply ends somewhere. Then the Perl script continues
> with the rest of the code, e.g. the Perl script prints some headings, then
> a table containing lines from the ssh command, and print some footnotes at
> the end of script. The output html looks 'normal' except there are fewer
> lines in the table. It's unlikely the Perl script aborted.
>
> Will ask web admin to check Apache log for any hint.
>
> Thanks again.
>
> -----Original Message-----
> From: André Warnier (tomcat) [mailto:aw@ice-sa.com]
> Sent: Monday, May 22, 2017 7:35 PM
> To: modperl@perl.apache.org
> Subject: Re: Please help: resource limit for running Perl under Apache?
>
> Hi.
>
> It sounds like what you need to do is :
> add some logging directly in your perl script, to a separate logfile.
> (And maybe re-open STDERR to that same logfile).
> Then you will see exactly where and why the perl script crashes under
> Apache.
> Do not forget that when the perl script runs under Apache, it runs under
> the same user-id as the Apache webserver.
>
> On 22.05.2017 12:40, ST Wong (ITSC) wrote:
> > Hi, I've a Perl script that does following:
> >
> > -Ssh to a device and get information, e.g.: open(DEV, "/usr/bin/ssh
> > -v
> > statuser\@192.168.11.1 sh get client list| ");
> >
> > -Loop through the result and display as html.
> >
> > The Perl script can complete without problem when run in bash or in
> Apache 2.2.
> >
> > However, when I put it on a new Apache 2.4 server, the script can't
> display all output -
> > the output table expected to be 1000 lines now ends at ~300. Checked
> that it seems the
> > ssh command terminated prematurely. The "while (<DEV>)" loop exists as
> there is no more
> > input data. The Perl can also complete without problem when run in
> bash on the same
> > server running Apache 2.4.
> >
> > I wonder if there is any resource limit for CGI/Perl when running under
> Apache 2.4.
> > Default OS resource limit looks alright:
> >
> > stack size (kbytes, -s) 8192
> >
> > cpu time (seconds, -t) unlimited
> >
> > max user processes (-u) 15014
> >
> > virtual memory (kbytes, -v) unlimited
> >
> > Sorry that I'm not web admin and don't have access to Apache logs.
> >
> > Would anyone please help? Thanks a lot.
> >
> > Regards
> >
>
>


--
John Dunlap
*CTO | Lariat *

*Direct:*
*john@lariat.co <john@lariat.co>*

*Customer Service:*
877.268.6667
support@lariat.co