openvpn-status icon indicating copy to clipboard operation
openvpn-status copied to clipboard

Timestamp format in openvpn-status.log

Open apatrick13 opened this issue 2 years ago • 3 comments

In my version of openvpn (xxx), the status log format changes in the timestamp field. Wed Jul 20 16:43:45 2022 -> 2022-07-20 16:43:45 This raises exceptions : openvpn_status.parser.ParsingError: expected valid format: time data '2022-07-20 16:43:45' does not match format '%a %b %d %H:%M:%S %Y'

To cope with this change, make the following changes in the file util.py rename DATETIME_FORMAT_OPENVPN to DATETIME_FORMAT_OPENVPN_F1 (= u'%a %b %d %H:%M:%S %Y') Add DATETIME_FORMAT_OPENVPN_F2 = u'%Y-%m-%d %H:%M:%S'

Change parse_time function : def parse_time(time): """Parses date and time from input string in OpenVPN logging format.""" if isinstance(time, datetime.datetime): return time try: res=datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN_F1) return res except Exception as e: pass return datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN_F2)

May be more simple solutions, but this one works :+1:

Regards

apatrick13 avatar Jul 20 '22 15:07 apatrick13

It will be beneficial to allow configuring the DATETIME_FORMAT_OPENVPN setting defined in `openvpn_status.utils'. I think we can make it look for a environment variable.

pandafy avatar Nov 09 '22 11:11 pandafy

Hi, idem... i have this: OpenVPN parsing error: expected valid format: time data '2023-04-05 21:38:47' does not match format '%a %b %d %H:%M:%S %Y'"" I have OpenVPN 2.5.1 on server (debian 11) and OpenVPN 2.5.7 on client (openwrt 22.03.3). Howto change this format? thanks.

mikysal78 avatar Apr 05 '23 19:04 mikysal78

I've got the same problem after updating debian 11 to 12. Any chances to have this fixed?.... it seems the issue is year old.

burbilog avatar Aug 01 '23 00:08 burbilog