tools-ctdb: scriptstatus should not count disabled scripts
authorMartin Schwenke <martin@meltin.net>
Tue, 6 May 2014 01:08:57 +0000 (11:08 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Wed, 28 May 2014 02:44:14 +0000 (12:44 +1000)
script_status->num_scripts is used as the count in this message:

  "%d scripts were executed last %s cycle\n"

However, script_status->num_scripts includes disabled scripts, which
are never actually executed.

Instead, count the number of scripts that aren't disabled and make the
message print that.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed May 28 02:27:48 CEST 2014 on sn-devel-104

(Imported from commit c1deb87fb78b84a551ad8dc1004247d8a836f9bc)

tools/ctdb.c

index d8265d7e01b5e2b52fe1b610dc8ff93025f9ccf3..a8eac9ef3b6451bdc0f359bb15bab6be8e7c64be 100644 (file)
@@ -1377,8 +1377,14 @@ static int control_one_scriptstatus(struct ctdb_context *ctdb,
        }
 
        if (!options.machinereadable) {
+               int num_run = 0;
+               for (i=0; i<script_status->num_scripts; i++) {
+                       if (script_status->scripts[i].status != -ENOEXEC) {
+                               num_run++;
+                       }
+               }
                printf("%d scripts were executed last %s cycle\n",
-                      script_status->num_scripts,
+                      num_run,
                       ctdb_eventscript_call_names[type]);
        }
        for (i=0; i<script_status->num_scripts; i++) {