From 6ad5c290351800cfa1c5fd31b334afe51d799fb5 Mon Sep 17 00:00:00 2001 From: jorgepastorr Date: Fri, 9 Feb 2024 07:13:51 +0100 Subject: [PATCH] aumentar proces on resources --- orchestra/contrib/mailboxes/backends.py | 20 ++++++++++++++++++- orchestra/contrib/systemusers/backends.py | 24 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/orchestra/contrib/mailboxes/backends.py b/orchestra/contrib/mailboxes/backends.py index 8de35114..cd329dde 100644 --- a/orchestra/contrib/mailboxes/backends.py +++ b/orchestra/contrib/mailboxes/backends.py @@ -452,12 +452,30 @@ class DovecotMaildirDisk(ServiceMonitor): self.append(textwrap.dedent("""\ function monitor () { SIZE=$(du -sb $1/Maildir/ 2> /dev/null || echo 0) && echo $SIZE | awk '{print $1}' + list=() }""")) def monitor(self, mailbox): context = self.get_context(mailbox) # self.append("echo %(object_id)s $(monitor %(maildir_path)s)" % context) - self.append("echo %(object_id)s $(monitor %(home)s)" % context) + # self.append("echo %(object_id)s $(monitor %(home)s)" % context) + self.append("list[${#list[@]}]=\'echo %(object_id)s $(monitor %(home)s)\'" % context) + + def commit(self): + self.append(textwrap.dedent("""\ + proces=0 + for cmd in "${list[@]}" + do + eval $cmd & + proces=$((proces+1)) + if [ $proces -ge 10 ];then + wait + proces=0 + fi + done + wait + exit $exit_code + """)) def get_context(self, mailbox): context = { diff --git a/orchestra/contrib/systemusers/backends.py b/orchestra/contrib/systemusers/backends.py index 70b439c0..6f0b80ea 100644 --- a/orchestra/contrib/systemusers/backends.py +++ b/orchestra/contrib/systemusers/backends.py @@ -287,13 +287,31 @@ class UNIXUserDisk(ServiceMonitor): self.append(textwrap.dedent("""\ function monitor () { { SIZE=$(du -bs "$1") && echo $SIZE || echo 0; } | awk {'print $1'} - }""" - )) + } + list=() + """)) def monitor(self, user): context = self.get_context(user) - self.append("echo %(object_id)s $(monitor %(base_home)s)" % context) + # self.append("echo %(object_id)s $(monitor %(base_home)s)" % context) + self.append("list[${#list[@]}]=\'echo %(object_id)s $(monitor %(base_home)s)\'" % context) + def commit(self): + self.append(textwrap.dedent("""\ + proces=0 + for cmd in "${list[@]}" + do + eval $cmd & + proces=$((proces+1)) + if [ $proces -ge 5 ];then + wait + proces=0 + fi + done + wait + exit $exit_code + """)) + def get_context(self, user): context = { 'object_id': user.pk,