ctdb-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@samba.org>
Wed, 28 May 2014 00:27:48 +0000 (02:27 +0200)
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

ctdb/tools/ctdb.c

index 624c61c2f80e1fca0dc0a86d70bacd832379d70d..8033fcb7ae21773b9b86f2c88493efb76b69f83b 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++) {