Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

env_stat.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1996-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: env_stat.c,v 12.23 2005/11/01 00:44:25 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #include "string.h"
00015 
00016 #if TIME_WITH_SYS_TIME
00017 #include <sys/time.h>
00018 #include <time.h>
00019 #else
00020 #if HAVE_SYS_TIME_H
00021 #include <sys/time.h>
00022 #else
00023 #include <time.h>
00024 #endif
00025 #endif
00026 #endif
00027 
00028 #include "db_int.h"
00029 #include "dbinc/db_page.h"
00030 #include "dbinc/db_shash.h"
00031 #include "dbinc/db_am.h"
00032 #include "dbinc/lock.h"
00033 #include "dbinc/log.h"
00034 #include "dbinc/mp.h"
00035 #include "dbinc/txn.h"
00036 
00037 #ifdef HAVE_STATISTICS
00038 static int   __env_print_all __P((DB_ENV *, u_int32_t));
00039 static int   __env_print_stats __P((DB_ENV *, u_int32_t));
00040 static int   __env_print_threads __P((DB_ENV *));
00041 static int   __env_stat_print __P((DB_ENV *, u_int32_t));
00042 static char *__env_thread_state_print __P((DB_THREAD_STATE));
00043 static const char *
00044              __reg_type __P((reg_type_t));
00045 
00046 /*
00047  * __env_stat_print_pp --
00048  *      DB_ENV->stat_print pre/post processor.
00049  *
00050  * PUBLIC: int __env_stat_print_pp __P((DB_ENV *, u_int32_t));
00051  */
00052 int
00053 __env_stat_print_pp(dbenv, flags)
00054         DB_ENV *dbenv;
00055         u_int32_t flags;
00056 {
00057         DB_THREAD_INFO *ip;
00058         int ret;
00059 
00060         PANIC_CHECK(dbenv);
00061         ENV_ILLEGAL_BEFORE_OPEN(dbenv, "DB_ENV->stat_print");
00062 
00063         if ((ret = __db_fchk(dbenv, "DB_ENV->stat_print",
00064             flags, DB_STAT_ALL | DB_STAT_CLEAR | DB_STAT_SUBSYSTEM)) != 0)
00065                 return (ret);
00066 
00067         ENV_ENTER(dbenv, ip);
00068         REPLICATION_WRAP(dbenv, (__env_stat_print(dbenv, flags)), ret);
00069         ENV_LEAVE(dbenv, ip);
00070         return (ret);
00071 }
00072 
00073 /*
00074  * __env_stat_print --
00075  *      DB_ENV->stat_print method.
00076  */
00077 static int
00078 __env_stat_print(dbenv, flags)
00079         DB_ENV *dbenv;
00080         u_int32_t flags;
00081 {
00082         time_t now;
00083         int ret;
00084 
00085         (void)time(&now);
00086         __db_msg(dbenv, "%.24s\tLocal time", ctime(&now));
00087 
00088         if ((ret = __env_print_stats(dbenv, flags)) != 0)
00089                 return (ret);
00090 
00091         if (LF_ISSET(DB_STAT_ALL) &&
00092             (ret = __env_print_all(dbenv, flags)) != 0)
00093                 return (ret);
00094 
00095         if ((ret = __env_print_threads(dbenv)) != 0)
00096                 return (ret);
00097 
00098         if (!LF_ISSET(DB_STAT_SUBSYSTEM))
00099                 return (0);
00100 
00101         /* The subsystems don't know anything about DB_STAT_SUBSYSTEM. */
00102         LF_CLR(DB_STAT_SUBSYSTEM);
00103 
00104         if (MUTEX_ON(dbenv)) {
00105                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00106                 if ((ret = __mutex_stat_print(dbenv, flags)) != 0)
00107                         return (ret);
00108         }
00109 
00110         if (LOGGING_ON(dbenv)) {
00111                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00112                 if ((ret = __log_stat_print(dbenv, flags)) != 0)
00113                         return (ret);
00114 
00115                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00116                 if ((ret = __dbreg_stat_print(dbenv, flags)) != 0)
00117                         return (ret);
00118         }
00119 
00120         if (LOCKING_ON(dbenv)) {
00121                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00122                 if ((ret = __lock_stat_print(dbenv, flags)) != 0)
00123                         return (ret);
00124         }
00125 
00126         if (MPOOL_ON(dbenv)) {
00127                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00128                 if ((ret = __memp_stat_print(dbenv, flags)) != 0)
00129                         return (ret);
00130         }
00131 
00132         if (REP_ON(dbenv)) {
00133                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00134                 if ((ret = __rep_stat_print(dbenv, flags)) != 0)
00135                         return (ret);
00136         }
00137 
00138         if (TXN_ON(dbenv)) {
00139                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00140                 if ((ret = __txn_stat_print(dbenv, flags)) != 0)
00141                         return (ret);
00142         }
00143 
00144         return (0);
00145 }
00146 
00147 /*
00148  * __env_print_stats --
00149  *      Display the default environment statistics.
00150  *
00151  */
00152 static int
00153 __env_print_stats(dbenv, flags)
00154         DB_ENV *dbenv;
00155         u_int32_t flags;
00156 {
00157         REGENV *renv;
00158         REGINFO *infop;
00159 
00160         infop = dbenv->reginfo;
00161         renv = infop->primary;
00162 
00163         if (LF_ISSET(DB_STAT_ALL)) {
00164                 __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00165                 __db_msg(dbenv, "Default database environment information:");
00166         }
00167         STAT_HEX("Magic number", renv->magic);
00168         STAT_LONG("Panic value", renv->panic);
00169         __db_msg(dbenv, "%d.%d.%d\tEnvironment version",
00170             renv->majver, renv->minver, renv->patchver);
00171         __db_msg(dbenv, "%.24s\tCreation time", ctime(&renv->timestamp));
00172         STAT_HEX("Environment ID", renv->envid);
00173         __mutex_print_debug_single(dbenv,
00174             "Primary region allocation and reference count mutex",
00175             renv->mtx_regenv, flags);
00176         STAT_LONG("References", renv->refcnt);
00177 
00178         return (0);
00179 }
00180 
00181 /*
00182  * __env_print_all --
00183  *      Display the debugging environment statistics.
00184  */
00185 static int
00186 __env_print_all(dbenv, flags)
00187         DB_ENV *dbenv;
00188         u_int32_t flags;
00189 {
00190         static const FN fn[] = {
00191                 { DB_ENV_AUTO_COMMIT,           "DB_ENV_AUTO_COMMIT" },
00192                 { DB_ENV_CDB,                   "DB_ENV_CDB" },
00193                 { DB_ENV_CDB_ALLDB,             "DB_ENV_CDB_ALLDB" },
00194                 { DB_ENV_CREATE,                "DB_ENV_CREATE" },
00195                 { DB_ENV_DBLOCAL,               "DB_ENV_DBLOCAL" },
00196                 { DB_ENV_DIRECT_DB,             "DB_ENV_DIRECT_DB" },
00197                 { DB_ENV_DIRECT_LOG,            "DB_ENV_DIRECT_LOG" },
00198                 { DB_ENV_DSYNC_DB,              "DB_ENV_DSYNC_DB" },
00199                 { DB_ENV_DSYNC_LOG,             "DB_ENV_DSYNC_LOG" },
00200                 { DB_ENV_FATAL,                 "DB_ENV_FATAL" },
00201                 { DB_ENV_LOCKDOWN,              "DB_ENV_LOCKDOWN" },
00202                 { DB_ENV_LOG_AUTOREMOVE,        "DB_ENV_LOG_AUTOREMOVE" },
00203                 { DB_ENV_LOG_INMEMORY,          "DB_ENV_LOG_INMEMORY" },
00204                 { DB_ENV_NOLOCKING,             "DB_ENV_NOLOCKING" },
00205                 { DB_ENV_NOMMAP,                "DB_ENV_NOMMAP" },
00206                 { DB_ENV_NOPANIC,               "DB_ENV_NOPANIC" },
00207                 { DB_ENV_OPEN_CALLED,           "DB_ENV_OPEN_CALLED" },
00208                 { DB_ENV_OVERWRITE,             "DB_ENV_OVERWRITE" },
00209                 { DB_ENV_PRIVATE,               "DB_ENV_PRIVATE" },
00210                 { DB_ENV_REGION_INIT,           "DB_ENV_REGION_INIT" },
00211                 { DB_ENV_RPCCLIENT,             "DB_ENV_RPCCLIENT" },
00212                 { DB_ENV_RPCCLIENT_GIVEN,       "DB_ENV_RPCCLIENT_GIVEN" },
00213                 { DB_ENV_SYSTEM_MEM,            "DB_ENV_SYSTEM_MEM" },
00214                 { DB_ENV_THREAD,                "DB_ENV_THREAD" },
00215                 { DB_ENV_TIME_NOTGRANTED,       "DB_ENV_TIME_NOTGRANTED" },
00216                 { DB_ENV_TXN_NOSYNC,            "DB_ENV_TXN_NOSYNC" },
00217                 { DB_ENV_TXN_WRITE_NOSYNC,      "DB_ENV_TXN_WRITE_NOSYNC" },
00218                 { DB_ENV_YIELDCPU,              "DB_ENV_YIELDCPU" },
00219                 { 0,                            NULL }
00220         };
00221         static const FN ofn[] = {
00222                 { DB_CREATE,                    "DB_CREATE" },
00223                 { DB_FORCE,                     "DB_FORCE" },
00224                 { DB_INIT_CDB,                  "DB_INIT_CDB" },
00225                 { DB_INIT_LOCK,                 "DB_INIT_LOCK" },
00226                 { DB_INIT_LOG,                  "DB_INIT_LOG" },
00227                 { DB_INIT_MPOOL,                "DB_INIT_MPOOL" },
00228                 { DB_INIT_REP,                  "DB_INIT_REP" },
00229                 { DB_INIT_TXN,                  "DB_INIT_TXN" },
00230                 { DB_LOCKDOWN,                  "DB_LOCKDOWN" },
00231                 { DB_NOMMAP,                    "DB_NOMMAP" },
00232                 { DB_PRIVATE,                   "DB_PRIVATE" },
00233                 { DB_RDONLY,                    "DB_RDONLY" },
00234                 { DB_RECOVER,                   "DB_RECOVER" },
00235                 { DB_RECOVER_FATAL,             "DB_RECOVER_FATAL" },
00236                 { DB_SYSTEM_MEM,                "DB_SYSTEM_MEM" },
00237                 { DB_THREAD,                    "DB_THREAD" },
00238                 { DB_TRUNCATE,                  "DB_TRUNCATE" },
00239                 { DB_TXN_NOSYNC,                "DB_TXN_NOSYNC" },
00240                 { DB_USE_ENVIRON,               "DB_USE_ENVIRON" },
00241                 { DB_USE_ENVIRON_ROOT,          "DB_USE_ENVIRON_ROOT" },
00242                 { 0,                            NULL }
00243         };
00244         static const FN vfn[] = {
00245                 { DB_VERB_DEADLOCK,             "DB_VERB_DEADLOCK" },
00246                 { DB_VERB_RECOVERY,             "DB_VERB_RECOVERY" },
00247                 { DB_VERB_REGISTER,             "DB_VERB_REGISTER" },
00248                 { DB_VERB_REPLICATION,          "DB_VERB_REPLICATION" },
00249                 { DB_VERB_WAITSFOR,             "DB_VERB_WAITSFOR" },
00250                 { 0,                            NULL }
00251         };
00252         static const FN regenvfn[] = {
00253                 { DB_REGENV_REPLOCKED,          "DB_REGENV_REPLOCKED" },
00254                 { 0,                            NULL }
00255         };
00256         DB_MSGBUF mb;
00257         REGENV *renv;
00258         REGINFO *infop;
00259         REGION *rp;
00260         u_int32_t i;
00261         char **p;
00262 
00263         infop = dbenv->reginfo;
00264         renv = infop->primary;
00265         DB_MSGBUF_INIT(&mb);
00266 
00267         __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00268         __db_prflags(dbenv,
00269             NULL, renv->init_flags, ofn, NULL, "\tInitialization flags");
00270         STAT_ULONG("Region slots", renv->region_cnt);
00271         __db_prflags(dbenv,
00272             NULL, renv->flags, regenvfn, NULL, "\tReplication flags");
00273         __db_msg(dbenv, "%.24s\tOperation timestamp",
00274             renv->op_timestamp == 0 ? "!Set" : ctime(&renv->op_timestamp));
00275         __db_msg(dbenv, "%.24s\tReplication timestamp",
00276             renv->rep_timestamp == 0 ? "!Set" : ctime(&renv->rep_timestamp));
00277 
00278         __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00279         __db_msg(dbenv, "Per region database environment information:");
00280         for (rp = R_ADDR(infop, renv->region_off),
00281             i = 0; i < renv->region_cnt; ++i, ++rp) {
00282                 if (rp->id == INVALID_REGION_ID)
00283                         continue;
00284                 __db_msg(dbenv, "%s Region:", __reg_type(rp->type));
00285                 STAT_LONG("Region ID", rp->id);
00286                 STAT_LONG("Segment ID", rp->segid);
00287                 __db_dlbytes(dbenv,
00288                     "Size", (u_long)0, (u_long)0, (u_long)rp->size);
00289         }
00290 
00291         __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00292         __db_msg(dbenv, "DB_ENV handle information:");
00293         STAT_ISSET("Errfile", dbenv->db_errfile);
00294         STAT_STRING("Errpfx", dbenv->db_errpfx);
00295         STAT_ISSET("Errcall", dbenv->db_errcall);
00296         STAT_ISSET("Feedback", dbenv->db_feedback);
00297         STAT_ISSET("Panic", dbenv->db_paniccall);
00298         STAT_ISSET("Malloc", dbenv->db_malloc);
00299         STAT_ISSET("Realloc", dbenv->db_realloc);
00300         STAT_ISSET("Free", dbenv->db_free);
00301         __db_prflags(dbenv, NULL, dbenv->verbose, vfn, NULL, "\tVerbose flags");
00302 
00303         STAT_ISSET("App private", dbenv->app_private);
00304         STAT_ISSET("App dispatch", dbenv->app_dispatch);
00305         STAT_STRING("Home", dbenv->db_home);
00306         STAT_STRING("Log dir", dbenv->db_log_dir);
00307         STAT_STRING("Tmp dir", dbenv->db_tmp_dir);
00308         if (dbenv->db_data_dir == NULL)
00309                 STAT_ISSET("Data dir", dbenv->db_data_dir);
00310         else {
00311                 for (p = dbenv->db_data_dir; *p != NULL; ++p)
00312                         __db_msgadd(dbenv, &mb, "%s\tData dir", *p);
00313                 DB_MSGBUF_FLUSH(dbenv, &mb);
00314         }
00315         STAT_FMT("Mode", "%#o", int, dbenv->db_mode);
00316         __db_prflags(dbenv, NULL, dbenv->open_flags, ofn, NULL, "\tOpen flags");
00317         STAT_ISSET("Lockfhp", dbenv->lockfhp);
00318         STAT_ISSET("Recovery table", dbenv->recover_dtab);
00319         STAT_ULONG("Number of recovery table slots", dbenv->recover_dtab_size);
00320         STAT_ISSET("RPC client", dbenv->cl_handle);
00321         STAT_LONG("RPC client ID", dbenv->cl_id);
00322         STAT_LONG("DB reference count", dbenv->db_ref);
00323         STAT_LONG("Shared memory key", dbenv->shm_key);
00324         __mutex_print_debug_single(
00325             dbenv, "DB handle mutex", dbenv->mtx_dblist, flags);
00326 
00327         STAT_ISSET("api1 internal", dbenv->api1_internal);
00328         STAT_ISSET("api2 internal", dbenv->api2_internal);
00329         STAT_ISSET("password", dbenv->passwd);
00330         STAT_ISSET("crypto handle", dbenv->crypto_handle);
00331         __mutex_print_debug_single(dbenv, "MT mutex", dbenv->mtx_mt, flags);
00332 
00333         __db_prflags(dbenv, NULL, dbenv->flags, fn, NULL, "\tFlags");
00334 
00335         return (0);
00336 }
00337 
00338 static char *
00339 __env_thread_state_print(state)
00340         DB_THREAD_STATE state;
00341 {
00342         switch (state) {
00343         case THREAD_ACTIVE:
00344                 return ("active");
00345         case THREAD_BLOCKED:
00346                 return ("blocked");
00347         case THREAD_OUT:
00348                 return ("out");
00349         default:
00350                 return ("unknown");
00351         }
00352 }
00353 
00354 /*
00355  * __env_print_threads --
00356  *      Display the current active threads
00357  *
00358  */
00359 static int
00360 __env_print_threads(dbenv)
00361         DB_ENV *dbenv;
00362 {
00363         DB_HASHTAB *htab;
00364         DB_THREAD_INFO *ip;
00365         u_int32_t i;
00366         char buf[DB_THREADID_STRLEN];
00367 
00368         htab = (DB_HASHTAB *)dbenv->thr_hashtab;
00369         __db_msg(dbenv, "Thread status blocks:");
00370         for (i = 0; i < dbenv->thr_nbucket; i++) {
00371                 for (ip = SH_TAILQ_FIRST(&htab[i], __db_thread_info);
00372                      ip != NULL;
00373                      ip = SH_TAILQ_NEXT(ip, dbth_links, __db_thread_info)) {
00374                         if (ip->dbth_state == THREAD_SLOT_NOT_IN_USE)
00375                                 continue;
00376                         __db_msg(dbenv, "\tprocess/thread %s: %s",
00377                             dbenv->thread_id_string(
00378                             dbenv, ip->dbth_pid, ip->dbth_tid, buf),
00379                             __env_thread_state_print(ip->dbth_state));
00380                 }
00381         }
00382         return (0);
00383 }
00384 
00385 /*
00386  * __db_print_fh --
00387  *      Print out a file handle.
00388  *
00389  * PUBLIC: void __db_print_fh __P((DB_ENV *, const char *, DB_FH *, u_int32_t));
00390  */
00391 void
00392 __db_print_fh(dbenv, tag, fh, flags)
00393         DB_ENV *dbenv;
00394         const char *tag;
00395         DB_FH *fh;
00396         u_int32_t flags;
00397 {
00398         static const FN fn[] = {
00399                 { DB_FH_NOSYNC, "DB_FH_NOSYNC" },
00400                 { DB_FH_OPENED, "DB_FH_OPENED" },
00401                 { DB_FH_UNLINK, "DB_FH_UNLINK" },
00402                 { 0,            NULL }
00403         };
00404 
00405         if (fh == NULL) {
00406                 STAT_ISSET(tag, fh);
00407                 return;
00408         }
00409 
00410         __mutex_print_debug_single(
00411             dbenv, "file-handle.mutex", fh->mtx_fh, flags);
00412 
00413         STAT_LONG("file-handle.reference count", fh->ref);
00414         STAT_LONG("file-handle.file descriptor", fh->fd);
00415         STAT_STRING("file-handle.file name", fh->name);
00416 
00417         STAT_ULONG("file-handle.page number", fh->pgno);
00418         STAT_ULONG("file-handle.page size", fh->pgsize);
00419         STAT_ULONG("file-handle.page offset", fh->offset);
00420 
00421         __db_prflags(dbenv, NULL, fh->flags, fn, NULL, "\tfile-handle.flags");
00422 }
00423 
00424 /*
00425  * __db_print_fileid --
00426  *      Print out a file ID.
00427  *
00428  * PUBLIC: void __db_print_fileid __P((DB_ENV *, u_int8_t *, const char *));
00429  */
00430 void
00431 __db_print_fileid(dbenv, id, suffix)
00432         DB_ENV *dbenv;
00433         u_int8_t *id;
00434         const char *suffix;
00435 {
00436         DB_MSGBUF mb;
00437         int i;
00438 
00439         if (id == NULL) {
00440                 STAT_ISSET("ID", id);
00441                 return;
00442         }
00443 
00444         DB_MSGBUF_INIT(&mb);
00445         for (i = 0; i < DB_FILE_ID_LEN; ++i, ++id) {
00446                 __db_msgadd(dbenv, &mb, "%x", (u_int)*id);
00447                 if (i < DB_FILE_ID_LEN - 1)
00448                         __db_msgadd(dbenv, &mb, " ");
00449         }
00450         if (suffix != NULL)
00451                 __db_msgadd(dbenv, &mb, "%s", suffix);
00452         DB_MSGBUF_FLUSH(dbenv, &mb);
00453 }
00454 
00455 /*
00456  * __db_dl --
00457  *      Display a big value.
00458  *
00459  * PUBLIC: void __db_dl __P((DB_ENV *, const char *, u_long));
00460  */
00461 void
00462 __db_dl(dbenv, msg, value)
00463         DB_ENV *dbenv;
00464         const char *msg;
00465         u_long value;
00466 {
00467         /*
00468          * Two formats: if less than 10 million, display as the number, if
00469          * greater than 10 million display as ###M.
00470          */
00471         if (value < 10000000)
00472                 __db_msg(dbenv, "%lu\t%s", value, msg);
00473         else
00474                 __db_msg(dbenv, "%luM\t%s (%lu)", value / 1000000, msg, value);
00475 }
00476 
00477 /*
00478  * __db_dl_pct --
00479  *      Display a big value, and related percentage.
00480  *
00481  * PUBLIC: void __db_dl_pct
00482  * PUBLIC:          __P((DB_ENV *, const char *, u_long, int, const char *));
00483  */
00484 void
00485 __db_dl_pct(dbenv, msg, value, pct, tag)
00486         DB_ENV *dbenv;
00487         const char *msg, *tag;
00488         u_long value;
00489         int pct;
00490 {
00491         DB_MSGBUF mb;
00492 
00493         DB_MSGBUF_INIT(&mb);
00494 
00495         /*
00496          * Two formats: if less than 10 million, display as the number, if
00497          * greater than 10 million, round it off and display as ###M.
00498          */
00499         if (value < 10000000)
00500                 __db_msgadd(dbenv, &mb, "%lu\t%s", value, msg);
00501         else
00502                 __db_msgadd(dbenv,
00503                     &mb, "%luM\t%s", (value + 500000) / 1000000, msg);
00504         if (tag == NULL)
00505                 __db_msgadd(dbenv, &mb, " (%d%%)", pct);
00506         else
00507                 __db_msgadd(dbenv, &mb, " (%d%% %s)", pct, tag);
00508 
00509         DB_MSGBUF_FLUSH(dbenv, &mb);
00510 }
00511 
00512 /*
00513  * __db_dlbytes --
00514  *      Display a big number of bytes.
00515  *
00516  * PUBLIC: void __db_dlbytes
00517  * PUBLIC:     __P((DB_ENV *, const char *, u_long, u_long, u_long));
00518  */
00519 void
00520 __db_dlbytes(dbenv, msg, gbytes, mbytes, bytes)
00521         DB_ENV *dbenv;
00522         const char *msg;
00523         u_long gbytes, mbytes, bytes;
00524 {
00525         DB_MSGBUF mb;
00526         const char *sep;
00527 
00528         DB_MSGBUF_INIT(&mb);
00529 
00530         /* Normalize the values. */
00531         while (bytes >= MEGABYTE) {
00532                 ++mbytes;
00533                 bytes -= MEGABYTE;
00534         }
00535         while (mbytes >= GIGABYTE / MEGABYTE) {
00536                 ++gbytes;
00537                 mbytes -= GIGABYTE / MEGABYTE;
00538         }
00539 
00540         if (gbytes == 0 && mbytes == 0 && bytes == 0)
00541                 __db_msgadd(dbenv, &mb, "0");
00542         else {
00543                 sep = "";
00544                 if (gbytes > 0) {
00545                         __db_msgadd(dbenv, &mb, "%luGB", gbytes);
00546                         sep = " ";
00547                 }
00548                 if (mbytes > 0) {
00549                         __db_msgadd(dbenv, &mb, "%s%luMB", sep, mbytes);
00550                         sep = " ";
00551                 }
00552                 if (bytes >= 1024) {
00553                         __db_msgadd(dbenv, &mb, "%s%luKB", sep, bytes / 1024);
00554                         bytes %= 1024;
00555                         sep = " ";
00556                 }
00557                 if (bytes > 0)
00558                         __db_msgadd(dbenv, &mb, "%s%luB", sep, bytes);
00559         }
00560 
00561         __db_msgadd(dbenv, &mb, "\t%s", msg);
00562 
00563         DB_MSGBUF_FLUSH(dbenv, &mb);
00564 }
00565 
00566 /*
00567  * __db_print_reginfo --
00568  *      Print out underlying shared region information.
00569  *
00570  * PUBLIC: void __db_print_reginfo __P((DB_ENV *, REGINFO *, const char *));
00571  */
00572 void
00573 __db_print_reginfo(dbenv, infop, s)
00574         DB_ENV *dbenv;
00575         REGINFO *infop;
00576         const char *s;
00577 {
00578         static const FN fn[] = {
00579                 { REGION_CREATE,        "REGION_CREATE" },
00580                 { REGION_CREATE_OK,     "REGION_CREATE_OK" },
00581                 { REGION_JOIN_OK,       "REGION_JOIN_OK" },
00582                 { 0,                    NULL }
00583         };
00584 
00585         __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00586         __db_msg(dbenv, "%s REGINFO information:",  s);
00587         STAT_STRING("Region type", __reg_type(infop->type));
00588         STAT_ULONG("Region ID", infop->id);
00589         STAT_STRING("Region name", infop->name);
00590         STAT_POINTER("Original region address", infop->addr_orig);
00591         STAT_POINTER("Region address", infop->addr);
00592         STAT_POINTER("Region primary address", infop->primary);
00593         STAT_ULONG("Region maximum allocation", infop->max_alloc);
00594         STAT_ULONG("Region allocated", infop->max_alloc);
00595 
00596         __db_prflags(dbenv, NULL, infop->flags, fn, NULL, "\tRegion flags");
00597 }
00598 
00599 /*
00600  * __reg_type --
00601  *      Return the region type string.
00602  */
00603 static const char *
00604 __reg_type(t)
00605         reg_type_t t;
00606 {
00607         switch (t) {
00608         case REGION_TYPE_ENV:
00609                 return ("Environment");
00610         case REGION_TYPE_LOCK:
00611                 return ("Lock");
00612         case REGION_TYPE_LOG:
00613                 return ("Log");
00614         case REGION_TYPE_MPOOL:
00615                 return ("Mpool");
00616         case REGION_TYPE_MUTEX:
00617                 return ("Mutex");
00618         case REGION_TYPE_TXN:
00619                 return ("Transaction");
00620         case INVALID_REGION_TYPE:
00621                 return ("Invalid");
00622         }
00623         return ("Unknown");
00624 }
00625 
00626 #else /* !HAVE_STATISTICS */
00627 
00628 /*
00629  * __db_stat_not_built --
00630  *      Common error routine when library not built with statistics.
00631  *
00632  * PUBLIC: int __db_stat_not_built __P((DB_ENV *));
00633  */
00634 int
00635 __db_stat_not_built(dbenv)
00636         DB_ENV *dbenv;
00637 {
00638         __db_err(dbenv, "Library build did not include statistics support");
00639         return (DB_OPNOTSUP);
00640 }
00641 
00642 int
00643 __env_stat_print_pp(dbenv, flags)
00644         DB_ENV *dbenv;
00645         u_int32_t flags;
00646 {
00647         COMPQUIET(flags, 0);
00648 
00649         return (__db_stat_not_built(dbenv));
00650 }
00651 #endif

Generated on Sun Dec 25 12:14:25 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2