summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2024-04-06 19:01:16 +0200
committernicolargo <nicolas@nicolargo.com>2024-04-06 19:01:16 +0200
commitd07c7719695125fb3f2322abff4d1fb0d539f33a (patch)
tree9aa7d6ea516facffdc011ba24f6f01123eb13b8d
parent39c51f8af8463407c22e9ba854ec606e5194b657 (diff)
Make ports plugin exportable
-rw-r--r--glances/exports/export.py2
-rw-r--r--glances/plugins/ports/__init__.py14
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):