A simple reusable app that checks and lists various information about your project and its dependencies
Project description
Django-heartbeat is a simple reusable app that checks and lists various information about your project and its dependencies
Requirements
- Python >=3.8 (tested with Python 3.8, 3.10)
- Django >=3.2.19<=4.0
Installation
Install using pip:
pip install django-heartbeat
Next, add 'heartbeat' to your settings.py INSTALLED_APPS:
INSTALLED_APPS = (
...
'heartbeat',
)
Configure urls.py
if 'heartbeat' in settings.INSTALLED_APPS:
from heartbeat.urls import urlpatterns as heartbeat_urls
urlpatterns += [
url(r'^heartbeat/', include(heartbeat_urls))
]
Usage
-
/heartbeat/
After this point you can access the /heartbeat/ endpoint and receive a 200 OK.
-
/heartbeat/1337/
If you want a more detailed view of some custom checkers you MUST configure a custom profile for heartbeat in your settings.py. The profile should be a dictionary containing at least the basic auth credentials or the key
disable
set toTrue
to disable basic authentication.
e.g.:
HEARTBEAT = {
'package_name': 'foo_project',
'checkers': [
'heartbeat.checkers.build',
'heartbeat.checkers.distribution_list',
'heartbeat.checkers.debug_mode',
],
'auth': {
'username': 'foo',
'password': 'bar',
},
}
If no checkers are defined, heartbeat will default to the following:
heartbeat.checkers.distribution_list
heartbeat.checkers.debug_mode
heartbeat.checkers.python
Available checkers
Please make sure you have the latest version of django-heartbeat since checker names changed in versions 1.0.8 and 2.0.0. If for some reason you cannot install the latest version, read the release notes for the version you have and the versions mentioned above.
heartbeat.checkers.build
- lists information about installed package
- Please be aware that in order for this checker to work you have to add the 'package_name': 'foo_package' key, value pair in the HEARTBEAT settings
heartbeat.checkers.databases
- displays information about the connection with your configured databases
heartbeat.checkers.debug_mode
- displays whether the DEBUG mode is set to True or False
heartbeat.checkers.distribution_list
- lists all installed dependencies
heartbeat.checkers.host
- displays various information about your system (e.g. hostname, number of CPUs, uptime, used/free memory, etc.)
heartbeat.checkers.memcached_status
- displays stats about your Memcached.
- Before enabling this checker please make sure that you have installed the appropriate Memcached binding (the two most common are python-memcached and pylibmc)
heartbeat.checkers.python
- lists the current python version
heartbeat.checkers.redis_status
- checks your connection with the Redis server
- Make sure that you have CACHEOPS_REDIS configured properly in your settings.py
Implementing your own checker
- my_checker.py:
def check(request): """ :param request: HttpRequest object :return: dict """ # Checker logic goes here return {'ping': 'pong'}
Note: The function name of your checker MUST be 'check' and has to return a JSON-serializable object
- add it to the settings.HEARTBEAT config
HEARTBEAT = { 'checkers': [ 'heartbeat.checkers.distribution_list', 'my_project.my_checker' ... ], ... }
Simple, huh?
If you would like to contribute to this library with a new checker(or any other functionality), feel free to make a pull request.
Contributors
- Andrei Prădan
- Dan Claudiu Pop
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-heartbeat-2.2.0.tar.gz
.
File metadata
- Download URL: django-heartbeat-2.2.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e3942576e0d7e82821846d3e96223ecba7e9fe0e971e66d8b7de039a328bb79 |
|
MD5 | 3c376a959e3e9133432854d96888f4dc |
|
BLAKE2b-256 | aeeaca669f5fc87bda594e278bb2c2cb711617af3267aa309a90a2b29ab1ec24 |
File details
Details for the file django_heartbeat-2.2.0-py3-none-any.whl
.
File metadata
- Download URL: django_heartbeat-2.2.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6ae2b93fffa7e40b638642f1d6ef1833a6f0d99ca6f6f9b58ba1ee96f07f48a |
|
MD5 | d8871d33c053fbe400373cba5e4baa59 |
|
BLAKE2b-256 | a351a86fe4e98a4498c33883d9e4e1edccacd18ec824cb279e57bc55cf74c582 |