26 struct timespec ts, tsrem;
28 int i, j, k, lost_connection = 0;
29 f64 heartbeat, prev_heartbeat = 0;
40 if (heartbeat > prev_heartbeat)
42 prev_heartbeat = heartbeat;
49 if (lost_connection > 10)
51 fformat (stderr,
"Lost connection to VPP...\n");
62 for (i = 0; i <
vec_len (res); i++)
67 for (k = 0; k <
vec_len (res[i].simple_counter_vec); k++)
68 for (j = 0; j <
vec_len (res[i].simple_counter_vec[k]); j++)
69 fformat (stdout,
"[%d]: %llu packets %s\n",
70 j, res[i].simple_counter_vec[k][j], res[i].
name);
74 for (k = 0; k <
vec_len (res[i].simple_counter_vec); k++)
75 for (j = 0; j <
vec_len (res[i].combined_counter_vec[k]); j++)
76 fformat (stdout,
"[%d]: %llu packets, %llu bytes %s\n",
77 j, res[i].combined_counter_vec[k][j].packets,
78 res[i].combined_counter_vec[k][j].bytes,
83 for (j = 0; j <
vec_len (res[i].error_vector); j++)
84 fformat (stdout,
"%llu %s\n", res[i].error_vector[j],
89 fformat (stdout,
"%.2f %s\n", res[i].scalar_value, res[i].name);
93 printf (
"Unknown value\n");
101 while (nanosleep (&ts, &tsrem) < 0)
120 u8 *stat_segment_name, *pattern = 0, **patterns = 0;
133 if (
unformat (a,
"socket-name %s", &stat_segment_name))
151 else if (
unformat (a,
"%s", &pattern))
158 "%s: usage [socket-name <name>] [ls|dump|poll] <patterns> ...\n",
167 fformat (stderr,
"Couldn't connect to vpp, does %s exist?\n",
182 for (i = 0; i <
vec_len (dir); i++)
192 for (i = 0; i <
vec_len (res); i++)
197 if (res[i].simple_counter_vec == 0)
199 for (k = 0; k <
vec_len (res[i].simple_counter_vec); k++)
200 for (j = 0; j <
vec_len (res[i].simple_counter_vec[k]); j++)
201 fformat (stdout,
"[%d @ %d]: %llu packets %s\n",
202 j, k, res[i].simple_counter_vec[k][j],
207 if (res[i].combined_counter_vec == 0)
209 for (k = 0; k <
vec_len (res[i].combined_counter_vec); k++)
210 for (j = 0; j <
vec_len (res[i].combined_counter_vec[k]); j++)
211 fformat (stdout,
"[%d @ %d]: %llu packets, %llu bytes %s\n",
212 j, k, res[i].combined_counter_vec[k][j].packets,
213 res[i].combined_counter_vec[k][j].bytes,
218 for (j = 0; j <
vec_len (res[i].error_vector); j++)
219 fformat (stdout,
"[@%d] %llu %s\n", j, res[i].error_vector[j],
224 fformat (stdout,
"%.2f %s\n", res[i].scalar_value, res[i].name);
228 if (res[i].name_vector == 0)
230 for (k = 0; k <
vec_len (res[i].name_vector); k++)
231 if (res[i].name_vector[k])
232 fformat (stdout,
"[%d]: %s %s\n", k, res[i].name_vector[k],
267 "%s: usage [socket-name <name>] [ls|dump|poll] <patterns> ...\n",
int stat_segment_connect(const char *socket_name)
void stat_segment_data_free(stat_segment_data_t *res)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int main(int argc, char **argv)
static int stat_poll_loop(u8 **patterns)
vl_api_fib_path_type_t type
void stat_segment_disconnect(void)
void * clib_mem_init(void *heap, uword size)
#define STAT_SEGMENT_SOCKET_FILE
#define vec_free(V)
Free vector's memory (no header).
char * stat_segment_index_to_name(uint32_t index)
uint32_t * stat_segment_ls(uint8_t **patterns)
stat_segment_data_t * stat_segment_dump(uint32_t *stats)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double stat_segment_heartbeat(void)