DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode
@ 2021-09-09 15:56 David Hunt
  2021-09-13 10:43 ` Bruce Richardson
  0 siblings, 1 reply; 5+ messages in thread
From: David Hunt @ 2021-09-09 15:56 UTC (permalink / raw)
  To: dev; +Cc: ciara.power, David Hunt

Add non-interactive mode to dpdk-telemetry.py so that a query string
can be supplied on the command line, and script dumps out data and
exits. Handing for calling from scripts.

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 usertools/dpdk-telemetry.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py
index e04aa04702..5ce772d49d 100755
--- a/usertools/dpdk-telemetry.py
+++ b/usertools/dpdk-telemetry.py
@@ -48,7 +48,7 @@ def get_app_name(pid):
     return None
 
 
-def handle_socket(path):
+def handle_socket(path, query):
     """ Connect to socket and handle user input """
     sock = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
     global CMDS
@@ -69,13 +69,17 @@ def handle_socket(path):
     sock.send("/".encode())
     CMDS = read_socket(sock, output_buf_len, False)["/"]
 
-    # interactive prompt
-    text = input('--> ').strip()
-    while text != "quit":
-        if text.startswith('/'):
-            sock.send(text.encode())
-            read_socket(sock, output_buf_len)
+    if (query != ""):
+        sock.send(query.encode())
+        read_socket(sock, output_buf_len)
+    else:
+        # interactive prompt
         text = input('--> ').strip()
+        while text != "quit":
+            if text.startswith('/'):
+                sock.send(text.encode())
+                read_socket(sock, output_buf_len)
+            text = input('--> ').strip()
     sock.close()
 
 
@@ -104,6 +108,8 @@ def get_dpdk_runtime_dir(fp):
 parser = argparse.ArgumentParser()
 parser.add_argument('-f', '--file-prefix', \
         help='Provide file-prefix for DPDK runtime directory', default='rte')
+parser.add_argument('-q', '--query', \
+        help='run this query and exit', default='')
 args = parser.parse_args()
 rdir = get_dpdk_runtime_dir(args.file_prefix)
-handle_socket(os.path.join(rdir, 'dpdk_telemetry.{}'.format(TELEMETRY_VERSION)))
+handle_socket(os.path.join(rdir, 'dpdk_telemetry.{}'.format(TELEMETRY_VERSION)), args.query)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode
  2021-09-09 15:56 [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode David Hunt
@ 2021-09-13 10:43 ` Bruce Richardson
  2021-09-13 10:53   ` Bruce Richardson
  0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2021-09-13 10:43 UTC (permalink / raw)
  To: David Hunt; +Cc: dev, ciara.power

On Thu, Sep 09, 2021 at 04:56:25PM +0100, David Hunt wrote:
> Add non-interactive mode to dpdk-telemetry.py so that a query string
> can be supplied on the command line, and script dumps out data and
> exits. Handing for calling from scripts.
> 
> Signed-off-by: David Hunt <david.hunt@intel.com>
> ---
Hi Dave,

I'm not sure I like the use of "-q" for adding a query mode - it's more a
shortcut parameter for a "quiet" mode. If I may, I'd suggest an alternative
approach here might be to improve support for piping the input commands to
the script instead so that you can do e.g. 

"echo /ethdev/stats,0 | dpdk-telemetry.py"

and have that work well in a script.

I'll do up a patchset for improving that and upstream it for feedback.

/Bruce

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode
  2021-09-13 10:43 ` Bruce Richardson
@ 2021-09-13 10:53   ` Bruce Richardson
  2021-09-15 10:49     ` Power, Ciara
  0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2021-09-13 10:53 UTC (permalink / raw)
  To: David Hunt; +Cc: dev, ciara.power

On Mon, Sep 13, 2021 at 11:43:25AM +0100, Bruce Richardson wrote:
> On Thu, Sep 09, 2021 at 04:56:25PM +0100, David Hunt wrote:
> > Add non-interactive mode to dpdk-telemetry.py so that a query string
> > can be supplied on the command line, and script dumps out data and
> > exits. Handing for calling from scripts.
> > 
> > Signed-off-by: David Hunt <david.hunt@intel.com>
> > ---
> Hi Dave,
> 
> I'm not sure I like the use of "-q" for adding a query mode - it's more a
> shortcut parameter for a "quiet" mode. If I may, I'd suggest an alternative
> approach here might be to improve support for piping the input commands to
> the script instead so that you can do e.g. 
> 
> "echo /ethdev/stats,0 | dpdk-telemetry.py"
> 
> and have that work well in a script.
> 
> I'll do up a patchset for improving that and upstream it for feedback.
> 

