Thread (8 messages) 8 messages, 4 authors, 2017-03-10

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

flat view

From: Van Haaren, Harry <hidden>
Date: 2017-02-27 15:12:05

-----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 <redacted>
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 <redacted>
---
One comment on using hostname retrieval below, but with that fixed in a v2;

Reviewed-by: Harry van Haaren <redacted>

 app/proc_info/main.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 119 insertions(+), 5 deletions(-)
<snip>
quoted hunk ↗ jump to hunk
+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");

quoted hunk ↗ jump to hunk
+
+	return 0;
+}
+
<snip>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help