From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 38A3DBD28 for ; Mon, 27 Feb 2017 16:12:05 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2017 07:12:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,215,1484035200"; d="scan'208";a="828936936" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by FMSMGA003.fm.intel.com with ESMTP; 27 Feb 2017 07:12:04 -0800 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.230]) by IRSMSX103.ger.corp.intel.com ([163.33.3.157]) with mapi id 14.03.0248.002; Mon, 27 Feb 2017 15:12:03 +0000 From: "Van Haaren, Harry" To: "Korynkevych, RomanX" , "dev@dpdk.org" CC: "Korynkevych, RomanX" Thread-Topic: [dpdk-dev] [PATCH] proc-info: added collectd-format and host-id options. Thread-Index: AQHSjr5/fZY8wwTV/EStzQhyw494RqF89mRQ Date: Mon, 27 Feb 2017 15:12:03 +0000 Message-ID: References: <1487955140-32598-1-git-send-email-romanx.korynkevych@intel.com> In-Reply-To: <1487955140-32598-1-git-send-email-romanx.korynkevych@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWQzYTAyNjEtNDE3Ny00ZGJiLWJmNzAtOTliZGY1YTIxYjFiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InlOVEJITDlOaVdqZ3MrcDFYRklmZUVOTmFyY3hmVFo2NmFVeDA2b2tySVE9In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] proc-info: added collectd-format and host-id options. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 15:12:06 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Roman Korynkevych > Sent: Friday, February 24, 2017 4:52 PM > To: dev@dpdk.org > Cc: Korynkevych, RomanX > Subject: [dpdk-dev] [PATCH] proc-info: added collectd-format and host-id = options. >=20 > Extended proc-info application to send DPDK port statistics to > STDOUT in the format expected by collectd exec plugin. Added > HOST ID option to identify the host DPDK process is running on > when multiple instance of DPDK are running in parallel. This is > needed for the barometer project in OPNFV. >=20 > Signed-off-by: Roman Korynkevych > --- One comment on using hostname retrieval below, but with that fixed in a v2; Reviewed-by: Harry van Haaren > app/proc_info/main.c | 124 +++++++++++++++++++++++++++++++++++++++++++++= +++--- > 1 file changed, 119 insertions(+), 5 deletions(-) > +static int > +proc_info_preparse_args(int argc, char **argv) > +{ > + char *prgname =3D argv[0]; > + int i; > + > + for (i =3D 0; i < argc; i++) { > + /* Print stats or xstats to STDOUT in collectd format */ > + if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) { > + enable_collectd_format =3D 1; > + stdout_fd =3D dup(STDOUT_FILENO); > + close(STDOUT_FILENO); > + } > + if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) { > + if ((i + 1) =3D=3D argc) { > + printf("Invalid host id or not specified\n"); > + proc_info_usage(prgname); > + return -1; > + } > + strncpy(host_id, argv[i+1], sizeof(host_id)); > + } > + } > + > + if (!strlen(host_id)) > + strcpy(host_id, "unknown"); We should get the machine hostname as a default, IMO better than "unknown".= We can fallback to that if the hostname isn't set at all: if (!strlen(host_id)) int err =3D gethostname(host_id, MAX_LONG_OPT_SZ-1); if(err) strcpy(host_id, "unknown"); > + > + return 0; > +} > +