From e465645594ae4d5976a06a8d7faab0fac01669f3 Mon Sep 17 00:00:00 2001 From: fred1m Date: Sun, 3 May 2020 16:17:33 +0200 Subject: [PATCH] performance: Add app for system monitoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Using cockpit-pcp in ‘System’ section. Signed-off-by: fred1m [sunil: Minor grammar fix in description, minor styling] [sunil: Drop the icon completely in favor of just the font icon] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/performance/__init__.py | 86 +++++++++++++++++++ .../etc/plinth/modules-enabled/performance | 1 + .../access.d/10freedombox-performance.conf | 1 + plinth/modules/performance/manifest.py | 15 ++++ plinth/modules/performance/tests/__init__.py | 0 plinth/modules/performance/urls.py | 13 +++ 6 files changed, 116 insertions(+) create mode 100644 plinth/modules/performance/__init__.py create mode 100644 plinth/modules/performance/data/etc/plinth/modules-enabled/performance create mode 100644 plinth/modules/performance/data/etc/security/access.d/10freedombox-performance.conf create mode 100644 plinth/modules/performance/manifest.py create mode 100644 plinth/modules/performance/tests/__init__.py create mode 100644 plinth/modules/performance/urls.py diff --git a/plinth/modules/performance/__init__.py b/plinth/modules/performance/__init__.py new file mode 100644 index 000000000..260171084 --- /dev/null +++ b/plinth/modules/performance/__init__.py @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +""" +FreedomBox app for System Monitoring (cockpit-pcp) in ‘System’. +""" + +from django.utils.translation import ugettext_lazy as _ + +from plinth import app as app_module +from plinth import menu +from plinth.daemon import Daemon + +from .manifest import clients + +version = 1 + +name = _('Performance') + +managed_services = [ + 'pmcd.service', 'pmie.service', 'pmlogger.service', 'pmproxy.service' +] + +managed_packages = ['cockpit-pcp'] + +_description = [ + ('Performance app allows you to collect, store and view information about ' + 'utilization of the hardware. This can give you basic insights into ' + 'usage patterns and whether the hardware is overloaded by users and ' + 'services.'), + ('Performance metrics are collected by Performance Co-Pilot and can be ' + 'viewed using the Cockpit app.'), +] + +app = None + + +class PerformanceApp(app_module.App): + """FreedomBox app for Performance.""" + + app_id = 'performance' + + def __init__(self): + """Create components for the app.""" + super().__init__() + info = app_module.Info(app_id=self.app_id, version=version, + name=_('Performance'), icon='fa-bar-chart', + short_description=_('System Monitoring'), + description=_description, + manual_page='Performance', clients=clients) + self.add(info) + + menu_item = menu.Menu('menu-performance', info.name, + info.short_description, info.icon, + 'performance:index', parent_url_name='system') + self.add(menu_item) + + daemon_0 = Daemon('daemon-performance-0', managed_services[0], + listen_ports=None) + self.add(daemon_0) + + daemon_1 = Daemon('daemon-performance-1', managed_services[1], + listen_ports=None) + self.add(daemon_1) + + daemon_2 = Daemon('daemon-performance-2', managed_services[2], + listen_ports=None) + self.add(daemon_2) + + daemon_3 = Daemon('daemon-performance-3', managed_services[3], + listen_ports=None) + self.add(daemon_3) + + +def init(): + """Initialize the Performance module.""" + global app + app = PerformanceApp() + + setup_helper = globals()['setup_helper'] + if setup_helper.get_state() != 'needs-setup' and app.is_enabled(): + app.set_enabled(True) + + +def setup(helper, old_version=None): + """Install and configure the module.""" + helper.install(managed_packages) + helper.call('post', app.enable) diff --git a/plinth/modules/performance/data/etc/plinth/modules-enabled/performance b/plinth/modules/performance/data/etc/plinth/modules-enabled/performance new file mode 100644 index 000000000..14c84862a --- /dev/null +++ b/plinth/modules/performance/data/etc/plinth/modules-enabled/performance @@ -0,0 +1 @@ +plinth.modules.performance diff --git a/plinth/modules/performance/data/etc/security/access.d/10freedombox-performance.conf b/plinth/modules/performance/data/etc/security/access.d/10freedombox-performance.conf new file mode 100644 index 000000000..cbc66d077 --- /dev/null +++ b/plinth/modules/performance/data/etc/security/access.d/10freedombox-performance.conf @@ -0,0 +1 @@ ++:pcp:cron diff --git a/plinth/modules/performance/manifest.py b/plinth/modules/performance/manifest.py new file mode 100644 index 000000000..4d0c87e6d --- /dev/null +++ b/plinth/modules/performance/manifest.py @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +""" +FreedomBox app for System Monitoring (cockpit-pcp) in ‘System’. +""" + +from django.utils.translation import ugettext_lazy as _ +from plinth.clients import validate + +clients = validate([{ + 'name': _('Cockpit'), + 'platforms': [{ + 'type': 'web', + 'url': '/_cockpit/' + }] +}]) diff --git a/plinth/modules/performance/tests/__init__.py b/plinth/modules/performance/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plinth/modules/performance/urls.py b/plinth/modules/performance/urls.py new file mode 100644 index 000000000..06920625d --- /dev/null +++ b/plinth/modules/performance/urls.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +""" +FreedomBox app for System Monitoring (cockpit-pcp) in ‘System’. +""" + +from django.conf.urls import url + +from plinth.views import AppView + +urlpatterns = [ + url(r'^sys/performance/$', AppView.as_view(app_id='performance'), + name='index'), +]