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.

Pipe apache 2.4 ErrorLog to script

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

  1. GrandAdmiral

    GrandAdmiral Member

    Joined:
    May 21, 2014
    Messages:
    19
    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 Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page