From 7a96ae976738aa2c0488d2b764a19a04f2918ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 2 Mar 2023 20:51:14 +0100 Subject: [PATCH] new: Fetch the exiting collection names from the monitoring interface --- lookyloo/lookyloo.py | 2 ++ website/web/__init__.py | 8 ++++++++ website/web/templates/tree.html | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index a23e9eff..9cba90c3 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -120,6 +120,8 @@ class Lookyloo(): self.monitoring = PyLookylooMonitoring(monitoring_config['url'], get_useragent_for_requests()) if self.monitoring.is_up: self.monitoring_enabled = True + # NOTE: maybe move that somewhere else: we'll need to restart the webserver + # if we change the settings in the monitoring instance self.monitoring_settings = self.monitoring.instance_settings() self.logger.info('Initializing context...') diff --git a/website/web/__init__.py b/website/web/__init__.py index a27ed32e..92f4f275 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -709,6 +709,13 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None): if cache.error: flash(cache.error, 'warning') + if lookyloo.monitoring_enabled: + try: + monitoring_collections = lookyloo.monitoring.collections() + except Exception as e: + monitoring_collections = [] + flash(f'Unable to get existing connections from the monitoring : {e}', 'warning') + return render_template('tree.html', tree_json=ct.to_json(), info=cache, tree_uuid=tree_uuid, public_domain=lookyloo.public_domain, @@ -717,6 +724,7 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None): meta=meta, enable_mail_notification=enable_mail_notification, enable_monitoring=lookyloo.monitoring_enabled, monitoring_settings=lookyloo.monitoring_settings if lookyloo.monitoring_enabled else None, + monitoring_collections=monitoring_collections if lookyloo.monitoring_enabled else [], enable_context_by_users=enable_context_by_users, enable_categorization=enable_categorization, enable_bookmark=enable_bookmark, diff --git a/website/web/templates/tree.html b/website/web/templates/tree.html index 694260fa..032ce544 100644 --- a/website/web/templates/tree.html +++ b/website/web/templates/tree.html @@ -740,8 +740,18 @@ {% endif %}
- + {% if monitoring_collections %} + + + + {% for name in monitoring_collections %} + + {% endfor %} + + {%else%} + + {% endif %}