[syslog-ng] Python help

Siem Korteweg Siem.Korteweg at qnh.nl
Wed Sep 16 07:57:09 CEST 2009


Hi,

this is not related to syslog-ng, so have a look at:
http://docs.python.org/library/re.html
and search for lookahead assertion

regards,

Siem

-----Oorspronkelijk bericht-----
Van: syslog-ng-bounces at lists.balabit.hu namens Jain, Vaibhav (GE Healthcare)
Verzonden: wo 16-9-2009 7:33
Aan: Syslog-ng users' and developers' mailing list
Onderwerp: [syslog-ng] Python help
 
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 --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3132 bytes
Desc: not available
Url : http://lists.balabit.hu/pipermail/syslog-ng/attachments/20090916/1b8c3048/attachment.bin 


More information about the syslog-ng mailing list