Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp format in openvpn-status.log #24

Open
apatrick13 opened this issue Jul 20, 2022 · 3 comments
Open

Timestamp format in openvpn-status.log #24

apatrick13 opened this issue Jul 20, 2022 · 3 comments

Comments

@apatrick13
Copy link

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 👍

Regards

@pandafy
Copy link

pandafy commented Nov 9, 2022

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.

@mikysal78
Copy link

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.

@burbilog
Copy link

burbilog commented Aug 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants