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 15, 2024
1 parent 2bde2f4 commit 06a88f0
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 2 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 deactivate. 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
3 changes: 3 additions & 0 deletions 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 @@ -347,11 +348,13 @@ class AbstractDeviceMonitoring(TimeStampedEditableModel):
'"{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;'
'"{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,6 +63,7 @@ class Migration(migrations.Migration):
('ok', 'ok'),
('problem', 'problem'),
('critical', 'critical'),
('deactivated', 'deactivated'),
],
db_index=True,
default='unknown',
Expand Down

0 comments on commit 06a88f0

Please sign in to comment.