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 GitHub Repo stars


✨ Features

  • ✅ Built-in system checks: CPU, memory, disk usage, Python version, OS
  • 📦 Modular service checks: MySQL, MongoDB, InfluxDB, HTTP, and more
  • 🧩 Custom check functions
  • 📧 Providers buildin: HTTP Service
  • 📧 Pusher buildin: Elastic Search
  • 🗃️ Storage buildin: MongoDB
  • 🧾 Diverse health output format
  • 🐍 Pythonic API design
  • 🔧 Extensible with easy register() method

📦 Installation

pip install pihace

🚀 Quick Start

from pihace.healthcheck import HealthCheck
from pihace.plugins.mysql import MySQL
from pihace.plugins.mongodb import MongoDB
from pihace.plugins.influxdb import InfluxDB
from pihace.plugins.http import HTTP

if __name__ == "__main__":
    hc = HealthCheck(with_system=True, name="example-api", version="v0.1.0")

    hc.register("MySQL A", MySQL(dsn="mysql://root:root@localhost:3306/testdb"), timeout=5, retries=2)
    hc.register("MongoDB B", MongoDB(dsn="mongodb://localhost:27017"))
    hc.register("InfluxDB C", InfluxDB(url="http://localhost:8086", token="admintoken", org="myorg"))
    hc.register("HTTP D", HTTP(url="https://example.com"))

    print(hc.check(output="str"))
    print(hc.check(output="json", pretty=True))
    print(hc.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

  • ElasticSearch

  • HTTP

  • 🧩 Custom check functions

🔌 Supported Providers

  • Web HTTP
  • Prometheus

🔌 Supported Pusher

  • ElasticSearch

🔌 Supported Storage

  • MongoDB

More plugins, providers, pusher, and storage are coming soon!


🧰 Development

Clone this repository:

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

Run tests:

python -m unittest

🐳 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 on github.


📫 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.12.0.tar.gz (14.2 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.12.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pihace-0.12.0.tar.gz
Algorithm Hash digest
SHA256 bcc50d4827cdde90c1a2bed37eee305fb840344149b8f083ea4fcbe6ec7fa074
MD5 952af5937fc34c1d84e9268c6e3fe70e
BLAKE2b-256 8f8c379da9ca8bbd4da352680a5b97dfdd5a0fb1cda0bbc60f17ce28c963e8aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pihace-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 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.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6064e73a59ca9ce5652a1e69ed573e186ad915c592036138813a1b27c84f8a6d
MD5 616e537da05fde8559ea403936b63795
BLAKE2b-256 a84e06848d2315a04bc2159fde462da226fe970a7996f44ededbbec5e2c62e47

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