Forge Forge/ Apache Check  by Franck Hisbergue
  Connexion  -  Fr / En
About

Apache Check is an little PHP script that checks Apache HTTP Server (or Nginx) configuration on a LAMP server (Linux-Apache-Mysql-PHP) or LEMP server (Linux-Nginx-Mysql-PHP).

The script looks at the Apache or Nginx config files, its processes, the memory usage, the CPU and disk IO. It also looks at PHP-FPM and MySql (or MariaDB) resources usage to guess overall usages in various situations. It does some checks on parameter values, indicates critical problems, give warnings and recommendations. You apply the recommendations of this software at your own risk, and you are solely responsible for the consequences of modifications you may apply to your system.

This script try to avoid dependencies, but as it has to look at processes and files descriptors in /proc, it has to be executed as root on the server.

Usage

First download the last version (2.0.2) of the script here, uncompress it (for example with unzip apachecheck_v2.0.2.zip), and copy the PHP script on your server.

If PHP CLI (Command Line Interpreter) is not installed, install it (for example apt-get install php-cli on Debian based systems).

As root user, execute the script : php apachecheck.php

you should have this kind of result :

root@Server:~# php apachecheck.php 
 
>> Apache Check v1.7 - Hisbergue Franck - for Server (x.x.x.x)
>> For bug reports, feature requests, comments or FAQ :
     https://xulops.net/forge/apachecheck.php
     Use --help to get all the options
 
>> DISCLAIMER : this script is provided 'as is', without warranty of any
     kind. You use the software at your own risk, and you are solely
     responsible for the consequences of modifications you may apply to your
     system.
>> Licensed under the Apache License, Version 2.0. You may not use this file
     except in compliance with the License. You may obtain a copy of the
     License at http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an 'AS IS' BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
     implied. See the License for the specific language governing
     permissions and limitations under the License.
 

-------- Server informations -----------------------------------------------
[..] OS type : Linux
[..] OS version : #1 SMP Debian 4.19.194-3 (2021-07-18)
[..] OS release : 4.19.0-17-amd64
[..] System uptime : 11 days 16 hours 24 minutes 17 secondes
[..] 1 CPU, 2 cores, 4 hyperthreaded
[..] Server total memory : 7.7Go, available memory : 6.6Go
[..] Disk free space : 1.5To on a total of 1.8To
[..] Estimated residual disk IO speed : 1.2Mo/s

-------- Apache basic informations -----------------------------------------
[OK] apachectl exists (/usr/sbin/apachectl)
[..] Found inode for port 80 in socket:[6300341] in /proc/7727/fd
[OK] Apache main process 'apache2' found : /usr/sbin/apache2 (pid 30370)
[..] Apache version : Apache/2.4.38 (Debian)
[..] Apache root directory : /etc/apache2
[..] Main apache config file : /etc/apache2/apache2.conf
[OK] Apache config files syntax is correct
[..] MPM used : event
[..] Apache uptime : 4 days 14 hours 48 minutes 50 secondes

-------- Apache common config file parameters ------------------------------
[..] apache user : www-data (uid 33)
[OK] Apache Pid in /var/run/apache2/apache2.pid matches port listener pid
[OK] TimeOut value is correct : 300
[OK] HostnameLookups is Off
[OK] ServerSignature is Off
[..] KeepAlive is 'On'
[OK] MaxKeepAliveRequests is between 100 and 500 : 100
[OK] KeepAliveTimeout is less than 15 : 5
[..] 14 VirtualHost found : 8 on port 80, 6 on port 443
[OK] All virtualhost names are in /etc/hosts

