Skip to content

Commit

Permalink
[req-changes] Documented "deactivated" status
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Nov 19, 2024
1 parent 2bde2f4 commit 3dca67f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/user/device-health-status.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ been crossed).

Example: ping is by default a critical metric which is expected to be
always 1 (reachable).

``DEACTIVATED``
---------------

The device is deactivated. All active and passive checks are disabled.
2 changes: 1 addition & 1 deletion docs/user/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ By default, if devices are not reachable by pings they are flagged as
============ ==========================================================
**type**: ``dict``
**default**: ``{'unknown': 'unknown', 'ok': 'ok', 'problem': 'problem',
'critical': 'critical'}``
'critical': 'critical', 'deactivated': 'deactivated'}``
============ ==========================================================

This setting allows to change the health status labels, for example, if we
Expand Down
1 change: 1 addition & 0 deletions openwisp_monitoring/device/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ def register_dashboard_items(self):
'problem': app_settings.HEALTH_STATUS_LABELS['problem'],
'critical': app_settings.HEALTH_STATUS_LABELS['critical'],
'unknown': app_settings.HEALTH_STATUS_LABELS['unknown'],
'deactivated': app_settings.HEALTH_STATUS_LABELS['deactivated'],
},
},
)
Expand Down
5 changes: 4 additions & 1 deletion openwisp_monitoring/device/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ class AbstractDeviceMonitoring(TimeStampedEditableModel):
('ok', _(app_settings.HEALTH_STATUS_LABELS['ok'])),
('problem', _(app_settings.HEALTH_STATUS_LABELS['problem'])),
('critical', _(app_settings.HEALTH_STATUS_LABELS['critical'])),
('deactivated', _(app_settings.HEALTH_STATUS_LABELS['deactivated'])),
)
status = StatusField(
_('health status'),
Expand All @@ -346,12 +347,14 @@ class AbstractDeviceMonitoring(TimeStampedEditableModel):
'"{0}" means the device has been recently added; \n'
'"{1}" means the device is operating normally; \n'
'"{2}" means the device is having issues but it\'s still reachable; \n'
'"{3}" means the device is not reachable or in critical conditions;'
'"{3}" means the device is not reachable or in critical conditions;\n'
'"{4}" means the device is deactivated;'
).format(
app_settings.HEALTH_STATUS_LABELS['unknown'],
app_settings.HEALTH_STATUS_LABELS['ok'],
app_settings.HEALTH_STATUS_LABELS['problem'],
app_settings.HEALTH_STATUS_LABELS['critical'],
app_settings.HEALTH_STATUS_LABELS['deactivated'],
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class Migration(migrations.Migration):
'critical',
_(app_settings.HEALTH_STATUS_LABELS['critical']),
),
(
'deactivated',
_(app_settings.HEALTH_STATUS_LABELS['deactivated']),
),
],
default='unknown',
db_index=True,
Expand Down
2 changes: 2 additions & 0 deletions openwisp_monitoring/device/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def get_health_status_labels():
'ok': 'ok',
'problem': 'problem',
'critical': 'critical',
'deactivated': 'deactivated',
},
)
try:
assert 'unknown' in labels
assert 'ok' in labels
assert 'problem' in labels
assert 'critical' in labels
assert 'deactivated' in labels
except AssertionError as e: # pragma: no cover
raise ImproperlyConfigured(
'OPENWISP_MONITORING_HEALTH_STATUS_LABELS must contain the following '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
const loadingOverlay = $('#device-map-container .ow-loading-spinner');
const localStorageKey = 'ow-map-shown';
const mapContainer = $('#device-map-container');
const statuses = ['critical', 'problem', 'ok', 'unknown'];
const statuses = ['critical', 'problem', 'ok', 'unknown', 'deactivated'];
const colors = {
ok: '#267126',
problem: '#ffb442',
critical: '#a72d1d',
unknown: '#353c44',
deactivated: '#0000',
};
const getLocationDeviceUrl = function (pk) {
return window._owGeoMapConfig.locationDeviceUrl.replace('000', pk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ class Migration(migrations.Migration):
('ok', 'ok'),
('problem', 'problem'),
('critical', 'critical'),
('deactivated', 'deactivated'),
],
db_index=True,
default='unknown',
help_text='"unknown" means the device has been recently added; \n'
'"ok" means the device is operating normally; \n'
'"problem" means the device is having issues but it\'s still reachable; \n'
'"critical" means the device is not reachable or in critical conditions;',
'"critical" means the device is not reachable or in critical conditions;\n'
'"deactivated" means the device is deactivated;',
max_length=100,
no_check_for_status=True,
verbose_name='health status',
Expand Down

0 comments on commit 3dca67f

Please sign in to comment.