title: How to convert test log file to json in a prescribed way
body: <p>I have a log file which is below.trying to take first server details <code>192.168.1.1</code> and check when it is connected and disconnected.then go to second server <code>192.168.1.2</code> details and check when it is connected and disconnected. Like way need to determine the connection time and disconnected time of all servers</p>
  
  <pre><code>str_ = '''Jan 23 2016 11:30:08AM - ssh 22 192.168.1.1 connected
  Jan 23 2016 12:04:56AM - ssh 22 192.168.1.2 connected
  Jan 23 2016 2:18:32PM - ssh 22 192.168.1.2 disconnected 
  Jan 23 2016 5:16:09PM - un x Dos attack from 201.10.0.4
  Jan 23 2016 10:43:44PM - ssh 22 192.168.1.1 disconnected
  Feb 1 2016  1:40:28AM - ssh 22 192.168.1.1 connected
  Feb 1 2016  2:21:52AM - un x Dos attack from 201.168.123.1
  Mar 29 2016 2:13:07PM - ssh 22 192.168.1.1 disconnected'''
  </code></pre>
  
  <p>How to convert my log file in to json</p>
  
  <p>My Expected out</p>
  
  <p><code>{1:{192.168.1.1:[(connected,Jan 23 2016 11:30:08AM),(disconnected,Jan 23 2016 10:43:44PM)]},
   2:{192.168.1.2:[(connected,Jan 23 2016 12:04:56AM),(disconnected,Jan 23 2016 2:18:32PM)]},
   3:{192.168.1.1:[(connected,Feb 1 2016  1:40:28AM),(disconnected,Mar 29 2016 2:13:07PM )]},
   4:{Dos:[201.10.0.4,201.168.123.1]}}</code></p>
  
  <p>My Pseudo code</p>
  
  <pre><code>import json
  import re
  i = 1
  result = {}
  with open('test.log') as f:
      lines = f.readlines()
      for line in lines:
          r = line.split('')
          #result[i] = {}
          i += 1 
  print(result) 
  with open('data.json', 'w') as fp:
      json.dump(result, fp)
  </code></pre>