Skip to content

Commit

Permalink
Add a dblogcron kw
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cvaroqui committed Sep 20, 2023
1 parent 20866ec commit 19ff38b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion opensvc/core/node/nodedict.py
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion opensvc/core/objects/svc.py
Expand Up @@ -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)
Expand Down

0 comments on commit 19ff38b

Please sign in to comment.