openvpn-status
openvpn-status copied to clipboard
Timestamp format in openvpn-status.log
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
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.
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.
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.