{ "info": { "author": "Kristian Ollegaard", "author_email": "kristian@oellegaard.com", "bugtrack_url": null, "classifiers": [], "description": "===================\ndjango-health-check\n===================\n\n|version| |ci| |coverage| |health| |license|\n\nThis project checks for various conditions and provides reports when anomalous\nbehavior is detected.\n\nThe following health checks are bundled with this project:\n\n- cache\n- database\n- storage\n- disk and memory utilization (via ``psutil``)\n- AWS S3 storage\n- Celery task queue\n\nWriting your own custom health checks is also very quick and easy.\n\nWe also like contributions, so don't be afraid to make a pull request.\n\nUse Cases\n---------\n\nThe primary intended use case is to monitor conditions via HTTP(S), with\nresponses available in HTML and JSON formats. When you get back a response that\nincludes one or more problems, you can then decide the appropriate course of\naction, which could include generating notifications and/or automating the\nreplacement of a failing node with a new one. If you are monitoring health in a\nhigh-availability environment with a load balancer that returns responses from\nmultiple nodes, please note that certain checks (e.g., disk and memory usage)\nwill return responses specific to the node selected by the load balancer.\n\nSupported Versions\n------------------\n\nWe officially only support the latest version of Python as well as the\nlatest version of Django and the latest Django LTS version.\n\n.. note:: The latest version to support Python 2 is 2.4.0\n\nInstallation\n------------\n\nFirst install the ``django-health-check`` package:\n\n.. code::\n\n pip install django-health-check\n\nAdd the health checker to a URL you want to use:\n\n.. code:: python\n\n urlpatterns = [\n # ...\n url(r'^ht/', include('health_check.urls')),\n ]\n\nAdd the ``health_check`` applications to your ``INSTALLED_APPS``:\n\n.. code:: python\n\n INSTALLED_APPS = [\n # ...\n 'health_check', # required\n 'health_check.db', # stock Django health checkers\n 'health_check.cache',\n 'health_check.storage',\n 'health_check.contrib.celery', # requires celery\n 'health_check.contrib.psutil', # disk and memory utilization; requires psutil\n 'health_check.contrib.s3boto_storage', # requires boto and S3BotoStorage backend\n ]\n\n(Optional) If using the ``psutil`` app, you can configure disk and memory\nthreshold settings; otherwise below defaults are assumed. If you want to disable\none of these checks, set its value to ``None``.\n\n.. code:: python\n\n HEALTH_CHECK = {\n 'DISK_USAGE_MAX': 90, # percent\n 'MEMORY_MIN' = 100, # in MB\n }\n\nIf using the DB check, run migrations:\n\n.. code::\n\n django-admin migrate\n\nSetting up monitoring\n---------------------\n\nYou can use tools like Pingdom_ or other uptime robots to monitor service status.\nThe ``/ht/`` endpoint will respond a HTTP 200 if all checks passed\nand a HTTP 500 if any of the tests failed.\n\n.. code::\n\n $ curl -v -X GET -H http://www.example.com/ht/\n\n > GET /ht/ HTTP/1.1\n > Host: www.example.com\n > Accept: */*\n >\n < HTTP/1.1 200 OK\n < Content-Type: text/html; charset=utf-8\n\n \n
\n

System status

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
CacheBackendworking
DatabaseBackendworking
S3BotoStorageHealthCheckworking
\n
\n\nGetting machine readable JSON reports\n-------------------------------------\n\nIf you want machine readable status reports you can request the ``/ht/``\nendpoint with the ``Accept`` HTTP header set to ``application/json``.\n\nThe backend will return a JSON response:\n\n.. code::\n\n $ curl -v -X GET -H \"Accept: application/json\" http://www.example.com/ht/\n\n > GET /ht/ HTTP/1.1\n > Host: www.example.com\n > Accept: application/json\n >\n < HTTP/1.1 200 OK\n < Content-Type: application/json\n\n {\n \"CacheBackend\": \"working\",\n \"DatabaseBackend\": \"working\",\n \"S3BotoStorageHealthCheck\": \"working\"\n }\n\nWriting a custom health check\n-----------------------------\n\nWriting a health check is quick and easy:\n\n.. code:: python\n\n from health_check.backends import BaseHealthCheckBackend\n\n class MyHealthCheckBackend(BaseHealthCheckBackend):\n def check_status(self):\n # The test code goes here.\n # You can use `self.add_error` or\n # raise a `HealthCheckException`,\n # similar to Django's form validation.\n pass\n\n def identifier(self):\n return self.__class__.__name__ # Display name on the endpoint.\n\nAfter writing a custom checker, register it in your app configuration:\n\n.. code:: python\n\n from django.apps import AppConfig\n\n from health_check.plugins import plugin_dir\n\n class MyAppConfig(AppConfig):\n name = 'my_app'\n\n def ready(self):\n from .backends import MyHealthCheckBackend\n plugin_dir.register(MyHealthCheckBackend)\n\nMake sure the application you write the checker into is registered in your ``INSTALLED_APPS``.\n\nCustomizing output\n------------------\n\nYou can customize HTML or JSON rendering by inheriting from ``MainView`` in ``health_check.views``\nand customizing the ``template_name``, ``get``, ``render_to_response`` and ``render_to_response_json`` properties:\n\n.. code:: python\n\n # views.py\n from health_check.views import MainView\n\n class HealthCheckCustomView(MainView):\n template_name = 'myapp/health_check_dashboard.html' # customize the used templates\n\n def get(self, request, *args, **kwargs):\n plugins = []\n # ...\n if 'application/json' in request.META.get('HTTP_ACCEPT', ''):\n return self.render_to_response_json(plugins, status)\n return self.render_to_response(plugins, status)\n\n def render_to_response(self, plugins, status): # customize HTML output\n return HttpResponse('COOL' if status == 200 else 'SWEATY', status=status)\n\n def render_to_response_json(self, plugins, status): # customize JSON output\n return JsonResponse(\n {str(p.identifier()): 'COOL' if status == 200 else 'SWEATY' for p in plugins}\n status=status\n )\n\n # urls.py\n import views\n\n urlpatterns = [\n # ...\n url(r'^ht/$', views.HealthCheckCustomView.as_view(), name='health_check_custom'),\n ]\n\nOther resources\n---------------\n\n- django-watchman_ is a package that does some of the same things in a slightly different way.\n- See this weblog_ about configuring Django and health checking with AWS Elastic Load Balancer.\n\n.. |version| image:: https://img.shields.io/pypi/v/django-health-check.svg\n :target: https://pypi.python.org/pypi/django-health-check/\n.. |ci| image:: https://api.travis-ci.org/KristianOellegaard/django-health-check.svg?branch=master\n :target: https://travis-ci.org/KristianOellegaard/django-health-check\n.. |coverage| image:: https://codecov.io/gh/KristianOellegaard/django-health-check/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/KristianOellegaard/django-health-check\n.. |health| image:: https://landscape.io/github/KristianOellegaard/django-health-check/master/landscape.svg?style=flat\n :target: https://landscape.io/github/KristianOellegaard/django-health-check/master\n.. |license| image:: https://img.shields.io/badge/license-BSD-blue.svg\n :target: LICENSE\n\n.. _Pingdom: https://www.pingdom.com/\n.. _django-watchman: https://github.com/mwarkentin/django-watchman\n.. _weblog: https://www.vincit.fi/en/blog/deploying-django-to-elastic-beanstalk-with-https-redirects-and-functional-health-checks/\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/KristianOellegaard/django-health-check", "keywords": "django", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "django-health-checkers", "package_url": "https://pypi.org/project/django-health-checkers/", "platform": "", "project_url": "https://pypi.org/project/django-health-checkers/", "project_urls": { "Homepage": "https://github.com/KristianOellegaard/django-health-check" }, "release_url": "https://pypi.org/project/django-health-checkers/3.5.0/", "requires_dist": null, "requires_python": "", "summary": "Run checks on services like databases, queue servers, celery processes, etc.", "version": "3.5.0" }, "last_serial": 3581726, "releases": { "3.5.0": [ { "comment_text": "", "digests": { "md5": "7c76b4e83b77c4e89c6a35f708b2fac2", "sha256": "279f5367a7a4cff5e74e375db995fadb1204c86923f21db73fcc77417013ac7f" }, "downloads": -1, "filename": "django_health_checkers-3.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7c76b4e83b77c4e89c6a35f708b2fac2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21943, "upload_time": "2018-02-14T15:47:03", "url": "https://files.pythonhosted.org/packages/55/f9/5e8e3a21582d22e4c763f2409452a831437336d0b1ceecbc771e1f86ffd8/django_health_checkers-3.5.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7c76b4e83b77c4e89c6a35f708b2fac2", "sha256": "279f5367a7a4cff5e74e375db995fadb1204c86923f21db73fcc77417013ac7f" }, "downloads": -1, "filename": "django_health_checkers-3.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7c76b4e83b77c4e89c6a35f708b2fac2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21943, "upload_time": "2018-02-14T15:47:03", "url": "https://files.pythonhosted.org/packages/55/f9/5e8e3a21582d22e4c763f2409452a831437336d0b1ceecbc771e1f86ffd8/django_health_checkers-3.5.0-py3-none-any.whl" } ] }