From: Howard Chu Date: Tue, 28 Jun 2011 07:16:05 +0000 (-0700) Subject: Return statistics for a DB X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~185 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=11e80dae6366516bca9e59c807f171073a596885;p=openldap Return statistics for a DB Eventually this will have to grow up to be like BDB db_stat... --- diff --git a/libraries/libmdb/mdb_stat.c b/libraries/libmdb/mdb_stat.c new file mode 100644 index 0000000000..505d62e65b --- /dev/null +++ b/libraries/libmdb/mdb_stat.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include "mdb.h" + +int main(int argc,char * argv[]) +{ + int i = 0, rc; + MDB_env *env; + MDB_db *db; + MDB_stat *mst; + char *envname = argv[1]; + char *subname = NULL; + + if (argc > 2) + subname = argv[2]; + + rc = mdbenv_create(&env, 0); + rc = mdbenv_open(env, envname, MDB_RDONLY, 0); + if (rc) { + printf("mdbenv_open failed, error %d\n", rc); + exit(1); + } + rc = mdb_open(env, NULL, NULL, 0, &db); + if (rc) { + printf("mdb_open failed, error %d\n", rc); + exit(1); + } + + rc = mdb_stat(db, &mst); + printf("Created at %s", ctime(&mst->ms_created_at)); + printf("Page size: %u\n", mst->ms_psize); + printf("Tree depth: %u\n", mst->ms_depth); + printf("Branch pages: %lu\n", mst->ms_branch_pages); + printf("Leaf pages: %lu\n", mst->ms_leaf_pages); + printf("Overflow pages: %lu\n", mst->ms_overflow_pages); + printf("Revisions: %lu\n", mst->ms_revisions); + printf("Entries: %lu\n", mst->ms_entries); + mdb_close(db); + mdbenv_close(env); + + return 0; +}