Created
June 12, 2018 18:07
-
-
Save isarandi/73496e0352d37353db4564c17aa55541 to your computer and use it in GitHub Desktop.
Parsing Tivoli Storage Manager logs for syslog-ng
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log { | |
source { file("/var/log/dsmsched.log" follow-freq(10) flags(no-parse)); }; | |
parser { python(class("TivoliParser")); }; | |
destination(d_syslog_tcp); | |
}; | |
python { | |
import re | |
import dateutil.parser | |
import socket | |
class TivoliParser(object): | |
def init(self, options): | |
self.regex = re.compile('(?P<timestamp>\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}) +(?P<MSG>.+)') | |
self.host = socket.gethostname() | |
return True | |
def parse(self, log_message): | |
match = re.match(self.regex, log_message['MESSAGE']) | |
if match: | |
for key, value in match.groupdict().items(): | |
log_message[key] = value | |
log_message['R_UNIXTIME'] = dateutil.parser.parse(log_message['timestamp']).strftime('%s') | |
log_message['HOST'] = self.host | |
return True | |
return False | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment