Skip to main content

A Python library for monitoring health of critical service dependencies.

Project description

Service Health Checker

service-health-checker is a Python library that validates the health of critical service dependencies and reports whether your system is safe to run.

It is designed for:

  • production readiness checks
  • container health checks
  • Kubernetes readiness probes
  • CI/CD deployment checks

Features

  • Health checks for dependencies such as:
    • databases
    • cache systems
    • message queues
    • external APIs
    • storage services
  • Simple status model: OK or FAILED
  • Aggregated report with optional fail-fast exit code for automation
  • Lightweight, no third-party dependencies

Installation

pip install service-health-checker

Quick Start (Library)

from service_health_checker import (
    ServiceMonitor,
    tcp_check,
    http_check,
    disk_space_check,
)

monitor = ServiceMonitor(timeout=3.0)

monitor.add_check("Database", tcp_check(host="127.0.0.1", port=5432))
monitor.add_check("Redis", tcp_check(host="127.0.0.1", port=6379))
monitor.add_check("Kafka", tcp_check(host="127.0.0.1", port=9092))
monitor.add_check("External API", http_check(url="https://api.example.com/health"))
monitor.add_check("Disk Space", disk_space_check(path="/", min_free_percent=10.0))

report = monitor.run()
print(report.to_table())

if not report.is_healthy:
    raise SystemExit("System is not safe to run")

Example Output

Service Health Report

Database        OK
Redis           OK
Kafka           OK
External API    FAILED
Disk Space      OK

CLI Usage

The package provides a CLI command:

service-health-check --http "External API=https://api.example.com/health" --disk "Disk Space=/,10"

Additional examples:

service-health-check \
  --tcp "Database=127.0.0.1:5432" \
  --tcp "Redis=127.0.0.1:6379" \
  --tcp "Kafka=127.0.0.1:9092" \
  --http "External API=https://api.example.com/health" \
  --disk "Disk Space=/,10" \
  --json

Exit codes:

  • 0 when all checks are healthy
  • 1 when one or more checks fail

Built-in Checks

  • tcp_check(host, port)
  • http_check(url, method="GET")
  • disk_space_check(path="/", min_free_percent=10.0)

API Overview

  • ServiceMonitor(timeout=3.0)
  • add_check(name, check_fn)
  • run() -> HealthReport

HealthReport provides:

  • results: list of individual service results
  • is_healthy: boolean overall status
  • to_table(): human-readable report
  • to_dict(): structured output

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

service_health_checker-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

service_health_checker-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file service_health_checker-0.1.0.tar.gz.

File metadata

  • Download URL: service_health_checker-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for service_health_checker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 885895cd985b145cdd4ce1ab5cc49d1d89463be55abf7e7bea71d384799ce0a5
MD5 5e4137e4ec08a7bf41596b097e85714c
BLAKE2b-256 df66b5abccd63e155414fc49d29b4571ae026fbb9a29cfa36481820e5e226089

See more details on using hashes here.

File details

Details for the file service_health_checker-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for service_health_checker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c42cea5237987284689f5f2b90b1696803209f2613df98fb5074493631c992e8
MD5 1a3dfebb5dc028f47e82783347448522
BLAKE2b-256 4551762d70321e4e7a67dda3866022b71bd257b31a850c003202d3b2b6b86499

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