{"id":147,"date":"2009-07-01T10:54:57","date_gmt":"2009-07-01T17:54:57","guid":{"rendered":"http:\/\/www.jacksonleung.com\/blog\/?p=147"},"modified":"2009-07-01T10:54:57","modified_gmt":"2009-07-01T17:54:57","slug":"finding-problematic-code-with-top-and-mod-status","status":"publish","type":"post","link":"http:\/\/www.jacksonleung.com\/blog\/finding-problematic-code-with-top-and-mod-status\/","title":{"rendered":"Finding Problematic Code with Top and Mod Status"},"content":{"rendered":"<p>The first step to fixing a problem is figuring out that there is one. Top is great command to examine what&#8217;s going on your system. It can tell you how resource intensive a process is, how long it&#8217;s been running, who executed it, and etc. Through Top, you can see if a process like httpd or Apache is taking up a lot of resources, if it is then a script executed via Apache is taking up a lot of resources. The problem with Top is that it doesn&#8217;t show you what script were executed via the web and how resource intensive that script is, and it&#8217;s not supposed to. Just like Windows&#8217; task manager, it doesn&#8217;t make any sense for it to keep track of what files are opened in Excel, that&#8217;s Excel&#8217;s job.<\/p>\n<p>Good thing for us, Apache is able to keep track of it through an Apache Module known as &#8220;mod_status&#8221;. Today&#8217;s post won&#8217;t cover how to install mod_status, what its graph looks like, or how to read it, but it&#8217;ll talk about how to use it in conjunction with Top to troubleshoot problematic scripts. This information is readily available on the web, but here&#8217;s a link to more info regarding the Apache module: <a href=\"http:\/\/httpd.apache.org\/docs\/2.0\/mod\/mod_status.html\">http:\/\/httpd.apache.org\/docs\/2.0\/mod\/mod_status.html<\/a><\/p>\n<p>Top allows us to identify which process is sucking up a lot of resources. Mod status keeps track of web calls and their corresponding PIDs. By look up a problem process in top and then finding that process in mod status, then we can start analyzing and fixing the problem. From that point on, we can start the &#8220;blaming&#8221; process \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first step to fixing a problem is figuring out that there is one. Top is great command to examine what&#8217;s going on your system. It can tell you how resource intensive a process is, how long it&#8217;s been running, who executed it, and etc. Through Top, you can see if a process like httpd &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.jacksonleung.com\/blog\/finding-problematic-code-with-top-and-mod-status\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Finding Problematic Code with Top and Mod Status&#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":[3,6],"tags":[],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-programming","category-work","entry"],"_links":{"self":[{"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/comments?post=147"}],"version-history":[{"count":1,"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":148,"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions\/148"}],"wp:attachment":[{"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/media?parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/categories?post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jacksonleung.com\/blog\/wp-json\/wp\/v2\/tags?post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}