Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Parse OpenVPN status logs in Python

Project description

openvpn-status is a Python library. It parses OpenVPN status log and turns it into Python data structure for you.

It is compatible with CPython 2.7, 3.4, 3.5, 3.6, 3.7 and PyPy.


pip install openvpn-status

Don’t forget to put it in / requirements.txt.

Getting Started

You could configure your OpenVPN server to log for client status. In usual it could be achieved by adding status /path/to/openvpn-status.log line to /etc/openvpn/openvpn.conf. For example:

proto udp
port 1194
dev tun0
status /var/run/openvpn-status.log

Once OpenVPN server running, the log file will be created and written. It looks like:

Updated,Thu Jun 18 08:12:15 2015
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since,,334948,1973012,Thu Jun 18 04:23:03 2015,,1817262,28981224,Thu Jun 18 04:08:39 2015
Virtual Address,Common Name,Real Address,Last Ref,,,Thu Jun 18 08:12:09 2015,,,Thu Jun 18 08:11:55 2015
Max bcast/mcast queue length,0

Now we could parse log file with this library:

from openvpn_status import parse_status

with open('/var/run/openvpn-status.log') as logfile:
    status = parse_status(

print(status.updated_at)  # datetime.datetime(2015, 6, 18, 8, 12, 15)

foo_client = status.client_list['']
print(foo_client.common_name)  #
print(foo_client.bytes_received)  # 334.9 kB
print(foo_client.bytes_sent)  # 2.0 MB
print(int(foo_client.bytes_sent))  # 2097152

More details are in the API reference.


If you want to report bugs or request features, please feel free to open issues on GitHub.

Of course, pull requests are always welcome.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for openvpn-status, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size openvpn_status-0.2.1-py2.py3-none-any.whl (8.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size openvpn-status-0.2.1.tar.gz (6.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page