Now at: http://patches.dpdk.org/project/dpdk/list/?series=18867

/Bruce

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode
  2021-09-13 10:53   ` Bruce Richardson
@ 2021-09-15 10:49     ` Power, Ciara
  2021-09-15 10:58       ` David Hunt
  0 siblings, 1 reply; 5+ messages in thread
From: Power, Ciara @ 2021-09-15 10:49 UTC (permalink / raw)
  To: Richardson, Bruce, Hunt, David; +Cc: dev

Hi Dave,

>-----Original Message-----
>From: Richardson, Bruce <bruce.richardson@intel.com>
>Sent: Monday 13 September 2021 11:54
>To: Hunt, David <david.hunt@intel.com>
>Cc: dev@dpdk.org; Power, Ciara <ciara.power@intel.com>
>Subject: Re: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive
>mode
>
>On Mon, Sep 13, 2021 at 11:43:25AM +0100, Bruce Richardson wrote:
>> On Thu, Sep 09, 2021 at 04:56:25PM +0100, David Hunt wrote:
>> > Add non-interactive mode to dpdk-telemetry.py so that a query string
>> > can be supplied on the command line, and script dumps out data and
>> > exits. Handing for calling from scripts.
>> >
>> > Signed-off-by: David Hunt <david.hunt@intel.com>
>> > ---
>> Hi Dave,
>>
>> I'm not sure I like the use of "-q" for adding a query mode - it's
>> more a shortcut parameter for a "quiet" mode. If I may, I'd suggest an
>> alternative approach here might be to improve support for piping the
>> input commands to the script instead so that you can do e.g.
>>
>> "echo /ethdev/stats,0 | dpdk-telemetry.py"
>>
>> and have that work well in a script.
>>
>> I'll do up a patchset for improving that and upstream it for feedback.
>>
>
>Now at: http://patches.dpdk.org/project/dpdk/list/?series=18867
>
>/Bruce

Thanks for this, although I do think the improvement to allow for piping is a better solution.
I have acked Bruce's patchset, hopefully that will be suitable for your use case.

Thanks,
Ciara

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode
  2021-09-15 10:49     ` Power, Ciara
@ 2021-09-15 10:58       ` David Hunt
  0 siblings, 0 replies; 5+ messages in thread
From: David Hunt @ 2021-09-15 10:58 UTC (permalink / raw)
  To: Power, Ciara, Richardson, Bruce; +Cc: dev


On 15/9/2021 11:49 AM, Power, Ciara wrote:
> Hi Dave,
>
>> -----Original Message-----
>> From: Richardson, Bruce <bruce.richardson@intel.com>
>> Sent: Monday 13 September 2021 11:54
>> To: Hunt, David <david.hunt@intel.com>
>> Cc: dev@dpdk.org; Power, Ciara <ciara.power@intel.com>
>> Subject: Re: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive
>> mode
>>
>> On Mon, Sep 13, 2021 at 11:43:25AM +0100, Bruce Richardson wrote:
>>> On Thu, Sep 09, 2021 at 04:56:25PM +0100, David Hunt wrote:
>>>> Add non-interactive mode to dpdk-telemetry.py so that a query string
>>>> can be supplied on the command line, and script dumps out data and
>>>> exits. Handing for calling from scripts.
>>>>
>>>> Signed-off-by: David Hunt <david.hunt@intel.com>
>>>> ---
>>> Hi Dave,
>>>
>>> I'm not sure I like the use of "-q" for adding a query mode - it's
>>> more a shortcut parameter for a "quiet" mode. If I may, I'd suggest an
>>> alternative approach here might be to improve support for piping the
>>> input commands to the script instead so that you can do e.g.
>>>
>>> "echo /ethdev/stats,0 | dpdk-telemetry.py"
>>>
>>> and have that work well in a script.
>>>
>>> I'll do up a patchset for improving that and upstream it for feedback.
>>>
>> Now at: http://patches.dpdk.org/project/dpdk/list/?series=18867
>>
>> /Bruce
> Thanks for this, although I do think the improvement to allow for piping is a better solution.
> I have acked Bruce's patchset, hopefully that will be suitable for your use case.
>
> Thanks,
> Ciara


+1

I'll mark my patchset as superceeded.

Rgds,
Dave.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-15 10:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09 15:56 [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode David Hunt
2021-09-13 10:43 ` Bruce Richardson
2021-09-13 10:53   ` Bruce Richardson
2021-09-15 10:49     ` Power, Ciara
2021-09-15 10:58       ` David Hunt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).