{"id":996,"date":"2017-03-10T14:37:54","date_gmt":"2017-03-10T14:37:54","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=996"},"modified":"2017-03-10T15:00:27","modified_gmt":"2017-03-10T15:00:27","slug":"less-ghetto-log-parser-website-hitcountdowntime-analysis","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2017\/03\/10\/less-ghetto-log-parser-website-hitcountdowntime-analysis\/","title":{"rendered":"Less Ghetto Log Parser for Website Hitcount\/Downtime Analysis"},"content":{"rendered":"<p>Yesterday I created a proof of concept script, which basically goes off and identifies the hitcounts of a website, and can give a technician within a short duration of time (minutes instead of hours) exactly where hitcounts are coming from and where.<\/p>\n<p>This is kind of a tradeoff, between a script that is automated, and one that is flexible.<\/p>\n<p>The end goal is to provide a hitcount vs memory commit metric value. A NEW TYPE OF METRIC! HURRAH! (This is needed by the industry IMO).<\/p>\n<p>And also would be nice to generate graphing and mean, average, and ranges, etc. So can provide output like &#8216;stat&#8217; tool. Here is how I have progress<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n#\r\n# Author: \tAdam Bull, Cirrus Infrastructure, Rackspace LTD\r\n# Date: \tMarch 20 2017\r\n# Use:\t\tThis script automates the analysis of webserver logs hitcounts and\r\n# \t\tprovides a breakdown to indicate whether outages are caused by website visits\r\n#\t\tIn correlation to memory and load avg figures\r\n\r\n\r\n# Settings\r\n\r\n# What logfile to get stats for\r\nlogfile=&quot;\/var\/log\/httpd\/google.com-access.log&quot;\r\n\r\n# What year month and day are we scanning for minute\/hour hits\r\nyear=2017\r\nmonth=Mar\r\nday=9\r\n\r\necho &quot;Total HITS: MARCH&quot;\r\ngrep &quot;\/$month\/$year&quot; &quot;$logfile&quot; | wc -l;\r\n\r\n# Hours\r\nfor i in 0{1..9} {10..24};\r\n\r\ndo echo &quot;      &gt; 9th March 2017, hits this $i hour&quot;;\r\ngrep &quot;$day\/$month\/$year:$i&quot; &quot;$logfile&quot; | wc -l;\r\n\r\n        # break down the minutes in a nested visual way thats AWsome\r\n\r\n# Minutes\r\nfor j in 0{1..9} {10..60};\r\ndo echo &quot;                  &gt;&gt;hits at $i:$j&quot;;\r\ngrep &quot;$day\/$month\/$year:$i:$j&quot; &quot;$logfile&quot; | wc -l;\r\ndone\r\n\r\ndone\r\n<\/pre>\n<p>Thing is, after I wrote this, I wasn&#8217;t really happy, so I refactored it a bit more;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n#\r\n# Author: \tAdam Bull, Cirrus Infrastructure, Rackspace LTD\r\n# Date: \tMarch 20 2017\r\n# Use:\t\tThis script automates the analysis of webserver logs hitcounts and\r\n# \t\tprovides a breakdown to indicate whether outages are caused by website visits\r\n#\t\tIn correlation to memory and load avg figures\r\n\r\n\r\n# Settings\r\n\r\n# What logfile to get stats for\r\nlogfile=&quot;\/var\/log\/httpd\/someweb.biz-access.log&quot;\r\n\r\n# What year month and day are we scanning for minute\/hour hits\r\nyear=2017\r\nmonth=Mar\r\nday=9\r\n\r\necho &quot;Total HITS: $month&quot;\r\ngrep &quot;\/$month\/$year&quot; &quot;$logfile&quot; | wc -l;\r\n\r\n# Hours\r\nfor i in 0{1..9} {10..24};\r\n\r\ndo\r\nhitsperhour=$(grep &quot;$day\/$month\/$year:$i&quot; &quot;$logfile&quot; | wc -l;);\r\necho &quot;    &gt; $day $month $year, hits this $ith hour: $hitsperhour&quot;\r\n\r\n        # break down the minutes in a nested visual way thats AWsome\r\n\r\n# Minutes\r\nfor j in 0{1..9} {10..59};\r\ndo\r\nhitsperminute=$(grep &quot;$day\/$month\/$year:$i:$j&quot; &quot;$logfile&quot; | wc -l);\r\necho &quot;                  &gt;&gt;hits at $i:$j  $hitsperminute&quot;;\r\ndone\r\n\r\ndone\r\n<\/pre>\n<p>Now it&#8217;s pretty leet.. well, simple. but functional. Here is what the output of the more nicely refined script; I&#8217;m really satisfied with the tabulation.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@822616-db1 automation]# .\/list-visits.sh\r\nTotal HITS: Mar\r\n6019301\r\n    &gt; 9 Mar 2017, hits this  hour: 28793\r\n                  &gt;&gt;hits at 01:01  416\r\n                  &gt;&gt;hits at 01:02  380\r\n                  &gt;&gt;hits at 01:03  417\r\n                  &gt;&gt;hits at 01:04  408\r\n                  &gt;&gt;hits at 01:05  385\r\n^C\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday I created a proof of concept script, which basically goes off and identifies the hitcounts of a website, and can give a technician within a short duration of time (minutes instead of hours) exactly where hitcounts are coming from &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2017\/03\/10\/less-ghetto-log-parser-website-hitcountdowntime-analysis\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/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":[33,42,19,15,70,10,78,73,74,61,75],"tags":[],"class_list":["post-996","post","type-post","status-publish","format-standard","hentry","category-apache","category-automation","category-bash","category-cloud","category-development","category-filesystem","category-grep","category-log-analysis","category-logging","category-rackspace","category-rackspace-cdn-logs"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":3,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":999,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/996\/revisions\/999"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}