diff options
author | Andre Lorbach <alorbach@adiscon.com> | 2013-07-03 18:18:59 +0200 |
---|---|---|
committer | Andre Lorbach <alorbach@adiscon.com> | 2013-07-03 18:18:59 +0200 |
commit | 2953e6dc81a0c32c8c45e3db12cdb9b65a4a0137 (patch) | |
tree | fc1605bbe6c886f0c84f4efe52653c082c3cefbd /plugins/impstats/statslog-splitter.py | |
parent | ebe5266336f1421f20edf844872ad2e2ab80c4b3 (diff) | |
download | rsyslog-2953e6dc81a0c32c8c45e3db12cdb9b65a4a0137.tar.gz rsyslog-2953e6dc81a0c32c8c45e3db12cdb9b65a4a0137.tar.bz2 rsyslog-2953e6dc81a0c32c8c45e3db12cdb9b65a4a0137.zip |
Fixed Datetime detection
Diffstat (limited to 'plugins/impstats/statslog-splitter.py')
-rwxr-xr-x | plugins/impstats/statslog-splitter.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/plugins/impstats/statslog-splitter.py b/plugins/impstats/statslog-splitter.py index 6a6870bf..3452e3b3 100755 --- a/plugins/impstats/statslog-splitter.py +++ b/plugins/impstats/statslog-splitter.py @@ -101,10 +101,11 @@ elif bSingleObjectOutput: # Found valid logline, save into file! if len(result) >= loglineindexes[iLogRegExIndex]["LN_LOGDATA"] and result[ loglineindexes[iLogRegExIndex]["LN_SYSLOGTAG"] ] == "rsyslogd-pstats": # Convert Datetime! - if isinstance( result[ loglineindexes[iLogRegExIndex]["LN_MONTH"] ], int ): - filedate = datetime.datetime.strptime(result[ loglineindexes[iLogRegExIndex]["LN_MONTH"] ] + " " + str(datetime.datetime.now().year) + " " + result[ loglineindexes[iLogRegExIndex]["LN_DAY"] ] + " " + result[ loglineindexes[iLogRegExIndex]["LN_TIME"] ] ,"%b %Y %d %H:%M:%S") - else: + try: + iMonth = int( result[ loglineindexes[iLogRegExIndex]["LN_MONTH"] ] ) filedate = datetime.datetime.strptime(result[ loglineindexes[iLogRegExIndex]["LN_MONTH"] ] + " " + str(datetime.datetime.now().year) + " " + result[ loglineindexes[iLogRegExIndex]["LN_DAY"] ] + " " + result[ loglineindexes[iLogRegExIndex]["LN_TIME"] ] ,"%m %Y %d %H:%M:%S") + except ValueError: + filedate = datetime.datetime.strptime(result[ loglineindexes[iLogRegExIndex]["LN_MONTH"] ] + " " + str(datetime.datetime.now().year) + " " + result[ loglineindexes[iLogRegExIndex]["LN_DAY"] ] + " " + result[ loglineindexes[iLogRegExIndex]["LN_TIME"] ] ,"%b %Y %d %H:%M:%S") # Split logdata into Array aProperties = result[ loglineindexes[iLogRegExIndex]["LN_LOGDATA"] ].split(" ") |