[dpdk-dev] [PATCH v2] proc-info: added collectd-format and host-id options.

Van Haaren, Harry harry.van.haaren at intel.com
Mon Feb 27 16:18:08 CET 2017


Apologies, I reviewed patch v2, but replied to v1 on the mailing list.


For reference, the original reply on v1:
http://dpdk.org/ml/archives/dev/2017-February/058518.html


The same feedback provided here:


> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Roman Korynkevych
> Sent: Monday, February 27, 2017 2:16 PM
> To: dev at dpdk.org
> Cc: Korynkevych, RomanX <romanx.korynkevych at intel.com>
> Subject: [dpdk-dev] [PATCH v2] proc-info: added collectd-format and host-id options.
> 
> 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.
> 
> Signed-off-by: Roman Korynkevych <romanx.korynkevych at intel.com>


One comment on using hostname retrieval below, but with that fixed in a v3;

Reviewed-by: Harry van Haaren <harry.van.haaren at intel.com>


> ---
>  app/proc_info/main.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 121 insertions(+), 5 deletions(-)
> 
> diff --git a/app/proc_info/main.c b/app/proc_info/main.c

<snip>

> 
> +static int
> +proc_info_preparse_args(int argc, char **argv)
> +{
> +	char *prgname = argv[0];
> +	int i;
> +
> +	for (i = 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 = 1;
> +			stdout_fd = dup(STDOUT_FILENO);
> +			close(STDOUT_FILENO);
> +		}
> +		if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
> +			if ((i + 1) == 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");
> +
> +	return 0;
> +}
> +


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 = gethostname(host_id, MAX_LONG_OPT_SZ-1);
     if(err)
          strcpy(host_id, "unknown");



More information about the dev mailing list