Giter VIP home page Giter VIP logo

apachebuddy.pl's Introduction

Apachebuddy.pl supercedes my own Redhat only bash script 'apachetuner.sh' so am hosting it.
However there is no active development on this perl script, because there are beter ways to achieve the same. 

Please check out Satori: http://satori.readthedocs.org/en/latest/ and 'ohai-solo' where most of the apachebuddy functionality has been implemented as Apache-plugins. See https://github.com/rackerlabs/ohai-plugins and particularly the Apache2 plugins: https://github.com/rackerlabs/ohai-plugins/blob/master/plugins/apache2.rb )

GET:
Grab this from http://apachebuddy.pl  (thanks to Will Parsons for that domain name)

BEWARE:
Do NOT run code you dont control as root on a server you care about. Who says something nefarious has not crept into this code? Just saying. Stay safe and review EVERYTHING.

If you use this daily, consider rolling .rpm and .debs for it.

apachebuddy.pl's People

Contributors

damianzaremba avatar gustavmaskowitz avatar oneiroi avatar tonyborries avatar will-parsons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apachebuddy.pl's Issues

DOS Newlines in Configs

On CentOS (6.4) Windows / DOS newlines in the config files cause a crash.

[root@tonyb-centoslamp apachebuddy.pl]# unix2dos /etc/httpd/conf/httpd.conf 
unix2dos: converting file /etc/httpd/conf/httpd.conf to DOS format ...
[root@tonyb-centoslamp apachebuddy.pl]# perl apachebuddy.pl 
########################################################################
# Apache Buddy v 0.3 ###################################################
########################################################################
Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/httpd
The process running on port 80 is Apache/2.2.15 (Unix)
Apache has been running 0d 0h 59m 40s
The full path to the Apache config file is: /etc/httpd/conf/httpd.conf
Apache is using prefork model

Examining your Apache configuration...
Apache runs as apache
Your max clients setting is 33

Analyzing memory use...
Your server has 489 MB of memory
Use of uninitialized value $proc_mem_usages[0] in division (/) at
    apachebuddy.pl line 330 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl will try to tell you the
    name of the variable (if any) that was undefined. In some cases it cannot
    do this, so it also tells you what operation you used the undefined value
    in.  Note, however, that perl optimizes your program and the operation
    displayed in the warning may not necessarily appear literally in your
    program.  For example, "that $foo" is usually optimized into "that "
    . $foo, and the warning will refer to the concatenation (.) operator,
    even though there is no . in your program.

