{"id":328,"date":"2009-04-29T21:10:41","date_gmt":"2009-04-29T14:10:41","guid":{"rendered":"http:\/\/adityo.blog.binusian.org\/?p=328"},"modified":"2009-04-29T21:19:45","modified_gmt":"2009-04-29T14:19:45","slug":"how-to-monitoring-apache-server-performance-and-status-using-mod_status","status":"publish","type":"post","link":"https:\/\/adityo.blog.binusian.org\/?p=328","title":{"rendered":"How to monitoring Apache server performance and status using mod_status"},"content":{"rendered":"<p>Okay it&#8217;s occur to me how i can monitor the specific process that happen on apache server, yes we can use top, ps aux , lsof etc command to monitor the process but we can only see a general info on it. And i found mod_status.<\/p>\n<h2><span style=\"font-size: large;\">What is mod_status ?<\/span><\/h2>\n<p>mod_status is a built in Apache web server modules (by default) and with that we can \u00a0get server status from a web browser. With this module you can easily find out how well your server is preforming. All reports are generated in a html format. You can easily find out following type of information:<\/p>\n<ol>\n<li>Total number of worker serving requests<\/li>\n<li>Total number of of idle worker<\/li>\n<li>Find the status of each worker, the number of requests that worker has performed and the total number of bytes served by the worker<\/li>\n<li>Total number byte count served<\/li>\n<li>Other information such as CPU usage, number of requests per second,current hosts and requests being processed etc.<\/li>\n<\/ol>\n<h2><span style=\"font-size: large;\">Setting the mod_status<\/span><\/h2>\n<p>Btw i use CentOS release 5.3 (Final) ,\u00a0httpd-manual-2.2.3-11.el5_1.centos.3 and\u00a0httpd-2.2.3-11.el5_1.centos.3 for this tutorial. Okay let&#8217;s start the set up:<\/p>\n<p>1. Go to httpd.conf or \/apache2.conf on \u00a0\/etc\/httpd\/conf\/httpd.conf or\u00a0\/etc\/apache2\/apache2.conf\u00a0\u00a0and add this<\/p>\n<p>&lt;Location \/server-status&gt;<br \/>\n\u00a0 \u00a0\u00a0SetHandler\u00a0server-status<br \/>\n\u00a0 \u00a0\u00a0Order\u00a0deny,allow<br \/>\n\u00a0 \u00a0\u00a0Deny\u00a0from\u00a0all<br \/>\n\u00a0 \u00a0\u00a0Allow\u00a0from\u00a0.your_domain.com<br \/>\n&lt;\/Location&gt;<\/p>\n<p>it means :<\/p>\n<p>server status will be acessible at location http:\/\/servername\/server-status, access will be denied to everybody but people connecting from domain your_domain.com and any sub-domain from your_domain.com.<\/p>\n<p>you could be using\u00a0<em>localhost<\/em>\u00a0instead of 127.0.0.1 for the only access for your\u00a0http:\/\/servername\/server-status. here is the settings:<\/p>\n<p>&lt;Location \/server-status&gt;<br \/>\n\u00a0 \u00a0\u00a0SetHandler\u00a0server-status<br \/>\n\u00a0 \u00a0\u00a0Order\u00a0deny,allow<br \/>\n\u00a0 \u00a0\u00a0Deny\u00a0from\u00a0all<br \/>\n\u00a0 \u00a0\u00a0Allow\u00a0from\u00a0127.0.0.1<br \/>\n&lt;\/Location&gt;<\/p>\n<p>If you did not want any resctriction you can set allow from all like this:<\/p>\n<p>&lt;Location \/server-status&gt;<br \/>\n\u00a0 \u00a0\u00a0SetHandler\u00a0server-status<br \/>\n\u00a0 \u00a0\u00a0Order\u00a0deny,allow<br \/>\n\u00a0 \u00a0\u00a0Allow\u00a0from\u00a0all<br \/>\n&lt;\/Location&gt;<\/p>\n<p>2. \u00a0Check your configuration and restart the settings<\/p>\n<p># service httpd restart<\/p>\n<p>3. Access your server-status on your\u00a0http:\/\/servername\/server-status<\/p>\n<p><a href=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-329\" title=\"mod1\" src=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod1.png\" alt=\"mod1\" width=\"500\" height=\"238\" srcset=\"https:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod1.png 500w, https:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod1-300x142.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>3. You will see a standard info on the server-status,\u00a0If you want to get more information from your server activity, you can add this on your httpd.conf\/apache2.conf:<\/p>\n<div class=\"geshifilter apache\">ExtendedStatus\u00a0On<\/div>\n<p>just above the\u00a0<em>&lt;Location \/server-status&gt;<\/em>\u00a0directive. But keep in mind that this cannot be set on a per virtualhost basis and will use more resources.<br \/>\nBut in another hand, you will be able to access more informations such as:<\/p>\n<ul>\n<li>Total accesses<\/li>\n<li>CPU usage<\/li>\n<li>number of requests\/sec, Bytes\/sec and Bytes\/request<\/li>\n<li>See the different clients connected to your server, on which virtual host as well as the page there are requesting, you can even access the time it took to request a specific page as well as the resources required.<\/li>\n<\/ul>\n<p>Then don&#8217;t forget to restart the httpd \/apache service<\/p>\n<p># service httpd restart\u00a0<\/p>\n<p>and you will see more info<\/p>\n<p><a href=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-330\" title=\"mod2\" src=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod2.png\" alt=\"mod2\" width=\"500\" height=\"318\" srcset=\"https:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod2.png 500w, https:\/\/adityo.blog.binusian.org\/files\/2009\/04\/mod2-300x190.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>and one more thing\u00a0You can get the status page to update itself automatically if you have a browser that supports &#8220;refresh&#8221;. Access the page<code>\u00a0http:\/\/servername\/server-status?refresh=N<\/code>\u00a0to refresh the page every N seconds.<\/p>\n<p>http:\/\/localhost\/server-status?refresh=2<\/p>\n<p>Here is the detail info of the\u00a0\u00a0http:\/\/servername\/server-status<\/p>\n<pre><code>Apache Server Status for somedomain.com\r\nServer Version: Apache\/1.3.9 (Unix) PHP\/4.0b3\r\nServer Built: Mar 4 2000 17:01:01<\/code><\/pre>\n<p>The first few lines identify and provide a brief description of your server. The server version information includes an incomplete list of some of the modules compiled into your server. Our example server is running on a Unix system and has been compiled with support for the\u00a0<a href=\"http:\/\/www.php.net\/\">PHP<\/a>\u00a0scripting language. (The level of detail provided by the server version line may be limited by the<a href=\"http:\/\/www.apache.org\/docs\/mod\/core.html#servertokens\">ServerTokens<\/a>\u00a0configuration directive.)<\/p>\n<pre><code>Current Time: Thursday, 13-Apr-2000 17:22:36 PDT\r\nRestart Time: Thursday, 13-Apr-2000 17:15:26 PDT\r\nParent Server Generation: 14\r\nServer uptime: 7 minutes 10 seconds\r\nTotal accesses: 42 - Total Traffic: 187 kB\r\nCPU Usage: u.1 s.1 cu0 cs0 - .0465% CPU load\r\n.0977 requests\/sec - 445 B\/second - 4559 B\/request\r\n3 requests currently being processed, 5 idle servers<\/code><\/pre>\n<p>The next block represents the server&#8217;s current state. Our example server has only been up for a few minutes and hasn&#8217;t yet seen much activity. It is currently dealing with three requests, one of which is my request for the server status itself. The message that five servers are idle servers is a clue that this server is configured to maintain a pool of at least five spare child processes ready to spring into action should the need arise.<\/p>\n<pre><code>K___K_W_........................................................\r\n................................................................\r\n................................................................\r\n................................................................\r\n\r\nScoreboard Key:\r\n   \"_\" Waiting for Connection, \"S\" Starting up, \"R\" Reading Request,\r\n   \"W\" Sending Reply, \"K\" KeepAlive (read), \"D\" DNS Lookup, \"L\" Logging,\r\n   \"G\" Gracefully finishing, \".\" Open slot with no current process<\/code><\/pre>\n<p>No, that&#8217;s not boring morse-code; it&#8217;s the &#8220;scoreboard,&#8221; a pseudo-graphical representation of the state of the server&#8217;s child processes. According to the included Scoreboard Key, our server is replying to one request, maintaining two KeepAlive connections, and is maintaining five idle processes. A busier server&#8217;s scoreboard would look more like:<\/p>\n<pre><code>WWKW__WW_KKKWK__KKKKWKKKKK_WKKK_KK__KRWKKK__KK___K____WKK__KWWKK\r\n_K___K___WWKWWW_W_W_WWWK_WW_WWWLWWW_KWWKKWKWWKWWKKWW_KWKKKKW__WK\r\nWKWWW_KKWKKKWK_KW_KKKK__KK_KKKWWK_KW__K_KKK_K..........W........\r\n................................................................<\/code><\/pre>\n<p>For more on pool regulation and KeepAlive, see my earlier HTTP Wrangler column,\u00a0<a href=\"http:\/\/www.oreillynet.com\/pub\/a\/apache\/2000\/03\/02\/configuring_apache.html\">&#8220;An Amble Through Apache Configuration.&#8221;<\/a><\/p>\n<pre><code>Srv  PID   Acc     M CPU  SS Req Conn Child Slot\r\n0-14 29987 0\/24\/24 W 0.09 2  0   0.0  0.16  0.16\r\n\r\nClient     VHost Request     Request\r\n127.0.0.1  www.mydomain.net  GET \/server-status HTTP\/1.0<\/code><\/pre>\n<p>In addition to a more general overview of your server&#8217;s activity,\u00a0<code>mod_status<\/code>\u00a0gets down to the nitty-gritty, displaying a snapshot of the individual requests it is currently handling. Let&#8217;s take a gander at a fairly representative request. Please note that the output above has been split in half for display purposes.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">0-14<\/td>\n<td valign=\"top\"><strong>Srv<\/strong><br \/>\nThe ID of the child process and its generation. The generation increases each   time a child process is restarted, whether due to a server-restart or a limit   placed on the number of processes a child is allowed to handle. See the\u00a0<a href=\"http:\/\/www.apache.org\/docs\/mod\/core.html#maxrequestsperchild\">MaxRequestsPerChild<\/a>\u00a0directive.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">29987<\/td>\n<td valign=\"top\"><strong>PID<\/strong><br \/>\nThe child&#8217;s process ID.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">0\/24\/24<\/td>\n<td valign=\"top\"><strong>Acc<\/strong><br \/>\nThe first number in this trio is the number of accesses or requests using   this connection. For non-KeepAlive connections, this will be 0 since each   request makes its own connection and so is always the first (and last). The   second is the number of requests handled thus far by this child. The third is   the number of requests handled by this slot; the child may have come and   gone, its slot taken by another.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">W<\/td>\n<td valign=\"top\"><strong>Mode<\/strong><br \/>\nThe child&#8217;s mode of operation; one of the following possibilities:\u00a0\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>&#8220;_&#8221; Waiting   for Connection, &#8220;S&#8221; Starting up,<\/p>\n<p>&#8220;R&#8221; Reading   Request, &#8220;W&#8221; Sending Reply,<\/p>\n<p>\u00a0&#8220;K&#8221; KeepAlive (read),<\/p>\n<p>&#8220;D&#8221; DNS   Lookup, &#8220;L&#8221; Logging, &#8220;G&#8221; Gracefully finishing,<\/p>\n<p>&#8220;.&#8221; Open   slot with no current process<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">0.09<br \/>\n2<br \/>\n0<br \/>\n0.0<br \/>\n0.16<br \/>\n0.16<\/td>\n<td valign=\"top\"><strong>CPU SS Req Conn Child Slot<\/strong><br \/>\nSome of the less useful bits and pieces&#8230;\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>CPU:   The child&#8217;s CPU usage in number of seconds.\u00a0<br \/>\nSS: Seconds elapsed since the beginning of the request.\u00a0<br \/>\nReq: Milliseconds taken to process the request.\u00a0<br \/>\nConn: Kilobytes transferred across this connection.\u00a0<br \/>\nChild: Megabytes transferred by this child process.\u00a0<br \/>\nSlot: Megabytes transferred by this slot, across children.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">www.mydomain.net<\/td>\n<td valign=\"top\"><strong>VHost<\/strong><br \/>\nPerhaps your server hosts multiple virtual domains; how would you determine   which page is being requested by\u00a0GET \/index.html?. The VHost column helps   you sort out which request is coming to which virtual host &#8212; in this   example, www.mydomain.net.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">GET \/server-status   HTTP\/1.0<\/td>\n<td valign=\"top\"><strong>Request<\/strong><br \/>\nThis particular hit is my request for server-status. The\u00a0GET\u00a0bit   indicates a simple request for a document (as opposed to sending data to the   server using POST). The browser (in this case the Unix command-line\u00a0wget\u00a0program)   is using\u00a0HTTP\u00a0version\u00a01.0.\u00a0\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>For   more on HTTP, see my earlier\u00a0<strong>HTTP   Wrangler<\/strong>\u00a0column,\u00a0<a href=\"http:\/\/www.oreillynet.com\/pub\/a\/apache\/2000\/02\/17\/introducing_apache.html\">&#8220;Introducing Apache.&#8221;<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Okay it&#8217;s occur to me how i can monitor the specific process that happen on apache server, yes we can use top, ps aux , lsof etc command to monitor the process but we can only see a general info on it. And i found mod_status. What is mod_status ? mod_status is a built in [&hellip;]<\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1587],"tags":[],"class_list":["post-328","post","type-post","status-publish","format-standard","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=328"}],"version-history":[{"count":4,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/328\/revisions"}],"predecessor-version":[{"id":332,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/328\/revisions\/332"}],"wp:attachment":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}