Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/43820/?format=api
http://patches.dpdk.org/api/patches/43820/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1535026093-101872-11-git-send-email-ciara.power@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": "<1535026093-101872-11-git-send-email-ciara.power@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1535026093-101872-11-git-send-email-ciara.power@intel.com", "date": "2018-08-23T12:08:12", "name": "[10/11] usertools: add client python script for telemetry", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "d437acea288aa17c09d36cb90b48ca02f10c5f00", "submitter": { "id": 978, "url": "http://patches.dpdk.org/api/people/978/?format=api", "name": "Power, Ciara", "email": "ciara.power@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/1535026093-101872-11-git-send-email-ciara.power@intel.com/mbox/", "series": [ { "id": 1038, "url": "http://patches.dpdk.org/api/series/1038/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1038", "date": "2018-08-23T12:08:02", "name": "introduce telemetry library", "version": 1, "mbox": "http://patches.dpdk.org/series/1038/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/43820/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/43820/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 AC9E05B1E;\n\tThu, 23 Aug 2018 14:08:46 +0200 (CEST)", "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 397E14C96\n\tfor <dev@dpdk.org>; Thu, 23 Aug 2018 14:08:39 +0200 (CEST)", "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t23 Aug 2018 05:08:38 -0700", "from silpixa00399503.ir.intel.com ([10.237.222.102])\n\tby fmsmga005.fm.intel.com with ESMTP; 23 Aug 2018 05:08:37 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.53,278,1531810800\"; d=\"scan'208\";a=\"256613890\"", "From": "Ciara Power <ciara.power@intel.com>", "To": "harry.van.haaren@intel.com, brian.archbold@intel.com,\n\temma.kenny@intel.com, ciara.power@intel.com", "Cc": "dev@dpdk.org", "Date": "Thu, 23 Aug 2018 13:08:12 +0100", "Message-Id": "<1535026093-101872-11-git-send-email-ciara.power@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1535026093-101872-1-git-send-email-ciara.power@intel.com>", "References": "<1535026093-101872-1-git-send-email-ciara.power@intel.com>", "Subject": "[dpdk-dev] [PATCH 10/11] 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": "This 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>\n---\n usertools/telemetry_client.py | 116 ++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 116 insertions(+)\n create mode 100644 usertools/telemetry_client.py", "diff": "diff --git a/usertools/telemetry_client.py b/usertools/telemetry_client.py\nnew file mode 100644\nindex 0000000..ede778c\n--- /dev/null\n+++ b/usertools/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/.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/.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": [ "10/11" ] }{ "id": 43820, "url": "