summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2023-12-16 14:33:44 +0100
committernicolargo <nicolas@nicolargo.com>2023-12-16 14:33:44 +0100
commit013bc99c78ab51fe006c9ac5350df23c33849798 (patch)
tree99cc5bd62332a5bfde069114ad1766e5ae6b44a2
parentae07ee1437b5f6f93eddedde9deda8449f9c4697 (diff)
Add Glances version plugin
-rw-r--r--glances/plugins/version/__init__.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/glances/plugins/version/__init__.py b/glances/plugins/version/__init__.py
new file mode 100644
index 00000000..7e7fe717
--- /dev/null
+++ b/glances/plugins/version/__init__.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Glances.
+#
+# SPDX-FileCopyrightText: 2023 Nicolas Hennion <nicolas@nicolargo.com>
+#
+# SPDX-License-Identifier: LGPL-3.0-only
+#
+
+"""version plugin.
+Just a simple plugin to get the Glances version.
+"""
+
+from glances import __version__ as glances_version
+from glances.plugins.plugin.model import GlancesPluginModel
+
+
+class PluginModel(GlancesPluginModel):
+ """Get the Glances versions.
+
+ stats is a string
+ """
+
+ def __init__(self, args=None, config=None):
+ """Init the plugin."""
+ super(PluginModel, self).__init__(args=args, config=config)
+
+ self.reset()
+
+ def reset(self):
+ """Reset/init the stats."""
+ self.stats = None
+
+ @GlancesPluginModel._check_decorator
+ @GlancesPluginModel._log_result_decorator
+ def update(self):
+ """Update the stats."""
+ # Reset stats
+ self.reset()
+
+ # Return psutil version as a tuple
+ if self.input_method == 'local':
+ # psutil version only available in local
+ try:
+ self.stats = glances_version
+ except NameError:
+ pass
+ else:
+ pass
+
+ return self.stats