dbca-utils 3.0.7__tar.gz → 3.0.9__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.
- dbca_utils-3.0.9/PKG-INFO +313 -0
- dbca_utils-3.0.9/README.md +285 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/pyproject.toml +1 -1
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/healthcheck/healthcheck.py +278 -242
- dbca_utils-3.0.7/PKG-INFO +0 -123
- dbca_utils-3.0.7/README.md +0 -95
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/LICENSE +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/__init__.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/apps.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/healthcheck/__init__.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/healthcheck/urls.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/middleware.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/models.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/src/dbca_utils/utils.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/__init__.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/apps.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/migrations/0001_initial.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/migrations/__init__.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/models.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/settings.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/templates/tests/test_model_list.html +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/tests.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/urls.py +0 -0
- {dbca_utils-3.0.7 → dbca_utils-3.0.9}/tests/views.py +0 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbca-utils
|
|
3
|
+
Version: 3.0.9
|
|
4
|
+
Summary: Utilities for DBCA Django apps
|
|
5
|
+
Author-Email: Rocky Chen <rocky.chen@dbca.wa.gov.au>, Ashley Felton <ashley.felton@dbca.wa.gov.au>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Classifier: Framework :: Django
|
|
8
|
+
Classifier: Framework :: Django :: 5.2
|
|
9
|
+
Classifier: Framework :: Django :: 6.0
|
|
10
|
+
Classifier: Environment :: Web Environment
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Project-URL: Homepage, https://github.com/dbca-wa/dbca-utils
|
|
21
|
+
Project-URL: Repository, https://github.com/dbca-wa/dbca-utils.git
|
|
22
|
+
Project-URL: Changelog, https://github.com/dbca-wa/dbca-utils/blob/main/CHANGELOG.md
|
|
23
|
+
Project-URL: GitHub, https://github.com/dbca-wa/dbca-utils
|
|
24
|
+
Requires-Python: <4.0,>=3.12
|
|
25
|
+
Requires-Dist: django<6.2,>=5.2
|
|
26
|
+
Requires-Dist: markupsafe>=3.0.3
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Overview
|
|
30
|
+
|
|
31
|
+
DBCA Django utility classes and functions.
|
|
32
|
+
|
|
33
|
+
## Requirements
|
|
34
|
+
|
|
35
|
+
- Python 3.12 or later
|
|
36
|
+
- Django 5.2 or later
|
|
37
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
Dependencies for this project are managed using [uv](https://docs.astral.sh/uv/).
|
|
41
|
+
With uv installed, change into the project directory and run:
|
|
42
|
+
|
|
43
|
+
uv sync
|
|
44
|
+
|
|
45
|
+
Activate the virtualenv like so:
|
|
46
|
+
|
|
47
|
+
source .venv/bin/activate
|
|
48
|
+
|
|
49
|
+
Run unit tests using `pytest` (or `tox`, to test against multiple Python versions):
|
|
50
|
+
|
|
51
|
+
pytest -sv
|
|
52
|
+
tox -v
|
|
53
|
+
|
|
54
|
+
## Releases
|
|
55
|
+
|
|
56
|
+
Tagged releases are built and pushed to PyPI automatically using a GitHub
|
|
57
|
+
workflow in the project. Update the project version in `pyproject.toml` and
|
|
58
|
+
tag the required commit with the same value to trigger a release. Packages
|
|
59
|
+
can also be built and uploaded manually to PyPI using [uv](https://docs.astral.sh/uv/guides/publish/#publishing-your-package),
|
|
60
|
+
if required:
|
|
61
|
+
|
|
62
|
+
uv build
|
|
63
|
+
uv publish
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
1. Install via uv/pip/etc.: `pip install dbca-utils`
|
|
68
|
+
|
|
69
|
+
## SSO Login Middleware
|
|
70
|
+
|
|
71
|
+
This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others).
|
|
72
|
+
The logout view will redirect to a separate logout page which clears the SSO session.
|
|
73
|
+
|
|
74
|
+
### Usage
|
|
75
|
+
|
|
76
|
+
Add `dbca_utils.middleware.SSOLoginMiddleware` to `settings.MIDDLEWARE` (after both of
|
|
77
|
+
`django.contrib.sessions.middleware.SessionMiddleware` and
|
|
78
|
+
`django.contrib.auth.middleware.AuthenticationMiddleware`.
|
|
79
|
+
Ensure that `AUTHENTICATION_BACKENDS` contains `django.contrib.auth.backends.ModelBackend`,
|
|
80
|
+
as this middleware depends on it for retrieving the logged in user for a session.
|
|
81
|
+
Note that the middleware will still work without it, but will reauthenticate the session
|
|
82
|
+
on every request, and `request.user.is_authenticated` won't work properly/will be false.
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
MIDDLEWARE = [
|
|
88
|
+
...,
|
|
89
|
+
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
90
|
+
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
91
|
+
'dbca_utils.middleware.SSOLoginMiddleware'
|
|
92
|
+
...,
|
|
93
|
+
]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Audit model mixin
|
|
97
|
+
|
|
98
|
+
`AuditMixin` is an extension of `Django.db.model.Model` that adds a number of additional fields:
|
|
99
|
+
|
|
100
|
+
- `creator` - FK to `AUTH_USER_MODEL`, used to record the object creator
|
|
101
|
+
- `modifier` - FK to `AUTH_USER_MODEL`, used to record who the object was last modified by
|
|
102
|
+
- `created` - a timestamp that is set on initial object save
|
|
103
|
+
- `modified` - an auto-updating timestamp (on each object save)
|
|
104
|
+
|
|
105
|
+
## Healthcheck feature
|
|
106
|
+
### Requirements
|
|
107
|
+
- Django 5.2 or later
|
|
108
|
+
- Declared the default cache and also the cache is shared by all pod instances
|
|
109
|
+
|
|
110
|
+
### Usage
|
|
111
|
+
- Install the app 'dbca_utils' in INSTALLED_APPS
|
|
112
|
+
- Service Configuration
|
|
113
|
+
- HEALTHCHECK_ENABLED: Optional. enable/disable the healthcheck service. default is 'true'
|
|
114
|
+
- CACHE_PREFIX: Optional. used as the prefix of the cache key. default is ''
|
|
115
|
+
- PORT: Optional. The listening port of the web application. default is '8080', used to send request to peer pod instance to get the resouces usage of the peer pod instance.
|
|
116
|
+
- WORKLOADS: Optional. Used if the web app has a fixed replicas.
|
|
117
|
+
- WORKLOAD_DEPLOYMENT: Optional. the workload is deployment if it is true; otherwise it is statefulset. default is 'true'
|
|
118
|
+
- WORKLOAD_FAILED_THRESHOLD: Optional. The number of continuous failed times to decide that a pod is offline.
|
|
119
|
+
- WORKLOAD_VOLUMES: Optional. can be 'disabled', 'false','automatic' or "," separated volume mounted point. default is "automatic".
|
|
120
|
+
- disabled|false: Don't harvest volume usage data
|
|
121
|
+
- automatic: Detect the persistent volume automatically.
|
|
122
|
+
- "," separated volume mounted points: the volume list
|
|
123
|
+
- HEALTHCHECK_SYSTEMDATA_ENABLED: Enable system resource data
|
|
124
|
+
- HEALTHCHECK_PROCESSDATA_ENABLED: Enable process resource data
|
|
125
|
+
- Endpoints added by this app
|
|
126
|
+
- /healthcheck/healthdata: An endpoint for client to harvest the resources usage data. This endpoint should be cofigured to use basic auth in nginx reverse proxy.
|
|
127
|
+
- /workload/healthcheck/healthdata: An internal endpoint used to get the resource usage of the peer pod instance. This endpoing should not be exposed in nginx reverse proxy.
|
|
128
|
+
- Nginx Configuration.
|
|
129
|
+
- Add a location 'location /healthcheck/' and configure it to use basic auth in nginx.
|
|
130
|
+
- Access the url : https://xxx.dbca.wa.gov.au/healthcheck/healthdata to get the health json data
|
|
131
|
+
- The sample data of the health data:
|
|
132
|
+
{
|
|
133
|
+
"workload0":{
|
|
134
|
+
"resources":{
|
|
135
|
+
"start_time":"2026-07-24T06:10:23",
|
|
136
|
+
"cpu_total":0.0,
|
|
137
|
+
"cpu_min":0.0,
|
|
138
|
+
"cpu_max":0.0,
|
|
139
|
+
"pmemory_total":292.28125,
|
|
140
|
+
"pmemory_min":95.53515625,
|
|
141
|
+
"pmemory_max":100.828125,
|
|
142
|
+
"vmemory_total":764.12890625,
|
|
143
|
+
"vmemory_min":207.8671875,
|
|
144
|
+
"vmemory_max":278.59765625,
|
|
145
|
+
"processes":3,
|
|
146
|
+
"process":{
|
|
147
|
+
"start_time":"2026-07-24T06:10:23",
|
|
148
|
+
"cmdline":[
|
|
149
|
+
"/app/.venv/bin/python",
|
|
150
|
+
"/app/.venv/bin/gunicorn",
|
|
151
|
+
"authome.wsgi",
|
|
152
|
+
"--config=gunicorn_gevent.py"
|
|
153
|
+
],
|
|
154
|
+
"cpu_num":0,
|
|
155
|
+
"cpu_pcent":0.0,
|
|
156
|
+
"pmemory":100.828125,
|
|
157
|
+
"vmemory":207.8671875,
|
|
158
|
+
"children":[
|
|
159
|
+
{
|
|
160
|
+
"start_time":"2026-07-24T06:10:24",
|
|
161
|
+
"cmdline":[
|
|
162
|
+
"/app/.venv/bin/python",
|
|
163
|
+
"/app/.venv/bin/gunicorn",
|
|
164
|
+
"authome.wsgi",
|
|
165
|
+
"--config=gunicorn_gevent.py"
|
|
166
|
+
],
|
|
167
|
+
"cpu_num":1,
|
|
168
|
+
"cpu_pcent":0.0,
|
|
169
|
+
"pmemory":95.53515625,
|
|
170
|
+
"vmemory":277.6640625
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"start_time":"2026-07-24T06:10:24",
|
|
174
|
+
"cmdline":[
|
|
175
|
+
"/app/.venv/bin/python",
|
|
176
|
+
"/app/.venv/bin/gunicorn",
|
|
177
|
+
"authome.wsgi",
|
|
178
|
+
"--config=gunicorn_gevent.py"
|
|
179
|
+
],
|
|
180
|
+
"cpu_num":3,
|
|
181
|
+
"cpu_pcent":0.0,
|
|
182
|
+
"pmemory":95.91796875,
|
|
183
|
+
"vmemory":278.59765625,
|
|
184
|
+
"currentprocess":true
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"system":{
|
|
190
|
+
"cpu_pcent":0.0,
|
|
191
|
+
"cpucores_pcent":[
|
|
192
|
+
0.0,
|
|
193
|
+
0.0,
|
|
194
|
+
0.0,
|
|
195
|
+
0.0
|
|
196
|
+
],
|
|
197
|
+
"memory_total":31.279705047607422,
|
|
198
|
+
"memory_used":12.220211029052734,
|
|
199
|
+
"memory_pcent":39.06753919339612,
|
|
200
|
+
"bytes_sent":9028205,
|
|
201
|
+
"bytes_recv":9246094
|
|
202
|
+
},
|
|
203
|
+
"volumes":{
|
|
204
|
+
"/app/captcha":{
|
|
205
|
+
"size":1024,
|
|
206
|
+
"used":0,
|
|
207
|
+
"pcent":0.006103515625,
|
|
208
|
+
"unit":"M"
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"hostname":"auth2-uat11-5b495b67cb-z8vwj"
|
|
212
|
+
},
|
|
213
|
+
"workload1":{
|
|
214
|
+
"resources":{
|
|
215
|
+
"start_time":"2026-07-24T06:11:45",
|
|
216
|
+
"cpu_total":0.0,
|
|
217
|
+
"cpu_min":0.0,
|
|
218
|
+
"cpu_max":0.0,
|
|
219
|
+
"pmemory_total":292.02734375,
|
|
220
|
+
"pmemory_min":95.4140625,
|
|
221
|
+
"pmemory_max":100.6171875,
|
|
222
|
+
"vmemory_total":763.84375,
|
|
223
|
+
"vmemory_min":207.8359375,
|
|
224
|
+
"vmemory_max":278.546875,
|
|
225
|
+
"processes":3,
|
|
226
|
+
"process":{
|
|
227
|
+
"start_time":"2026-07-24T06:11:45",
|
|
228
|
+
"cmdline":[
|
|
229
|
+
"/app/.venv/bin/python",
|
|
230
|
+
"/app/.venv/bin/gunicorn",
|
|
231
|
+
"authome.wsgi",
|
|
232
|
+
"--config=gunicorn_gevent.py"
|
|
233
|
+
],
|
|
234
|
+
"cpu_num":1,
|
|
235
|
+
"cpu_pcent":0.0,
|
|
236
|
+
"pmemory":100.6171875,
|
|
237
|
+
"vmemory":207.8359375,
|
|
238
|
+
"children":[
|
|
239
|
+
{
|
|
240
|
+
"start_time":"2026-07-24T06:11:46",
|
|
241
|
+
"cmdline":[
|
|
242
|
+
"/app/.venv/bin/python",
|
|
243
|
+
"/app/.venv/bin/gunicorn",
|
|
244
|
+
"authome.wsgi",
|
|
245
|
+
"--config=gunicorn_gevent.py"
|
|
246
|
+
],
|
|
247
|
+
"cpu_num":2,
|
|
248
|
+
"cpu_pcent":0.0,
|
|
249
|
+
"pmemory":95.4140625,
|
|
250
|
+
"vmemory":277.4609375
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"start_time":"2026-07-24T06:11:46",
|
|
254
|
+
"cmdline":[
|
|
255
|
+
"/app/.venv/bin/python",
|
|
256
|
+
"/app/.venv/bin/gunicorn",
|
|
257
|
+
"authome.wsgi",
|
|
258
|
+
"--config=gunicorn_gevent.py"
|
|
259
|
+
],
|
|
260
|
+
"cpu_num":3,
|
|
261
|
+
"cpu_pcent":0.0,
|
|
262
|
+
"pmemory":95.99609375,
|
|
263
|
+
"vmemory":278.546875,
|
|
264
|
+
"currentprocess":true
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"system":{
|
|
270
|
+
"cpu_pcent":13.1,
|
|
271
|
+
"cpucores_pcent":[
|
|
272
|
+
15.4,
|
|
273
|
+
12.2,
|
|
274
|
+
12.0,
|
|
275
|
+
12.7
|
|
276
|
+
],
|
|
277
|
+
"memory_total":31.279705047607422,
|
|
278
|
+
"memory_used":12.220211029052734,
|
|
279
|
+
"memory_pcent":39.06753919339612,
|
|
280
|
+
"bytes_sent":9099207,
|
|
281
|
+
"bytes_recv":9055029
|
|
282
|
+
},
|
|
283
|
+
"volumes":{
|
|
284
|
+
"/app/captcha":{
|
|
285
|
+
"size":1024,
|
|
286
|
+
"used":0,
|
|
287
|
+
"pcent":0.006103515625,
|
|
288
|
+
"unit":"M"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
"hostname":"auth2-uat11-5b495b67cb-dpdjp"
|
|
292
|
+
},
|
|
293
|
+
"summary":{
|
|
294
|
+
"cpu_total":0.0,
|
|
295
|
+
"cpu_min":0.0,
|
|
296
|
+
"cpu_max":0.0,
|
|
297
|
+
"process_cpu_min":0.0,
|
|
298
|
+
"process_cpu_max":0.0,
|
|
299
|
+
"pmemory_total":584.30859375,
|
|
300
|
+
"pmemory_min":292.02734375,
|
|
301
|
+
"pmemory_max":292.28125,
|
|
302
|
+
"process_pmemory_min":95.4140625,
|
|
303
|
+
"process_pmemory_max":100.828125,
|
|
304
|
+
"vmemory_total":1527.97265625,
|
|
305
|
+
"vmemory_min":763.84375,
|
|
306
|
+
"vmemory_max":764.12890625,
|
|
307
|
+
"process_vmemory_min":207.8359375,
|
|
308
|
+
"process_vmemory_max":278.59765625,
|
|
309
|
+
"processes_total":6,
|
|
310
|
+
"workloads_running":2,
|
|
311
|
+
"workloads_failed":0
|
|
312
|
+
}
|
|
313
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
DBCA Django utility classes and functions.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Python 3.12 or later
|
|
8
|
+
- Django 5.2 or later
|
|
9
|
+
|
|
10
|
+
## Development
|
|
11
|
+
|
|
12
|
+
Dependencies for this project are managed using [uv](https://docs.astral.sh/uv/).
|
|
13
|
+
With uv installed, change into the project directory and run:
|
|
14
|
+
|
|
15
|
+
uv sync
|
|
16
|
+
|
|
17
|
+
Activate the virtualenv like so:
|
|
18
|
+
|
|
19
|
+
source .venv/bin/activate
|
|
20
|
+
|
|
21
|
+
Run unit tests using `pytest` (or `tox`, to test against multiple Python versions):
|
|
22
|
+
|
|
23
|
+
pytest -sv
|
|
24
|
+
tox -v
|
|
25
|
+
|
|
26
|
+
## Releases
|
|
27
|
+
|
|
28
|
+
Tagged releases are built and pushed to PyPI automatically using a GitHub
|
|
29
|
+
workflow in the project. Update the project version in `pyproject.toml` and
|
|
30
|
+
tag the required commit with the same value to trigger a release. Packages
|
|
31
|
+
can also be built and uploaded manually to PyPI using [uv](https://docs.astral.sh/uv/guides/publish/#publishing-your-package),
|
|
32
|
+
if required:
|
|
33
|
+
|
|
34
|
+
uv build
|
|
35
|
+
uv publish
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
1. Install via uv/pip/etc.: `pip install dbca-utils`
|
|
40
|
+
|
|
41
|
+
## SSO Login Middleware
|
|
42
|
+
|
|
43
|
+
This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others).
|
|
44
|
+
The logout view will redirect to a separate logout page which clears the SSO session.
|
|
45
|
+
|
|
46
|
+
### Usage
|
|
47
|
+
|
|
48
|
+
Add `dbca_utils.middleware.SSOLoginMiddleware` to `settings.MIDDLEWARE` (after both of
|
|
49
|
+
`django.contrib.sessions.middleware.SessionMiddleware` and
|
|
50
|
+
`django.contrib.auth.middleware.AuthenticationMiddleware`.
|
|
51
|
+
Ensure that `AUTHENTICATION_BACKENDS` contains `django.contrib.auth.backends.ModelBackend`,
|
|
52
|
+
as this middleware depends on it for retrieving the logged in user for a session.
|
|
53
|
+
Note that the middleware will still work without it, but will reauthenticate the session
|
|
54
|
+
on every request, and `request.user.is_authenticated` won't work properly/will be false.
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
MIDDLEWARE = [
|
|
60
|
+
...,
|
|
61
|
+
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
62
|
+
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
63
|
+
'dbca_utils.middleware.SSOLoginMiddleware'
|
|
64
|
+
...,
|
|
65
|
+
]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Audit model mixin
|
|
69
|
+
|
|
70
|
+
`AuditMixin` is an extension of `Django.db.model.Model` that adds a number of additional fields:
|
|
71
|
+
|
|
72
|
+
- `creator` - FK to `AUTH_USER_MODEL`, used to record the object creator
|
|
73
|
+
- `modifier` - FK to `AUTH_USER_MODEL`, used to record who the object was last modified by
|
|
74
|
+
- `created` - a timestamp that is set on initial object save
|
|
75
|
+
- `modified` - an auto-updating timestamp (on each object save)
|
|
76
|
+
|
|
77
|
+
## Healthcheck feature
|
|
78
|
+
### Requirements
|
|
79
|
+
- Django 5.2 or later
|
|
80
|
+
- Declared the default cache and also the cache is shared by all pod instances
|
|
81
|
+
|
|
82
|
+
### Usage
|
|
83
|
+
- Install the app 'dbca_utils' in INSTALLED_APPS
|
|
84
|
+
- Service Configuration
|
|
85
|
+
- HEALTHCHECK_ENABLED: Optional. enable/disable the healthcheck service. default is 'true'
|
|
86
|
+
- CACHE_PREFIX: Optional. used as the prefix of the cache key. default is ''
|
|
87
|
+
- PORT: Optional. The listening port of the web application. default is '8080', used to send request to peer pod instance to get the resouces usage of the peer pod instance.
|
|
88
|
+
- WORKLOADS: Optional. Used if the web app has a fixed replicas.
|
|
89
|
+
- WORKLOAD_DEPLOYMENT: Optional. the workload is deployment if it is true; otherwise it is statefulset. default is 'true'
|
|
90
|
+
- WORKLOAD_FAILED_THRESHOLD: Optional. The number of continuous failed times to decide that a pod is offline.
|
|
91
|
+
- WORKLOAD_VOLUMES: Optional. can be 'disabled', 'false','automatic' or "," separated volume mounted point. default is "automatic".
|
|
92
|
+
- disabled|false: Don't harvest volume usage data
|
|
93
|
+
- automatic: Detect the persistent volume automatically.
|
|
94
|
+
- "," separated volume mounted points: the volume list
|
|
95
|
+
- HEALTHCHECK_SYSTEMDATA_ENABLED: Enable system resource data
|
|
96
|
+
- HEALTHCHECK_PROCESSDATA_ENABLED: Enable process resource data
|
|
97
|
+
- Endpoints added by this app
|
|
98
|
+
- /healthcheck/healthdata: An endpoint for client to harvest the resources usage data. This endpoint should be cofigured to use basic auth in nginx reverse proxy.
|
|
99
|
+
- /workload/healthcheck/healthdata: An internal endpoint used to get the resource usage of the peer pod instance. This endpoing should not be exposed in nginx reverse proxy.
|
|
100
|
+
- Nginx Configuration.
|
|
101
|
+
- Add a location 'location /healthcheck/' and configure it to use basic auth in nginx.
|
|
102
|
+
- Access the url : https://xxx.dbca.wa.gov.au/healthcheck/healthdata to get the health json data
|
|
103
|
+
- The sample data of the health data:
|
|
104
|
+
{
|
|
105
|
+
"workload0":{
|
|
106
|
+
"resources":{
|
|
107
|
+
"start_time":"2026-07-24T06:10:23",
|
|
108
|
+
"cpu_total":0.0,
|
|
109
|
+
"cpu_min":0.0,
|
|
110
|
+
"cpu_max":0.0,
|
|
111
|
+
"pmemory_total":292.28125,
|
|
112
|
+
"pmemory_min":95.53515625,
|
|
113
|
+
"pmemory_max":100.828125,
|
|
114
|
+
"vmemory_total":764.12890625,
|
|
115
|
+
"vmemory_min":207.8671875,
|
|
116
|
+
"vmemory_max":278.59765625,
|
|
117
|
+
"processes":3,
|
|
118
|
+
"process":{
|
|
119
|
+
"start_time":"2026-07-24T06:10:23",
|
|
120
|
+
"cmdline":[
|
|
121
|
+
"/app/.venv/bin/python",
|
|
122
|
+
"/app/.venv/bin/gunicorn",
|
|
123
|
+
"authome.wsgi",
|
|
124
|
+
"--config=gunicorn_gevent.py"
|
|
125
|
+
],
|
|
126
|
+
"cpu_num":0,
|
|
127
|
+
"cpu_pcent":0.0,
|
|
128
|
+
"pmemory":100.828125,
|
|
129
|
+
"vmemory":207.8671875,
|
|
130
|
+
"children":[
|
|
131
|
+
{
|
|
132
|
+
"start_time":"2026-07-24T06:10:24",
|
|
133
|
+
"cmdline":[
|
|
134
|
+
"/app/.venv/bin/python",
|
|
135
|
+
"/app/.venv/bin/gunicorn",
|
|
136
|
+
"authome.wsgi",
|
|
137
|
+
"--config=gunicorn_gevent.py"
|
|
138
|
+
],
|
|
139
|
+
"cpu_num":1,
|
|
140
|
+
"cpu_pcent":0.0,
|
|
141
|
+
"pmemory":95.53515625,
|
|
142
|
+
"vmemory":277.6640625
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"start_time":"2026-07-24T06:10:24",
|
|
146
|
+
"cmdline":[
|
|
147
|
+
"/app/.venv/bin/python",
|
|
148
|
+
"/app/.venv/bin/gunicorn",
|
|
149
|
+
"authome.wsgi",
|
|
150
|
+
"--config=gunicorn_gevent.py"
|
|
151
|
+
],
|
|
152
|
+
"cpu_num":3,
|
|
153
|
+
"cpu_pcent":0.0,
|
|
154
|
+
"pmemory":95.91796875,
|
|
155
|
+
"vmemory":278.59765625,
|
|
156
|
+
"currentprocess":true
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"system":{
|
|
162
|
+
"cpu_pcent":0.0,
|
|
163
|
+
"cpucores_pcent":[
|
|
164
|
+
0.0,
|
|
165
|
+
0.0,
|
|
166
|
+
0.0,
|
|
167
|
+
0.0
|
|
168
|
+
],
|
|
169
|
+
"memory_total":31.279705047607422,
|
|
170
|
+
"memory_used":12.220211029052734,
|
|
171
|
+
"memory_pcent":39.06753919339612,
|
|
172
|
+
"bytes_sent":9028205,
|
|
173
|
+
"bytes_recv":9246094
|
|
174
|
+
},
|
|
175
|
+
"volumes":{
|
|
176
|
+
"/app/captcha":{
|
|
177
|
+
"size":1024,
|
|
178
|
+
"used":0,
|
|
179
|
+
"pcent":0.006103515625,
|
|
180
|
+
"unit":"M"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"hostname":"auth2-uat11-5b495b67cb-z8vwj"
|
|
184
|
+
},
|
|
185
|
+
"workload1":{
|
|
186
|
+
"resources":{
|
|
187
|
+
"start_time":"2026-07-24T06:11:45",
|
|
188
|
+
"cpu_total":0.0,
|
|
189
|
+
"cpu_min":0.0,
|
|
190
|
+
"cpu_max":0.0,
|
|
191
|
+
"pmemory_total":292.02734375,
|
|
192
|
+
"pmemory_min":95.4140625,
|
|
193
|
+
"pmemory_max":100.6171875,
|
|
194
|
+
"vmemory_total":763.84375,
|
|
195
|
+
"vmemory_min":207.8359375,
|
|
196
|
+
"vmemory_max":278.546875,
|
|
197
|
+
"processes":3,
|
|
198
|
+
"process":{
|
|
199
|
+
"start_time":"2026-07-24T06:11:45",
|
|
200
|
+
"cmdline":[
|
|
201
|
+
"/app/.venv/bin/python",
|
|
202
|
+
"/app/.venv/bin/gunicorn",
|
|
203
|
+
"authome.wsgi",
|
|
204
|
+
"--config=gunicorn_gevent.py"
|
|
205
|
+
],
|
|
206
|
+
"cpu_num":1,
|
|
207
|
+
"cpu_pcent":0.0,
|
|
208
|
+
"pmemory":100.6171875,
|
|
209
|
+
"vmemory":207.8359375,
|
|
210
|
+
"children":[
|
|
211
|
+
{
|
|
212
|
+
"start_time":"2026-07-24T06:11:46",
|
|
213
|
+
"cmdline":[
|
|
214
|
+
"/app/.venv/bin/python",
|
|
215
|
+
"/app/.venv/bin/gunicorn",
|
|
216
|
+
"authome.wsgi",
|
|
217
|
+
"--config=gunicorn_gevent.py"
|
|
218
|
+
],
|
|
219
|
+
"cpu_num":2,
|
|
220
|
+
"cpu_pcent":0.0,
|
|
221
|
+
"pmemory":95.4140625,
|
|
222
|
+
"vmemory":277.4609375
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"start_time":"2026-07-24T06:11:46",
|
|
226
|
+
"cmdline":[
|
|
227
|
+
"/app/.venv/bin/python",
|
|
228
|
+
"/app/.venv/bin/gunicorn",
|
|
229
|
+
"authome.wsgi",
|
|
230
|
+
"--config=gunicorn_gevent.py"
|
|
231
|
+
],
|
|
232
|
+
"cpu_num":3,
|
|
233
|
+
"cpu_pcent":0.0,
|
|
234
|
+
"pmemory":95.99609375,
|
|
235
|
+
"vmemory":278.546875,
|
|
236
|
+
"currentprocess":true
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"system":{
|
|
242
|
+
"cpu_pcent":13.1,
|
|
243
|
+
"cpucores_pcent":[
|
|
244
|
+
15.4,
|
|
245
|
+
12.2,
|
|
246
|
+
12.0,
|
|
247
|
+
12.7
|
|
248
|
+
],
|
|
249
|
+
"memory_total":31.279705047607422,
|
|
250
|
+
"memory_used":12.220211029052734,
|
|
251
|
+
"memory_pcent":39.06753919339612,
|
|
252
|
+
"bytes_sent":9099207,
|
|
253
|
+
"bytes_recv":9055029
|
|
254
|
+
},
|
|
255
|
+
"volumes":{
|
|
256
|
+
"/app/captcha":{
|
|
257
|
+
"size":1024,
|
|
258
|
+
"used":0,
|
|
259
|
+
"pcent":0.006103515625,
|
|
260
|
+
"unit":"M"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"hostname":"auth2-uat11-5b495b67cb-dpdjp"
|
|
264
|
+
},
|
|
265
|
+
"summary":{
|
|
266
|
+
"cpu_total":0.0,
|
|
267
|
+
"cpu_min":0.0,
|
|
268
|
+
"cpu_max":0.0,
|
|
269
|
+
"process_cpu_min":0.0,
|
|
270
|
+
"process_cpu_max":0.0,
|
|
271
|
+
"pmemory_total":584.30859375,
|
|
272
|
+
"pmemory_min":292.02734375,
|
|
273
|
+
"pmemory_max":292.28125,
|
|
274
|
+
"process_pmemory_min":95.4140625,
|
|
275
|
+
"process_pmemory_max":100.828125,
|
|
276
|
+
"vmemory_total":1527.97265625,
|
|
277
|
+
"vmemory_min":763.84375,
|
|
278
|
+
"vmemory_max":764.12890625,
|
|
279
|
+
"process_vmemory_min":207.8359375,
|
|
280
|
+
"process_vmemory_max":278.59765625,
|
|
281
|
+
"processes_total":6,
|
|
282
|
+
"workloads_running":2,
|
|
283
|
+
"workloads_failed":0
|
|
284
|
+
}
|
|
285
|
+
}
|