summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-10-02 22:00:29 +0200
committerDamjan Marion <dmarion@me.com>2018-10-02 21:26:28 +0000
commitbf49590c07162be44b21d0e0440e7fb96b2746d5 (patch)
tree06ba921f8f1540adc096459f30772770811c6a0c
parent94495f2a6a68ac2202b7715ce09620f1ba6fe673 (diff)
Stats: vpp_prometheus_export fixes.
- Crash on /sys/nodes if per-node-counters off - Require patterns parameters. Change-Id: If4fddefb17504a92ba462c7af91e373601b66a5c Signed-off-by: Ole Troan <ot@cisco.com>
-rw-r--r--src/vpp-api/client/stat_client.c4
-rw-r--r--src/vpp/app/vpp_get_stats.c4
-rw-r--r--src/vpp/app/vpp_prometheus_export.c9
3 files changed, 16 insertions, 1 deletions
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index b5aab74de8a..a539fbaa4e6 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -177,6 +177,8 @@ copy_data (stat_segment_directory_entry_t * ep)
break;
case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
+ if (ep->offset == 0)
+ return result;
simple_c = stat_segment_pointer (sm->shared_header, ep->offset);
result.simple_counter_vec = vec_dup (simple_c);
offset_vector =
@@ -190,6 +192,8 @@ copy_data (stat_segment_directory_entry_t * ep)
break;
case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
+ if (ep->offset == 0)
+ return result;
combined_c = stat_segment_pointer (sm->shared_header, ep->offset);
result.combined_counter_vec = vec_dup (combined_c);
offset_vector =
diff --git a/src/vpp/app/vpp_get_stats.c b/src/vpp/app/vpp_get_stats.c
index 1852b772b5e..d500f8fdb90 100644
--- a/src/vpp/app/vpp_get_stats.c
+++ b/src/vpp/app/vpp_get_stats.c
@@ -192,6 +192,8 @@ reconnect:
switch (res[i].type)
{
case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
+ if (res[i].simple_counter_vec == 0)
+ continue;
for (k = 0; k < vec_len (res[i].simple_counter_vec) - 1; k++)
for (j = 0; j < vec_len (res[i].simple_counter_vec[k]); j++)
fformat (stdout, "[%d @ %d]: %llu packets %s\n",
@@ -200,6 +202,8 @@ reconnect:
break;
case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
+ if (res[i].simple_counter_vec == 0)
+ continue;
for (k = 0; k < vec_len (res[i].combined_counter_vec); k++)
for (j = 0; j < vec_len (res[i].combined_counter_vec[k]); j++)
fformat (stdout, "[%d @ %d]: %llu packets, %llu bytes %s\n",
diff --git a/src/vpp/app/vpp_prometheus_export.c b/src/vpp/app/vpp_prometheus_export.c
index 65e014783a0..8d09bc209a3 100644
--- a/src/vpp/app/vpp_prometheus_export.c
+++ b/src/vpp/app/vpp_prometheus_export.c
@@ -257,6 +257,13 @@ main (int argc, char **argv)
}
}
+ if (vec_len (patterns) == 0)
+ {
+ fformat (stderr,
+ "%s: usage [socket-name <name>] <patterns> ...\n", argv[0]);
+ exit (1);
+ }
+
rv = stat_segment_connect ((char *) stat_segment_name);
if (rv)
{
@@ -280,7 +287,7 @@ main (int argc, char **argv)
}
else
{
- struct sockaddr_in6 clientaddr;
+ struct sockaddr_in6 clientaddr = { 0 };
char address[INET6_ADDRSTRLEN];
socklen_t addrlen;
getpeername (conn_sock, (struct sockaddr *) &clientaddr, &addrlen);