Skip to main content

Python Integrated Health Check - A modular and extensible health check system for services and system resources.

Project description

pihace

Python Integrated Health Check (pihace) is a modular and extensible Python library for system and service health monitoring. It helps you build consistent, informative, and developer-friendly health check endpoints or tools across your applications and infrastructure.

PyPI Python Version License


✨ Features

  • ✅ Built-in system checks: CPU, memory, disk usage, Python version, OS
  • 📦 Modular service checks: MySQL, MongoDB, InfluxDB, and more
  • 🧩 Custom check functions
  • 🧾 Unified health output format
  • 🐍 Pythonic API design
  • 🔧 Extensible with easy register() method

📦 Installation

pip install pihace

🚀 Quick Start

import pihace
from pihace.checkers import MySQL, MongoDB, InfluxDB

healthcheck = pihace.HealthCheck(
    with_system=True,
    component_name="something-api",
    component_version="v1.0.0"
)

healthcheck.register("MySQL A", MySQL(dsn="mysql://root:root@127.0.0.1:3306/testdb"))
healthcheck.register("MongoDB B", MongoDB(dsn="mongodb://localhost:27017/test"))
healthcheck.register("InfluxDB C", InfluxDB(url="http://localhost:8086/health"))

print(healthcheck.check())

🧪 Custom Health Check

def function_that_mock_failure():
    return (False, "something broke")

def function_that_mock_success():
    return True

healthcheck.register("Mock Fail", function_that_mock_failure)
healthcheck.register("Mock Success", function_that_mock_success)`

📤 Example Output

{
  "status": "Partially Available",
  "timestamp": "2023-07-01T14:59:55.711Z",
  "failure": {
    "MongoDB B": "authentication failed"
  },
  "rate": "2/3",
  "system": {
    "cpu_usage": "18%",
    "memory_usage": "32%",
    "disk_usage": "47%",
    "memory_available": "512MB",
    "python_version": "3.10",
    "os": "Windows 10"
  },
  "component": {
    "name": "something-api",
    "version": "v1.0.0"
  }
}

🔌 Supported Checkers

  • MySQL

  • MongoDB

  • InfluxDB

  • 🧩 Custom check functions

More integrations are coming soon!


🧰 Development

Clone this repository:

git clone https://github.com/yourusername/pihace.git
cd pihace
pip install -e ".[dev]"`

Run tests:

pytest

🐳 Docker Compose Example

Start a testing environment:

docker-compose up

📜 License

This project is licensed under the Apache License 2.0.


🤝 Contributing

Contributions are welcome! Please open an issue or PR to add new checkers, fix bugs, or suggest improvements.


📫 Author

Ahmad Zein Al Wafi
📧 ahmadzeinalwafi@outlook.com
🔗 LinkedIn
🌍 Website


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

pihace-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

pihace-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pihace-0.2.0.tar.gz.

File metadata

  • Download URL: pihace-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for pihace-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fa18a164ed0cf89237e9af8295d29f2385e1dff000ad5726ec1f424e2e1f405d
MD5 0f3b17460405ed6c7d079ff25f20a670
BLAKE2b-256 6eecb16221af93fdb7b0a47796ddacd834c03706a5ea512f467de5f7d0db5e45

See more details on using hashes here.

File details

Details for the file pihace-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pihace-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for pihace-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 470af7ef682d6a5a4d34f1e2148d79785f789a024ad53191bf1a049ea28da7be
MD5 3a909ce542d6dfdaf16bfc2752f4d8cc
BLAKE2b-256 19e77cadb08102538c9ef2cc859767e374ed00821e14d3b40072dd060fb5fd67

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