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);
96 printf (
"Unknown value\n");
104 while (nanosleep (&ts, &tsrem) < 0)
123 u8 *stat_segment_name, *pattern = 0, **patterns = 0;
136 if (
unformat (a,
"socket-name %s", &stat_segment_name))
154 else if (
unformat (a,
"%s", &pattern))
161 "%s: usage [socket-name <name>] [ls|dump|poll] <patterns> ...\n",
170 fformat (stderr,
"Couldn't connect to vpp, does %s exist?\n",
185 for (i = 0; i <
vec_len (dir); i++)
195 for (i = 0; i <
vec_len (res); i++)
200 if (res[i].simple_counter_vec == 0)
202 for (k = 0; k <
vec_len (res[i].simple_counter_vec); k++)
203 for (j = 0; j <
vec_len (res[i].simple_counter_vec[k]); j++)
204 fformat (stdout,
"[%d @ %d]: %llu packets %s\n",
205 j, k, res[i].simple_counter_vec[k][j],
210 if (res[i].combined_counter_vec == 0)
212 for (k = 0; k <
vec_len (res[i].combined_counter_vec); k++)
213 for (j = 0; j <
vec_len (res[i].combined_counter_vec[k]); j++)
214 fformat (stdout,
"[%d @ %d]: %llu packets, %llu bytes %s\n",
215 j, k, res[i].combined_counter_vec[k][j].packets,
216 res[i].combined_counter_vec[k][j].bytes,
221 for (j = 0; j <
vec_len (res[i].error_vector); j++)
222 fformat (stdout,
"[@%d] %llu %s\n", j, res[i].error_vector[j],
227 fformat (stdout,
"%.2f %s\n", res[i].scalar_value, res[i].name);
231 if (res[i].name_vector == 0)
233 for (k = 0; k <
vec_len (res[i].name_vector); k++)
234 if (res[i].name_vector[k])
235 fformat (stdout,
"[%d]: %s %s\n", k, res[i].name_vector[k],
273 "%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
sll srl srl sll sra u16x4 i
#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)