django-health-check 3.20.4__tar.gz → 3.20.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {django_health_check-3.20.4 → django_health_check-3.20.6}/LICENSE +1 -1
  2. django_health_check-3.20.6/PKG-INFO +60 -0
  3. django_health_check-3.20.6/README.md +22 -0
  4. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/_version.py +3 -3
  5. {django_health_check-3.20.4 → django_health_check-3.20.6}/pyproject.toml +6 -6
  6. django_health_check-3.20.4/PKG-INFO +0 -337
  7. django_health_check-3.20.4/README.md +0 -299
  8. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/__init__.py +0 -0
  9. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/backends.py +0 -0
  10. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/cache/__init__.py +0 -0
  11. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/cache/apps.py +0 -0
  12. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/cache/backends.py +0 -0
  13. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/conf.py +0 -0
  14. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/__init__.py +0 -0
  15. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery/__init__.py +0 -0
  16. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery/apps.py +0 -0
  17. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery/backends.py +0 -0
  18. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery/tasks.py +0 -0
  19. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery_ping/__init__.py +0 -0
  20. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery_ping/apps.py +0 -0
  21. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/celery_ping/backends.py +0 -0
  22. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/db_heartbeat/__init__.py +0 -0
  23. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/db_heartbeat/apps.py +0 -0
  24. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/db_heartbeat/backends.py +0 -0
  25. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/mail/__init__.py +0 -0
  26. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/mail/apps.py +0 -0
  27. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/mail/backends.py +0 -0
  28. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/migrations/__init__.py +0 -0
  29. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/migrations/apps.py +0 -0
  30. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/migrations/backends.py +0 -0
  31. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/psutil/__init__.py +0 -0
  32. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/psutil/apps.py +0 -0
  33. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/psutil/backends.py +0 -0
  34. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/rabbitmq/__init__.py +0 -0
  35. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/rabbitmq/apps.py +0 -0
  36. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/rabbitmq/backends.py +0 -0
  37. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/redis/__init__.py +0 -0
  38. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/redis/apps.py +0 -0
  39. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/redis/backends.py +0 -0
  40. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/s3boto3_storage/__init__.py +0 -0
  41. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/s3boto3_storage/apps.py +0 -0
  42. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/s3boto3_storage/backends.py +0 -0
  43. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/s3boto_storage/__init__.py +0 -0
  44. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/s3boto_storage/apps.py +0 -0
  45. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/contrib/s3boto_storage/backends.py +0 -0
  46. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/__init__.py +0 -0
  47. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/apps.py +0 -0
  48. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/backends.py +0 -0
  49. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/migrations/0001_initial.py +0 -0
  50. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/migrations/0002_alter_testmodel_options.py +0 -0
  51. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/migrations/__init__.py +0 -0
  52. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/db/models.py +0 -0
  53. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/exceptions.py +0 -0
  54. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/management/__init__.py +0 -0
  55. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/management/commands/__init__.py +0 -0
  56. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/management/commands/health_check.py +0 -0
  57. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/mixins.py +0 -0
  58. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/plugins.py +0 -0
  59. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/storage/__init__.py +0 -0
  60. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/storage/apps.py +0 -0
  61. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/storage/backends.py +0 -0
  62. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/templates/health_check/index.html +0 -0
  63. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/urls.py +0 -0
  64. {django_health_check-3.20.4 → django_health_check-3.20.6}/health_check/views.py +0 -0
