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

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


> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Roman Korynkevych
> Sent: Friday, February 24, 2017 4:52 PM
> To: dev at dpdk.org
> Cc: Korynkevych, RomanX <romanx.korynkevych at intel.com>
> Subject: [dpdk-dev] [PATCH] 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 v2;

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


>  app/proc_info/main.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 119 insertions(+), 5 deletions(-)

<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");



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");


> +
> +	return 0;
> +}
> +

<snip>


More information about the dev mailing list