MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / stat_thread_int

Function stat_thread_int

plugins/dbqueuedb/dbqueuedb.c:553–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551static int get_stats(struct dbtable *, int, void *, struct consumer_stat *);
552
553static void stat_thread_int(struct dbtable *db, int fullstat, int walk_queue)
554{
555 if (db->dbtype != DBTYPE_QUEUE && db->dbtype != DBTYPE_QUEUEDB)
556 logmsg(LOGMSG_ERROR, "'%s' is not a queue\n", db->tablename);
557 else {
558 int ii;
559 struct consumer_stat stats[MAXCONSUMERS] = {{0}};
560 int flags = 0;
561 const struct bdb_queue_stats *bdbstats;
562
563 bdbstats = bdb_queue_get_stats(db->handle);
564
565 logmsg(LOGMSG_USER, "(scanning queue '%s' for stats, please wait...)\n",
566 db->tablename);
567 if (!walk_queue)
568 flags = BDB_QUEUE_WALK_FIRST_ONLY;
569 if (fullstat)
570 flags |= BDB_QUEUE_WALK_KNOWN_CONSUMERS_ONLY;
571 get_stats(db, flags, NULL, stats);
572
573 logmsg(LOGMSG_USER, "queue '%s':-\n", db->tablename);
574 logmsg(LOGMSG_USER, " geese added %u\n", db->num_goose_adds);
575 logmsg(LOGMSG_USER, " geese consumed %u\n", db->num_goose_consumes);
576 logmsg(LOGMSG_USER, " bdb get bdbstats %u log %u phys\n",
577 bdbstats->n_logical_gets, bdbstats->n_physical_gets);
578 logmsg(LOGMSG_USER, " bdb deadlocks add %u get %u con %u\n",
579 bdbstats->n_add_deadlocks, bdbstats->n_get_deadlocks,
580 bdbstats->n_consume_deadlocks);
581 logmsg(LOGMSG_USER, " bdb get not founds %u\n", bdbstats->n_get_not_founds);
582 logmsg(LOGMSG_USER, " bdb con bdbstats new [con %u, abt %u, gee %u], old %u\n",
583 bdbstats->n_new_way_frags_consumed,
584 bdbstats->n_new_way_frags_aborted,
585 bdbstats->n_new_way_geese_consumed,
586 bdbstats->n_old_way_frags_consumed);
587
588 if (db->dbtype == DBTYPE_QUEUEDB) {
589 consumer_lock_read(db);
590 }
591 for (ii = 0; ii < MAXCONSUMERS; ii++) {
592 struct consumer *consumer = db->consumers[ii];
593
594 if (!fullstat && !consumer && !stats[ii].has_stuff)
595 continue;
596
597 if (consumer) {
598 logmsg(LOGMSG_USER, " [consumer %02d]: ", ii);
599 switch (consumer->base.type) {
600 default:
601 logmsg(LOGMSG_USER, "unknown consumer type %d?!\n", consumer->base.type);
602 break;
603 }
604 logmsg(LOGMSG_USER, " %u messages consumed\n", consumer->n_consumed);
605 if (walk_queue)
606 logmsg(LOGMSG_USER, " %d items on queue\n", stats[ii].depth);
607 } else
608 logmsg(LOGMSG_USER, " [consumer %02d]: none\n", ii);
609
610 if (stats[ii].has_stuff) {

Callers 1

stat_threadFunction · 0.85

Calls 4

bdb_queue_get_statsFunction · 0.85
get_statsFunction · 0.70
logmsgFunction · 0.50
comdb2_time_epochFunction · 0.50

Tested by

no test coverage detected