0

so far I have my script that runs perfect, but my next step is to tail, the log file, and the python script to always be running, the log file is always being updated, so the problem I am having with my current script it will take only parts of the log, and not continuously read it, and parse what it needs to.

Here is my current Script.

dd = {'f8:27:93:88:1c:95' : 'Austin iPhone',
  'dc:9f:db:1a:60:64' : '4-Ops-AP',
  'dc:9f:db:1a:60:62' : '4-TechOffices-AP',
  'dc:9f:db:1a:61:b9' : '7-SalesReception-AP',
  'dc:9f:db:1a:60:63' : '7-Marketing-AP',
  'dc:9f:db:1a:61:bd' : '7-Sales-Engineers-AP',
  'dc:9f:db:1a:60:f3' : '4-Dev-AP',
  'dc:9f:db:1a:2c:dd' : '4-Hurricane-AP',
  '24:a4:3c:02:cf:f6' : '6-Meeting-AP',
  'dc:9f:db:1a:60:ef' : '4-Lounge-AP',
  'dc:9f:db:1a:61:ba' : '7-QA-AP',
  'dc:9f:db:1a:60:5f' : '4-TechFloor-AP',
  'dc:9f:db:1a:2d:95' : '4-training1-AP'}

dat = '[2014-07-22 10:21:06,821] <inform_stat-3> WARN  event  - [event] User[78:a3:e4:3b:bd:3d] roams from AP[dc:9f:db:1a:60:64] to AP[dc:9f:db:1a:2d:95] on "channel 11(ng)"'
aps = []
for elem in dat.split(server.log):
    if elem.startswith('User['):
        uname = dd.get(elem[5:-1], 'Unknown')
    if elem.startswith('AP['):
        aps.append(dd.get(elem[3:-1], 'Unknown'))

Section of the Server.log

`[2014-07-23 11:45:37,034] <http-bio-8080-exec-32> WARN  inform - from [dc:9f:db:1a:61:bd](7-Sales-Engineers, U7P, 3.1.9.2442): state=CONNECTED, ext/stun_ip=10.0.81.61, dev_ip=10.0.81.61, up=42935
[2014-07-23 11:45:37,288] <inform_stat-2> WARN  event  - [event] User[0c:3e:9f:5a:50:79] roams from AP[dc:9f:db:1a:60:63] to AP[dc:9f:db:1a:61:bd] on "channel 6(ng)"
  • `server.log` seems to be undefined. Can you provide a short, complete version of your program? See http://stackoverflow.com/help/mcve – Robᵩ Jul 23 '14 at 15:02
  • 1
    possible duplicate of [How can I tail a log file in Python?](http://stackoverflow.com/questions/12523044/how-can-i-tail-a-log-file-in-python) – Robᵩ Jul 23 '14 at 15:03
  • I added a snippet of the Server.log above – Dimitri Pantzos Jul 23 '14 at 15:48

0 Answers0