Skip to main content

No project description provided

Project description

PyPI - Python Version Coverage Status PyPI - Downloads

Network Health Check

Configurable command line application that can be used to test network conditions are as expected.

Very early work in progress version!

Quickstart

Installation

Install the Python package:

pip install netcheck

Or use with Docker:

docker pull ghcr.io/hardbyte/netcheck:latest

Individual Assertions

By default netcheck won't output anything if the check passes.

$ poetry run netcheck dns

Pass the -v flag to see what is going on:

$ poetry run netcheck dns -v
DNS check with nameserver None looking up host 'github.com'
✔ Passed (as expected)
{
  "type": "dns",
  "nameserver": null,
  "host": "github.com",
  "timeout": 10,
  "result": {
    "A": [
      "20.248.137.48"
    ]
  }
}

Each check can be configured, e.g. you can specify the server and host for a dns check, and tell netcheck whether a particular configuration is expected to pass or fail:

$ poetry run netcheck dns --server 1.1.1.1 --host hardbyte.nz --should-pass -v
DNS check with nameserver 1.1.1.1 looking up host 'hardbyte.nz'
✔ Passed (as expected)
{
  "type": "dns",
  "nameserver": "1.1.1.1",
  "host": "hardbyte.nz",
  "timeout": 10,
  "result": {
    "A": [
      "209.58.165.79"
    ]
  }
}

A few other individual examples:

$ netcheck dns --server=1.1.1.1 --host=made.updomain --should-fail -v
DNS check with nameserver 1.1.1.1 looking up host 'made.updomain'
❌ Failed. As expected.
{
  "type": "dns",
  "nameserver": "1.1.1.1",
  "host": "made.updomain",
  "timeout": 10,
  "result": {
    "exception-type": "NXDOMAIN",
    "exception": "The DNS query name does not exist: made.updomain."
  }
}

$ netcheck http --method=get --url=https://s3.ap-southeast-2.amazonaws.com --should-pass
$ poetry run netcheck http --method=post --url=https://s3.ap-southeast-2.amazonaws.com --should-fail -v
http check with url 'https://s3.ap-southeast-2.amazonaws.com'
❌ Failed. As expected.
{
  "type": "http",
  "method": "post",
  "url": "https://s3.ap-southeast-2.amazonaws.com",
  "result": {
    "status-code": 405,
    "exception-type": "HTTPError",
    "exception": "405 Client Error: Method Not Allowed for url: https://s3.ap-southeast-2.amazonaws.com/"
  }
}

Configuration via file

The main way to run netcheck is passing in a list of assertions. A json file can be provided with a list of assertions to be checked:

{
  "assertions": [
    {"name":  "deny-cloudflare-dns", "rules": [{"type": "dns", "server":  "1.1.1.1", "host": "github.com", "expected": "pass"}] }
  ]
}

And the command can be called:

$ poetry run netcheck run --config config.json 
Loaded 2 assertions
Running test 'cloudflare-dns'
Running test 'github-status'

Or with --verbose:

$ poetry run netcheck run --config tests/testdata/simple-config.json -v
Loaded 2 assertions
Running test 'cloudflare-dns'
DNS check with nameserver 1.1.1.1 looking up host 'github.com' Passed (as expected)
{
  "type": "dns",
  "nameserver": "1.1.1.1",
  "host": "github.com",
  "timeout": 10,
  "result": {
    "A": [
      "20.248.137.48"
    ]
  }
}
Running test 'github-status'
http check with url 'https://github.com/status' Passed (as expected)
{
  "type": "http",
  "method": "get",
  "url": "https://github.com/status",
  "result": {
    "status-code": 200
  }
}

Development

Update version and create a release on GitHub, Pypi release will be carried out by a Github action.

To release manually, use Poetry:

poetry version patch
poetry build
poetry publish

Project details


Download files

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

Source Distribution

netcheck-0.1.7.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netcheck-0.1.7-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file netcheck-0.1.7.tar.gz.

File metadata

  • Download URL: netcheck-0.1.7.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/6.0.10-arch2-1

File hashes

Hashes for netcheck-0.1.7.tar.gz
Algorithm Hash digest
SHA256 561d734e0c47c46937ce9c383363e76a7fe123dee89473c34b712ed5d7fb632c
MD5 df1823d720f4fc2719fc133e22fa7ae6
BLAKE2b-256 966c9de5451337beb22e39c042cf2f2ab5dade232fac3bd26fd1356c2a42c6ec

See more details on using hashes here.

File details

Details for the file netcheck-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: netcheck-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/6.0.10-arch2-1

File hashes

Hashes for netcheck-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fef4d9d36474a196a99cb119f24a1fdff26e01014ef35e1c8320330280bf5ab7
MD5 2e0e38f31326926a9f94e8d863d6a331
BLAKE2b-256 a4c3b7cb96e80914224b08091182a19bad972d2d4d6aeb8c81a47e340878b4c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page