connectivity-check


Nameconnectivity-check JSON
Version 2023.10.2 PyPI version JSON
download
home_page
SummaryNetwork and Website Connectivity Checks with DataDog metrics reporting
upload_time2023-10-30 18:16:12
maintainer
docs_urlNone
authorSchlomo Schapiro
requires_python>=3.10,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Connectivity Check

Python CLI program to check the various aspects of Internet connectivity.

This tool has been written to validate the network routing configuration,
especially in the context of a split tunnel VPN connection and to help validate
network policies.

## Installation

Install from [PyPI](https://pypi.org/project/connectivity-check):

```text
pip install connectivity-check
```

## Features

Currently implements the following features:

### Split Tunnel Routing

Check if the routing for a given destination is different compared to a
reference destination. For example, check if the routing for `google.com` is
different compared to `baidu.com` for a given VPN connection that should only
route `google.com` through the VPN.

### TLS Certificate Authority Inspection

Check if the TLS certificate for a given destination is issued by a given
certificate authority. For example, check if the TLS certificate for
`google.com` is issued by Cloudflare, indicating that TLS interception is
active.

This can also be used to validate if

1. the TLS certificate is issued by a given desired CA
2. the TLS certificate is valid for a minimum amount of time and not expired

### HTTP(S) Response Content Inspection

Check if the HTTP(S) response content for a given destination contains a given
string. For example, check if the HTTP(S) response content for `bad-site.com`
contains the string `Access Forbidden` to validate a policy that forbids access
to `bad-site.com`.

### TCP Connect Latency

Check the TCP connect latency for a given destination. For example, check the
TCP connect latency for `google.com` to validate the latency for a network or
VPN connection.

### Internet Speed

Check the Internet speed via [Cloudflare Speed Test](https://speed.cloudflare.com/)
or [Ookla Speedtest](https://www.speedtest.net/). For example, check the Internet
speed for a network or VPN connection.

### Batch Mode

Checks can be specified either individually via command line or - to specify
multiple checks - via a YAML file for batch mode.

See [successfulchecks.yaml](./successfulchecks.yaml) and the other YAML files
for an example.

### DataDog reporting

Optionally, report metrics to DataDog via a locally running statsd under a given
prefix.

## CLI Interface

```text
NAME
    connectivity-check - Run various network and HTTP connectivity checks

SYNOPSIS
    connectivity-check - COMMAND

DESCRIPTION
    Run given command for single check.
    Use checks command with YAML file for batch mode.

    --datadog PREFIX        Enable DogstatsD mode (UDP localhost:8125) and set prefix for metrics reporting

COMMANDS
    COMMAND is one of the following:

     check_cert
       Check the certificate issuer

     check_content
       Check the content of remote location

     check_latency
       Check latency based on TCP connections

     check_routing
       Compare IPv4 routing between two destinations

     check_speed_cloudflare
       Check the network speed via Cloudflare speed.cloudflare.com

     check_speed_ookla
       Check the network speed via Oookla speedtest.net

     checks
       Run all checks in config file
```

Example output of all checks passing:

```text
$ connectivity-check checks successfulchecks.yaml
DD: schlomo.cert = 1 / ['target:google.com']
Certificate from google.com matches issuer »Google« (CN=GTS CA 1C3,O=Google Trust Services LLC,C=US) and expiration in more than 5 (62) days
Check check_cert({'target': 'google.com', 'issuer': 'Google'}) OK
DD: schlomo.content = 1 / ['target:https://google.com/drive']
Content from https://google.com/drive matches »download«
Check check_content({'target': 'https://google.com/drive', 'content': 'download'}) OK
DD: schlomo.routing = 1 / ['target:google.com', 'device:en7']
Routing to google.com via 192.168.11.1/en7 is same as route to mail.google.com
Check check_routing({'target': 'google.com', 'reference': 'mail.google.com', 'same': True}) OK
DD: schlomo.latency.average = 21 / ['target:google.com']
DD: schlomo.latency.minimum = 19 / ['target:google.com']
DD: schlomo.latency.maximum = 26 / ['target:google.com']
TCP connection latency to google.com:443 is 21 (limit 150)
Check check_latency({'target': 'https://google.com/', 'latency': 150}) OK
DD: schlomo.speed_cloudflare.download = 213.05 / ['target:speed.cloudflare.com', 'host:speed.cloudflare.com in Berlin (Land Berlin)']
DD: schlomo.speed_cloudflare.upload = 40.45 / ['target:speed.cloudflare.com', 'host:speed.cloudflare.com in Berlin (Land Berlin)']
DD: schlomo.speed_cloudflare.latency = 20.83 / ['target:speed.cloudflare.com', 'host:speed.cloudflare.com in Berlin (Land Berlin)']
Speedtest to speed.cloudflare.com in Berlin (Land Berlin) D:213.05 U:40.45 Mb/s at 20.83 ms
Check check_speed_cloudflare({'latency': 150}) OK
0 failed and 5 successful checks
```

Example output of failing checks:

```text
$ connectivity-check checks failingchecks.yaml
Certificate from google.com matches issuer »google« (CN=GTS CA 1C3,O=Google Trust Services LLC,C=US) and expiration in more than 5 (62) days
Check check_cert({'target': 'google.com', 'issuer': 'google'}) OK
Check check_content({'target': 'https://ifconfig.me/all', 'content': 'yahoo'}) FAILED
ERROR: Content from https://ifconfig.me/all fails content match »yahoo«

ip_addr: 2003:ea:XXXX:XXXX:XXXX:XXXX
remote_host: unavailable
user_agent: python-requests/2.31.0
port: 53210
language:
referer:
connection:
keep_alive:
method: GET
encoding: gzip, deflate
mime: */*
charset:
via: 1.1 google
```

## Development

We use [Python Poetry](https://python-poetry.org/) to manage this project, most
important calls are:

* `poetry install` to create a virtual environment (venv) and install the
  dependencies
* `poetry shell` to enter the venv
* `peotry run pytest` or `pytest` within the venv to run the unit tests
* `poetry build` to create distributable archives in `dist/`

When making changes, please ensure that the test coverage doesn't go down.

This project uses [Fire](https://github.com/google/python-fire) to expose the
`ConnectivityChecks`  class as a CLI. The individual check functions can also
be imported and used directly.

## License

This project is licensed under the Apache License, Version 2.0 - see the
[LICENSE](./LICENSE) file for details.

## Acknowledgments

This tool was developy by Schlomo Schapiro at [Forto](https://forto.com/) and
then [released](https://github.com/freight-hub/connectivity-check) as Open
Source. From there it was forked by [Schlomo Schapiro](https://github.com/schlomo)
and published to [PyPI](https://pypi.org/project/connectivity-check) to ensure
ongoing maintenance and support.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "connectivity-check",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Schlomo Schapiro",
    "author_email": "schlomo+connectivity-check@schapiro.org",
    "download_url": "https://files.pythonhosted.org/packages/31/e1/a8595b622d3886d4c3acecb3d9c15d6877d7af22e339f80dd73dbe23346a/connectivity_check-2023.10.2.tar.gz",
    "platform": null,
    "description": "# Connectivity Check\n\nPython CLI program to check the various aspects of Internet connectivity.\n\nThis tool has been written to validate the network routing configuration,\nespecially in the context of a split tunnel VPN connection and to help validate\nnetwork policies.\n\n## Installation\n\nInstall from [PyPI](https://pypi.org/project/connectivity-check):\n\n```text\npip install connectivity-check\n```\n\n## Features\n\nCurrently implements the following features:\n\n### Split Tunnel Routing\n\nCheck if the routing for a given destination is different compared to a\nreference destination. For example, check if the routing for `google.com` is\ndifferent compared to `baidu.com` for a given VPN connection that should only\nroute `google.com` through the VPN.\n\n### TLS Certificate Authority Inspection\n\nCheck if the TLS certificate for a given destination is issued by a given\ncertificate authority. For example, check if the TLS certificate for\n`google.com` is issued by Cloudflare, indicating that TLS interception is\nactive.\n\nThis can also be used to validate if\n\n1. the TLS certificate is issued by a given desired CA\n2. the TLS certificate is valid for a minimum amount of time and not expired\n\n### HTTP(S) Response Content Inspection\n\nCheck if the HTTP(S) response content for a given destination contains a given\nstring. For example, check if the HTTP(S) response content for `bad-site.com`\ncontains the string `Access Forbidden` to validate a policy that forbids access\nto `bad-site.com`.\n\n### TCP Connect Latency\n\nCheck the TCP connect latency for a given destination. For example, check the\nTCP connect latency for `google.com` to validate the latency for a network or\nVPN connection.\n\n### Internet Speed\n\nCheck the Internet speed via [Cloudflare Speed Test](https://speed.cloudflare.com/)\nor [Ookla Speedtest](https://www.speedtest.net/). For example, check the Internet\nspeed for a network or VPN connection.\n\n### Batch Mode\n\nChecks can be specified either individually via command line or - to specify\nmultiple checks - via a YAML file for batch mode.\n\nSee [successfulchecks.yaml](./successfulchecks.yaml) and the other YAML files\nfor an example.\n\n### DataDog reporting\n\nOptionally, report metrics to DataDog via a locally running statsd under a given\nprefix.\n\n## CLI Interface\n\n```text\nNAME\n    connectivity-check - Run various network and HTTP connectivity checks\n\nSYNOPSIS\n    connectivity-check - COMMAND\n\nDESCRIPTION\n    Run given command for single check.\n    Use checks command with YAML file for batch mode.\n\n    --datadog PREFIX        Enable DogstatsD mode (UDP localhost:8125) and set prefix for metrics reporting\n\nCOMMANDS\n    COMMAND is one of the following:\n\n     check_cert\n       Check the certificate issuer\n\n     check_content\n       Check the content of remote location\n\n     check_latency\n       Check latency based on TCP connections\n\n     check_routing\n       Compare IPv4 routing between two destinations\n\n     check_speed_cloudflare\n       Check the network speed via Cloudflare speed.cloudflare.com\n\n     check_speed_ookla\n       Check the network speed via Oookla speedtest.net\n\n     checks\n       Run all checks in config file\n```\n\nExample output of all checks passing:\n\n```text\n$ connectivity-check checks successfulchecks.yaml\nDD: schlomo.cert = 1 / ['target:google.com']\nCertificate from google.com matches issuer \u00bbGoogle\u00ab (CN=GTS CA 1C3,O=Google Trust Services LLC,C=US) and expiration in more than 5 (62) days\nCheck check_cert({'target': 'google.com', 'issuer': 'Google'}) OK\nDD: schlomo.content = 1 / ['target:https://google.com/drive']\nContent from https://google.com/drive matches \u00bbdownload\u00ab\nCheck check_content({'target': 'https://google.com/drive', 'content': 'download'}) OK\nDD: schlomo.routing = 1 / ['target:google.com', 'device:en7']\nRouting to google.com via 192.168.11.1/en7 is same as route to mail.google.com\nCheck check_routing({'target': 'google.com', 'reference': 'mail.google.com', 'same': True}) OK\nDD: schlomo.latency.average = 21 / ['target:google.com']\nDD: schlomo.latency.minimum = 19 / ['target:google.com']\nDD: schlomo.latency.maximum = 26 / ['target:google.com']\nTCP connection latency to google.com:443 is 21 (limit 150)\nCheck check_latency({'target': 'https://google.com/', 'latency': 150}) OK\nDD: schlomo.speed_cloudflare.download = 213.05 / ['target:speed.cloudflare.com', 'host:speed.cloudflare.com in Berlin (Land Berlin)']\nDD: schlomo.speed_cloudflare.upload = 40.45 / ['target:speed.cloudflare.com', 'host:speed.cloudflare.com in Berlin (Land Berlin)']\nDD: schlomo.speed_cloudflare.latency = 20.83 / ['target:speed.cloudflare.com', 'host:speed.cloudflare.com in Berlin (Land Berlin)']\nSpeedtest to speed.cloudflare.com in Berlin (Land Berlin) D:213.05 U:40.45 Mb/s at 20.83 ms\nCheck check_speed_cloudflare({'latency': 150}) OK\n0 failed and 5 successful checks\n```\n\nExample output of failing checks:\n\n```text\n$ connectivity-check checks failingchecks.yaml\nCertificate from google.com matches issuer \u00bbgoogle\u00ab (CN=GTS CA 1C3,O=Google Trust Services LLC,C=US) and expiration in more than 5 (62) days\nCheck check_cert({'target': 'google.com', 'issuer': 'google'}) OK\nCheck check_content({'target': 'https://ifconfig.me/all', 'content': 'yahoo'}) FAILED\nERROR: Content from https://ifconfig.me/all fails content match \u00bbyahoo\u00ab\n\nip_addr: 2003:ea:XXXX:XXXX:XXXX:XXXX\nremote_host: unavailable\nuser_agent: python-requests/2.31.0\nport: 53210\nlanguage:\nreferer:\nconnection:\nkeep_alive:\nmethod: GET\nencoding: gzip, deflate\nmime: */*\ncharset:\nvia: 1.1 google\n```\n\n## Development\n\nWe use [Python Poetry](https://python-poetry.org/) to manage this project, most\nimportant calls are:\n\n* `poetry install` to create a virtual environment (venv) and install the\n  dependencies\n* `poetry shell` to enter the venv\n* `peotry run pytest` or `pytest` within the venv to run the unit tests\n* `poetry build` to create distributable archives in `dist/`\n\nWhen making changes, please ensure that the test coverage doesn't go down.\n\nThis project uses [Fire](https://github.com/google/python-fire) to expose the\n`ConnectivityChecks`  class as a CLI. The individual check functions can also\nbe imported and used directly.\n\n## License\n\nThis project is licensed under the Apache License, Version 2.0 - see the\n[LICENSE](./LICENSE) file for details.\n\n## Acknowledgments\n\nThis tool was developy by Schlomo Schapiro at [Forto](https://forto.com/) and\nthen [released](https://github.com/freight-hub/connectivity-check) as Open\nSource. From there it was forked by [Schlomo Schapiro](https://github.com/schlomo)\nand published to [PyPI](https://pypi.org/project/connectivity-check) to ensure\nongoing maintenance and support.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Network and Website Connectivity Checks with DataDog metrics reporting",
    "version": "2023.10.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb22f4e6f608501e064c04fe905d914b1d5aa422fc14925548509df128ce3540",
                "md5": "2e728721c830fc96d7f8cb9571c24ad1",
                "sha256": "a50aa82486060a8c157e5730bc5e7881b24c6fdd06ad64771d6ab39c1a9e8516"
            },
            "downloads": -1,
            "filename": "connectivity_check-2023.10.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2e728721c830fc96d7f8cb9571c24ad1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 21463,
            "upload_time": "2023-10-30T18:16:11",
            "upload_time_iso_8601": "2023-10-30T18:16:11.222085Z",
            "url": "https://files.pythonhosted.org/packages/bb/22/f4e6f608501e064c04fe905d914b1d5aa422fc14925548509df128ce3540/connectivity_check-2023.10.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31e1a8595b622d3886d4c3acecb3d9c15d6877d7af22e339f80dd73dbe23346a",
                "md5": "f907858d28a0613ef987c291a9c9a530",
                "sha256": "cf632beab22e346dd5f7c3ecc41e503632963841e3a5fd4c7f4e3327f4a4c5aa"
            },
            "downloads": -1,
            "filename": "connectivity_check-2023.10.2.tar.gz",
            "has_sig": false,
            "md5_digest": "f907858d28a0613ef987c291a9c9a530",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 15637,
            "upload_time": "2023-10-30T18:16:12",
            "upload_time_iso_8601": "2023-10-30T18:16:12.848790Z",
            "url": "https://files.pythonhosted.org/packages/31/e1/a8595b622d3886d4c3acecb3d9c15d6877d7af22e339f80dd73dbe23346a/connectivity_check-2023.10.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-30 18:16:12",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "connectivity-check"
}
        
Elapsed time: 0.15280s