Skip to main content

OpenVPN Status

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

It is compatible with Python 2.7, 3.6 to 3.10, and PyPy.

Installation

pip install openvpn-status

Don’t forget to put it in setup.py / 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:

OpenVPN CLIENT LIST
Updated,Thu Jun 18 08:12:15 2015
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
foo@example.com,10.10.10.10:49502,334948,1973012,Thu Jun 18 04:23:03 2015
bar@example.com,10.10.10.10:64169,1817262,28981224,Thu Jun 18 04:08:39 2015
ROUTING TABLE
Virtual Address,Common Name,Real Address,Last Ref
192.168.255.134,foo@example.com,10.10.10.10:49502,Thu Jun 18 08:12:09 2015
192.168.255.126,bar@example.com,10.10.10.10:64169,Thu Jun 18 08:11:55 2015
GLOBAL STATS
Max bcast/mcast queue length,0
END

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(logfile.read())

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

foo_client = status.client_list['169.254.0.1']
print(foo_client.common_name)  # foo@example.com
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.

Contributing

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

Of course, pull requests are always welcome.

Metadata

Release files for openvpn-status 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openvpn-status 0.2.2
File Size Uploaded
openvpn-status-0.2.2.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openvpn-status 0.2.2
File Interpreter ABI Platform
openvpn_status-0.2.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 15.9 kB

Release files / openvpn-status-0.2.2.tar.gz

Download URL openvpn-status-0.2.2.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ed9de7b6bb4590b171eefe23f6900bb904c70f4eb0e2c53a3faaf9b87dc5ffeb
BLAKE2b-256 checksum
How to use checksums
f7934f74dc81ca438c8ad16e5d0e9dd00a84f4cfe735372befa34e9eefced221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / openvpn_status-0.2.2-py2.py3-none-any.whl

Download URL openvpn_status-0.2.2-py2.py3-none-any.whl
Size 8.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e094e816384a0fa4f6aa7e5717d85db632bcdc7fa08c37613caaf42146d7ac7b
BLAKE2b-256 checksum
How to use checksums
a608fb96f5e5511c612b5395d33d587ce6eb8bf5ed9d948bf9761c2eb0ac3fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page