{"id":4295,"date":"2014-08-18T15:54:06","date_gmt":"2014-08-18T20:54:06","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=4295"},"modified":"2014-08-18T15:54:06","modified_gmt":"2014-08-18T20:54:06","slug":"determine-the-number-of-active-sessions-from-the-jboss-access-log","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2014\/08\/18\/determine-the-number-of-active-sessions-from-the-jboss-access-log\/","title":{"rendered":"Determine the number of active sessions from the JBOSS access log"},"content":{"rendered":"<p>While planning for holiday shopper traffic, we realized that we did not record the number of active sessions at any given time during holiday 2013.<\/p>\n<p>To come up with something that would get us close, we wrote what is below to read the access log.  If the last request for a given session id had not been issued more recently than 20 minutes ago (our session lifetime defined in web.xml), then it was not considered to be active.  Using this, we read the file by minute and populated short term python dictionaries that held active sessions in the previous 20 minutes.  After scrubbing them for sessions that were no longer active, we printed the minute and size of the dictionary in that minute.<\/p>\n<pre>\r\n\"\"\"\r\n-----------------------------------------------------------------------------------\r\nAuthor:         Steve Howard\r\nDate:           November 14, 2013\r\nPurpose:        Provide count of sessions active in the access log.  This is\r\n                  defined as those sessions that have had at least one request\r\n                  in the previous 20 minutes\r\n-----------------------------------------------------------------------------------\r\n\"\"\"\r\n\r\nimport sys\r\nif len(sys.argv) == 2:\r\n  f = open(sys.argv[1])\r\nelse:\r\n  f = sys.stdin\r\nd = dict() #fast to search by key, or JSESSIONID in our case\r\ntim = dict()\r\n\r\nmin = 0\r\n\r\n#read each line in the provided file...\r\nfor l in f:\r\n  #...then split it into an array...\r\n  l2 = l.split()\r\n  #...and if it isn't an akamai performance request or a load balancer request, and it is\r\n  #   in the new log format with JSESSIONID...\r\n  #if l.find(\"sure_route\") == -1 and l2[0] != \"-\" and len(l2) == 13:\r\n  if l.find(\"sure_route\") == -1 and len(l2) == 13:\r\n    t=l2[2].split(\":\")\r\n    currmin = (int(t[1]) * 60) + int(t[2])\r\n    d[l2[9]] = currmin\r\n  if currmin != min:\r\n    for i in d:\r\n      if currmin - d[i] < 20:\r\n        tim[i] = d[i]\r\n    print currmin,len(tim)\r\n    min = currmin\r\n    d = tim.copy()\r\n    tim.clear()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>While planning for holiday shopper traffic, we realized that we did not record the number of active sessions at any given time during holiday 2013. To come up with something that would get us close, we wrote what is below&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2014\/08\/18\/determine-the-number-of-active-sessions-from-the-jboss-access-log\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[49,26],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/4295"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=4295"}],"version-history":[{"count":3,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/4295\/revisions"}],"predecessor-version":[{"id":4298,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/4295\/revisions\/4298"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=4295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=4295"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=4295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}