diff --git a/docs/user/device-health-status.rst b/docs/user/device-health-status.rst index 7dfd4e4c..dff9cb71 100644 --- a/docs/user/device-health-status.rst +++ b/docs/user/device-health-status.rst @@ -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. diff --git a/docs/user/settings.rst b/docs/user/settings.rst index 9490ff99..3fdf6380 100644 --- a/docs/user/settings.rst +++ b/docs/user/settings.rst @@ -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 diff --git a/openwisp_monitoring/device/apps.py b/openwisp_monitoring/device/apps.py index 84d0ab87..904709ab 100644 --- a/openwisp_monitoring/device/apps.py +++ b/openwisp_monitoring/device/apps.py @@ -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'], }, }, ) diff --git a/openwisp_monitoring/device/base/models.py b/openwisp_monitoring/device/base/models.py index 51dc8b26..872bc53f 100644 --- a/openwisp_monitoring/device/base/models.py +++ b/openwisp_monitoring/device/base/models.py @@ -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'), @@ -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'], ), ) diff --git a/openwisp_monitoring/device/migrations/0001_squashed_0002_devicemonitoring.py b/openwisp_monitoring/device/migrations/0001_squashed_0002_devicemonitoring.py index 80279e23..d9cffe09 100644 --- a/openwisp_monitoring/device/migrations/0001_squashed_0002_devicemonitoring.py +++ b/openwisp_monitoring/device/migrations/0001_squashed_0002_devicemonitoring.py @@ -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, diff --git a/openwisp_monitoring/device/settings.py b/openwisp_monitoring/device/settings.py index d239e3ea..23805176 100644 --- a/openwisp_monitoring/device/settings.py +++ b/openwisp_monitoring/device/settings.py @@ -27,6 +27,7 @@ def get_health_status_labels(): 'ok': 'ok', 'problem': 'problem', 'critical': 'critical', + 'deactivated': 'deactivated', }, ) try: @@ -34,6 +35,7 @@ def get_health_status_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 ' diff --git a/openwisp_monitoring/device/static/monitoring/js/device-map.js b/openwisp_monitoring/device/static/monitoring/js/device-map.js index 00fc8a15..986f4ceb 100644 --- a/openwisp_monitoring/device/static/monitoring/js/device-map.js +++ b/openwisp_monitoring/device/static/monitoring/js/device-map.js @@ -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); diff --git a/tests/openwisp2/sample_device_monitoring/migrations/0001_initial.py b/tests/openwisp2/sample_device_monitoring/migrations/0001_initial.py index 2ff29a4f..173721f2 100644 --- a/tests/openwisp2/sample_device_monitoring/migrations/0001_initial.py +++ b/tests/openwisp2/sample_device_monitoring/migrations/0001_initial.py @@ -63,6 +63,7 @@ class Migration(migrations.Migration): ('ok', 'ok'), ('problem', 'problem'), ('critical', 'critical'), + ('deactivated', 'deactivated'), ], db_index=True, default='unknown',