This provides a way to get a list of all stopwatches associated with a
particular engine node. This list can be used as part of scripts, like:

    for i in $(ovn-appctl inc-engine/list-stopwatches <node_name>); do
        ovn-appctl stopwatch/show $i
        ovn-appctl stopwatch/reset $i
    done

Signed-off-by: Mark Michelson <[email protected]>
---
 lib/inc-proc-eng.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c
index 98eec6297..74079526e 100644
--- a/lib/inc-proc-eng.c
+++ b/lib/inc-proc-eng.c
@@ -195,6 +195,31 @@ engine_set_log_timeout_cmd(struct unixctl_conn *conn, int 
argc OVS_UNUSED,
     unixctl_command_reply(conn, NULL);
 }
 
+static void
+engine_list_stopwatch_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                          const char *argv[], void *arg OVS_UNUSED)
+{
+    const char *node_name = argv[1];
+    struct engine_node *node;
+    struct ds output_str = DS_EMPTY_INITIALIZER;
+    VECTOR_FOR_EACH (&engine_nodes, node) {
+        if (strcmp(node->name, node_name)) {
+            continue;
+        }
+        ds_put_format(&output_str, "%s\n", node->recompute_stopwatch);
+        for (size_t i = 0; i < node->n_inputs; i++) {
+            struct engine_node_input *input = &node->inputs[i];
+            if (!input->change_handler) {
+                continue;
+            }
+            ds_put_format(&output_str, "%s\n", input->change_handler_name);
+        }
+    }
+
+    unixctl_command_reply(conn, ds_cstr(&output_str));
+    ds_destroy(&output_str);
+}
+
 static void
 engine_get_compute_failure_info(struct engine_node *node)
 {
@@ -229,6 +254,8 @@ engine_init(struct engine_node *node, struct engine_arg 
*arg)
                              engine_trigger_recompute_cmd, NULL);
     unixctl_command_register("inc-engine/compute-log-timeout", "", 1, 1,
                              engine_set_log_timeout_cmd, NULL);
+    unixctl_command_register("inc-engine/list-stopwatches", "", 1, 1,
+                             engine_list_stopwatch_cmd, NULL);
 }
 
 void
-- 
2.51.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to