Skip to main content

Gets various network diagnostics for a pc

Project description

py-net-diags

A Python package for network diagnostics that collects various metrics about your machine's network connection.

Installation

Basic Installation

pip install py-net-diags

With Optional speedcheck Support

pip install py-net-diags[speedcheck]

Configuration

Environment Variables

Create a .env file based on the provided .env-sample:

# ConnectWise API Configuration
RUNNING_IN_ASIO=true/false    # Set to true if running in ASIO environment
CW_BASE_URL=your_cw_url       # ConnectWise base URL
AUTHORIZATION=your_auth_token # ConnectWise authorization token
CLIENTID=your_client_id       # ConnectWise client ID

# Retry Configuration
RETRY_ATTEMPTS=3              # Number of retry attempts for operations
RETRY_DELAY=2                 # Delay in seconds between retry attempts

Usage Examples

from py_net_diags import NetworkDiagnostics

# Initialize the diagnostics tool
diag = NetworkDiagnostics()

# Run all diagnostics
results = diag.run_diagnostics()
print(results)

# Save the results to a file (txt, json, pdf)
paths = {
    "txt": "/path/to/output.txt",
    "json": "/path/to/output.json",
    "pdf": "/path/to/output.pdf"
}

diag.save_results_as_txt(paths["txt"])
diag.save_results_as_json(paths["json"])
diag.save_results_as_pdf(paths["pdf"])

# Optional: Upload to CW_PSA
import logging
from py_net_diags import ConnectWiseServiceAPI

logger = logging.getLogger(__name__)

service_api = ConnectWiseServiceAPI(log=logger)

# Makes sure the ticket id is an integer
ticket_id = diag.parse_ticket_id(ticket_id)

# Add an internal note:
note_response = service_api.add_ticket_note(ticket_id=ticket_id, note_text=md_msg, internal=True)
print(note_response)

# Add the PDF as an attachment on the ticket:
attachment_response = service_api.upload_attachment(ticket_id=ticket_id, file_path=paths["pdf"])
print(attachment_response)

Conda Environment Setup

Basic Environment

name: net-diags
channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.11
  - pip
  - pip:
      - py-net-diags

With speedcheck Support

name: net-diags-full
channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.11
  - pip
  - pip:
      - "py-net-diags[speedcheck]"

Save either of these as environment.yml and create the environment with:

conda env create -f environment.yml

License

MIT

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

py_net_diags-0.1.1.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

py_net_diags-0.1.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file py_net_diags-0.1.1.tar.gz.

File metadata

  • Download URL: py_net_diags-0.1.1.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for py_net_diags-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af6434ff5154a30480af850fdf3f269c5ba1e71e3071f8d907133866180ba8a1
MD5 888441a4c4d13908fabdf87d7d2d634a
BLAKE2b-256 e2ec6bbd799b324102ccb91cfcdec68ce5d8136d79f47912046ea5a1dd6da2b4

See more details on using hashes here.

File details

Details for the file py_net_diags-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: py_net_diags-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for py_net_diags-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b58012c5fb721b0acc4a3927e8fe9bdf2ffb6f827a6264c0b3a842f27cfad2c
MD5 5cd0c8e5f00833a108ebfe3727f74243
BLAKE2b-256 8250b881d3158e42c667f988b089e133d7193b7bb59d32664435074d595221b1

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