You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by F10 <as...@ukr.net> on 2010/05/18 17:07:48 UTC

Logging CPU / Memory usage

Hello list
I am writing a module that would be logged cpu time and memory usage for each query to the vhost.
Need help how to implement it.
-- 
Only one 0_o

Re: Logging CPU / Memory usage

Posted by F10 <as...@ukr.net>.
Yes, this module don't work with the threaded.
How can I get a correct data, when the request will be completed.
May be there is another hook that is called after the completed request.


On Thu, May 20, 2010 at 09:42:01PM +0200, Ben Noordhuis wrote:
> You are updating global variables in code that is run concurrently. It
> might work OK with the pre-fork MPM but it certainly won't with the
> threaded MPM.
> 
> 

-- 
Only one 0_o

Re: Logging CPU / Memory usage

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
You are updating global variables in code that is run concurrently. It
might work OK with the pre-fork MPM but it certainly won't with the
threaded MPM.

Re: Logging CPU / Memory usage

Posted by F10 <as...@ukr.net>.
I created a module,

http://paste.org/pastebin/view/18743

apxs2 -c -i mod_foo.c
LoadModule myhits_module /usr/lib/apache2/modules/mod_foo.so
LogFormat "%{cpu}n" rusage
CustomLog /tmp/access.log rusage

The problem is when I run this http://paste.org/pastebin/view/18744 script the first time, 
the values are equal to 0, but must be like this

#php php.php > /dev/null; time
shell  0.52s user 0.10s system 0% cpu 150:48:31.83 total
children  87.95s user 25.02s system 0% cpu 150:48:31.83 total

The following requests of the script shows the correct conclusion cpu.
Why in the first time, cpu equal 0, how to fix it?

On Tue, May 18, 2010 at 06:07:48PM +0300, F10 wrote:
> Hello list
> I am writing a module that would be logged cpu time and memory usage for each query to the vhost.
> Need help how to implement it.
> -- 
> Only one 0_o
> 
> 

-- 
Only one 0_o

Re: Logging CPU / Memory usage

Posted by F10 <as...@ukr.net>.
Thank you for your reply.
I'll see how this module works.

On Tue, May 18, 2010 at 05:23:51PM +0200, Jerome Renard wrote:
> Hello,
> 
> On Tue, May 18, 2010 at 5:07 PM, F10 <as...@ukr.net> wrote:
> > Hello list
> > I am writing a module that would be logged cpu time and memory usage for each query to the vhost.
> > Need help how to implement it.
> 
> How about reading how mod_status works first ? :)
> 
> - http://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/generators/mod_status.c
> 
> Cheers,
> 
> --
> Jérôme
> 
> 

-- 
Only one 0_o

Re: Logging CPU / Memory usage

Posted by Jerome Renard <je...@gmail.com>.
Hello,

On Tue, May 18, 2010 at 5:07 PM, F10 <as...@ukr.net> wrote:
> Hello list
> I am writing a module that would be logged cpu time and memory usage for each query to the vhost.
> Need help how to implement it.

How about reading how mod_status works first ? :)

- http://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/generators/mod_status.c

Cheers,

--
Jérôme