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 fformat (stdout,
"%llu %s\n", res[i].error_value, res[i].name);
87 fformat (stdout,
"%.2f %s\n", res[i].scalar_value, res[i].name);
91 printf (
"Unknown value\n");
99 while (nanosleep (&ts, &tsrem) < 0)
118 u8 *stat_segment_name, *pattern = 0, **patterns = 0;
131 if (
unformat (a,
"socket-name %s", &stat_segment_name))
149 else if (
unformat (a,
"%s", &pattern))
156 "%s: usage [socket-name <name>] [ls|dump|poll] <patterns> ...\n",
165 fformat (stderr,
"Couldn't connect to vpp, does %s exist?\n",
180 for (i = 0; i <
vec_len (dir); i++)
190 for (i = 0; i <
vec_len (res); i++)
195 if (res[i].simple_counter_vec == 0)
197 for (k = 0; k <
vec_len (res[i].simple_counter_vec); k++)
198 for (j = 0; j <
vec_len (res[i].simple_counter_vec[k]); j++)
199 fformat (stdout,
"[%d @ %d]: %llu packets %s\n",
200 j, k, res[i].simple_counter_vec[k][j],
205 if (res[i].combined_counter_vec == 0)
207 for (k = 0; k <
vec_len (res[i].combined_counter_vec); k++)
208 for (j = 0; j <
vec_len (res[i].combined_counter_vec[k]); j++)
209 fformat (stdout,
"[%d @ %d]: %llu packets, %llu bytes %s\n",
210 j, k, res[i].combined_counter_vec[k][j].packets,
211 res[i].combined_counter_vec[k][j].bytes,
216 fformat (stdout,
"%llu %s\n", res[i].error_value, res[i].name);
220 fformat (stdout,
"%.2f %s\n", res[i].scalar_value, res[i].name);
224 if (res[i].name_vector == 0)
226 for (k = 0; k <
vec_len (res[i].name_vector); k++)
227 if (res[i].name_vector[k])
228 fformat (stdout,
"[%d]: %s %s\n", k, res[i].name_vector[k],
263 "%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)
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)