[syslog-ng] Python help

Jain, Vaibhav (GE Healthcare) Vaibhav.Jain at ge.com
Wed Sep 16 07:33:34 CEST 2009


Hi,
 
I am using a python parser for parsing the incoming message from
syslog-ng. In my log messages some fields are optional and some are
not.I want to know how to handle these optional parameters in the python
regual expression.
 
for example:
 
sample log :->
        
    log='Sep 15 22:23:37 ecis007 codeSystemName=5 UserID="Admin"'
 
regular expression :->
 
    aregex=re.compile(r"(?P<destmonth>\S+) (?P<devicedate>\S+)
(?P<devtime>\S+) (?P<devicename>\S+)
codeSystemName=(?P<EventIDcodeSystemName>.*)")

 
if I run the following python command then i can get all the parameters
r=aregex.match(log2)
 
but
 
if "codeSystemName=5" is a optional parameters and it is not in some
messages then my parser is not able to parse the message.
        log='Sep 15 22:23:37 ecis007 UserID="Admin'
 
 
let me know how to write the regex for optional parameters ?
 
Regards,
Vaibhav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.balabit.hu/pipermail/syslog-ng/attachments/20090916/8af94d61/attachment.htm 


More information about the syslog-ng mailing list