diff options
Diffstat (limited to 'src/repmgr/repmgr_stat.c')
-rw-r--r-- | src/repmgr/repmgr_stat.c | 74 |
1 files changed, 63 insertions, 11 deletions
diff --git a/src/repmgr/repmgr_stat.c b/src/repmgr/repmgr_stat.c index fd6dabd3..215f4719 100644 --- a/src/repmgr/repmgr_stat.c +++ b/src/repmgr/repmgr_stat.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ @@ -55,7 +55,9 @@ __repmgr_stat(env, statp, flags) { DB_REP *db_rep; DB_REPMGR_STAT *copy, *stats; - uintmax_t tmp; + REPMGR_SITE *site; + u_int32_t tmp; + u_int i; int ret; db_rep = env->rep_handle; @@ -73,6 +75,20 @@ __repmgr_stat(env, statp, flags) memset(stats, 0, sizeof(DB_REPMGR_STAT)); stats->st_max_elect_threads = tmp; } + stats->st_incoming_queue_gbytes = db_rep->input_queue.gbytes; + stats->st_incoming_queue_bytes = db_rep->input_queue.bytes; + LOCK_MUTEX(db_rep->mutex); + for (i = 0; i < db_rep->site_cnt; i++) { + site = SITE_FROM_EID(i); + if (site->membership != 0) { + copy->st_site_total++; + if (FLD_ISSET(site->gmdb_flags, SITE_VIEW)) + copy->st_site_views++; + else + copy->st_site_participants++; + } + } + UNLOCK_MUTEX(db_rep->mutex); *statp = copy; return (0); @@ -148,6 +164,11 @@ __repmgr_print_stats(env, flags) (u_long)sp->st_msgs_queued); __db_dl(env, "Number of messages discarded due to queue length", (u_long)sp->st_msgs_dropped); + __db_dlbytes(env, "Incoming message size in queue", + (u_long)sp->st_incoming_queue_gbytes, (u_long)0, + (u_long)sp->st_incoming_queue_bytes); + __db_dl(env, "Number of messages discarded due to incoming queue full", + (u_long)sp->st_incoming_msgs_dropped); __db_dl(env, "Number of existing connections dropped", (u_long)sp->st_connection_drop); __db_dl(env, "Number of failed new connection attempts", @@ -156,6 +177,14 @@ __repmgr_print_stats(env, flags) (u_long)sp->st_elect_threads); __db_dl(env, "Election threads for which space is reserved", (u_long)sp->st_max_elect_threads); + __db_dl(env, "Number of participant sites in replication group", + (u_long)sp->st_site_participants); + __db_dl(env, "Total number of sites in replication group", + (u_long)sp->st_site_total); + __db_dl(env, "Number of view sites in replication group", + (u_long)sp->st_site_views); + __db_dl(env, "Number of automatic replication process takeovers", + (u_long)sp->st_takeovers); __os_ufree(env, sp); @@ -171,7 +200,7 @@ __repmgr_print_sites(env) u_int count, i; int ret; - if ((ret = __repmgr_site_list(env->dbenv, &count, &list)) != 0) + if ((ret = __repmgr_site_list_int(env, &count, &list)) != 0) return (ret); if (count == 0) @@ -189,6 +218,9 @@ __repmgr_print_sites(env) list[i].status == DB_REPMGR_CONNECTED ? "" : "dis"); __db_msgadd(env, &mb, ", %speer", F_ISSET(&list[i], DB_REPMGR_ISPEER) ? "" : "non-"); + __db_msgadd(env, &mb, ", %s", + F_ISSET(&list[i], DB_REPMGR_ISVIEW) ? + "view" : "participant"); __db_msgadd(env, &mb, ")"); DB_MSGBUF_FLUSH(env, &mb); } @@ -238,26 +270,46 @@ __repmgr_stat_print_pp(dbenv, flags) #endif /* - * PUBLIC: int __repmgr_site_list __P((DB_ENV *, u_int *, DB_REPMGR_SITE **)); + * PUBLIC: int __repmgr_site_list_pp + * PUBLIC: __P((DB_ENV *, u_int *, DB_REPMGR_SITE **)); */ int -__repmgr_site_list(dbenv, countp, listp) +__repmgr_site_list_pp(dbenv, countp, listp) DB_ENV *dbenv; u_int *countp; DB_REPMGR_SITE **listp; { - DB_REP *db_rep; - REP *rep; - DB_REPMGR_SITE *status; ENV *env; DB_THREAD_INFO *ip; + int ret; + + env = dbenv->env; + + ENV_ENTER(env, ip); + ret = __repmgr_site_list_int(env, countp, listp); + ENV_LEAVE(env, ip); + + return (ret); +} + +/* + * PUBLIC: int __repmgr_site_list_int __P((ENV *, u_int *, DB_REPMGR_SITE **)); + */ +int +__repmgr_site_list_int(env, countp, listp) + ENV *env; + u_int *countp; + DB_REPMGR_SITE **listp; +{ + DB_REP *db_rep; + DB_REPMGR_SITE *status; + REP *rep; REPMGR_SITE *site; size_t array_size, total_size; int eid, locked, ret; u_int count, i; char *name; - env = dbenv->env; db_rep = env->rep_handle; ret = 0; @@ -269,10 +321,8 @@ __repmgr_site_list(dbenv, countp, listp) LOCK_MUTEX(db_rep->mutex); locked = TRUE; - ENV_ENTER(env, ip); if (rep->siteinfo_seq > db_rep->siteinfo_seq) ret = __repmgr_sync_siteaddr(env); - ENV_LEAVE(env, ip); if (ret != 0) goto err; } else { @@ -329,6 +379,8 @@ __repmgr_site_list(dbenv, countp, listp) if (FLD_ISSET(site->config, DB_REPMGR_PEER)) F_SET(&status[i], DB_REPMGR_ISPEER); + if (FLD_ISSET(site->gmdb_flags, SITE_VIEW)) + F_SET(&status[i], DB_REPMGR_ISVIEW); /* * If we haven't started a communications thread, connection |