php - Asterisk full log parser -


i want make log parser for asterisk pbx, don't know start. figured out need log. lines need this: [apr 12 11:11:56] verbose[3359] logger.c: -- called 111 number in verbose[....] same 1 call.

the first thing have lines contain verbose number can identify call. second thing read text, there standard texts won't hard recognize.

the thing read real time (the file written real time), , display in webpage. php or ajax.

the thing want is, show rows in webpage users call. , new call added under current/answered call.

any tips, examples great.

thanks, sebastian

i in 2 programs can work simple cgi programs.

  1. first program parses log , show date , call identifier. such identifier link 2nd program. in python can use regexp:

    # 1st group - date, 2nd - callid rx_verbose =  re.compile(r'(.*) verbose\[(\d+)\] ')  def make_link(call_id):     return(' <a href="show_call.cgi?call_id=%d>%d</a>' % (call_id, call_id))  def show_calls(logfn):     call_ids = []     f = open(logfn)     line in f:         rx = rx_verbose.search(line)         if rx:             call_id = int(rx.group(2))             if not call_id in call_ids:                 print('%s %s' % (rx.group(1), make_link(call_id)))                 call_ids.append(call_id)     f.close() 
  2. this program show lines has call identifier:

    def show_call_datails(logfn, call_id):     search_str = ' verbose[%s] ' % call_id     f = open(logfn)     line in f:         if search_str in line:             print(line.rstrip())     f.close() 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -