diff --git a/InvenTree/InvenTree/context.py b/InvenTree/InvenTree/context.py index aa66402ed6..8753749e3f 100644 --- a/InvenTree/InvenTree/context.py +++ b/InvenTree/InvenTree/context.py @@ -7,9 +7,18 @@ Provides extra global data to all templates. from InvenTree.status_codes import SalesOrderStatus, PurchaseOrderStatus from InvenTree.status_codes import BuildStatus, StockStatus +import InvenTree.status + from users.models import RuleSet +def health_status(request): + + return { + "system_healthy": InvenTree.status.check_system_health(), + } + + def status_codes(request): return { diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 3fc16464c6..d0695c4b7d 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -227,6 +227,7 @@ TEMPLATES = [ 'django.template.context_processors.i18n', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'InvenTree.context.health_status', 'InvenTree.context.status_codes', 'InvenTree.context.user_roles', ], diff --git a/InvenTree/InvenTree/status.py b/InvenTree/InvenTree/status.py new file mode 100644 index 0000000000..ec2422a254 --- /dev/null +++ b/InvenTree/InvenTree/status.py @@ -0,0 +1,39 @@ +""" +Provides system status functionality checks. +""" + +from django.utils.translation import ugettext as _ + +import logging + + +logger = logging.getLogger(__name__) + + +def check_system_health(**kwargs): + """ + Check that the InvenTree system is running OK. + + Returns True if all system checks pass. + """ + + result = True + + if not check_celery_worker(**kwargs): + result = False + logger.warning(_("Celery worker check failed")) + + if not result: + logger.warning(_("InvenTree system health checks failed")) + + return result + + +def check_celery_worker(**kwargs): + """ + Check that a celery worker is running. + """ + + # TODO - Checks that the configured celery worker thing is running + + return True diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index b2ef8f965a..d392c4cb62 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -792,7 +792,7 @@ class DatabaseStatsView(AjaxView): """ View for displaying database statistics """ ajax_template_name = "stats.html" - ajax_form_title = _("Database Statistics") + ajax_form_title = _("System Information") def get_context_data(self, **kwargs): diff --git a/InvenTree/templates/about.html b/InvenTree/templates/about.html index 0fbeef8454..80b29742ef 100644 --- a/InvenTree/templates/about.html +++ b/InvenTree/templates/about.html @@ -16,11 +16,6 @@
- - - - - diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index 148a96c583..9dafd5769e 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -52,7 +52,11 @@ diff --git a/InvenTree/templates/stats.html b/InvenTree/templates/stats.html index 5b194f17a5..7b8a9bb93a 100644 --- a/InvenTree/templates/stats.html +++ b/InvenTree/templates/stats.html @@ -4,6 +4,33 @@
{% trans "Instance Name" %}{% inventree_instance_name %}
{% trans "InvenTree Version" %}{% inventree_version %}
+ + + + + + + + + + + + + + + + {% if not system_healthy %} + {% for issue in system_issues %} + + {% endfor %} + {% endif %} +
{% trans "Server" %}
{% trans "Instance Name" %}{% inventree_instance_name %}
{% trans "Server status" %} + {% if system_healthy %} + {% trans "Healthy" %} + {% else %} + {% trans "Issues detected" %} + {% endif %} +
{% trans "Parts" %}