From 19ff38b1a5255b4992139c3c7fd5c3e7a639e034 Mon Sep 17 00:00:00 2001 From: Christophe Varoqui Date: Wed, 20 Sep 2023 17:53:19 +0200 Subject: [PATCH] Add a dblogcron kw This keyword disables the log sending to the collector for actions running with --cron. These actions can run at high frequency and make the collector log table bloated and useless. --- opensvc/core/node/nodedict.py | 9 ++++++++- opensvc/core/objects/svc.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/opensvc/core/node/nodedict.py b/opensvc/core/node/nodedict.py index 6e78ebf4f..0e3039162 100644 --- a/opensvc/core/node/nodedict.py +++ b/opensvc/core/node/nodedict.py @@ -420,7 +420,14 @@ "keyword": "dblog", "convert": "boolean", "default": True, - "text": "If true and dbopensvc is set, the objects action logs are reported to the collector. Set to false to disable log reporting to the collector, event if dbopensvc is set." + "text": "If true and dbopensvc is set, the objects action logs are reported to the collector. Set to false to disable log reporting to the collector, even if dbopensvc is set." + }, + { + "section": "node", + "keyword": "dblogcron", + "convert": "boolean", + "default": True, + "text": "If true and dbopensvc is set, the objects croned action logs are reported to the collector. Set to false to disable croned actions log reporting to the collector." }, { "section": "node", diff --git a/opensvc/core/objects/svc.py b/opensvc/core/objects/svc.py index b521558aa..c8843088a 100644 --- a/opensvc/core/objects/svc.py +++ b/opensvc/core/objects/svc.py @@ -1010,8 +1010,15 @@ def _action(self, action, options=None): action.startswith("json_"): return self.do_print_action(action, options) - if self.published_action(action, options): + def is_logged_action(): + if self.options.cron and not self.node.oget("node", "dblogcron"): + return False if self.node.oget("node", "dblog") and self.node.collector_env.dbopensvc and self.node.collector_env.uuid: + return True + return False + + if self.published_action(action, options): + if is_logged_action(): err = self.do_logged_action(action, options) else: self.log_action_header(action, options)