SlideShare a Scribd company logo
1 of 2
Download to read offline
Cheatsheet:ApacheServer(httpd)Monitoring
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
Throughput and latency metrics—more info
METRIC DESCRIPTION COMMAND
Total requests* curl -s localhost/server-status?auto | grep 'Total Accesses'
Total kilobytes served* curl -s localhost/server-status?auto | grep 'Total kBytes'
Total requests served/sec* curl -s localhost/server-status?auto | grep 'ReqPerSec'
Total bytes served/sec* curl -s localhost/server-status?auto | grep 'BytesPerSec'
*Calculated over the server's entire lifetime
Resource utilization and activity metrics—more info
METRIC DESCRIPTION COMMAND
CPU utilization (over the server's lifetime) curl -s localhost/server-status?auto | grep 'CPULoad'
Busy workers curl -s localhost/server-status?auto | grep 'BusyWorkers'
Idle workers curl -s localhost/server-status?auto | grep 'IdleWorkers'
Asynchronous connections: writing* curl -s localhost/server-status?auto | grep 'ConnsAsyncWriting'
Asynchronous connections: keep-alive* curl -s localhost/server-status?auto | grep 'ConnsAsyncKeepAlive'
Asynchronous connections: closing* curl -s localhost/server-status?auto | grep 'ConnsAsyncClosing'
*Only available for event MPM users
Default directories and config locations (Linux)
INFORMATION DEBIAN/UBUNTU RHEL/CENTOS
Main configuration file /etc/apache2/apache2.conf /etc/httpd/conf/httpd.conf
Error and access logs /var/log/apache2 /var/log/httpd
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)
Useful commands (Linux)
ACTION DEBIAN/UBUNTU RHEL/CENTOS
Check version of Apache apachectl -v httpd -v
Check which modules are loaded apachectl -M httpd -t -D DUMP_MODULES
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,
mpm_prefork, or mpm_event)
Disable the current MPM module:
sudo a2dismod <MPM_NAME>
and then enable the desired MPM module:
sudo a2enmod <MPM_NAME>
Comment out LoadModule for current MPM module &
uncomment desired module in
/etc/httpd/conf.modules.d/00-mpm.conf
Check config file syntax apachectl -t httpd -t
Restart Apache sudo apachectl restart sudo service httpd restart
Gracefully restart Apache sudo apachectl graceful sudo service httpd graceful
*Requires a restart to take effect
Access log variables—more info
To update your log config:
ʒ
ʒ 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"
VARIABLE DEFINITION
%h Remote hostname
%l Remote logname
%u Remote user
%t Time Apache received the request, formatted as [16/Jun/2017:15:59:09 -0400] with last number as
time zone offset from GMT
"%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:ApacheServer(httpd)MonitoringwithDatadog
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
Datadog's out-of-the-box screenboard for monitoring Apache.
Throughput metrics—more info
METRIC DESCRIPTION DATADOG METRIC NAME
Total requests over the server’s lifetime apache.net.hits
Total bytes served over the server’s lifetime apache.net.bytes
Requests served/sec* apache.net.request_per_s
Bytes served/sec* apache.net.bytes_per_s
*Calculated for each collection period (15–20 seconds)
Resource utilization and activity metrics—more info
METRIC DESCRIPTION DATADOG METRIC NAME
CPU utilization (%) system.cpu.system
Busy workers apache.performance.busy_workers
Idle workers apache.performance.idle_workers
Asynchronous connections: writing* apache.conns_async_writing
Asynchronous connections: keep-alive* apache.conns_async_keep_alive
Asynchronous connections: closing* apache.conns_async_closing
*Only available for event MPM users
Default directories and config locations (Linux)
INFORMATION DEBIAN/UBUNTU RHEL/CENTOS
Main configuration file /etc/apache2/apache2.conf /etc/httpd/conf/httpd.conf
Error and access logs /var/log/apache2 /var/log/httpd
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)
Useful commands (Linux)
ACTION DEBIAN/UBUNTU RHEL/CENTOS
Check version of Apache apachectl -v httpd -v
Check which modules are loaded apachectl -M httpd -t -D DUMP_MODULES
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,
mpm_prefork, or mpm_event)
Disable the current MPM module:
sudo a2dismod <MPM_NAME>
and then enable the desired MPM module:
sudo a2enmod <MPM_NAME>
Comment out LoadModule for current MPM module &
uncomment desired module in
/etc/httpd/conf.modules.d/00-mpm.conf
Check config file syntax apachectl -t httpd -t
Restart Apache sudo apachectl restart sudo service httpd restart
Gracefully restart Apache sudo apachectl graceful sudo service httpd graceful
*Requires a restart to take effect
Access log variables—more info
To update your log config:
ʒ
ʒ 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"
VARIABLE DEFINITION
%h Remote hostname
%l Remote logname
%u Remote user
%t Time Apache received the request, formatted as [16/Jun/2017:15:59:09 -0400] with last number as
time zone offset from GMT
"%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

