From b076621121fb1cd41c4c8436f88e065ba366e771 Mon Sep 17 00:00:00 2001 From: Renat Kasimov Date: Wed, 14 Oct 2026 12:11:35 +0200 Subject: [PATCH 1/2] [CPCLOUD-1394] Fix for Cloudlinux dbgov plugin --- agent360/plugins/cloudlinux-dbgov.py | 84 ++++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/agent360/plugins/cloudlinux-dbgov.py b/agent360/plugins/cloudlinux-dbgov.py index a7957c8..4c21e83 100644 --- a/agent360/plugins/cloudlinux-dbgov.py +++ b/agent360/plugins/cloudlinux-dbgov.py @@ -1,42 +1,42 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -import plugins -import json - - -class Plugin(plugins.BasePlugin): - __name__ = 'cloudlinux-dbgov' - - def run(self, config): - ''' - Beta plugin to monitor cloudlinux db governor users - Requires sudo access to lveinfo (whereis lveinfo) add to /etc/sudoers: - agent360 ALL=(ALL) NOPASSWD: /REPLACE/PATH/TO/lveinfo - - To enable add to /etc/agent360.ini: - [cloudlinux-dbgov] - enabled = yes - ''' - data = os.popen('sudo lveinfo --dbgov --period 5m -o cpu --limit 20 --json').read() - results = {} - - try: - data = json.loads(data) - except Exception: - return "Could not load lveinfo dbgov data" - - if data['success'] is not 1: - return "Failed to load lveinfo dbgov" - - results = {} - - for line in data['data']: - username = line['USER'] - del line['USER'] - results[username] = line - - return results - -if __name__ == '__main__': - Plugin().execute() +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +import plugins +import json + + +class Plugin(plugins.BasePlugin): + __name__ = 'cloudlinux-dbgov' + + def run(self, config): + ''' + Beta plugin to monitor cloudlinux db governor users + Requires sudo access to lveinfo (whereis lveinfo) add to /etc/sudoers: + agent360 ALL=(ALL) NOPASSWD: /REPLACE/PATH/TO/lveinfo + + To enable add to /etc/agent360.ini: + [cloudlinux-dbgov] + enabled = yes + ''' + data = os.popen('sudo lveinfo --dbgov --period 5m -o cpu --limit 20 --json').read() + results = {} + + try: + data = json.loads(data) + except Exception: + return "Could not load lveinfo dbgov data" + + if data.get('success') != 1: + return "Failed to load lveinfo dbgov" + + results = {} + + for line in data['data']: + # USER may be an int (UID without a username), keys must be uniform + username = str(line.pop('USER')) + results[username] = line + + return results + +if __name__ == '__main__': + Plugin().execute() From c16a2c3799e1dc7a973d7b81e5fbd8e1e3de966f Mon Sep 17 00:00:00 2001 From: Renat Kasimov Date: Wed, 14 Oct 2026 12:13:09 +0200 Subject: [PATCH 2/2] Fix endings --- agent360/plugins/cloudlinux-dbgov.py | 84 ++++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/agent360/plugins/cloudlinux-dbgov.py b/agent360/plugins/cloudlinux-dbgov.py index 4c21e83..e20727d 100644 --- a/agent360/plugins/cloudlinux-dbgov.py +++ b/agent360/plugins/cloudlinux-dbgov.py @@ -1,42 +1,42 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -import plugins -import json - - -class Plugin(plugins.BasePlugin): - __name__ = 'cloudlinux-dbgov' - - def run(self, config): - ''' - Beta plugin to monitor cloudlinux db governor users - Requires sudo access to lveinfo (whereis lveinfo) add to /etc/sudoers: - agent360 ALL=(ALL) NOPASSWD: /REPLACE/PATH/TO/lveinfo - - To enable add to /etc/agent360.ini: - [cloudlinux-dbgov] - enabled = yes - ''' - data = os.popen('sudo lveinfo --dbgov --period 5m -o cpu --limit 20 --json').read() - results = {} - - try: - data = json.loads(data) - except Exception: - return "Could not load lveinfo dbgov data" - - if data.get('success') != 1: - return "Failed to load lveinfo dbgov" - - results = {} - - for line in data['data']: - # USER may be an int (UID without a username), keys must be uniform - username = str(line.pop('USER')) - results[username] = line - - return results - -if __name__ == '__main__': - Plugin().execute() +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +import plugins +import json + + +class Plugin(plugins.BasePlugin): + __name__ = 'cloudlinux-dbgov' + + def run(self, config): + ''' + Beta plugin to monitor cloudlinux db governor users + Requires sudo access to lveinfo (whereis lveinfo) add to /etc/sudoers: + agent360 ALL=(ALL) NOPASSWD: /REPLACE/PATH/TO/lveinfo + + To enable add to /etc/agent360.ini: + [cloudlinux-dbgov] + enabled = yes + ''' + data = os.popen('sudo lveinfo --dbgov --period 5m -o cpu --limit 20 --json').read() + results = {} + + try: + data = json.loads(data) + except Exception: + return "Could not load lveinfo dbgov data" + + if data.get('success') != 1: + return "Failed to load lveinfo dbgov" + + results = {} + + for line in data['data']: + # USER may be an int (UID without a username), keys must be uniform + username = str(line.pop('USER')) + results[username] = line + + return results + +if __name__ == '__main__': + Plugin().execute()