Cheatsheet: Apache Server (HTTPD) Monitoring: More Info
Cheatsheet: Apache Server (HTTPD) Monitoring: More Info
Cheatsheet: Apache Server (HTTPD) Monitoring: More Info
Note:
ʒʒ Direct the curl commands to your server's IP address, e.g. curl localhost/server-status?auto
ʒʒ Windows users should download cURL to use the commands below
ʒʒ To query these metrics, mod_status and ExtendedStatus must be enabled (more info here)
ʒʒ For more info on Apache monitoring, visit dtdg.co/monitor-apache
Total kilobytes served* curl -s localhost/server-status?auto | grep 'Total kBytes' Check which modules are loaded apachectl -M httpd -t -D DUMP_MODULES
Total requests served/sec* curl -s localhost/server-status?auto | grep 'ReqPerSec' Enable a module* sudo a2enmod <MODULE_NAME> Uncomment or add the module to the config file
curl -s localhost/server-status?auto | grep 'BytesPerSec'
(/etc/httpd/conf.modules.d/00-base.conf )
Total bytes served/sec*
Disable a module* sudo a2dismod <MODULE_NAME> Comment out or remove the module from the config file
(/etc/httpd/conf.modules.d/00-base.conf )
*Calculated over the server's entire lifetime
Update the MPM* (mpm_worker, Disable the current MPM module: Comment out LoadModule for current MPM module &
mpm_prefork, or mpm_event) sudo a2dismod <MPM_NAME> uncomment desired module in
and then enable the desired MPM module: /etc/httpd/conf.modules.d/00-mpm.conf
sudo a2enmod <MPM_NAME>
Resource utilization and activity metrics—more info Check config file syntax apachectl -t httpd -t
METRIC DESCRIPTION COMMAND Restart Apache sudo apachectl restart sudo service httpd restart
CPU utilization (over the server's lifetime) curl -s localhost/server-status?auto | grep 'CPULoad'
Gracefully restart Apache sudo apachectl graceful sudo service httpd graceful
Busy workers curl -s localhost/server-status?auto | grep 'BusyWorkers'
Idle workers curl -s localhost/server-status?auto | grep 'IdleWorkers' *Requires a restart to take effect
Asynchronous connections: writing* curl -s localhost/server-status?auto | grep 'ConnsAsyncWriting'
Asynchronous connections: closing* curl -s localhost/server-status?auto | grep 'ConnsAsyncClosing' Access log variables—more info
To update your log config:
*Only available for event MPM users ʒʒ RHEL/CentOS: Update <IfModule log_config_module> within your main config file (/etc/httpd/conf/httpd.conf)
ʒʒ Debian/Ubuntu: Update CustomLog line within Virtual Host file (within /etc/apache2/sites-enabled directory)
Combined LogFormat: "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
Common LogFormat: "%h %l %u %t \"%r\" %>s %b"
Default directories and config locations (Linux)
INFORMATION DEBIAN/UBUNTU RHEL/CENTOS VARIABLE DEFINITION
%h Remote hostname
Main configuration file /etc/apache2/apache2.conf /etc/httpd/conf/httpd.conf
%l Remote logname
Error and access logs /var/log/apache2 /var/log/httpd
%u Remote user
MPM configuration file /etc/apache2/mods-enabled/<MPM_NAME>.conf Add/edit the <IfModule MPM_NAME> directive in main
config file (location above) %t Time Apache received the request, formatted as [16/Jun/2017:15:59:09 -0400] with last number as
time zone offset from GMT
mod_status permissions /etc/apache2/mods-enabled/status.conf Edit the <Location /server-status> directive in
main config file (location above) \"%r\" First line of the request in quotes (e.g. "GET /server-status?auto HTTP/1.1")
%>s Final HTTP status of request
%b Size of response (bytes)
\"%{Referer}i\" Referer: address of the referring web page
\"%{User-agent}i\" User-Agent: web browser or agent issuing the client request
Cheatsheet: Apache Server (httpd) Monitoring with Datadog
Note:
ʒʒ To collect these metrics, your servers must have mod_status and ExtendedStatus enabled (more info here)
ʒʒ For metric descriptions and more info: dtdg.co/monitor-apache
Enable a module* sudo a2enmod <MODULE_NAME> Uncomment or add the module to the config file
(/etc/httpd/conf.modules.d/00-base.conf )
Disable a module* sudo a2dismod <MODULE_NAME> Comment out or remove the module from the config file
(/etc/httpd/conf.modules.d/00-base.conf )
Update the MPM* (mpm_worker, Disable the current MPM module: Comment out LoadModule for current MPM module &
mpm_prefork, or mpm_event) sudo a2dismod <MPM_NAME> uncomment desired module in
and then enable the desired MPM module: /etc/httpd/conf.modules.d/00-mpm.conf
sudo a2enmod <MPM_NAME>
Check config file syntax apachectl -t httpd -t
Gracefully restart Apache sudo apachectl graceful sudo service httpd graceful
MPM configuration file /etc/apache2/mods-enabled/<MPM_NAME>.conf Add/edit the <IfModule MPM_NAME> directive in main
config file (location above)
mod_status permissions /etc/apache2/mods-enabled/status.conf Edit the <Location /server-status> directive in
main config file (location above)