Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/46649/?format=api
http://patches.dpdk.org/api/patches/46649/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181011165837.81030-13-kevin.laatz@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20181011165837.81030-13-kevin.laatz@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20181011165837.81030-13-kevin.laatz@intel.com", "date": "2018-10-11T16:58:36", "name": "[v4,12/13] usertools: add client python script for telemetry", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "c5a57e2bd78a004cb76fe20022e640167740a6f7", "submitter": { "id": 921, "url": "http://patches.dpdk.org/api/people/921/?format=api", "name": "Kevin Laatz", "email": "kevin.laatz@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20181011165837.81030-13-kevin.laatz@intel.com/mbox/", "series": [ { "id": 1846, "url": "http://patches.dpdk.org/api/series/1846/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1846", "date": "2018-10-11T16:58:24", "name": "introduce telemetry library", "version": 4, "mbox": "http://patches.dpdk.org/series/1846/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/46649/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/46649/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 15C0D1B6FC;\n\tThu, 11 Oct 2018 18:59:24 +0200 (CEST)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id DD7EA1B5E6\n\tfor <dev@dpdk.org>; Thu, 11 Oct 2018 18:59:16 +0200 (CEST)", "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Oct 2018 09:59:15 -0700", "from silpixa00397517.ir.intel.com (HELO\n\tsilpixa00397517.ger.corp.intel.com) ([10.237.222.54])\n\tby orsmga001.jf.intel.com with ESMTP; 11 Oct 2018 09:59:05 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.54,369,1534834800\"; d=\"scan'208\";a=\"98571704\"", "From": "Kevin Laatz <kevin.laatz@intel.com>", "To": "dev@dpdk.org", "Cc": "harry.van.haaren@intel.com, stephen@networkplumber.org,\n\tgaetan.rivet@6wind.com, shreyansh.jain@nxp.com, thomas@monjalon.net, \n\tmattias.ronnblom@ericsson.com, bruce.richardson@intel.com,\n\tCiara Power <ciara.power@intel.com>,\n\tBrian Archbold <brian.archbold@intel.com>,\n\tKevin Laatz <kevin.laatz@intel.com>", "Date": "Thu, 11 Oct 2018 17:58:36 +0100", "Message-Id": "<20181011165837.81030-13-kevin.laatz@intel.com>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20181011165837.81030-1-kevin.laatz@intel.com>", "References": "<20181010105134.48079-1-kevin.laatz@intel.com>\n\t<20181011165837.81030-1-kevin.laatz@intel.com>", "Subject": "[dpdk-dev] [PATCH v4 12/13] usertools: add client python script for\n\ttelemetry", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Ciara Power <ciara.power@intel.com>\n\nThis patch adds a python script which can be used as a demo\nclient. The script is interactive and will allow the user to\nregister, request statistics, and unregister.\n\nTo run the script, an argument for the client file path must\nbe passed in: \"python telemetry_client.py <file_path>\".\n\nThis script is useful to see how the Telemetry API for DPDK\nis used, and how to make the initial connection.\n\nSigned-off-by: Ciara Power <ciara.power@intel.com>\nSigned-off-by: Brian Archbold <brian.archbold@intel.com>\nSigned-off-by: Kevin Laatz <kevin.laatz@intel.com>\n---\n usertools/dpdk-telemetry-client.py | 116 +++++++++++++++++++++++++++++++++++++\n 1 file changed, 116 insertions(+)\n create mode 100644 usertools/dpdk-telemetry-client.py", "diff": "diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py\nnew file mode 100644\nindex 0000000..71c6be7\n--- /dev/null\n+++ b/usertools/dpdk-telemetry-client.py\n@@ -0,0 +1,116 @@\n+# SPDK-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2018 Intel Corporation\n+\n+import socket\n+import os\n+import sys\n+import time\n+\n+BUFFER_SIZE = 200000\n+\n+METRICS_REQ = \"{\\\"action\\\":0,\\\"command\\\":\\\"ports_all_stat_values\\\",\\\"data\\\":null}\"\n+API_REG = \"{\\\"action\\\":1,\\\"command\\\":\\\"clients\\\",\\\"data\\\":{\\\"client_path\\\":\\\"\"\n+API_UNREG = \"{\\\"action\\\":2,\\\"command\\\":\\\"clients\\\",\\\"data\\\":{\\\"client_path\\\":\\\"\"\n+DEFAULT_FP = \"/var/run/dpdk/default_client\"\n+\n+class Socket:\n+\n+ def __init__(self):\n+ self.send_fd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n+ self.recv_fd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n+ self.client_fd = None\n+\n+ def __del__(self):\n+ try:\n+ self.send_fd.close()\n+ self.recv_fd.close()\n+ self.client_fd.close()\n+ except:\n+ print(\"Error - Sockets could not be closed\")\n+\n+class Client:\n+\n+ def __init__(self): # Creates a client instance\n+ self.socket = Socket()\n+ self.file_path = None\n+ self.choice = None\n+ self.unregistered = 0\n+\n+ def __del__(self):\n+ try:\n+ if self.unregistered == 0:\n+ self.unregister();\n+ except:\n+ print(\"Error - Client could not be destroyed\")\n+\n+ def getFilepath(self, file_path): # Gets arguments from Command-Line and assigns to instance of client\n+ self.file_path = file_path\n+\n+ def register(self): # Connects a client to DPDK-instance\n+ if os.path.exists(self.file_path):\n+ os.unlink(self.file_path)\n+ try:\n+ self.socket.recv_fd.bind(self.file_path)\n+ except socket.error as msg:\n+ print (\"Error - Socket binding error: \" + str(msg) + \"\\n\")\n+ self.socket.recv_fd.settimeout(2)\n+ self.socket.send_fd.connect(\"/var/run/dpdk/rte/telemetry\")\n+ JSON = (API_REG + self.file_path + \"\\\"}}\")\n+ self.socket.send_fd.sendall(JSON)\n+ self.socket.recv_fd.listen(1)\n+ self.socket.client_fd = self.socket.recv_fd.accept()[0]\n+\n+ def unregister(self): # Unregister a given client\n+ self.socket.client_fd.send(API_UNREG + self.file_path + \"\\\"}}\")\n+ self.socket.client_fd.close()\n+\n+ def requestMetrics(self): # Requests metrics for given client\n+ self.socket.client_fd.send(METRICS_REQ)\n+ data = self.socket.client_fd.recv(BUFFER_SIZE)\n+ print \"\\nResponse: \\n\", str(data)\n+\n+ def repeatedlyRequestMetrics(self, sleep_time): # Recursively requests metrics for given client\n+ print(\"\\nPlease enter the number of times you'd like to continuously request Metrics:\")\n+ n_requests = int(input(\"\\n:\"))\n+ print(\"\\033[F\") #Removes the user input from screen, cleans it up\n+ print(\"\\033[K\")\n+ for i in range(n_requests):\n+ self.requestMetrics()\n+ time.sleep(sleep_time)\n+\n+ def interactiveMenu(self, sleep_time): # Creates Interactive menu within the script\n+ while self.choice != 3:\n+ print(\"\\nOptions Menu\")\n+ print(\"[1] Send for Metrics for all ports\")\n+ print(\"[2] Send for Metrics for all ports recursively\")\n+ print(\"[3] Unregister client\")\n+\n+ try:\n+ self.choice = int(input(\"\\n:\"))\n+ print(\"\\033[F\") #Removes the user input for screen, cleans it up\n+ print(\"\\033[K\")\n+ if self.choice == 1:\n+ self.requestMetrics()\n+ elif self.choice == 2:\n+ self.repeatedlyRequestMetrics(sleep_time)\n+ elif self.choice == 3:\n+ self.unregister()\n+ self.unregistered = 1\n+ else:\n+ print(\"Error - Invalid request choice\")\n+ except:\n+ pass\n+\n+if __name__ == \"__main__\":\n+\n+ sleep_time = 1\n+ file_path = \"\"\n+ if (len(sys.argv) == 2):\n+\tfile_path = sys.argv[1]\n+ else:\n+ print(\"Warning - No filepath passed, using default (\" + DEFAULT_FP + \").\")\n+\tfile_path = DEFAULT_FP\n+ client = Client()\n+ client.getFilepath(file_path)\n+ client.register()\n+ client.interactiveMenu(sleep_time)\n", "prefixes": [ "v4", "12/13" ] }{ "id": 46649, "url": "