Commit Graph

14 Commits

Author SHA1 Message Date
Chengwen Feng
66542840df usertools/telemetry: add JSON pretty print
Currently, the dpdk-telemetry.py show JSON in raw format under
interactive mode, which is not good for human reading.

E.g. The command '/ethdev/xstats,0' will output:
{"/ethdev/xstats": {"rx_good_packets": 0, "tx_good_packets": 0,
"rx_good_bytes": 0, "tx_good_bytes": 0, "rx_missed_errors": 0,
"rx_errors": 0, "tx_errors": 0, "rx_mbuf_allocation_errors": 0,
"rx_q0_packets": 0,...}}

This patch supports JSON pretty print by adding extra indent=2
parameter under interactive mode, so the same command will output:
{
  "/ethdev/xstats": {
    "rx_good_packets": 0,
    "tx_good_packets": 0,
    "rx_good_bytes": 0,
    "tx_good_bytes": 0,
    "rx_missed_errors": 0,
    "rx_errors": 0,
    "rx_mbuf_allocation_errors": 0,
    "rx_q0_packets": 0,
    ...
  }
}

Note: the non-interactive mode is made machine-readable and remains the
original way (it means don't use indent to pretty print).

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
2022-10-31 16:13:55 +01:00
Stephen Hemminger
1835a22f34 support systemd service convention for runtime directory
Systemd.exec supports configuring the runtime directory of a service
via RuntimeDirectory=. This creates the directory with the necessary
permissions which actual service may not have if running in container.

The change to DPDK is to look for the environment RUNTIME_DIRECTORY
first and use that in preference to the fallback alternatives.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
2022-02-09 19:12:40 +01:00
Conor Walsh
9055bcde19 usertools/telemetry: list file-prefixes
This patch adds the option --list (-l) to dpdk-telemetry.py which will
print all of the available file-prefixes for DPDK processes that have
telemetry enabled.
The prefixes will also be printed if the user passes an incorrect prefix
in the --file-prefix (-f) option.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-19 17:15:10 +02:00
Conor Walsh
6839b8ade4 usertools/telemetry: fix instance option help
The instance option help text was incorrect, this patch corrects it.

Fixes: 11435aae20 ("usertools/telemetry: connect to separate instances")

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2021-10-19 17:15:10 +02:00
Bruce Richardson
b95af1946a usertools/telemetry: provide info on available sockets
When a user runs the dpdk-telemetry script and fails to connect because
the socket path does not exist, run a scan for possible sockets that
could be connected to and inform the user of the command needed to
connect to those.

For example:

  $ ./dpdk-telemetry.py -i4
  Connecting to /run/user/1000/dpdk/rte/dpdk_telemetry.v2:4
  Error connecting to /run/user/1000/dpdk/rte/dpdk_telemetry.v2:4

  Other DPDK telemetry sockets found:
  - dpdk_telemetry.v2  # Connect with './dpdk-telemetry.py'
  - dpdk_telemetry.v2:2  # Connect with './dpdk-telemetry.py -i 2'
  - dpdk_telemetry.v2:1  # Connect with './dpdk-telemetry.py -i 1'

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
2021-10-14 20:57:07 +02:00
Bruce Richardson
11435aae20 usertools/telemetry: connect to separate instances
For processes run using "in-memory" mode sharing the same runtime dir,
we add support for connecting to the separate instance sockets created
using ":1", ":2" etc. via new "-i" or "--instance" argument. Add details
on connecting to separate instances to the telemetry howto document.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Tested-by: Conor Walsh <conor.walsh@intel.com>
2021-10-14 20:57:06 +02:00
Bruce Richardson
72727e0d56 usertools: silence prompts for telemetry input pipe
When the input to the script is coming from a device which is not a TTY
then we become less verbose and skip the prompts and helpful messages
about what is happening.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-01 17:30:27 +02:00
Bruce Richardson
744e9a87c5 usertools: fix handling EOF for telemetry input pipe
To allow the script to take queries from input pipes e.g. "echo
/ethdev/stats,0 | dpdk-telemetry.py", we need to handle the case of EOF
correctly without crashing with an exception. Do this by using a
try-except block around the input handling.

Fixes: 6a2967c112 ("usertools: add new telemetry script")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-01 17:30:26 +02:00
Bruce Richardson
ea3ef0b85f usertools: fix flake8 compliance of telemetry script
Fix style errors reported by flake8.

Fixes: 6a2967c112 ("usertools: add new telemetry script")
Fixes: 2d9a697e41 ("usertools: add file-prefix option for telemetry")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-01 17:30:01 +02:00
Bruce Richardson
d786e30e80 usertools: print process name when telemetry connects
When the dpdk-telemetry client connects to a DPDK instance, we can use the
PID provided in the initial connection message to query from /proc the name
of the process we are connected to, and display that to the user. We use
the "cmdline" procfs entry for the query since that is available on both
Linux and FreeBSD (assuming procfs is mounted on the BSD instance).

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
2021-03-25 18:00:46 +01:00
Kevin Laatz
2d9a697e41 usertools: add file-prefix option for telemetry
Currently the dpdk-telemetry.py script connects to all running DPDK apps
consecutively. With the addition of this file-prefix argument, we can limit
the amount of information returned providing improved consumability and
precision to the user.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2021-03-25 17:53:10 +01:00
Louise Kilheeney
3f6f83626c support python 3 only
Changed scripts to explicitly use Python 3 only, to avoid
maintaining Python 2.
Removed deprecation notices.

Signed-off-by: Louise Kilheeney <louise.kilheeney@intel.com>
Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Robin Jarry <robin.jarry@6wind.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
2020-10-02 13:51:00 +02:00
Ciara Power
3b4c9d7bd6 usertools: fix telemetry user socket path
The path to the socket when running the script as a regular user needed
to be updated to match the logic in EAL.

Fixes: 6a2967c112 ("usertools: add new telemetry script")
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
2020-06-25 01:10:12 +02:00
Bruce Richardson
6a2967c112 usertools: add new telemetry script
This patch adds a python script that can be used with the new telemetry
socket. It connects as a client to the socket, and allows the user send
a command and see the JSON response.

The example usage below shows the script connecting to the new telemetry
socket, and sending three default telemetry commands entered by the user.
The response for each command is shown below the user input.

Connecting to /var/run/dpdk/rte/dpdk_telemetry.v2
{"version": "DPDK 20.05.0-rc0", "pid": 32794, "max_output_len": 16384}
--> /
{"/": ["/", "/help", "/info"]}
--> /info
{"/info": {"version": "DPDK 20.05.0-rc0", "pid": 32794, \
    "max_output_len": 16384}}
--> /help,/info
{"/help": {"/info": "Returns DPDK Telemetry information. \
    Takes no parameters"}}

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
Reviewed-by: Keith Wiles <keith.wiles@intel.com>
2020-05-10 23:56:47 +02:00