From: Eric Bollengier Date: Mon, 20 Feb 2023 08:43:55 +0000 (+0100) Subject: Fix typo in MaximumConcurrentJobPerLevel script X-Git-Tag: Beta-15.0.0~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d65ed70f0534253136dcc9b8f55ff34239a7c9b;p=thirdparty%2Fbacula.git Fix typo in MaximumConcurrentJobPerLevel script --- diff --git a/bacula/scripts/MaximumConcurrentJobPerLevel b/bacula/scripts/MaximumConcurrentJobPerLevel index 22321588a..2049d7966 100755 --- a/bacula/scripts/MaximumConcurrentJobPerLevel +++ b/bacula/scripts/MaximumConcurrentJobPerLevel @@ -3,24 +3,29 @@ # License: BSD 2-Clause; see file LICENSE-FOSS use strict; +my $VERSION = 1; ################################################################ # Installation ################################################################ # -# Copy the script into /opt/bacula/scripts -# - Configure the variables at the top of the script (bconsole, limits) -# - Use the following runscript +# - Install the perl extension JSON (perl-JSON or libjson-perl) +# +# - Copy the script into /opt/bacula/scripts +# - Configure the variables at the top of the script (bconsole, limits) +# - Use the following runscript # Job { # RunScript { # RunsWhen = Queued # Command = "/opt/bacula/scripts/MaximumConcurrentJobPerLevel '%c' %l" -# Fail On Error = no +# Abort Job On Error = no # RunsOnClient = no # } # ... # } - +# +# Can be executed manually, and the VERBOSE=1 environnement variable +# might help to diagnose problems. ################################################################ # Custom @@ -98,17 +103,18 @@ if (!$running) { } my $json = JSON::decode_json($running); -if (!$json) { +if (!$json || !$json->{running}) { print "ERROR: Unable to decode JSON output from Director. Job control disabled.\n"; exit -1; } my @jobs = grep { - $_->{level} eq $l && $_->{jobstatus} eq 'R' + $_->{level} eq $l && $_->{status} eq 'R' } @{ $json->{running} }; my $nb = scalar(@jobs); print "Found $nb Job(s) running at level $level for $client\n"; + if ($nb <= $MaximumConcurrentJob{$level}) { exit 0; } else {