From a2df72bdcc9a9e71b285a45fa8dec7285e113b2f Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 6 Oct 2017 15:30:48 -0700 Subject: [PATCH] Support using GUI cli command to refresh GUI's counters. This makes JSON output more precise, but only works with 5.3.7 LANforge GUIs and higher. --- lf_wifi_rest_example.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lf_wifi_rest_example.pl b/lf_wifi_rest_example.pl index 1e502eb8..641c97c2 100755 --- a/lf_wifi_rest_example.pl +++ b/lf_wifi_rest_example.pl @@ -336,6 +336,16 @@ for ($i = 0; $i<@cxs; $i++) { $utils->doAsyncCmd($cmd); } +# LANforge 5.3.7 GUI has 'cli' cmd to run arbitrary commands. So, ask it +# to refresh the endpoints and cx now that they are running. This will only +# work on a unix-like system, but one could use a real tcp connection with a bit +# more work. Assumes GUI is running with option: -cli-socket 3990 on the local machine. +$cmd = "echo -e cli show_endp\\\\ncli show_port\\\\ncli show_cx\\\\nexit | nc localhost 3990"; +#print("Running cmd: $cmd\n"); +$rslt = `$cmd`; +#print $rslt; + + print("Sleeping 5 seconds to let connections initialize...\n"); sleep(5); @@ -475,6 +485,14 @@ for ($i = 0; $i<@cxs; $i++) { $utils->doCmd($cmd); } +# Refresh GUI stats before we query JSON. +$cmd = "echo -e cli show_port\\\\ncli show_cx\\\\nexit | nc localhost 3990"; +#print("Running cmd: $cmd\n"); +$rslt = `$cmd`; + +# Wait 2 seconds for reports to come back to the GUI. +sleep(2); + # Gather some stats using JSON. This assumes the GUI is running on the local machine on port 8080 # [lanforge@lf0313-6477 LANforgeGUI_5.3.7]$ pwd # /home/lanforge/LANforgeGUI_5.3.7