More Related Content

Similar to Apache Cheat Sheet

Ugif 09 2013 new environment and dynamic setting in ids 12.10
Ugif 09 2013   new environment and dynamic setting in ids 12.10Ugif 09 2013   new environment and dynamic setting in ids 12.10
Ugif 09 2013 new environment and dynamic setting in ids 12.10UGIF
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceohadlevy
 
Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]Joshua Harlow
 
AWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On GuideAWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On GuideManas Mondal
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheWildan Maulana
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1Susant Sahani
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5William Lee
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuWirabumi Software
 
Painless Perl Ports with cpan2port
Painless Perl Ports with cpan2portPainless Perl Ports with cpan2port
Painless Perl Ports with cpan2portBenny Siegert
 
Information on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHMInformation on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHMHTS Hosting
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsAlessandro Pilotti
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practiceDocker, Inc.
 
How to go the extra mile on monitoring
How to go the extra mile on monitoringHow to go the extra mile on monitoring
How to go the extra mile on monitoringTiago Simões
 
nginx: writing your first module
nginx: writing your first modulenginx: writing your first module
nginx: writing your first moduleredivy
 

Similar to Apache Cheat Sheet (20)

Centos config
Centos configCentos config
Centos config
 
Ugif 09 2013 new environment and dynamic setting in ids 12.10
Ugif 09 2013   new environment and dynamic setting in ids 12.10Ugif 09 2013   new environment and dynamic setting in ids 12.10
Ugif 09 2013 new environment and dynamic setting in ids 12.10
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conference
 
Chap 19 web
Chap 19 webChap 19 web
Chap 19 web
 
Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]
 
AWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On GuideAWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On Guide
 
Refcard en-a4
Refcard en-a4Refcard en-a4
Refcard en-a4
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With Apache
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
 
Painless Perl Ports with cpan2port
Painless Perl Ports with cpan2portPainless Perl Ports with cpan2port
Painless Perl Ports with cpan2port
 
Php Power Tools
Php Power ToolsPhp Power Tools
Php Power Tools
 
Information on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHMInformation on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHM
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on Windows
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practice
 
How to go the extra mile on monitoring
How to go the extra mile on monitoringHow to go the extra mile on monitoring
How to go the extra mile on monitoring
 
nginx: writing your first module
nginx: writing your first modulenginx: writing your first module
nginx: writing your first module
 
Apache
ApacheApache
Apache
 

Recently uploaded

