MCPcopy Create free account
hub / github.com/corosync/corosync / stats_map_get

Function stats_map_get

exec/stats.c:325–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325cs_error_t stats_map_get(const char *key_name,
326 void *value,
327 size_t *value_len,
328 icmap_value_types_t *type)
329{
330 struct cs_stats_conv *statinfo;
331 struct stats_item *item;
332 totempg_stats_t *pg_stats;
333 struct knet_link_status link_status;
334 struct ipcs_conn_stats ipcs_conn_stats;
335 struct ipcs_global_stats ipcs_global_stats;
336 struct knet_handle_stats knet_handle_stats;
337 int res;
338 int nodeid;
339 int link_no;
340 int service_id;
341 uint32_t pid;
342 unsigned int sm_event;
343 char *sm_type;
344 void *conn_ptr;
345
346 item = qb_map_get(stats_map, key_name);
347 if (!item) {
348 return CS_ERR_NOT_EXIST;
349 }
350
351 statinfo = item->cs_conv;
352 switch (statinfo->type) {
353 case STAT_PG:
354 pg_stats = api->totem_get_stats();
355 stats_map_set_value(statinfo, pg_stats, value, value_len, type);
356 break;
357 case STAT_SRP:
358 pg_stats = api->totem_get_stats();
359 stats_map_set_value(statinfo, pg_stats->srp, value, value_len, type);
360 break;
361 case STAT_KNET_HANDLE:
362 res = totemknet_handle_get_stats(&knet_handle_stats);
363 if (res != CS_OK) {
364 return res;
365 }
366 stats_map_set_value(statinfo, &knet_handle_stats, value, value_len, type);
367 break;
368 case STAT_KNET:
369 if (sscanf(key_name, "stats.knet.node%d.link%d", &nodeid, &link_no) != 2) {
370 return CS_ERR_NOT_EXIST;
371 }
372
373 /* Validate node & link IDs */
374 if (nodeid <= 0 || nodeid > KNET_MAX_HOST ||
375 link_no < 0 || link_no > KNET_MAX_LINK) {
376 return CS_ERR_NOT_EXIST;
377 }
378
379 /* Always get the latest stats */
380 res = totemknet_link_get_status((knet_node_id_t)nodeid, (uint8_t)link_no, &link_status);
381 if (res != CS_OK) {
382 return CS_ERR_LIBRARY;

Callers 3

stats_trigger_trackersFunction · 0.85
stats_map_notify_fnFunction · 0.85
stats_map_track_addFunction · 0.85

Calls 5

stats_map_set_valueFunction · 0.85
cs_ipcs_get_conn_statsFunction · 0.85
cs_ipcs_get_global_statsFunction · 0.85

Tested by

no test coverage detected