The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Build apache with custom patches

Discussion in 'EasyApache' started by HEKTO, Dec 7, 2007.

  1. HEKTO

    HEKTO Member

    Joined:
    Dec 17, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Hi!

    I want to rebuild my apache with one little patch which gives ability for apache to change its process title in order to include url there. I need it to have additional information in 'top' results to know what exact proccesses are eating too much cpu.

    How can I do this? I need to keep all other options made by me using easyapache and just only apply one patch with setproctitle. Help me please!
     
  2. DaveUsedToWorkHere

    DaveUsedToWorkHere Well-Known Member

    Joined:
    Dec 28, 2001
    Messages:
    689
    Likes Received:
    1
    Trophy Points:
    18
    Depending on your patch, you can find information about customizing your Apache install here http://www.cpanel.net/support/docs/ea/ea3/
     
  3. HEKTO

    HEKTO Member

    Joined:
    Dec 17, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    I don't know if someone need to know how to apply custom patches to apache using Easyapache plugin system but since I've managed to do it with lack of official information I am going to share it with everyone who may concern.

    My goal is to patch apache 1.3 working in the linux enviroment to be able to see in the 'top' results what request each apache process handles every moment. I need to monitor it cause servers do not use phpSuExec and cause it is impossible to catch heavy processes using only mod_stat.

    I'm not going to describe all of the researching process and will give you only results :)

    Firstly I have to say that by default linux systems have no function to change titles of processes. So I had to find appropriate library. I took it from Alt Linux repositary. Here is the link ( ftp://ftp.altlinux.com/pub/distribu...s/files/SRPMS/setproctitle-0.3.1-alt1.src.rpm ). After installation I've got libsetproctitle.so shared library in my /usr/lib directory.

    After that I've written perl module for easy apache. I named it as SetProcTitlePatch.pm and placed it into /var/cpanel/easy/apache/custom_opt_mods/Cpanel/Easy/Apache

    Here is the source:

    -[cut here]-----------

    package Cpanel::Easy::Apache::SetProcTitlePatch;

    our $easyconfig = {

    'name' => 'SetProcTitle patch',
    'version' => '$Rev: 1 $',
    'hastargz' => 1,
    'url' => '',

    'dryrun' => {
    '0' => {
    'name' => 'Checking for Apache 1',
    'command' => sub {
    my ($self) = @_;
    $ap_ver = $self->{'working_profile'}{'Apache'}{'version'};
    if ( $ap_ver ne '1' ) {
    return ( 0, 'Not valid for [_1]', "Apache $ap_ver" );
    }
    return ( 1, 'Ok' );
    },
    },
    },

    'step' => {
    '0' => {
    'name' => 'Applying SetProcTitle patch',
    'command' => sub {
    my ($self) = @_;
    return $self->apply_patch( 'apache_set_proc_title.patch' );
    },
    },
    },
    };

    1;

    -[cut here]-----------

    I also prepared the patch, named it 'apache_set_proc_title.patch' and put it to the tarball named SetProcTitlePatch.pm.tar.gz into the same directory with SetProcTitlePatch.pm.

    Here is the source of the patch:

    -[cut here]-----------

    --- apache_1.3.39/src/main/http_main.c 2007-06-04 23:26:21.000000000 +0400
    +++ apache_1.3.39/src/main/http_main.c 2007-12-07 14:25:44.000000000 +0300
    @@ -63,6 +63,9 @@
    #include "scoreboard.h"
    #include "multithread.h"
    #include <sys/stat.h>
    +
    +#include <setproctitle.h>
    +
    #ifdef USE_SHMGET_SCOREBOARD
    #include <sys/types.h>
    #include <sys/ipc.h>
    @@ -4862,6 +4865,8 @@
    * signal (SIGUSR1, SIG_IGN);
    */

    + setproctitle( "%s%s", r->hostname, r->unparsed_uri );
    +
    (void) ap_update_child_status(my_child_num, SERVER_BUSY_WRITE, r);

    /* process the request if it was read without error */

    -[cut here]-----------

    For correct compilation I had to point to the apache make script that it should use shared-library for linking. I did it creating file named LIBS in /var/cpanel/easy/apache/rawenv.
    It contains only one line:

    -[cut here]-----------
    -lsetproctitle
    -[cut here]-----------

    After I did all of that things I can recompile apache server selecting this patch in Easyapache interface. And now I can monitor heavy processes just pressing 'c' key in 'top' :)

    I hope it can be useful for anybody.
     
Loading...

Share This Page