-------- event MPM config parameters ---------------------------------------
[..] ServerLimit found : 21
[OK] MaxConnectionsPerChild / MaxRequestsPerChild is correct : 20000
[..] HTTP/2 is activated : HTTP/2 over TLS and HTTP/2 over TCP
[..] ThreadsPerChild found : 50
[..] ThreadLimit found : 50
[OK] ThreadLimit value is correct : 50
[..] MinSpareThreads found : 50
[..] MaxSpareThreads found : 150
[OK] MinSpareThreads value is correct : 
[OK] MaxSpareThreads value is correct : 150
[..] StartServers found : 2
[..] MaxRequestWorkers / MaxClients found : 1050
[OK] MaxRequestWorkers value is correct : 1050
[..] AsyncRequestWorkerFactor not found, using default value (2)

-------- Large log check ---------------------------------------------------
[OK] No large log files
[OK] MaxClients / MaxRequestWorkers hasn't been reached recently

-------- PHP-FPM -----------------------------------------------------------
[..] PHP-FPM parent process found (1) : 15074
[OK] PHP-FPM config files syntax is correct
[..] PHP-FPM pools found : 7
[..] PHP-FPM childs processes found : 25
[..] PHP-FPM CPU usage : 2.02%
[..] Total PHP-FPM memory usage : 42.0Mo
[..] Smallest PHP-FPM child memory usage : 2.8Mo
[..] Biggest PHP-FPM child memory usage : 6.4Mo
[..] Average PHP-FPM child memory usage : 4.5Mo
[..] PHP-FPM disk IO : 199o/s read, 171o/s write

-------- MySql check -------------------------------------------------------
[..] mysql user found, uid 108
[..] MySql process id found : 637 (/usr/sbin/mysqld)
[..] MySql threads found : 37
[..] MySql CPU usage : 3.08%
[..] MySql total memory usage : 487.5Mo
[..] Estimated MySql memory usage per connection : 3.3Mo
[..] MySql disk IO : 15Ko read, 12Ko write

-------- Apache child processes --------------------------------------------
[..] Detected child processes uid : 33 (www-data)
[..] Apache childs processes found : 2
[..] Apache CPU usage : 1.38%
[..] Apache disk IO : 5Ko/s read, 5Ko/s write
[OK] Parent process memory usage : 2.2Mo
[..] Total apache memory usage : 22.1Mo
[..] Smallest child memory usage : 19.9Mo
[..] Biggest child memory usage : 19.9Mo
[..] Average child memory usage : 19.9Mo

-------- Memory, CPU and IO considerations (all included) ------------------
[..] Estimated avg memory usage per apache child : 177.7Mo
[..] Estimated max memory usage per apache child : 193.1Mo
[OK] There is enough avalaible memory to support the actual average
     configuration of MaxRequestWorkers / MaxClients (1050) : (3.5Go/6.6Go)
[OK] There is enough avalaible memory to support the biggest usecase of
     MaxRequestWorkers / MaxClients (1050) : (3.8Go/6.6Go)
[..] Estimated avg CPU usage per Apache child : 6.48%
[OK] The CPU is fast enough to support the actual configuration of
     MaxRequestWorkers / MaxClients (1050) : (136.09% / 260%)
[..] Estimated avg disk IO per Apache child : 38.2Ko/s
[OK] The disk is fast enough to support the actual configuration of
     MaxRequestWorkers / MaxClients (1050) : (763.2Ko/1.2Mo)
[..] Maximum value for MaxRequestWorkers / MaxClients on this server is
     about 1500
[OK] MaxClients / MaxRequestWorkers (1050) is smaller than 1500

Other options are listed using the --help option : php apachecheck.php --help

    -a       --apache-config   Display Apache config files content
    -c       --skip-cpu        Don't do CPU usage measures and checks
    -d       --skip-io         Don't do disk IO usage measures and checks
    -h       --help            Display this help and exit
    -i       --no-internet     Don't get IP and don't check for new version
    -l       --skip-log        Don't do large log checks
    -m       --skip-memory     Don't do memoru usage measures and checks
    -p port  --port=port       Change port (default 80)

License

Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License. You may obtain a copy of the License at : http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Donate
You can use, copy, modify and redistribute this script for free, in compliance with the License. If you want to thank the developper, or want to support further developpements, you can use this button to donate.


Xulops Forge - Page about