dnsdist-console


Namednsdist-console JSON
Version 1.4.5 PyPI version JSON
download
home_pagehttps://github.com/dmachard/dnsdist_console
SummaryPython client for dnsdist console
upload_time2024-04-17 09:30:37
maintainerNone
docs_urlNone
authorDenis MACHARD
requires_pythonNone
licenseNone
keywords dnsdist console client
VCS
bugtrack_url
requirements libnacl scrypt
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python client for dnsdist console

Tool to interact with your dnsdist console from Python.

![powerdns dnsdist 1.9.x](https://img.shields.io/badge/dnsdist%201.9.x-tested-green) ![powerdns dnsdist 1.8.x](https://img.shields.io/badge/dnsdist%201.8.x-tested-green) ![powerdns dnsdist 1.7.x](https://img.shields.io/badge/dnsdist%201.7.x-tested-green) ![powerdns dnsdist 1.6.x](https://img.shields.io/badge/dnsdist%201.6.x-tested-green) 

## Table of contents
* [Installation](#installation)
* [Generate console key](#generate-console-key)
* [Generate hash password](#generate-hash-password)
* [Run command](#run-command)
* [Get statistics](#get-statistics)
* [Display basic dashboard](#display-basic-dashboard)

## Installation

![python 3.12.x](https://img.shields.io/badge/python%203.12.x-tested-blue) ![python 3.11.x](https://img.shields.io/badge/python%203.11.x-tested-blue) ![python 3.10.x](https://img.shields.io/badge/python%203.10.x-tested-blue) ![python 3.9.x](https://img.shields.io/badge/python%203.9.x-tested-blue) ![python 3.8.x](https://img.shields.io/badge/python%203.8.x-tested-blue)

This module can be installed from [pypi](https://pypi.org/project/dnsdist_console/) website

```python
pip install dnsdist_console
```

## Generate console key

You must configure your dnsdist load balancer to accept remote connection to the console.
This module can be used to generate the secret key as below.

The command in one line 

```bash
python3 -c "from dnsdist_console import Key;print(Key().generate())"
OTgmgAR6zbrfrYlKgsAAJn+by4faMqI1bVCvzacXMW0=
```

Save-it in your `/etc/dnsdist/dnsdist.conf` with the `setKey` directive.

```
controlSocket('0.0.0.0:5199')
setKey("GQpEpQoIuzA6kzgwDokX9JcXPXFvO1Emg1wAXToJ0ag=")
```

## Generate hash password

You can use this module to generate a hash for the webserver of your dnsdist.
Since 1.7.0 the password should be hashed and salted.

The command in one line 

```bash
python3 -c "from dnsdist_console import HashPassword as H;print(H().generate(\"bonjour\"))"
$scrypt$ln=10,p=1,r=8$SZmi+pjuZ4u7L4jhXIkLww==$VRW7BuYUjSVjkjDIK6J1VB/RWx2s4gbz+YXgflWspf8=
```

## Run command

Configure the client with the IP address and the TCP port of your dnsdist as well as the associated secret key. If the provided key is incorrect, an exception will be raised.

```python
from dnsdist_console import Console

console_ip = "127.0.0.1"
console_port = 5199
console_key = "GQpEpQoIuzA6kzgwDokX9JcXPXFvO1Emg1wAXToJ0ag="

console = Console(host=console_ip,
                  port=console_port, 
                  key=console_key)
```

Please refer to the [dnsdist documentation](https://dnsdist.org/reference/config.html) for all available commands.

```python
o = console.send_command(cmd="showVersion()")
print(o)
dnsdist 1.4.0

```

## Get statistics

Use this module to extract some statistics on your dnsdist load balancer.
Statistics are stored in a python dictionary.

```python
from dnsdist_console import Statistics

s = Statistics(console=console)
print(s["global"]["queries"])
3993

# get top queries
print(s["top-queries"])
[
    {'entry': 'www.apple.com.', 'hits': '9'},
    {'entry': 'www.facebook.com.', 'hits': '3'},
    {'entry': 'www.microsoft.com.', 'hits': '3'}
]


# get top nx domain
print(s["top-nxdomain"])
[
    {'entry': 'www.nxdomain.com.', 'hits': '1'}
    
]

# get top clients
print(s["top-clients"])
[
    {'entry': '127.0.0.1', 'hits': '21'}
]
```
    
## Display basic dashboard

You can use this client to display a dashboard of your dnsdist from your command line.
The dashboard is updated every second.

```python
from dnsdist_console import Dashboard

Dashboard(console=console)
```

Run your script and you will see something like below.

```bash
Dashboard for dnsdist

Global:
        Uptime (seconds): 47735
        Number of queries: 0
        Query per second: 0
        ACL drops: 0
        Dynamic drops: 0
        Rule drops: 0
        CPU Usage (%s): 2.8
        Cache hitrate: 0
Backends:
        #0 / 10.0.0.140:53 / -- / dns_others
                Number of queries: 0
                Query per second: 0.0
                Number of drops: 0
        #1 / 10.0.0.55:53 / -- / dns_internal
                Number of queries: 0
                Query per second: 0.0
                Number of drops: 0
        #2 / 8.8.8.8:53 / -- / dns_internet
                Number of queries: 0
                Query per second: 0.0
                Number of drops: 0
        #3 / 1.1.1.1:53 / dns_1 / --
                Number of queries: 0
                Query per second: 0.0
                Number of drops: 0

Ctrl+C to exit
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dmachard/dnsdist_console",
    "name": "dnsdist-console",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "dnsdist console client",
    "author": "Denis MACHARD",
    "author_email": "d.machard@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/50/0c/4e39efe6a04c7d68c6ff9f31f53a4253707f2b0216c40cda3d9c9653af3f/dnsdist_console-1.4.5.tar.gz",
    "platform": "any",
    "description": "# Python client for dnsdist console\n\nTool to interact with your dnsdist console from Python.\n\n![powerdns dnsdist 1.9.x](https://img.shields.io/badge/dnsdist%201.9.x-tested-green) ![powerdns dnsdist 1.8.x](https://img.shields.io/badge/dnsdist%201.8.x-tested-green) ![powerdns dnsdist 1.7.x](https://img.shields.io/badge/dnsdist%201.7.x-tested-green) ![powerdns dnsdist 1.6.x](https://img.shields.io/badge/dnsdist%201.6.x-tested-green) \n\n## Table of contents\n* [Installation](#installation)\n* [Generate console key](#generate-console-key)\n* [Generate hash password](#generate-hash-password)\n* [Run command](#run-command)\n* [Get statistics](#get-statistics)\n* [Display basic dashboard](#display-basic-dashboard)\n\n## Installation\n\n![python 3.12.x](https://img.shields.io/badge/python%203.12.x-tested-blue) ![python 3.11.x](https://img.shields.io/badge/python%203.11.x-tested-blue) ![python 3.10.x](https://img.shields.io/badge/python%203.10.x-tested-blue) ![python 3.9.x](https://img.shields.io/badge/python%203.9.x-tested-blue) ![python 3.8.x](https://img.shields.io/badge/python%203.8.x-tested-blue)\n\nThis module can be installed from [pypi](https://pypi.org/project/dnsdist_console/) website\n\n```python\npip install dnsdist_console\n```\n\n## Generate console key\n\nYou must configure your dnsdist load balancer to accept remote connection to the console.\nThis module can be used to generate the secret key as below.\n\nThe command in one line \n\n```bash\npython3 -c \"from dnsdist_console import Key;print(Key().generate())\"\nOTgmgAR6zbrfrYlKgsAAJn+by4faMqI1bVCvzacXMW0=\n```\n\nSave-it in your `/etc/dnsdist/dnsdist.conf` with the `setKey` directive.\n\n```\ncontrolSocket('0.0.0.0:5199')\nsetKey(\"GQpEpQoIuzA6kzgwDokX9JcXPXFvO1Emg1wAXToJ0ag=\")\n```\n\n## Generate hash password\n\nYou can use this module to generate a hash for the webserver of your dnsdist.\nSince 1.7.0 the password should be hashed and salted.\n\nThe command in one line \n\n```bash\npython3 -c \"from dnsdist_console import HashPassword as H;print(H().generate(\\\"bonjour\\\"))\"\n$scrypt$ln=10,p=1,r=8$SZmi+pjuZ4u7L4jhXIkLww==$VRW7BuYUjSVjkjDIK6J1VB/RWx2s4gbz+YXgflWspf8=\n```\n\n## Run command\n\nConfigure the client with the IP address and the TCP port of your dnsdist as well as the associated secret key. If the provided key is incorrect, an exception will be raised.\n\n```python\nfrom dnsdist_console import Console\n\nconsole_ip = \"127.0.0.1\"\nconsole_port = 5199\nconsole_key = \"GQpEpQoIuzA6kzgwDokX9JcXPXFvO1Emg1wAXToJ0ag=\"\n\nconsole = Console(host=console_ip,\n                  port=console_port, \n                  key=console_key)\n```\n\nPlease refer to the [dnsdist documentation](https://dnsdist.org/reference/config.html) for all available commands.\n\n```python\no = console.send_command(cmd=\"showVersion()\")\nprint(o)\ndnsdist 1.4.0\n\n```\n\n## Get statistics\n\nUse this module to extract some statistics on your dnsdist load balancer.\nStatistics are stored in a python dictionary.\n\n```python\nfrom dnsdist_console import Statistics\n\ns = Statistics(console=console)\nprint(s[\"global\"][\"queries\"])\n3993\n\n# get top queries\nprint(s[\"top-queries\"])\n[\n    {'entry': 'www.apple.com.', 'hits': '9'},\n    {'entry': 'www.facebook.com.', 'hits': '3'},\n    {'entry': 'www.microsoft.com.', 'hits': '3'}\n]\n\n\n# get top nx domain\nprint(s[\"top-nxdomain\"])\n[\n    {'entry': 'www.nxdomain.com.', 'hits': '1'}\n    \n]\n\n# get top clients\nprint(s[\"top-clients\"])\n[\n    {'entry': '127.0.0.1', 'hits': '21'}\n]\n```\n    \n## Display basic dashboard\n\nYou can use this client to display a dashboard of your dnsdist from your command line.\nThe dashboard is updated every second.\n\n```python\nfrom dnsdist_console import Dashboard\n\nDashboard(console=console)\n```\n\nRun your script and you will see something like below.\n\n```bash\nDashboard for dnsdist\n\nGlobal:\n        Uptime (seconds): 47735\n        Number of queries: 0\n        Query per second: 0\n        ACL drops: 0\n        Dynamic drops: 0\n        Rule drops: 0\n        CPU Usage (%s): 2.8\n        Cache hitrate: 0\nBackends:\n        #0 / 10.0.0.140:53 / -- / dns_others\n                Number of queries: 0\n                Query per second: 0.0\n                Number of drops: 0\n        #1 / 10.0.0.55:53 / -- / dns_internal\n                Number of queries: 0\n                Query per second: 0.0\n                Number of drops: 0\n        #2 / 8.8.8.8:53 / -- / dns_internet\n                Number of queries: 0\n                Query per second: 0.0\n                Number of drops: 0\n        #3 / 1.1.1.1:53 / dns_1 / --\n                Number of queries: 0\n                Query per second: 0.0\n                Number of drops: 0\n\nCtrl+C to exit\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for dnsdist console",
    "version": "1.4.5",
    "project_urls": {
        "Homepage": "https://github.com/dmachard/dnsdist_console"
    },
    "split_keywords": [
        "dnsdist",
        "console",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15ae99f6e18723d26a225471f1666a14f4dfb9afcf44e9e447d73b1eefdb5a61",
                "md5": "469e2c264f0dee59cffba195103603ba",
                "sha256": "01abaa53a04c6063c8975f512736ffb1b25ac4df5d9f29e23c823f6008f93e96"
            },
            "downloads": -1,
            "filename": "dnsdist_console-1.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "469e2c264f0dee59cffba195103603ba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10486,
            "upload_time": "2024-04-17T09:30:36",
            "upload_time_iso_8601": "2024-04-17T09:30:36.730163Z",
            "url": "https://files.pythonhosted.org/packages/15/ae/99f6e18723d26a225471f1666a14f4dfb9afcf44e9e447d73b1eefdb5a61/dnsdist_console-1.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "500c4e39efe6a04c7d68c6ff9f31f53a4253707f2b0216c40cda3d9c9653af3f",
                "md5": "b334194b74e6798d9737776825c43be1",
                "sha256": "2e0306c5acebf1c9d30fbad4e84340a497318800ee4aec12b190ce8129ce6efc"
            },
            "downloads": -1,
            "filename": "dnsdist_console-1.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "b334194b74e6798d9737776825c43be1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8223,
            "upload_time": "2024-04-17T09:30:37",
            "upload_time_iso_8601": "2024-04-17T09:30:37.927340Z",
            "url": "https://files.pythonhosted.org/packages/50/0c/4e39efe6a04c7d68c6ff9f31f53a4253707f2b0216c40cda3d9c9653af3f/dnsdist_console-1.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 09:30:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dmachard",
    "github_project": "dnsdist_console",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "libnacl",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "scrypt",
            "specs": [
                [
                    "==",
                    "0.8.24"
                ]
            ]
        }
    ],
    "lcname": "dnsdist-console"
}
        
Elapsed time: 0.23334s