GithubHelp home page GithubHelp logo

Comments (6)

richardforth avatar richardforth commented on May 26, 2024

While technically we are drifting into application land, I added this because parsing apache error logs is in theory an apache administration task. So, This does not come under "scope creep" and I am happy to work on this if it is popular.

from apache2buddy.

richardforth avatar richardforth commented on May 26, 2024

Slight snag though, apache2buddy has traditionally only scanned the generic apache error log in /var/log/httpd/[error.log / error_log](depending on distro).

Would it be worth the time scanning all the error logs and reporting on each one individually? What if they have 200 vhosts with individual log files? Hmmm. Also would this produce too much data? No, not if we limit it to the top 5 maybe.But the 200 vhosts = 200 logs....still thats a lot of output. It might take too long.

Thoughts?

from apache2buddy.

richardforth avatar richardforth commented on May 26, 2024

Kept it simple for now, similar to maxclients hit detection, show last 5 PHP Fatal Errrors

from apache2buddy.

richardforth avatar richardforth commented on May 26, 2024
       # Check 19 : PHP Fatal Errors
        # This has been abstracted out into a separate subroutine
        # This addresses issue #6 'Check for and report on PHP Fatal Errors in the logs'
        detect_php_fatal_errors($model, $process_name);
}

sub detect_php_fatal_errors {
        our ($model, $process_name) = @_;
        if ($model eq "worker") {
                return;
        } else {
                if ( ! $NOINFO ) {
                        print "\n${PURPLE}Detecting PHP Fatal Errors....${ENDC}\n";
                        print "\n${CYAN}PRO TIP: If this process appears to hang, press CTRL + c to exit the program, and then\ngo check for a large error log file in /var/log/httpd or /var/log/apache2.${ENDC}\n\n";
                }
        }
        our $phpfatalerr = 0;
        if ($process_name eq "/usr/sbin/httpd") {
                our $phpfatalerr_hits = `grep -i fatal /var/log/httpd/error_log  | tail -5`;
        } elsif ($process_name eq "/usr/local/apache/bin/httpd") {
                our $phpfatalerr_hits = `grep -i fatal /usr/local/apache/logs/error_log | tail -5`;
        } else {
                our $phpfatalerr_hits = `grep -i fatal /var/log/apache2/error.log | tail -5`;
        }
        our $phpfatalerr_hits;
        if ($phpfatalerr_hits) {
                $phpfatalerr = 1;
        }
        our $phpfatalerr;
        if ($phpfatalerr) {
                if ( ! $NOWARN ) {
                        show_warn_box();
                        print "${RED}PHP Fatal errors were found, see the last 5 entries below${ENDC}\n";
                        show_advisory_box(); print "${YELLOW}Check the logs, there may be much more.${ENDC}\n";
                        print $phpfatalerr_hits;
                }
        } else {
                if ( ! $NOOK ) {
                        show_ok_box();
                        print "${GREEN}No PHP Fatal errors were found.${ENDC}\n";
                        return;
                }
        }
}

from apache2buddy.

richardforth avatar richardforth commented on May 26, 2024

Only checking the main error log in apache, not sure if php fatal errors are logged in both vhost AND main error logs or not.

may adjust code slightly

from apache2buddy.

richardforth avatar richardforth commented on May 26, 2024
        # Check 19 : PHP Fatal Errors
        # This has been abstracted out into a separate subroutine
        # This addresses issue #6 'Check for and report on PHP Fatal Errors in the logs'
        detect_php_fatal_errors($model, $process_name);
}

sub detect_php_fatal_errors {
        our ($model, $process_name) = @_;
        if ($model eq "worker") {
                return;
        } else {
                if ( ! $NOINFO ) {
                        print "\n${PURPLE}Detecting PHP Fatal Errors....${ENDC}\n";
                        print "\n${CYAN}PRO TIP: If this process appears to hang, press CTRL + c to exit the program, and then\ngo check for a large error log file in /var/log/httpd or /var/log/apache2.${ENDC}\n\n";
                }
        }
        our $phpfatalerr = 0;
        if ($process_name eq "/usr/sbin/httpd") {
                our $phpfatalerr_hits = `grep -Hi fatal /var/log/httpd/* | grep -i php | grep -i error | tail -5`;
        } elsif ($process_name eq "/usr/local/apache/bin/httpd") {
                our $phpfatalerr_hits = `grep -Hi fatal /usr/local/apache/logs/* | grep -i php | grep -i error | tail -5`;
        } else {
                our $phpfatalerr_hits = `grep -Hi fatal /var/log/apache2/* | grep -i php | grep -i error | tail -5`;
        }
        our $phpfatalerr_hits;
        if ($phpfatalerr_hits) {
                $phpfatalerr = 1;
        }
        our $phpfatalerr;
        if ($phpfatalerr) {
                if ( ! $NOWARN ) {
                        show_warn_box();
                        print "${RED}PHP Fatal errors were found, see the last 5 entries below${ENDC}\n";
                        show_advisory_box(); print "${YELLOW}Check the logs, there may be much more.${ENDC}\n";
                        print $phpfatalerr_hits;
                }
        } else {
                if ( ! $NOOK ) {
                        show_ok_box();
                        print "${GREEN}No PHP Fatal Errors were found.${ENDC}\n";
                        return;
                }
        }
}

Committed to master branch, closing.

from apache2buddy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.