{"id":13808,"date":"2019-04-06T09:25:43","date_gmt":"2019-04-06T09:25:43","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13808"},"modified":"2019-04-06T09:25:43","modified_gmt":"2019-04-06T09:25:43","slug":"how-to-monitor-apache-web-server-load-and-page-statistics","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-monitor-apache-web-server-load-and-page-statistics\/","title":{"rendered":"How to Monitor Apache Web Server Load and Page Statistics"},"content":{"rendered":"<p>As promised in our earlier tutorials of\u00a0<strong>Apache Series<\/strong>, Today we are here with another article on the\u00a0<strong>Apache HTTP<\/strong>\u00a0web server which can make a\u00a0<strong>System Administrators<\/strong>\u00a0life much easier to handle load of Apache web server using\u00a0<strong>mod_status<\/strong>\u00a0module.<\/p>\n<h3>What is mod_status?<\/h3>\n<p><strong>mod_status<\/strong>\u00a0is an\u00a0<strong>Apache<\/strong>\u00a0module which helps to monitor web server load and current httpd connections with an\u00a0<strong>HTML<\/strong>\u00a0interface which can be accessible via a web browser.<\/p>\n<p>Apache\u2019s mod_status shows a plain HTML page containing the information about current statistics of web server state including.<\/p>\n<ol>\n<li>Total number of incoming requests<\/li>\n<li>Total number of bytes and counts server<\/li>\n<li>CPU usage of Web server<\/li>\n<li>Server Load<\/li>\n<li>Server Uptime<\/li>\n<li>Total Traffic<\/li>\n<li>Total number of idle workers<\/li>\n<li>PIDs with respective client and many more.<\/li>\n<\/ol>\n<p>The default Apache Project enabled their server statistics page to the general public. To have a demo of busy web site\u2019s status page, visit.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.apache.org\/server-status\" target=\"_blank\" rel=\"noopener\">http:\/\/www.apache.org\/server-status<\/a><\/li>\n<\/ol>\n<h5>Testing Environment<\/h5>\n<p>We have used following\u00a0<strong>Testing Environment<\/strong>\u00a0for this article to explore more about\u00a0<strong>mod_status<\/strong>\u00a0with some practical examples and screen-shots.<\/p>\n<ol>\n<li><strong>Operating System<\/strong>\u00a0\u2013 CentOS 6.5<\/li>\n<li><strong>Application<\/strong>\u00a0\u2013 Apache Web Server<\/li>\n<li><strong>IP Address<\/strong>\u00a0\u2013 5.175.142.66<\/li>\n<li><strong>DocumentRoot<\/strong>\u2013 \/var\/www\/html<\/li>\n<li><strong>Apache Configuration file<\/strong>\u00a0\u2013 \/etc\/httpd\/conf\/httpd.conf (for Red Hat)<\/li>\n<li><strong>Default HTTP Port<\/strong>\u00a0\u2013 80 TCP<\/li>\n<li><strong>Test Configuration Settings<\/strong>\u00a0\u2013 httpd -t<\/li>\n<\/ol>\n<p>The prerequisites for this tutorial is that you should already aware how to install and configure a\u00a0<strong>Basic Apache Server<\/strong>. If you don\u2019t know how to setup Apache, read the following article that might help you in setting up your own Apache Web Server.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/creating-your-own-webserver-and-hosting-a-website-from-your-linux-box\/\" target=\"_blank\" rel=\"noopener\">Create Your Own Webserver and Hosting A Website in Linux<\/a><\/li>\n<\/ol>\n<h3>How to Enable mod_status in Apache<\/h3>\n<p>The default Apache installation comes with\u00a0<strong>mod_status<\/strong>\u00a0enabled. If not, make sure to enable it in Apache configuration file at.<\/p>\n<pre>[root@tecmint ~]# vi \/etc\/httpd\/conf\/httpd.conf<\/pre>\n<p>Search for the word \u201c<strong>mod_status<\/strong>\u201d or keep scrolling down until you find a line containing.<\/p>\n<pre>#LoadModule status_module modules\/mod_status.so<\/pre>\n<p>If you see a\u00a0<strong>\u2018#<\/strong>\u2018 character at the beginning of \u201cLoadModule\u201d, that means mod_status is disabled. Remove the \u2018<strong>#<\/strong>\u2018 to enable mod_status.<\/p>\n<pre>LoadModule status_module modules\/mod_status.so<\/pre>\n<h4>Configure mod_status<\/h4>\n<p>Now again search for the word \u201c<strong>Location<\/strong>\u201d or scroll down until you find a section for\u00a0<strong>mod_status<\/strong>\u00a0which should look like following.<\/p>\n<pre># Allow server status reports generated by mod_status,\r\n# with the URL of http:\/\/servername\/server-status\r\n# Change the \".example.com\" to match your domain to enable.\r\n#\r\n#&lt;Location \/server-status&gt;\r\n#    SetHandler server-status\r\n#    Order deny,allow\r\n#    Deny from all\r\n#    Allow from .example.com\r\n#&lt;\/Location&gt;<\/pre>\n<p>In the above section, uncomment the lines for\u00a0<strong>Location directive<\/strong>,\u00a0<strong>SetHandler<\/strong>\u00a0and the\u00a0<strong>directory restrictions<\/strong>according to your needs. For example, I am keeping it simple with the\u00a0<strong>Order Allow<\/strong>,\u00a0<strong>deny<\/strong>\u00a0and it\u2019s\u00a0<strong>allowed for all<\/strong>.<\/p>\n<pre>&lt;Location \/server-status&gt;\r\n   SetHandler server-status\r\n   Order allow,deny\r\n   Deny from all\r\n   Allow from all \r\n&lt;\/Location&gt;<\/pre>\n<p><strong>Note<\/strong>\u00a0: The above configuration is the default configuration for default Apache web site (single website). If you\u2019ve created one or more\u00a0<a href=\"https:\/\/www.tecmint.com\/apache-ip-based-and-name-based-virtual-hosting\/\" target=\"_blank\" rel=\"noopener\">Apache Virtual Hosts<\/a>, the above configuration will won\u2019t work.<\/p>\n<p>So, basically, you need to define the same configuration for each virtual host for any domains you\u2019ve configured in Apache. For example, the virtual host configuration for mod_status will look like this.<\/p>\n<pre>&lt;VirtualHost *:80&gt;\r\n    ServerAdmin tecmint@example.com\r\n    DocumentRoot \/var\/www\/html\/example.com\r\n    ServerName example.com\r\n    ErrorLog logs\/example.com-error_log\r\n    CustomLog logs\/example.com-access_log common\r\n<strong>&lt;Location \/server-status&gt;\r\n   SetHandler server-status\r\n   Order allow,deny\r\n   Deny from all\r\n   Allow from example.com \r\n&lt;\/Location&gt;<\/strong>\r\n&lt;\/VirtualHost&gt;<\/pre>\n<h4>Enable ExtendedStatus<\/h4>\n<p>The \u201c<strong>ExtendedStatus<\/strong>\u201d settings adds more information to the statistics page like,\u00a0<strong>CPU usage<\/strong>,\u00a0<strong>request per second<\/strong>,\u00a0<strong>total traffic<\/strong>, etc. To enable it, edit the the same\u00a0<strong>httpd.conf<\/strong>\u00a0file and search for the word \u201c<strong>Extended<\/strong>\u201d and Uncomment the line and set the status \u201c<strong>On<\/strong>\u201d for\u00a0<strong>ExtendedStatus<\/strong>\u00a0directive.<\/p>\n<pre># ExtendedStatus controls whether Apache will generate \"full\" status\r\n# information (ExtendedStatus On) or just basic information (ExtendedStatus\r\n# Off) when the \"server-status\" handler is called. The default is Off.\r\n#\r\nExtendedStatus On<\/pre>\n<h4>Restart Apache<\/h4>\n<p>Now make sure that you\u2019ve correctly enabled and configured Apache server status page. You can also check for the errors in the\u00a0<strong>httpd.conf<\/strong>\u00a0configuration using following command.<\/p>\n<pre>[root@tecmint ~]# httpd -t\r\n\r\nSyntax OK<\/pre>\n<p>Once, you get syntax is\u00a0<strong>OK<\/strong>, you can able to restart the<strong>\u00a0httpd<\/strong>\u00a0service.<\/p>\n<pre>[root@tecmint ~]# service httpd restart\r\nStopping httpd:                                          [  OK  ]\r\nStarting httpd:                                          [  OK  ]<\/pre>\n<h4>Access mod_status Page<\/h4>\n<p>The Apache status page will be accessible via your domain name with \u201c<strong>\/server-status<\/strong>\u201d at the following URL\u2019s.<\/p>\n<pre>http:\/\/serveripaddress\/server-status\r\n\r\nOR\r\n\r\nhttp:\/\/serev-hostname\/server-status<\/pre>\n<p>You will see something similar to the following page with\u00a0<strong>ExtendedStatus<\/strong>\u00a0enabled.<\/p>\n<div id=\"attachment_5334\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-5334\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status-620x420.jpeg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status-620x420.jpeg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status.jpeg 1024w\" alt=\"Apache mod_status\" width=\"620\" height=\"420\" aria-describedby=\"caption-attachment-5334\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-5334\" class=\"wp-caption-text\">Apache mod_status View<\/p>\n<\/div>\n<p>In above Snapshot, you can see that an\u00a0<strong>HTML<\/strong>\u00a0interface, which shows all information about\u00a0<strong>server uptime<\/strong>,\u00a0<strong>process Id<\/strong>\u00a0with its\u00a0<strong>respective client<\/strong>, the page they are trying to access.<\/p>\n<p>It also shows the meaning and usage of all the abbreviations used to display the status which helps us to understand the situation better.<\/p>\n<p>You can also refresh the page every time seconds (say\u00a0<strong>5 seconds<\/strong>) to see the updated statistics. To set the automate refresh, please add \u201c<strong>?refresh=N\u201d<\/strong>\u00a0at the end of the\u00a0<strong>URL<\/strong>. Where\u00a0<strong>N<\/strong>\u00a0can be replaced with the number of seconds which you want your page to get refreshed.<\/p>\n<pre>http:\/\/serveripaddress\/server-status\/?refresh=5<\/pre>\n<div id=\"attachment_5335\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status-refresh.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-5335\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status-refresh-620x418.jpeg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status-refresh-620x418.jpeg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/01\/mod_status-refresh.jpeg 1024w\" alt=\"Apache mod_status Refresh\" width=\"620\" height=\"418\" aria-describedby=\"caption-attachment-5335\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-5335\" class=\"wp-caption-text\">Apache mod_status Refresh<\/p>\n<\/div>\n<h4>Command line Status Page View<\/h4>\n<p>You can also view the Apache status page from the command-line interface using the special command-line browsers called\u00a0<a href=\"https:\/\/www.tecmint.com\/command-line-web-browsers\/\" target=\"_blank\" rel=\"noopener\">links or lynx<\/a>. You can install them using default package manager utility called\u00a0<strong>yum<\/strong>\u00a0as shown below.<\/p>\n<pre># yum install links\r\n\r\nOR\r\n\r\n# yum install lynx<\/pre>\n<p>Once, you\u2019ve installed the, you can get the same statistics on your terminal by using following command.<\/p>\n<pre>[root@tecmint ~]# links http:\/\/serveripaddress\/server-status\r\nOR\r\n[root@tecmint ~]# lynx http:\/\/serveripaddress\/server-status\r\nOR\r\n[root@tecmint ~]#  \/etc\/init.d\/httpd fullstatus<\/pre>\n<h5>Sample Output<\/h5>\n<pre>                     Apache Server Status for localhost\r\n   Server Version: Apache\/2.2.15 (Unix) DAV\/2 PHP\/5.3.3\r\n   Server Built: Aug 13 2013 17:29:28\r\n\r\n   --------------------------------------------------------------------------\r\n   Current Time: Tuesday, 14-Jan-2014 04:34:13 EST\r\n   Restart Time: Tuesday, 14-Jan-2014 00:33:05 EST\r\n   Parent Server Generation: 0\r\n   Server uptime: 4 hours 1 minute 7 seconds\r\n   Total accesses: 2748 - Total Traffic: 9.6 MB\r\n   CPU Usage: u.9 s1.06 cu0 cs0 - .0135% CPU load\r\n   .19 requests\/sec - 695 B\/second - 3658 B\/request\r\n   1 requests currently being processed, 4 idle workers\r\n .__.__W...\r\n\r\n   Scoreboard Key:\r\n   \"_\" Waiting for Connection, \"S\" Starting up, \"R\" Reading Request,\r\n   \"W\" Sending Reply, \"K\" Keepalive (read), \"D\" DNS Lookup,\r\n   \"C\" Closing connection, \"L\" Logging, \"G\" Gracefully finishing,\r\n   \"I\" Idle cleanup of worker, \".\" Open slot with no current process\r\n\r\nSrv PID     Acc    M CPU   SS  Req Conn Child Slot     Client        VHost             Request\r\n0-0 -    0\/0\/428   . 0.30 5572 0   0.0  0.00  1.34 127.0.0.1      5.175.142.66 OPTIONS * HTTP\/1.0\r\n                                                                               GET\r\n1-0 5606 0\/639\/639 _ 0.46 4    0   0.0  2.18  2.18 115.113.134.14 5.175.142.66 \/server-status?refresh=5\r\n                                                                               HTTP\/1.1\r\n                                                                               GET\r\n2-0 5607 0\/603\/603 _ 0.43 0    0   0.0  2.09  2.09 115.113.134.14 5.175.142.66 \/server-status?refresh=5\r\n                                                                               HTTP\/1.1\r\n3-0 -    0\/0\/337   . 0.23 5573 0   0.0  0.00  1.09 127.0.0.1      5.175.142.66 OPTIONS * HTTP\/1.0\r\n                                                                               GET\r\n4-0 5701 0\/317\/317 _ 0.23 9    0   0.0  1.21  1.21 115.113.134.14 5.175.142.66 \/server-status?refresh=5\r\n                                                                               HTTP\/1.1\r\n                                                                               GET\r\n5-0 5708 0\/212\/213 _ 0.15 6    0   0.0  0.85  0.85 115.113.134.14 5.175.142.66 \/server-status?refresh=5\r\n                                                                               HTTP\/1.1\r\n6-0 5709 0\/210\/210 W 0.16 0    0   0.0  0.84  0.84 127.0.0.1      5.175.142.66 GET \/server-status\r\n                                                                               HTTP\/1.1\r\n7-0 -    0\/0\/1     . 0.00 5574 0   0.0  0.00  0.00 127.0.0.1      5.175.142.66 OPTIONS * HTTP\/1.0\r\n\r\n   --------------------------------------------------------------------------\r\n\r\n    Srv  Child Server number - generation\r\n    PID  OS process ID\r\n    Acc  Number of accesses this connection \/ this child \/ this slot\r\n     M   Mode of operation\r\n    CPU  CPU usage, number of seconds\r\n    SS   Seconds since beginning of most recent request\r\n    Req  Milliseconds required to process most recent request\r\n   Conn  Kilobytes transferred this connection\r\n   Child Megabytes transferred this child\r\n   Slot  Total megabytes transferred this slot\r\n   --------------------------------------------------------------------------\r\n\r\n    Apache\/2.2.15 (CentOS) Server at localhost Port 80<\/pre>\n<h3>Conclusion<\/h3>\n<p>Apache\u2019s\u00a0<strong>mod_status<\/strong>\u00a0module is a very handy monitoring tool for monitoring performance of a web server\u2019s activity and can able to highlight problems itself. For more information read the status page that can be help you to become a more successful web server administrator.<\/p>\n<ol>\n<li><a href=\"https:\/\/httpd.apache.org\/docs\/2.0\/mod\/mod_status.html\" target=\"_blank\" rel=\"noopener\">Apache mod_status Homepage<\/a><\/li>\n<\/ol>\n<p>That\u2019s all for\u00a0<strong>mod_status<\/strong>\u00a0for now.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/monitor-apache-web-server-load-and-page-statistics\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As promised in our earlier tutorials of\u00a0Apache Series, Today we are here with another article on the\u00a0Apache HTTP\u00a0web server which can make a\u00a0System Administrators\u00a0life much easier to handle load of Apache web server using\u00a0mod_status\u00a0module. What is mod_status? mod_status\u00a0is an\u00a0Apache\u00a0module which helps to monitor web server load and current httpd connections with an\u00a0HTML\u00a0interface which can be &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-monitor-apache-web-server-load-and-page-statistics\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Monitor Apache Web Server Load and Page Statistics&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13808","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13808"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13808\/revisions"}],"predecessor-version":[{"id":13809,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13808\/revisions\/13809"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}