Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Pipe apache 2.4 ErrorLog to script

Discussion in 'General Discussion' started by GrandAdmiral, Jan 18, 2016.

  1. GrandAdmiral

    GrandAdmiral Active Member

    Joined:
    May 21, 2014
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi

    Title pretty much says it all, I'm testing a new way of pinning down redirection loops by piping errors through a script which recognizes the relevant error and simultaneously captures the Apache request status. This would show the faulty script without bogging down the entire server by putting Apache into debug logging mode.

    I've managed to get a script written and it does execute when Apache starts but only for the first two errors then nothing.

    I've added this line to the pre-virtual host include (the script includes writing to the error_log):
    Code:
    ErrorLog "|$/usr/local/apache/ApacheState.pl"
    And here is the script:
    Code:
    #!/usr/bin/perl
    
    $|=1; # Don't buffer
        use strict;
        use warnings;
        use LWP::Simple;
    
    open (MYFILE, '>>/usr/local/apache/logs/error_log');
    print MYFILE get('http://127.0.0.1/whm-server-status');
    my $input = <STDIN>;
    chomp($input);
    print MYFILE $input;
    close (MYFILE);
    exit;
    Help!
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,509
    Likes Received:
    1,964
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice