{ "info": { "author": "Luis Fernando Gomes", "author_email": "luiscoms@ateliedocodigo.com.br", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Flask", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3" ], "description": "Healthcheck\n-----------\n\n.. image:: https://github.com/ateliedocodigo/py-healthcheck/raw/develop/py-healthcheck.jpg\n :target: https://pypi.python.org/pypi/py-healthcheck\n\n.. image:: https://badge.fury.io/py/py-healthcheck.svg\n :target: https://badge.fury.io/py/py-healthcheck\n\n.. image:: https://requires.io/github/ateliedocodigo/py-healthcheck/requirements.svg?branch=develop\n :target: https://requires.io/github/ateliedocodigo/py-healthcheck/requirements/?branch=develop\n :alt: Requirements Status\n\n.. image:: https://travis-ci.org/ateliedocodigo/py-healthcheck.svg?branch=develop\n :target: https://travis-ci.org/ateliedocodigo/py-healthcheck\n\n\nHealthcheck is a library to write simple healthcheck functions that can\nbe used to monitor your application. It is possible to use in a ``Flask``\napp or ``Tornado`` app. It's useful for asserting that your dependencies\nare up and running and your application can respond to HTTP requests.\nThe Healthcheck functions can be exposed via a user defined ``Flask``\nroute so you can use an external monitoring application (``monit``,\n``nagios``, ``Runscope``, etc.) to check the status and uptime of your\napplication.\n\nNew in version 1.1: Healthcheck also gives you a simple Flask route to\nview information about your application's environment. By default, this\nincludes data about the operating system, the Python environment, the\ncurrent process, and the application config. You can customize which\nsections are included, or add your own sections to the output.\n\nInstalling\n----------\n\n::\n\n pip install py-healthcheck\n\nUsage\n-----\n\nHere's an example of basic usage with ``Flask``:\n\n.. code:: python\n\n from flask import Flask\n from healthcheck import HealthCheck, EnvironmentDump\n\n app = Flask(__name__)\n\n health = HealthCheck()\n envdump = EnvironmentDump()\n\n # add your own check function to the healthcheck\n def redis_available():\n client = _redis_client()\n info = client.info()\n return True, \"redis ok\"\n\n health.add_check(redis_available)\n\n # add your own data to the environment dump\n def application_data():\n return {\"maintainer\": \"Luis Fernando Gomes\",\n \"git_repo\": \"https://github.com/ateliedocodigo/py-healthcheck\"}\n\n envdump.add_section(\"application\", application_data)\n\n # Add a flask route to expose information\n app.add_url_rule(\"/healthcheck\", \"healthcheck\", view_func=lambda: health.run())\n app.add_url_rule(\"/environment\", \"environment\", view_func=lambda: envdump.run())\n\nTo use with ``Tornado`` you can import the ``TornadoHandler``:\n\n.. code:: python\n\n import tornado.web\n from healthcheck import TornadoHandler, HealthCheck, EnvironmentDump\n\n app = tornado.web.Application()\n\n health = HealthCheck()\n envdump = EnvironmentDump()\n\n # add your own check function to the healthcheck\n def redis_available():\n client = _redis_client()\n info = client.info()\n return True, \"redis ok\"\n\n health.add_check(redis_available)\n\n # add your own data to the environment dump or healthcheck\n def application_data():\n return {\"maintainer\": \"Luis Fernando Gomes\",\n \"git_repo\": \"https://github.com/ateliedocodigo/py-healthcheck\"}\n\n # ou choose where you want to output this information\n health.add_section(\"application\", application_data)\n health.add_section(\"version\", __version__)\n envdump.add_section(\"application\", application_data)\n\n # Add a tornado handler to expose information\n app.add_handlers(\n r\".*\",\n [\n (\n \"/healthcheck\",\n TornadoHandler, dict(checker=health)\n ),\n (\n \"/environment\",\n TornadoHandler, dict(checker=envdump)\n ),\n ]\n )\n\nAlternatively you can set all together:\n\n.. code:: python\n\n import tornado.web\n from healthcheck import TornadoHandler, HealthCheck, EnvironmentDump\n\n # add your own check function to the healthcheck\n def redis_available():\n client = _redis_client()\n info = client.info()\n return True, \"redis ok\"\n\n health = HealthCheck(checkers=[redis_available])\n\n # add your own data to the environment dump\n def application_data():\n return {\"maintainer\": \"Luis Fernando Gomes\",\n \"git_repo\": \"https://github.com/ateliedocodigo/py-healthcheck\"}\n\n envdump = EnvironmentDump(application=application_data)\n\n app = tornado.web.Application([\n (\"/healthcheck\", TornadoHandler, dict(checker=health)),\n (\"/environment\", TornadoHandler, dict(checker=envdump)),\n ])\n\nTo run all of your check functions, make a request to the healthcheck\nURL you specified, like this:\n\n::\n\n curl \"http://localhost:5000/healthcheck\"\n\nAnd to view the environment data, make a check to the URL you specified\nfor EnvironmentDump:\n\n::\n\n curl \"http://localhost:5000/environment\"\n\nThe HealthCheck class\n---------------------\n\nCheck Functions\n~~~~~~~~~~~~~~~\n\nCheck functions take no arguments and should return a tuple of (bool,\nstr). The boolean is whether or not the check passed. The message is any\nstring or output that should be rendered for this check. Useful for\nerror messages/debugging.\n\n.. code:: python\n\n # add check functions\n def addition_works():\n if 1 + 1 == 2:\n return True, \"addition works\"\n else:\n return False, \"the universe is broken\"\n\nAny exceptions that get thrown by your code will be caught and handled\nas errors in the healthcheck:\n\n.. code:: python\n\n # add check functions\n def throws_exception():\n bad_var = None\n bad_var['explode']\n\nWill output:\n\n.. code:: json\n\n {\n \"status\": \"failure\",\n \"results\": [\n {\n \"output\": \"'NoneType' object has no attribute '__getitem__'\",\n \"checker\": \"throws_exception\",\n \"passed\": false\n }\n ]\n }\n\nNote, all checkers will get run and all failures will be reported. It's\nintended that they are all separate checks and if any one fails the\nhealthcheck overall is failed.\n\nCaching\n~~~~~~~\n\nIn Runscope's infrastructure, the /healthcheck endpoint is hit\nsurprisingly often. haproxy runs on every server, and each haproxy hits\nevery healthcheck twice a minute. (So if we have 30 servers in our\ninfrastructure, that's 60 healthchecks per minute to every Flask\nservice.) Plus, monit hits every healthcheck 6 times a minute.\n\nTo avoid putting too much strain on backend services, health check\nresults can be cached in process memory. By default, health checks that\nsucceed are cached for 27 seconds, and failures are cached for 9\nseconds. These can be overridden with the ``success_ttl`` and\n``failed_ttl`` parameters. If you don't want to use the cache at all,\ninitialize the Healthcheck object with\n``success_ttl=None, failed_ttl=None``.\n\nCustomizing\n~~~~~~~~~~~\n\nYou can customize the status codes, headers, and output format for\nsuccess and failure responses.\n\nThe EnvironmentDump class\n-------------------------\n\nBuilt-in data sections\n~~~~~~~~~~~~~~~~~~~~~~\n\nBy default, EnvironmentDump data includes these 4 sections:\n\n- ``os``: information about your operating system.\n- ``python``: information about your Python executable, Python path,\n and installed packages.\n- ``process``: information about the currently running Python process,\n including the PID, command line arguments, and all environment\n variables.\n\nSome of the data is scrubbed to avoid accidentally exposing passwords or\naccess keys/tokens. Config keys and environment variable names are\nscanned for ``key``, ``token``, or ``pass``. If those strings are\npresent in the name of the variable, the value is not included.\n\nDisabling built-in data sections\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFor security reasons, you may want to disable an entire section. You can\ndisable sections when you instantiate the ``EnvironmentDump`` object,\nlike this:\n\n.. code:: python\n\n envdump = EnvironmentDump(include_python=False, \n include_os=False,\n include_process=False)\n\nAdding custom data sections\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can add a new section to the output by registering a function of\nyour own. Here's an example of how this would be used:\n\n.. code:: python\n\n def application_data():\n return {\"maintainer\": \"Luis Fernando Gomes\",\n \"git_repo\": \"https://github.com/ateliedocodigo/py-healthcheck\"\n \"config\": app.config}\n\n envdump = EnvironmentDump()\n envdump.add_section(\"application\", application_data)\n\n\nCredits\n-------\n\nThis project was forked from `Runscope/healthcheck \n`_. since ``1.3.1``", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/ateliedocodigo/py-healthcheck/tarball/1.9.0", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ateliedocodigo/py-healthcheck", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "py-healthcheck", "package_url": "https://pypi.org/project/py-healthcheck/", "platform": "any", "project_url": "https://pypi.org/project/py-healthcheck/", "project_urls": { "Download": "https://github.com/ateliedocodigo/py-healthcheck/tarball/1.9.0", "Homepage": "https://github.com/ateliedocodigo/py-healthcheck" }, "release_url": "https://pypi.org/project/py-healthcheck/1.9.0/", "requires_dist": null, "requires_python": "", "summary": "Adds healthcheck endpoints to Flask or Tornado apps", "version": "1.9.0" }, "last_serial": 5354722, "releases": { "1.4.0": [ { "comment_text": "", "digests": { "md5": "f369e58f67d1bfaf7f9e914b98847167", "sha256": "c6503cbac7305590fa50419e3c98c33894b38e6dc544a471f99468dcf0138359" }, "downloads": -1, "filename": "py-healthcheck-1.4.0.tar.gz", "has_sig": false, "md5_digest": "f369e58f67d1bfaf7f9e914b98847167", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6473, "upload_time": "2017-01-24T19:16:50", "url": "https://files.pythonhosted.org/packages/1f/de/3eb4bc93e76ca4b787e3d8147e7aeafabb335e94496615a8d289531e3692/py-healthcheck-1.4.0.tar.gz" } ], "1.5.0": [ { "comment_text": "", "digests": { "md5": "8221bcf9cac5481a2066f675551d0cb4", "sha256": "77d2591072290726a20150be4754761ad316cbdfafd35d4ae36739a4143ee1c7" }, "downloads": -1, "filename": "py-healthcheck-1.5.0.tar.gz", "has_sig": false, "md5_digest": "8221bcf9cac5481a2066f675551d0cb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6784, "upload_time": "2017-02-17T16:07:40", "url": "https://files.pythonhosted.org/packages/45/4a/0a1f54d3fde9f9da85db730d538f04195a33720a3213a56caf4b06015eec/py-healthcheck-1.5.0.tar.gz" } ], "1.6.0": [ { "comment_text": "", "digests": { "md5": "90fef2c3eb0823190d3989517272208e", "sha256": "50c991d7b54eecf523822af48f31989b08808d8afb233dbb6405a9278cdeff3f" }, "downloads": -1, "filename": "py-healthcheck-1.6.0.tar.gz", "has_sig": false, "md5_digest": "90fef2c3eb0823190d3989517272208e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7112, "upload_time": "2017-03-31T16:11:02", "url": "https://files.pythonhosted.org/packages/87/a7/d43c81b9c7888e3e7f27cce6dfe0467033adb6f116607230e8e4abade3a7/py-healthcheck-1.6.0.tar.gz" } ], "1.6.1": [ { "comment_text": "", "digests": { "md5": "0f1bd0a77ba3bd3fd59efc4cb25d484b", "sha256": "4da8ede9a5f3cc3954b78931c1855b691271d472f92490955b15661d05041177" }, "downloads": -1, "filename": "py-healthcheck-1.6.1.tar.gz", "has_sig": false, "md5_digest": "0f1bd0a77ba3bd3fd59efc4cb25d484b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7138, "upload_time": "2017-04-04T20:56:23", "url": "https://files.pythonhosted.org/packages/e1/aa/ae425328882ce2c6782b45c4c2c03bd5e509c3472db0cfaa4b366f1e72c5/py-healthcheck-1.6.1.tar.gz" } ], "1.7.0": [ { "comment_text": "", "digests": { "md5": "0cf699a7a5c76e5e3363d2243bda8d96", "sha256": "d08879025eab9cdfdc463bf70843619e506c4b0d13e8f47c9f419d684c416106" }, "downloads": -1, "filename": "py-healthcheck-1.7.0.tar.gz", "has_sig": false, "md5_digest": "0cf699a7a5c76e5e3363d2243bda8d96", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7254, "upload_time": "2017-11-01T13:35:10", "url": "https://files.pythonhosted.org/packages/57/16/0eabe8daf0f25d8908626d754ca3d1e2e5ad3bffb37ca69835ab7911d6fd/py-healthcheck-1.7.0.tar.gz" } ], "1.7.1.post1": [ { "comment_text": "", "digests": { "md5": "cd847d1dd7f79f62accd8cd4533af4ce", "sha256": "0be204058bf5035b62d3aa83445e9a2c0e9d723f03d2ade22f9ee2e9b39de6ab" }, "downloads": -1, "filename": "py-healthcheck-1.7.1.post1.tar.gz", "has_sig": false, "md5_digest": "cd847d1dd7f79f62accd8cd4533af4ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7358, "upload_time": "2018-07-20T14:05:45", "url": "https://files.pythonhosted.org/packages/6a/2f/b88c313969d7c1858d05ec9accd6c66f10fb13868ae01d89f81fb3392d9c/py-healthcheck-1.7.1.post1.tar.gz" } ], "1.7.2": [ { "comment_text": "", "digests": { "md5": "c5a90591ab8c1d26aa845e53fc6570a2", "sha256": "3106071a1ff6343b90a378ed02e6625afb2b041b12e644e8eac74e97d9fa33f3" }, "downloads": -1, "filename": "py-healthcheck-1.7.2.tar.gz", "has_sig": false, "md5_digest": "c5a90591ab8c1d26aa845e53fc6570a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7296, "upload_time": "2018-09-18T13:53:03", "url": "https://files.pythonhosted.org/packages/41/b4/acac294fde507ca080060b5077838f013f363978de0aa4e47b317c9eb812/py-healthcheck-1.7.2.tar.gz" } ], "1.8.0": [ { "comment_text": "", "digests": { "md5": "c413c85265d159f092f4b4cfda334c87", "sha256": "51c1e1807b5fb81941f8975a65beb9c39221a9204c80b48999db3b83dd16f32e" }, "downloads": -1, "filename": "py-healthcheck-1.8.0.tar.gz", "has_sig": false, "md5_digest": "c413c85265d159f092f4b4cfda334c87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7466, "upload_time": "2019-04-15T13:19:24", "url": "https://files.pythonhosted.org/packages/79/6e/cdafa2795cab4ca49509ecb2daa5a02306b2af46f53a8b564e28d5c47645/py-healthcheck-1.8.0.tar.gz" } ], "1.8.1": [ { "comment_text": "", "digests": { "md5": "5c5e2762384e0a61f2c033cfb23242c2", "sha256": "b110b52559fb41c625e3f88917deca6369fb47a3e13ce0b26b1f6ef0a99aa955" }, "downloads": -1, "filename": "py-healthcheck-1.8.1.tar.gz", "has_sig": false, "md5_digest": "5c5e2762384e0a61f2c033cfb23242c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7480, "upload_time": "2019-05-17T17:06:32", "url": "https://files.pythonhosted.org/packages/95/71/f8cd6c876dc32bfbb47e4ddc4bd245d2194a259b2193d2e8d87430493a5c/py-healthcheck-1.8.1.tar.gz" } ], "1.9.0": [ { "comment_text": "", "digests": { "md5": "5526f0d17bcb16add76bab44e2f096b0", "sha256": "6adf7f881c0c521509c4720175a1ec8baed6e00b650e801b5f7c36b135418394" }, "downloads": -1, "filename": "py-healthcheck-1.9.0.tar.gz", "has_sig": false, "md5_digest": "5526f0d17bcb16add76bab44e2f096b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8296, "upload_time": "2019-06-03T22:16:22", "url": "https://files.pythonhosted.org/packages/46/1c/abcde544fbcd4c61081710df49879038d3fa08934a0b36c9664195322c83/py-healthcheck-1.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5526f0d17bcb16add76bab44e2f096b0", "sha256": "6adf7f881c0c521509c4720175a1ec8baed6e00b650e801b5f7c36b135418394" }, "downloads": -1, "filename": "py-healthcheck-1.9.0.tar.gz", "has_sig": false, "md5_digest": "5526f0d17bcb16add76bab44e2f096b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8296, "upload_time": "2019-06-03T22:16:22", "url": "https://files.pythonhosted.org/packages/46/1c/abcde544fbcd4c61081710df49879038d3fa08934a0b36c9664195322c83/py-healthcheck-1.9.0.tar.gz" } ] }