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.1.0.tar.gz (7.0 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.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pihace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4948ac9a0093c08bc290c135bb11b94a0fdaa9a420c21c103ecb24991ea4ece1
MD5 cecac37d4aeb4382955620a520e61ce8
BLAKE2b-256 4aed52767f37598aa8dec4f28f90f5e257ca692dbb77d7ea02b5a97453351ff5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pihace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55e9dab9d89dbdf2e34f6db9857ef8b163f5c56073ce611460b8d4a80fca3bed
MD5 e4ed5ba0fd514ce07ef3aecfda590a64
BLAKE2b-256 b4569faa6548ebb8c5d3d0973e3afde8ff4048628d4e29ba7e8bc649d9a1fe71

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