openvpn-status


Nameopenvpn-status JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/tonyseek/openvpn-status
SummaryParse OpenVPN status logs in Python
upload_time2023-01-11 03:02:18
maintainer
docs_urlNone
authorJiangge Zhang
requires_python
licenseMIT
keywords openvpn status log
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            OpenVPN Status
==============

.. summary-begin

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

.. summary-end

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


Installation
------------

.. code-block:: bash

    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:

.. code-block:: python

    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.


.. _`API reference`: https://openvpn-status.readthedocs.io/en/latest/api.html
.. _GitHub: https://github.com/tonyseek/openvpn-status/issues

.. |Build Status| image:: https://img.shields.io/travis/tonyseek/openvpn-status.svg
   :target: https://travis-ci.org/tonyseek/openvpn-status
   :alt: Build Status
.. |Coverage Status| image:: https://img.shields.io/coveralls/tonyseek/openvpn-status.svg
   :target: https://coveralls.io/r/tonyseek/openvpn-status
   :alt: Coverage Status
.. |Wheel Status| image:: https://img.shields.io/pypi/wheel/openvpn-status.svg
   :target: https://warehouse.python.org/project/openvpn-status
   :alt: Wheel Status
.. |PyPI Version| image:: https://img.shields.io/pypi/v/openvpn-status.svg
   :target: https://pypi.python.org/pypi/openvpn-status
   :alt: PyPI Version

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tonyseek/openvpn-status",
    "name": "openvpn-status",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "openvpn,status,log",
    "author": "Jiangge Zhang",
    "author_email": "tonyseek@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f7/93/4f74dc81ca438c8ad16e5d0e9dd00a84f4cfe735372befa34e9eefced221/openvpn-status-0.2.2.tar.gz",
    "platform": "Any",
    "description": "OpenVPN Status\n==============\n\n.. summary-begin\n\n**openvpn-status** is a Python library. It parses OpenVPN status log and turns\nit into Python data structure for you.\n\n.. summary-end\n\nIt is compatible with Python `2.7`, `3.6` to `3.10`, and PyPy.\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n    pip install openvpn-status\n\nDon't forget to put it in ``setup.py`` / ``requirements.txt``.\n\n\nGetting Started\n---------------\n\nYou could configure your OpenVPN server to log for client status. In usual it\ncould be achieved by adding ``status /path/to/openvpn-status.log`` line to\n``/etc/openvpn/openvpn.conf``. For example::\n\n    proto udp\n    port 1194\n    dev tun0\n    status /var/run/openvpn-status.log\n\nOnce OpenVPN server running, the log file will be created and written. It looks\nlike::\n\n    OpenVPN CLIENT LIST\n    Updated,Thu Jun 18 08:12:15 2015\n    Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since\n    foo@example.com,10.10.10.10:49502,334948,1973012,Thu Jun 18 04:23:03 2015\n    bar@example.com,10.10.10.10:64169,1817262,28981224,Thu Jun 18 04:08:39 2015\n    ROUTING TABLE\n    Virtual Address,Common Name,Real Address,Last Ref\n    192.168.255.134,foo@example.com,10.10.10.10:49502,Thu Jun 18 08:12:09 2015\n    192.168.255.126,bar@example.com,10.10.10.10:64169,Thu Jun 18 08:11:55 2015\n    GLOBAL STATS\n    Max bcast/mcast queue length,0\n    END\n\nNow we could parse log file with this library:\n\n.. code-block:: python\n\n    from openvpn_status import parse_status\n\n    with open('/var/run/openvpn-status.log') as logfile:\n        status = parse_status(logfile.read())\n\n    print(status.updated_at)  # datetime.datetime(2015, 6, 18, 8, 12, 15)\n\n    foo_client = status.client_list['169.254.0.1']\n    print(foo_client.common_name)  # foo@example.com\n    print(foo_client.bytes_received)  # 334.9 kB\n    print(foo_client.bytes_sent)  # 2.0 MB\n    print(int(foo_client.bytes_sent))  # 2097152\n\n\nMore details are in the `API reference`_.\n\n\nContributing\n------------\n\nIf you want to report bugs or request features, please feel free to open\nissues on GitHub_.\n\nOf course, pull requests are always welcome.\n\n\n.. _`API reference`: https://openvpn-status.readthedocs.io/en/latest/api.html\n.. _GitHub: https://github.com/tonyseek/openvpn-status/issues\n\n.. |Build Status| image:: https://img.shields.io/travis/tonyseek/openvpn-status.svg\n   :target: https://travis-ci.org/tonyseek/openvpn-status\n   :alt: Build Status\n.. |Coverage Status| image:: https://img.shields.io/coveralls/tonyseek/openvpn-status.svg\n   :target: https://coveralls.io/r/tonyseek/openvpn-status\n   :alt: Coverage Status\n.. |Wheel Status| image:: https://img.shields.io/pypi/wheel/openvpn-status.svg\n   :target: https://warehouse.python.org/project/openvpn-status\n   :alt: Wheel Status\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/openvpn-status.svg\n   :target: https://pypi.python.org/pypi/openvpn-status\n   :alt: PyPI Version\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Parse OpenVPN status logs in Python",
    "version": "0.2.2",
    "split_keywords": [
        "openvpn",
        "status",
        "log"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a608fb96f5e5511c612b5395d33d587ce6eb8bf5ed9d948bf9761c2eb0ac3fe8",
                "md5": "a61507f6efcff2644388460573ea3a30",
                "sha256": "e094e816384a0fa4f6aa7e5717d85db632bcdc7fa08c37613caaf42146d7ac7b"
            },
            "downloads": -1,
            "filename": "openvpn_status-0.2.2-py2.py3-none-any.whl",
            "has_sig": true,
            "md5_digest": "a61507f6efcff2644388460573ea3a30",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 8411,
            "upload_time": "2023-01-11T03:02:15",
            "upload_time_iso_8601": "2023-01-11T03:02:15.511611Z",
            "url": "https://files.pythonhosted.org/packages/a6/08/fb96f5e5511c612b5395d33d587ce6eb8bf5ed9d948bf9761c2eb0ac3fe8/openvpn_status-0.2.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7934f74dc81ca438c8ad16e5d0e9dd00a84f4cfe735372befa34e9eefced221",
                "md5": "ce30acb97966765d5a6c83e8fef556fb",
                "sha256": "ed9de7b6bb4590b171eefe23f6900bb904c70f4eb0e2c53a3faaf9b87dc5ffeb"
            },
            "downloads": -1,
            "filename": "openvpn-status-0.2.2.tar.gz",
            "has_sig": true,
            "md5_digest": "ce30acb97966765d5a6c83e8fef556fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7536,
            "upload_time": "2023-01-11T03:02:18",
            "upload_time_iso_8601": "2023-01-11T03:02:18.651482Z",
            "url": "https://files.pythonhosted.org/packages/f7/93/4f74dc81ca438c8ad16e5d0e9dd00a84f4cfe735372befa34e9eefced221/openvpn-status-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-11 03:02:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "tonyseek",
    "github_project": "openvpn-status",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openvpn-status"
}
        
Elapsed time: 0.03009s