From 5299164022593ce7f8b3109d57b398e8687039ff Mon Sep 17 00:00:00 2001 From: Fahad Khan Date: Thu, 28 Sep 2023 06:09:16 +0000 Subject: stats: added optional CLI arg "port" to specify non-default port There are cases where default port for prometheus exporter is not available e.g. when multiple vpp are running on single node. Type: improvement Change-Id: I39701486f9dfaf4dc9f08aab56e88126687b507a Signed-off-by: Fahad Khan --- src/vpp/app/vpp_prometheus_export.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vpp/app/vpp_prometheus_export.c b/src/vpp/app/vpp_prometheus_export.c index 69baeb02fc7..35117c9f32f 100644 --- a/src/vpp/app/vpp_prometheus_export.c +++ b/src/vpp/app/vpp_prometheus_export.c @@ -242,6 +242,9 @@ main (int argc, char **argv) { unformat_input_t _argv, *a = &_argv; u8 *stat_segment_name, *pattern = 0, **patterns = 0; + u16 port = SERVER_PORT; + char *usage = + "%s: usage [socket-name ] [port <0 - 65535>] ...\n"; int rv; /* Allocating 256MB heap */ @@ -255,23 +258,22 @@ main (int argc, char **argv) { if (unformat (a, "socket-name %s", &stat_segment_name)) ; + else if (unformat (a, "port %d", &port)) + ; else if (unformat (a, "%s", &pattern)) { vec_add1 (patterns, pattern); } else { - fformat (stderr, - "%s: usage [socket-name ] ...\n", - argv[0]); + fformat (stderr, usage, argv[0]); exit (1); } } if (vec_len (patterns) == 0) { - fformat (stderr, - "%s: usage [socket-name ] ...\n", argv[0]); + fformat (stderr, usage, argv[0]); exit (1); } @@ -283,7 +285,7 @@ main (int argc, char **argv) exit (1); } - int fd = start_listen (SERVER_PORT); + int fd = start_listen (port); if (fd < 0) { exit (1); -- cgit 1.2.3-korg