]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix typo in MaximumConcurrentJobPerLevel script
authorEric Bollengier <eric@baculasystems.com>
Mon, 20 Feb 2023 08:43:55 +0000 (09:43 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
bacula/scripts/MaximumConcurrentJobPerLevel

index 22321588aa4bdd5b5e68a2e437f84fe9b7a17b71..2049d796634f29fb14b47ac7e7abc4f6dea2b41f 100755 (executable)
@@ -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 {