What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Apache Cheat Sheet

  • 1. Cheatsheet:ApacheServer(httpd)Monitoring 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 Throughput and latency metrics—more info METRIC DESCRIPTION COMMAND Total requests* curl -s localhost/server-status?auto | grep 'Total Accesses' Total kilobytes served* curl -s localhost/server-status?auto | grep 'Total kBytes' Total requests served/sec* curl -s localhost/server-status?auto | grep 'ReqPerSec' Total bytes served/sec* curl -s localhost/server-status?auto | grep 'BytesPerSec' *Calculated over the server's entire lifetime Resource utilization and activity metrics—more info METRIC DESCRIPTION COMMAND CPU utilization (over the server's lifetime) curl -s localhost/server-status?auto | grep 'CPULoad' Busy workers curl -s localhost/server-status?auto | grep 'BusyWorkers' Idle workers curl -s localhost/server-status?auto | grep 'IdleWorkers' Asynchronous connections: writing* curl -s localhost/server-status?auto | grep 'ConnsAsyncWriting' Asynchronous connections: keep-alive* curl -s localhost/server-status?auto | grep 'ConnsAsyncKeepAlive' Asynchronous connections: closing* curl -s localhost/server-status?auto | grep 'ConnsAsyncClosing' *Only available for event MPM users Default directories and config locations (Linux) INFORMATION DEBIAN/UBUNTU RHEL/CENTOS Main configuration file /etc/apache2/apache2.conf /etc/httpd/conf/httpd.conf Error and access logs /var/log/apache2 /var/log/httpd 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) Useful commands (Linux) ACTION DEBIAN/UBUNTU RHEL/CENTOS Check version of Apache apachectl -v httpd -v Check which modules are loaded apachectl -M httpd -t -D DUMP_MODULES 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, mpm_prefork, or mpm_event) Disable the current MPM module: sudo a2dismod <MPM_NAME> and then enable the desired MPM module: sudo a2enmod <MPM_NAME> Comment out LoadModule for current MPM module & uncomment desired module in /etc/httpd/conf.modules.d/00-mpm.conf Check config file syntax apachectl -t httpd -t Restart Apache sudo apachectl restart sudo service httpd restart Gracefully restart Apache sudo apachectl graceful sudo service httpd graceful *Requires a restart to take effect Access log variables—more info To update your log config: ʒ ʒ 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" VARIABLE DEFINITION %h Remote hostname %l Remote logname %u Remote user %t Time Apache received the request, formatted as [16/Jun/2017:15:59:09 -0400] with last number as time zone offset from GMT "%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
  • 2. Cheatsheet:ApacheServer(httpd)MonitoringwithDatadog 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 Datadog's out-of-the-box screenboard for monitoring Apache. Throughput metrics—more info METRIC DESCRIPTION DATADOG METRIC NAME Total requests over the server’s lifetime apache.net.hits Total bytes served over the server’s lifetime apache.net.bytes Requests served/sec* apache.net.request_per_s Bytes served/sec* apache.net.bytes_per_s *Calculated for each collection period (15–20 seconds) Resource utilization and activity metrics—more info METRIC DESCRIPTION DATADOG METRIC NAME CPU utilization (%) system.cpu.system Busy workers apache.performance.busy_workers Idle workers apache.performance.idle_workers Asynchronous connections: writing* apache.conns_async_writing Asynchronous connections: keep-alive* apache.conns_async_keep_alive Asynchronous connections: closing* apache.conns_async_closing *Only available for event MPM users Default directories and config locations (Linux) INFORMATION DEBIAN/UBUNTU RHEL/CENTOS Main configuration file /etc/apache2/apache2.conf /etc/httpd/conf/httpd.conf Error and access logs /var/log/apache2 /var/log/httpd 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) Useful commands (Linux) ACTION DEBIAN/UBUNTU RHEL/CENTOS Check version of Apache apachectl -v httpd -v Check which modules are loaded apachectl -M httpd -t -D DUMP_MODULES 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, mpm_prefork, or mpm_event) Disable the current MPM module: sudo a2dismod <MPM_NAME> and then enable the desired MPM module: sudo a2enmod <MPM_NAME> Comment out LoadModule for current MPM module & uncomment desired module in /etc/httpd/conf.modules.d/00-mpm.conf Check config file syntax apachectl -t httpd -t Restart Apache sudo apachectl restart sudo service httpd restart Gracefully restart Apache sudo apachectl graceful sudo service httpd graceful *Requires a restart to take effect Access log variables—more info To update your log config: ʒ ʒ 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" VARIABLE DEFINITION %h Remote hostname %l Remote logname %u Remote user %t Time Apache received the request, formatted as [16/Jun/2017:15:59:09 -0400] with last number as time zone offset from GMT "%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