@@ -1,4 +1,4 @@
1
- Copyright (C) 2011-2019 Kristian Øllegaard and contributors
1
+ Copyright (C) 2011-2025 Johannes Maron, Kristian Øllegaard and contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-health-check
3
+ Version: 3.20.6
4
+ Summary: Monitor the health of your Django app and its connected services.
5
+ Keywords: django,postgresql
6
+ Author-email: Kristian Ollegaard <kristian@oellegaard.com>, Johannes Maron <johannes@maron.family>
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Framework :: Django
11
+ Classifier: Framework :: Django :: 4.2
12
+ Classifier: Framework :: Django :: 5.2
13
+ Classifier: Framework :: Django :: 6.0
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Software Development :: Quality Assurance
26
+ Classifier: Topic :: System :: Logging
27
+ Classifier: Topic :: System :: Monitoring
28
+ Classifier: Topic :: Utilities
29
+ License-File: LICENSE
30
+ Requires-Dist: Django>=4.2
31
+ Project-URL: Changelog, https://github.com/codingjoe/django-health-check/releases
32
+ Project-URL: Documentation, https://codingjoe.dev/django-health-check/
33
+ Project-URL: Homepage, https://codingjoe.dev/django-health-check/
34
+ Project-URL: Issues, https://github.com/codingjoe/django-health-check/issues
35
+ Project-URL: Releasenotes, https://github.com/codingjoe/django-health-check/releases/latest
36
+ Project-URL: Source, https://github.com/codingjoe/django-health-check
37
+
38
+ <p align="center">
39
+ <picture>
40
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/codingjoe/django-health-check/raw/main/docs/images/logo-dark.svg">
41
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/codingjoe/django-health-check/raw/main/docs/images/logo-light.svg">
42
+ <img alt="Django HealthCheck: Pluggable health checks for Django applications" src="https://github.com/codingjoe/django-health-check/raw/main/docs/images/logo-light.svg">
43
+ </picture>
44
+ <br>
45
+ <a href="https://codingjoe.dev/django-health-check/">Documentation</a> |
46
+ <a href="https://github.com/codingjoe/django-health-check/issues/new/choose">Issues</a> |
47
+ <a href="https://github.com/codingjoe/django-health-check/releases">Changelog</a> |
48
+ <a href="https://github.com/sponsors/codingjoe">Funding</a> 💚
49
+ </p>
50
+
51
+ # Django HealthCheck
52
+
53
+ _Pluggable health checks for Django applications_
54
+
55
+ [![version](https://img.shields.io/pypi/v/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
56
+ [![coverage](https://codecov.io/gh/codingjoe/django-health-check/branch/main/graph/badge.svg)](https://codecov.io/gh/codingjoe/django-health-check)
57
+ [![pyversion](https://img.shields.io/pypi/pyversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
58
+ [![djversion](https://img.shields.io/pypi/djversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
59
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://pypi.python.org/pypi/django-health-check/)
60
+
@@ -0,0 +1,22 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/codingjoe/django-health-check/raw/main/docs/images/logo-dark.svg">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/codingjoe/django-health-check/raw/main/docs/images/logo-light.svg">
5
+ <img alt="Django HealthCheck: Pluggable health checks for Django applications" src="https://github.com/codingjoe/django-health-check/raw/main/docs/images/logo-light.svg">
6
+ </picture>
7
+ <br>
8
+ <a href="https://codingjoe.dev/django-health-check/">Documentation</a> |
9
+ <a href="https://github.com/codingjoe/django-health-check/issues/new/choose">Issues</a> |
10
+ <a href="https://github.com/codingjoe/django-health-check/releases">Changelog</a> |
11
+ <a href="https://github.com/sponsors/codingjoe">Funding</a> 💚
12
+ </p>
13
+
14
+ # Django HealthCheck
15
+
16
+ _Pluggable health checks for Django applications_
17
+
18
+ [![version](https://img.shields.io/pypi/v/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
19
+ [![coverage](https://codecov.io/gh/codingjoe/django-health-check/branch/main/graph/badge.svg)](https://codecov.io/gh/codingjoe/django-health-check)
20
+ [![pyversion](https://img.shields.io/pypi/pyversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
21
+ [![djversion](https://img.shields.io/pypi/djversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
22
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://pypi.python.org/pypi/django-health-check/)
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '3.20.4'
32
- __version_tuple__ = version_tuple = (3, 20, 4)
31
+ __version__ = version = '3.20.6'
32
+ __version_tuple__ = version_tuple = (3, 20, 6)
33
33
 
34
- __commit_id__ = commit_id = 'g10efa3e81'
34
+ __commit_id__ = commit_id = 'g7fee8b1af'
@@ -44,12 +44,12 @@ dependencies = [
44
44
 
45
45
  [project.urls]
46
46
  # https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
47
- Homepage = "https://django-health-check.readthedocs.io/"
48
- Changelog = "https://github.com/revsys/django-health-check/releases"
49
- Source = "https://github.com/revsys/django-health-check"
50
- Releasenotes = "https://github.com/revsys/django-health-check/releases/latest"
51
- Documentation = "https://django-health-check.readthedocs.io/"
52
- Issues = "https://github.com/revsys/django-health-check/issues"
47
+ Homepage = "https://codingjoe.dev/django-health-check/"
48
+ Changelog = "https://github.com/codingjoe/django-health-check/releases"
49
+ Source = "https://github.com/codingjoe/django-health-check"
50
+ Releasenotes = "https://github.com/codingjoe/django-health-check/releases/latest"
51
+ Documentation = "https://codingjoe.dev/django-health-check/"
52
+ Issues = "https://github.com/codingjoe/django-health-check/issues"
53
53
 
54
54
  [dependency-groups]
55
55
  dev = [
@@ -1,337 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: django-health-check
3
- Version: 3.20.4
4
- Summary: Monitor the health of your Django app and its connected services.
5
- Keywords: django,postgresql
6
- Author-email: Kristian Ollegaard <kristian@oellegaard.com>, Johannes Maron <johannes@maron.family>
7
- Requires-Python: >=3.10
8
- Description-Content-Type: text/markdown
9
- Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: Framework :: Django
11
- Classifier: Framework :: Django :: 4.2
12
- Classifier: Framework :: Django :: 5.2
13
- Classifier: Framework :: Django :: 6.0
14
- Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: MIT License
16
- Classifier: Operating System :: OS Independent
17
- Classifier: Programming Language :: Python
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Programming Language :: Python :: 3.10
21
- Classifier: Programming Language :: Python :: 3.11
22
- Classifier: Programming Language :: Python :: 3.12
23
- Classifier: Programming Language :: Python :: 3.13
24
- Classifier: Programming Language :: Python :: 3.14
25
- Classifier: Topic :: Software Development :: Quality Assurance
26
- Classifier: Topic :: System :: Logging
27
- Classifier: Topic :: System :: Monitoring
28
- Classifier: Topic :: Utilities
29
- License-File: LICENSE
30
- Requires-Dist: Django>=4.2
31
- Project-URL: Changelog, https://github.com/revsys/django-health-check/releases
32
- Project-URL: Documentation, https://django-health-check.readthedocs.io/
33
- Project-URL: Homepage, https://django-health-check.readthedocs.io/
34
- Project-URL: Issues, https://github.com/revsys/django-health-check/issues
35
- Project-URL: Releasenotes, https://github.com/revsys/django-health-check/releases/latest
36
- Project-URL: Source, https://github.com/revsys/django-health-check
37
-
38
- # django-health-check
39
-
40
- [![version](https://img.shields.io/pypi/v/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
41
- [![pyversion](https://img.shields.io/pypi/pyversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
42
- [![djversion](https://img.shields.io/pypi/djversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
43
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://pypi.python.org/pypi/django-health-check/)
44
-
45
- This project checks for various conditions and provides reports when anomalous
46
- behavior is detected.
47
-
48
- The following health checks are bundled with this project:
49
-
50
- - cache
51
- - database
52
- - storage
53
- - disk and memory utilization (via `psutil`)
54
- - AWS S3 storage
55
- - Celery task queue
56
- - Celery ping
57
- - RabbitMQ
58
- - Migrations
59
- - Database Heartbeat (Lightweight version of `health_check.db`)
60
- - email (SMTP)
61
-
62
- Writing your own custom health checks is also very quick and easy.
63
-
64
- We also like contributions, so don't be afraid to make a pull request.
65
-
66
- ## Use Cases
67
-
68
- The primary intended use case is to monitor conditions via HTTP(S), with
69
- responses available in HTML and JSON formats. When you get back a response that
70
- includes one or more problems, you can then decide the appropriate course of
71
- action, which could include generating notifications and/or automating the
72
- replacement of a failing node with a new one. If you are monitoring health in a
73
- high-availability environment with a load balancer that returns responses from
74
- multiple nodes, please note that certain checks (e.g., disk and memory usage)
75
- will return responses specific to the node selected by the load balancer.
76
-
77
- ## Supported Versions
78
-
79
- We officially only support the latest version of Python as well as the
80
- latest version of Django and the latest Django LTS version.
81
-
82
- ## Installation
83
-
84
- First, install the `django-health-check` package:
85
-
86
- ```shell
87
- $ pip install django-health-check
88
- ```
89
-
90
- Add the health checker to a URL you want to use:
91
-
92
- ```python
93
- urlpatterns = [
94
- # ...
95
- path('ht/', include('health_check.urls')),
96
- ]
97
- ```
98
-
99
- Add the `health_check` applications to your `INSTALLED_APPS`:
100
-
101
- ```python
102
- INSTALLED_APPS = [
103
- # ...
104
- 'health_check', # required
105
- 'health_check.db', # stock Django health checkers
106
- 'health_check.cache',
107
- 'health_check.storage',
108
- 'health_check.contrib.migrations',
109
- 'health_check.contrib.celery', # requires celery
110
- 'health_check.contrib.celery_ping', # requires celery
111
- 'health_check.contrib.psutil', # disk and memory utilization; requires psutil
112
- 'health_check.contrib.s3boto3_storage', # requires boto3 and S3BotoStorage backend
113
- 'health_check.contrib.rabbitmq', # requires RabbitMQ broker
114
- 'health_check.contrib.redis', # requires Redis broker
115
- 'health_check.contrib.db_heartbeat',
116
- 'health_check.contrib.mail',
117
- ]
118
- ```
119
-
120
- **Note:** If using `boto 2.x.x` use `health_check.contrib.s3boto_storage`
121
-
122
- (Optional) If using the `psutil` app, you can configure disk and memory
123
- threshold settings; otherwise below defaults are assumed. If you want to disable
124
- one of these checks, set its value to `None`.
125
-
126
- ```python
127
- HEALTH_CHECK = {
128
- 'DISK_USAGE_MAX': 90, # percent
129
- 'MEMORY_MIN': 100, # in MB
130
- }
131
- ```
132
-
133
- (Optional) If using the `mail` app, you can configure timeout
134
- threshold settings; otherwise below defaults are assumed.
135
-
136
- ```python
137
- HEALTH_CHECK = {
138
- 'MAIL_TIMEOUT': 15, # seconds
139
- }
140
- ```
141
-
142
- To use Health Check Subsets, Specify a subset name and associate it with the relevant health check services to utilize Health Check Subsets. (New in version 3.18.0)
143
-
144
- ```python
145
- HEALTH_CHECK = {
146
- # .....
147
- "SUBSETS": {
148
- "startup-probe": ["MigrationsHealthCheck", "DatabaseBackend"],
149
- "liveness-probe": ["DatabaseBackend"],
150
- "<SUBSET_NAME>": ["<Health_Check_Service_Name>"]
151
- },
152
- # .....
153
- }
154
- ```
155
-
156
- To only execute specific subset of health check
157
-
158
- ```shell
159
- curl -X GET -H "Accept: application/json" http://www.example.com/ht/startup-probe/
160
- ```
161
-
162
- If using the DB check, run migrations:
163
-
164
- ```shell
165
- $ django-admin migrate
166
- ```
167
-
168
- To use the RabbitMQ healthcheck, please make sure that there is a variable named
169
- `BROKER_URL` on django.conf.settings with the required format to connect to your
170
- rabbit server. For example:
171
-
172
- ```python
173
- BROKER_URL = "amqp://myuser:mypassword@localhost:5672/myvhost"
174
- ```
175
-
176
- To use the Redis healthcheck, please make sure that there is a variable named `REDIS_URL`
177
- on django.conf.settings with the required format to connect to your redis server. For example:
178
-
179
- ```python
180
- REDIS_URL = "redis://localhost:6370"
181
- ```
182
-
183
- The cache healthcheck tries to write and read a specific key within the cache backend.
184
- It can be customized by setting `HEALTHCHECK_CACHE_KEY` to another value:
185
-
186
- ```python
187
- HEALTHCHECK_CACHE_KEY = "custom_healthcheck_key"
188
- ```
189
-
190
- Additional connection options may be specified by defining a variable `HEALTHCHECK_REDIS_URL_OPTIONS` on the settings module.
191
-
192
- ## Setting up monitoring
193
-
194
- You can use tools like Pingdom, StatusCake or other uptime robots to monitor service status.
195
- The `/ht/` endpoint will respond with an HTTP 200 if all checks passed
196
- and with an HTTP 500 if any of the tests failed.
197
- Getting machine-readable JSON reports
198
-
199
- If you want machine-readable status reports you can request the `/ht/`
200
- endpoint with the `Accept` HTTP header set to `application/json`
201
- or pass `format=json` as a query parameter.
202
-
203
- The backend will return a JSON response:
204
-
205
- ```shell
206
- $ curl -v -X GET -H "Accept: application/json" http://www.example.com/ht/
207
-
208
- > GET /ht/ HTTP/1.1
209
- > Host: www.example.com
210
- > Accept: application/json
211
- >
212
- < HTTP/1.1 200 OK
213
- < Content-Type: application/json
214
-
215
- {
216
- "CacheBackend": "working",
217
- "DatabaseBackend": "working",
218
- "S3BotoStorageHealthCheck": "working"
219
- }
220
-
221
- $ curl -v -X GET http://www.example.com/ht/?format=json
222
-
223
- > GET /ht/?format=json HTTP/1.1
224
- > Host: www.example.com
225
- >
226
- < HTTP/1.1 200 OK
227
- < Content-Type: application/json
228
-
229
- {
230
- "CacheBackend": "working",
231
- "DatabaseBackend": "working",
232
- "S3BotoStorageHealthCheck": "working"
233
- }
234
- ```
235
-
236
- ## Writing a custom health check
237
-
238
- Writing a health check is quick and easy:
239
-
240
- ```python
241
- from health_check.backends import BaseHealthCheckBackend
242
-
243
- class MyHealthCheckBackend(BaseHealthCheckBackend):
244
- #: The status endpoints will respond with a 200 status code
245
- #: even if the check errors.
246
- critical_service = False
247
-
248
- def check_status(self):
249
- # The test code goes here.
250
- # You can use `self.add_error` or
251
- # raise a `HealthCheckException`,
252
- # similar to Django's form validation.
253
- pass
254
-
255
- def identifier(self):
256
- return self.__class__.__name__ # Display name on the endpoint.
257
- ```
258
-
259
- After writing a custom checker, register it in your app configuration:
260
-
261
- ```python
262
- from django.apps import AppConfig
263
-
264
- from health_check.plugins import plugin_dir
265
-
266
- class MyAppConfig(AppConfig):
267
- name = 'my_app'
268
-
269
- def ready(self):
270
- from .backends import MyHealthCheckBackend
271
- plugin_dir.register(MyHealthCheckBackend)
272
- ```
273
-
274
- Make sure the application you write the checker into is registered in your
275
- `INSTALLED_APPS`.
276
-
277
- ## Customizing output
278
-
279
- You can customize HTML or JSON rendering by inheriting from `MainView` in
280
- `health_check.views` and customizing the `template_name`, `get`, `render_to_response`
281
- and `render_to_response_json` properties:
282
-
283
- ```python
284
- # views.py
285
- from health_check.views import MainView
286
-
287
- class HealthCheckCustomView(MainView):
288
- template_name = 'myapp/health_check_dashboard.html' # customize the used templates
289
-
290
- def get(self, request, *args, **kwargs):
291
- plugins = []
292
- status = 200 # needs to be filled status you need
293
- # ...
294
- if 'application/json' in request.META.get('HTTP_ACCEPT', ''):
295
- return self.render_to_response_json(plugins, status)
296
- return self.render_to_response(plugins, status)
297
-
298
- def render_to_response(self, plugins, status): # customize HTML output
299
- return HttpResponse('COOL' if status == 200 else 'SWEATY', status=status)
300
-
301
- def render_to_response_json(self, plugins, status): # customize JSON output
302
- return JsonResponse(
303
- {str(p.identifier()): 'COOL' if status == 200 else 'SWEATY' for p in plugins},
304
- status=status
305
- )
306
-
307
- # urls.py
308
- import views
309
-
310
- urlpatterns = [
311
- # ...
312
- path('ht/', views.HealthCheckCustomView.as_view(), name='health_check_custom'),
313
- ]
314
- ```
315
-
316
- ## Django command
317
-
318
- You can run the Django command `health_check` to perform your health checks via the command line,
319
- or periodically with a cron, as follow:
320
-
321
- ```shell
322
- django-admin health_check
323
- ```
324
-
325
- This should yield the following output:
326
-
327
- ```
328
- DatabaseHealthCheck ... working
329
- CustomHealthCheck ... unavailable: Something went wrong!
330
- ```
331
-
332
- Similar to the http version, a critical error will cause the command to quit with the exit code `1`.
333
-
334
- ## Other resources
335
-
336
- - [django-watchman](https://github.com/mwarkentin/django-watchman) is a package that does some of the same things in a slightly different way.
337
-
@@ -1,299 +0,0 @@
1
- # django-health-check
2
-
3
- [![version](https://img.shields.io/pypi/v/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
4
- [![pyversion](https://img.shields.io/pypi/pyversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
5
- [![djversion](https://img.shields.io/pypi/djversions/django-health-check.svg)](https://pypi.python.org/pypi/django-health-check/)
6
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://pypi.python.org/pypi/django-health-check/)
7
-
8
- This project checks for various conditions and provides reports when anomalous
9
- behavior is detected.
10
-
11
- The following health checks are bundled with this project:
12
-
13
- - cache
14
- - database
15
- - storage
16
- - disk and memory utilization (via `psutil`)
17
- - AWS S3 storage
18
- - Celery task queue
19
- - Celery ping
20
- - RabbitMQ
21
- - Migrations
22
- - Database Heartbeat (Lightweight version of `health_check.db`)
23
- - email (SMTP)
24
-
25
- Writing your own custom health checks is also very quick and easy.
26
-
27
- We also like contributions, so don't be afraid to make a pull request.
28
-
29
- ## Use Cases
30
-
31
- The primary intended use case is to monitor conditions via HTTP(S), with
32
- responses available in HTML and JSON formats. When you get back a response that
33
- includes one or more problems, you can then decide the appropriate course of
34
- action, which could include generating notifications and/or automating the
35
- replacement of a failing node with a new one. If you are monitoring health in a
36
- high-availability environment with a load balancer that returns responses from
37
- multiple nodes, please note that certain checks (e.g., disk and memory usage)
38
- will return responses specific to the node selected by the load balancer.
39
-
40
- ## Supported Versions
41
-
42
- We officially only support the latest version of Python as well as the
43
- latest version of Django and the latest Django LTS version.
44
-
45
- ## Installation
46
-
47
- First, install the `django-health-check` package:
48
-
49
- ```shell
50
- $ pip install django-health-check
51
- ```
52
-
53
- Add the health checker to a URL you want to use:
54
-
55
- ```python
56
- urlpatterns = [
57
- # ...
58
- path('ht/', include('health_check.urls')),
59
- ]
60
- ```
61
-
62
- Add the `health_check` applications to your `INSTALLED_APPS`:
63
-
64
- ```python
65
- INSTALLED_APPS = [
66
- # ...
67
- 'health_check', # required
68
- 'health_check.db', # stock Django health checkers
69
- 'health_check.cache',
70
- 'health_check.storage',
71
- 'health_check.contrib.migrations',
72
- 'health_check.contrib.celery', # requires celery
73
- 'health_check.contrib.celery_ping', # requires celery
74
- 'health_check.contrib.psutil', # disk and memory utilization; requires psutil
75
- 'health_check.contrib.s3boto3_storage', # requires boto3 and S3BotoStorage backend
76
- 'health_check.contrib.rabbitmq', # requires RabbitMQ broker
77
- 'health_check.contrib.redis', # requires Redis broker
78
- 'health_check.contrib.db_heartbeat',
79
- 'health_check.contrib.mail',
80
- ]
81
- ```
82
-
83
- **Note:** If using `boto 2.x.x` use `health_check.contrib.s3boto_storage`
84
-
85
- (Optional) If using the `psutil` app, you can configure disk and memory
86
- threshold settings; otherwise below defaults are assumed. If you want to disable
87
- one of these checks, set its value to `None`.
88
-
89
- ```python
90
- HEALTH_CHECK = {
91
- 'DISK_USAGE_MAX': 90, # percent
92
- 'MEMORY_MIN': 100, # in MB
93
- }
94
- ```
95
-
96
- (Optional) If using the `mail` app, you can configure timeout
97
- threshold settings; otherwise below defaults are assumed.
98
-
99
- ```python
100
- HEALTH_CHECK = {
101
- 'MAIL_TIMEOUT': 15, # seconds
102
- }
103
- ```
104
-
105
- To use Health Check Subsets, Specify a subset name and associate it with the relevant health check services to utilize Health Check Subsets. (New in version 3.18.0)
106
-
107
- ```python
108
- HEALTH_CHECK = {
109
- # .....
110
- "SUBSETS": {
111
- "startup-probe": ["MigrationsHealthCheck", "DatabaseBackend"],
112
- "liveness-probe": ["DatabaseBackend"],
113
- "<SUBSET_NAME>": ["<Health_Check_Service_Name>"]
114
- },
115
- # .....
116
- }
117
- ```
118
-
119
- To only execute specific subset of health check
120
-
121
- ```shell
122
- curl -X GET -H "Accept: application/json" http://www.example.com/ht/startup-probe/
123
- ```
124
-
125
- If using the DB check, run migrations:
126
-
127
- ```shell
128
- $ django-admin migrate
129
- ```
130
-
131
- To use the RabbitMQ healthcheck, please make sure that there is a variable named
132
- `BROKER_URL` on django.conf.settings with the required format to connect to your
133
- rabbit server. For example:
134
-
135
- ```python
136
- BROKER_URL = "amqp://myuser:mypassword@localhost:5672/myvhost"
137
- ```
138
-
139
- To use the Redis healthcheck, please make sure that there is a variable named `REDIS_URL`
140
- on django.conf.settings with the required format to connect to your redis server. For example:
141
-
142
- ```python
143
- REDIS_URL = "redis://localhost:6370"
144
- ```
145
-
146
- The cache healthcheck tries to write and read a specific key within the cache backend.
147
- It can be customized by setting `HEALTHCHECK_CACHE_KEY` to another value:
148
-
149
- ```python
150
- HEALTHCHECK_CACHE_KEY = "custom_healthcheck_key"
151
- ```
152
-
153
- Additional connection options may be specified by defining a variable `HEALTHCHECK_REDIS_URL_OPTIONS` on the settings module.
154
-
155
- ## Setting up monitoring
156
-
157
- You can use tools like Pingdom, StatusCake or other uptime robots to monitor service status.
158
- The `/ht/` endpoint will respond with an HTTP 200 if all checks passed
159
- and with an HTTP 500 if any of the tests failed.
160
- Getting machine-readable JSON reports
161
-
162
- If you want machine-readable status reports you can request the `/ht/`
163
- endpoint with the `Accept` HTTP header set to `application/json`
164
- or pass `format=json` as a query parameter.
165
-
166
- The backend will return a JSON response:
167
-
168
- ```shell
169
- $ curl -v -X GET -H "Accept: application/json" http://www.example.com/ht/
170
-
171
- > GET /ht/ HTTP/1.1
172
- > Host: www.example.com
173
- > Accept: application/json
174
- >
175
- < HTTP/1.1 200 OK
176
- < Content-Type: application/json
177
-
178
- {
179
- "CacheBackend": "working",
180
- "DatabaseBackend": "working",
181
- "S3BotoStorageHealthCheck": "working"
182
- }
183
-
184
- $ curl -v -X GET http://www.example.com/ht/?format=json
185
-
186
- > GET /ht/?format=json HTTP/1.1
187
- > Host: www.example.com
188
- >
189
- < HTTP/1.1 200 OK
190
- < Content-Type: application/json
191
-
192
- {
193
- "CacheBackend": "working",
194
- "DatabaseBackend": "working",
195
- "S3BotoStorageHealthCheck": "working"
196
- }
197
- ```
198
-
199
- ## Writing a custom health check
200
-
201
- Writing a health check is quick and easy:
202
-
203
- ```python
204
- from health_check.backends import BaseHealthCheckBackend
205
-
206
- class MyHealthCheckBackend(BaseHealthCheckBackend):
207
- #: The status endpoints will respond with a 200 status code
208
- #: even if the check errors.
209
- critical_service = False
210
-
211
- def check_status(self):
212
- # The test code goes here.
213
- # You can use `self.add_error` or
214
- # raise a `HealthCheckException`,
215
- # similar to Django's form validation.
216
- pass
217
-
218
- def identifier(self):
219
- return self.__class__.__name__ # Display name on the endpoint.
220
- ```
221
-
222
- After writing a custom checker, register it in your app configuration:
223
-
224
- ```python
225
- from django.apps import AppConfig
226
-
227
- from health_check.plugins import plugin_dir
228
-
229
- class MyAppConfig(AppConfig):
230
- name = 'my_app'
231
-
232
- def ready(self):
233
- from .backends import MyHealthCheckBackend
234
- plugin_dir.register(MyHealthCheckBackend)
235
- ```
236
-
237
- Make sure the application you write the checker into is registered in your
238
- `INSTALLED_APPS`.
239
-
240
- ## Customizing output
241
-
242
- You can customize HTML or JSON rendering by inheriting from `MainView` in
243
- `health_check.views` and customizing the `template_name`, `get`, `render_to_response`
244
- and `render_to_response_json` properties:
245
-
246
- ```python
247
- # views.py
248
- from health_check.views import MainView
249
-
250
- class HealthCheckCustomView(MainView):
251
- template_name = 'myapp/health_check_dashboard.html' # customize the used templates
252
-
253
- def get(self, request, *args, **kwargs):
254
- plugins = []
255
- status = 200 # needs to be filled status you need
256
- # ...
257
- if 'application/json' in request.META.get('HTTP_ACCEPT', ''):
258
- return self.render_to_response_json(plugins, status)
259
- return self.render_to_response(plugins, status)
260
-
261
- def render_to_response(self, plugins, status): # customize HTML output
262
- return HttpResponse('COOL' if status == 200 else 'SWEATY', status=status)
263
-
264
- def render_to_response_json(self, plugins, status): # customize JSON output
265
- return JsonResponse(
266
- {str(p.identifier()): 'COOL' if status == 200 else 'SWEATY' for p in plugins},
267
- status=status
268
- )
269
-
270
- # urls.py
271
- import views
272
-
273
- urlpatterns = [
274
- # ...
275
- path('ht/', views.HealthCheckCustomView.as_view(), name='health_check_custom'),
276
- ]
277
- ```
278
-
279
- ## Django command
280
-
281
- You can run the Django command `health_check` to perform your health checks via the command line,
282
- or periodically with a cron, as follow:
283
-
284
- ```shell
285
- django-admin health_check
286
- ```
287
-
288
- This should yield the following output:
289
-
290
- ```
291
- DatabaseHealthCheck ... working
292
- CustomHealthCheck ... unavailable: Something went wrong!
293
- ```
294
-
295
- Similar to the http version, a critical error will cause the command to quit with the exit code `1`.
296
-
297
- ## Other resources
298
-
299
- - [django-watchman](https://github.com/mwarkentin/django-watchman) is a package that does some of the same things in a slightly different way.