Use of uninitialized value $proc_mem_usages[0] in division (/) at
    apachebuddy.pl line 336 (#1)
Use of uninitialized value $count in division (/) at apachebuddy.pl line 350 (#1)

Illegal division by zero at apachebuddy.pl line 350 (#2)
    (F) You tried to divide a number by 0.  Either something was wrong in
    your logic, or you need to put a conditional in to guard against
    meaningless input.

Uncaught exception from user code:
    Illegal division by zero at apachebuddy.pl line 350.
 at apachebuddy.pl line 350
    main::get_memory_usage('/usr/sbin/httpd', 'apache\x{d}', 'average') called at apachebuddy.pl line 1044
[root@tonyb-centoslamp apachebuddy.pl]# dos2unix /etc/httpd/conf/httpd.conf 
dos2unix: converting file /etc/httpd/conf/httpd.conf to UNIX format ...
[root@tonyb-centoslamp apachebuddy.pl]# perl apachebuddy.pl 
########################################################################
# Apache Buddy v 0.3 ###################################################
########################################################################
Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/httpd
The process running on port 80 is Apache/2.2.15 (Unix)
Apache has been running 0d 01h 00m 05s
The full path to the Apache config file is: /etc/httpd/conf/httpd.conf
Apache is using prefork model

Examining your Apache configuration...
Apache runs as apache
Your max clients setting is 33

Analyzing memory use...
Your server has 489 MB of memory
The largest apache process is using 6.92 MB of memory
The smallest apache process is using 6.92 MB of memory
The average apache process is using 6.92 MB of memory
Going by the average Apache process, Apache can potentially use 228.36 MB RAM (46.70 % of available RAM)
Going by the largest Apache process, Apache can potentially use 228.36 MB RAM (46.70 % of available RAM)

Generating reports...
### GENERAL REPORT ###

Settings considered for this report:

    Your server's physical RAM:     489MB
    Apache's MaxClients directive:      33
    Apache MPM Model:           prefork
    Largest Apache process (by memory): 6.92MB
[ OK ]  Your MaxClients setting is within an acceptable range.
    Max potential memory usage:         228.36 MB

    Percentage of RAM allocated to Apache   46.70 %

-----------------------------------------------------------------------
-----------------------------------------------------------------------

Ignore IfModule block if Module is not loaded

On Debian/Ubuntu you have blocks for each MPM, when apache-buddy extract the value it take the last value, here the MaxClients from the event MPM, but I'm in prefork

<IfModule mpm_prefork_module>
    StartServers         4
    MinSpareServers      5
    MaxSpareServers      20
    MaxClients           30
    MaxRequestsPerChild  4000
</IfModule>

<IfModule mpm_event_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>
# apache2 -l
Compiled in modules:
  core.c
  mod_log_config.c
  mod_logio.c
  mod_version.c
  prefork.c
  http_core.c
  mod_so.c

New line error

Apache Buddy v 0.3

Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/httpd
The process running on port 80 is Apache/2.4.18 (Amazon)
Apache has been running 0d 0h 05m 25s
The full path to the Apache config file is: /etc/httpd/conf/httpd.conf
Unable to determine whether Apache is using worker or prefork

Examining your Apache configuration...
Unsuccessful stat on filename containing newline at apachebuddy.pl line 125 (#1)
(W newline) A file operation was attempted on a filename, and that
operation failed, PROBABLY because the filename contained a newline,
PROBABLY because you forgot to chomp() it off. See "chomp" in perlfunc.

Apache runs as apache
Your max clients setting is 30

Analyzing memory use...
Your server has 995 MB of memory

Generating reports...

GENERAL REPORT

Settings considered for this report:

    Your server's physical RAM:             995MB
    Apache's MaxClients directive:          30
    Apache MPM Model:                       0
    Largest Apache process (by memory):     25.99MB


Question: get_apache_model

In get_apache_model()

my $model = $process_name -l | egrep "worker.c|prefork.c";

doesn't work in CENTOS 7.0 when I switch over from prefork to mpm

I had to hack the code to use $process_name -V | egrep "worker|prefork" to determine mpm/worker.

NGINX

I wish this could be ported for NGINX web engine.

Unable to open file: /etc/apache2/conf.d/*

Running apachebuddy.pl on an ubuntu server on rackspace:

$ sudo perl apachebuddy.pl

Apache Buddy v 0.3

Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/apache2
The process running on port 80 is Apache/2.2.14 (Ubuntu)
Apache has been running 0d 0h 06m 09s
The full path to the Apache config file is: /etc/apache2/apache2.conf
Apache is using prefork model

Examining your Apache configuration...
Uncaught exception from user code:
Unable to open file: /etc/apache2/conf.d/*
at apachebuddy.pl line 91
main::find_included_files('ARRAY(0x284d0c0)', 'ARRAY(0x284bf20)', 0) called at apachebuddy.pl line 65
main::build_config_array('/etc/apache2/apache2.conf', 0) called at apachebuddy.pl line 1001

$ uname -a
Linux myserver 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux

Host in one place

Hi Gus,

Since I added a few changes, I just wanted to make sure that the "current "version is always served.

I registered 'apachebuddy.pl' domain which redirects to the raw master on GitHub.

I think it might be an idea to drop the RPMs and the Cloud Files link, unless you want to keep them up to date?

Will.

"An undefined value was used as if it were already defined."

Just trying this out for the first time on an Amazon Linux (more or less Centos 6) box. Got this output on the first shot:

Apache Buddy v 0.4

Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/httpd
The process running on port 80 is Apache/2.2.22 (Unix)
Apache has been running 0d 01h 29m 29s
The full path to the Apache config file is: /etc/httpd/conf/httpd.conf
Apache is using prefork model

Examining your Apache configuration...
Apache runs as site.com
Your max clients setting is 150

Analyzing memory use...
Your server has 7473 MB of memory
Use of uninitialized value $proc_mem_usages[0] in division (/) at
./apachebuddy.pl line 318 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl will try to tell you the
name of the variable (if any) that was undefined. In some cases it cannot
do this, so it also tells you what operation you used the undefined value
in.  Note, however, that perl optimizes your program and the operation
displayed in the warning may not necessarily appear literally in your
program.  For example, "that $foo" is usually optimized into "that "
. $foo, and the warning will refer to the concatenation (.) operator,
even though there is no . in your program.

Use of uninitialized value $proc_mem_usages[0] in division (/) at
./apachebuddy.pl line 324 (#1)
Use of uninitialized value $count in division (/) at ./apachebuddy.pl line 338 (#1)

Illegal division by zero at ./apachebuddy.pl line 338 (#2)
(F) You tried to divide a number by 0. Either something was wrong in
your logic, or you need to put a conditional in to guard against
meaningless input.

Uncaught exception from user code:
Illegal division by zero at ./apachebuddy.pl line 338.
at ./apachebuddy.pl line 338
main::get_memory_usage('/usr/sbin/httpd', 'site.com', 'average') called at ./apachebuddy.pl line 1027

"Could not find Apache process. Exiting..."

I have apache2 installed via apt-get on ubuntu 13.10 x64. Here is the output of apachebuddy:

########################################################################
# Apache Buddy v 0.3 ###################################################
########################################################################
Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/apache2
The process running on port 80 is not Apache. 
 Falling back to process list...
Could not find Apache process. Exiting...

So you can see it finds apache2, but it somehow doesn't think it's apache...

Exceptions on Debian Wheezy x64

########################################################################
# Apache Buddy v 0.3 ###################################################
########################################################################
Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/apache2
The process running on port 80 is Apache/2.2.22 (Debian)
Apache has been running 2d 20h 42m 22s
The full path to the Apache config file is: /etc/apache2/apache2.conf
Apache is using worker model

Examining your Apache configuration...
Uncaught exception from user code:
        Unable to open file: /etc/apache2/conf.d/*
 at apachebuddy.pl line 91
        main::find_included_files('ARRAY(0xfa2908)', 'ARRAY(0xfa28a8)', '/etc/apache2') called at apachebuddy.pl line 65
        main::build_config_array('/etc/apache2/apache2.conf', '/etc/apache2') called at apachebuddy.pl line 1001

Using the event mpm

Just tried this out and it doesn't report that I am using the event mpm. Furthermore, it is showing a maxclients value of 256, however, because I am using the event-mpm it should be showing the value of maxrequestworkers which is 500. That maxclients value is automatically written into the httpd.conf file and I am specifying my own values below it including the maxrequestworkers value as it should be for apache 2.4.

Apache Buddy v 0.3

Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/local/apache/bin/httpd
The process running on port 80 is Apache/2.4.16 (Unix)
Apache has been running 3d 02h 53m 29s
The full path to the Apache config file is: /usr/local/apache/conf/httpd.conf
Unable to determine whether Apache is using worker or prefork

Examining your Apache configuration...
Apache runs as nobody
Your max clients setting is 256

Analyzing memory use...
Your server has 7864 MB of memory

Generating reports...

GENERAL REPORT

Settings considered for this report:

    Your server's physical RAM:             7864MB
    Apache's MaxClients directive:          256
    Apache MPM Model:                       0
    Largest Apache process (by memory):     328.66MB


Config variables not defined error.

After updating to PHP 5.5.8, started happening after I updated to PHP 5.5.8 when running ApacheBuddy on my Digital Ocean server (Ubuntu 12.04.3 x64).

########################################################################
# Apache Buddy v 0.3 ###################################################
########################################################################
Gathering information...
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/apache2
[Tue Feb 11 23:40:26.259005 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue Feb 11 23:40:26.259223 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue Feb 11 23:40:26.259399 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue Feb 11 23:40:26.259496 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue Feb 11 23:40:26.259588 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Feb 11 23:40:26.268925 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Feb 11 23:40:26.269286 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Feb 11 23:40:26.269364 2014] [core:warn] [pid 4664] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
Use of uninitialized value $output[0] in pattern match (m//) at
    /tmp/apachebuddy/apachebuddy.pl line 373 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl will try to tell you the
    name of the variable (if any) that was undefined. In some cases it cannot
    do this, so it also tells you what operation you used the undefined value
    in.  Note, however, that perl optimizes your program and the operation
    displayed in the warning may not necessarily appear literally in your
    program.  For example, "that $foo" is usually optimized into "that "
    . $foo, and the warning will refer to the concatenation (.) operator,
    even though there is no . in your program.

The process running on port 80 is not Apache

Any idea what may be causing this?

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.