From d07c7719695125fb3f2322abff4d1fb0d539f33a Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 6 Apr 2024 19:01:16 +0200 Subject: Make ports plugin exportable --- glances/exports/export.py | 2 -- glances/plugins/ports/__init__.py | 14 ++++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/glances/exports/export.py b/glances/exports/export.py index cbe1eb84..aaa6e045 100644 --- a/glances/exports/export.py +++ b/glances/exports/export.py @@ -32,8 +32,6 @@ class GlancesExport(object): 'help', 'now', 'plugin', - 'ports', - # 'processlist', 'psutilversion', 'quicklook', 'version', diff --git a/glances/plugins/ports/__init__.py b/glances/plugins/ports/__init__.py index 3b771d9d..2032b5ed 100644 --- a/glances/plugins/ports/__init__.py +++ b/glances/plugins/ports/__init__.py @@ -98,6 +98,10 @@ class PluginModel(GlancesPluginModel): # Call the father class super(PluginModel, self).exit() + def get_key(self): + """Return the key of the list.""" + return 'indice' + @GlancesPluginModel._check_decorator @GlancesPluginModel._log_result_decorator def update(self): @@ -120,10 +124,6 @@ class PluginModel(GlancesPluginModel): return self.stats - def get_key(self): - """Return the key of the list.""" - return 'indice' - def get_ports_alert(self, port, header="", log=False): """Return the alert status relative to the port scan return value.""" ret = 'OK' @@ -247,6 +247,10 @@ class ThreadScanner(threading.Thread): # Is part of Ports plugin self.plugin_name = "ports" + def get_key(self): + """Return the key of the list.""" + return 'indice' + def run(self): """Grab the stats. @@ -265,6 +269,8 @@ class ThreadScanner(threading.Thread): # Scan an URL elif 'url' in p and requests_tag: self._web_scan(p) + # Add the key for every element + p['key'] = self.get_key() @property def stats(self): -- cgit v1.2.3