HI!
In my monitoring check I'd like to indicate how many entries are in a database.
Currently I'm using the no-op search control without any filtering to count the entries which is obviously a huge waste of CPU and I/O ressources for just retrieving the raw number of DB entries.
Is it easily possible to access the id2e sub-DB and query number of entries?
Something like
mdb_stat -s id2e -e <db-path> | grep Entries
but from Python with python-lmdb or a similar module. (Yes, I know subprocess module but I really hate invoking command-line tools from Python.)
Ciao, Michael.
On 1/16/20 3:57 PM, Michael Ströder wrote:
In my monitoring check I'd like to indicate how many entries are in a database.
Currently I'm using the no-op search control without any filtering to count the entries which is obviously a huge waste of CPU and I/O ressources for just retrieving the raw number of DB entries.
Is it easily possible to access the id2e sub-DB and query number of entries?
Ideally this should be added to cn=monitor along with olmMDBPagesMax and friends.
Ciao, Michael.
Michael Ströder wrote:
On 1/16/20 3:57 PM, Michael Ströder wrote:
In my monitoring check I'd like to indicate how many entries are in a database.
Currently I'm using the no-op search control without any filtering to count the entries which is obviously a huge waste of CPU and I/O ressources for just retrieving the raw number of DB entries.
Is it easily possible to access the id2e sub-DB and query number of entries?
Ideally this should be added to cn=monitor along with olmMDBPagesMax and friends.
Submit an ITS enhancement request.
On 1/17/20 3:13 AM, Howard Chu wrote:
Michael Ströder wrote:
On 1/16/20 3:57 PM, Michael Ströder wrote:
In my monitoring check I'd like to indicate how many entries are in a database. [..] Is it easily possible to access the id2e sub-DB and query number of entries?
Ideally this should be added to cn=monitor along with olmMDBPagesMax and friends.
Submit an ITS enhancement request.
https://www.openldap.org/its/index.cgi?findid=9154
Rationale: For security reasons the monitor check should not have read access to .mdb files.
Ciao, Michael.
Michael Ströder wrote:
HI!
In my monitoring check I'd like to indicate how many entries are in a database.
Currently I'm using the no-op search control without any filtering to count the entries which is obviously a huge waste of CPU and I/O ressources for just retrieving the raw number of DB entries.
Is it easily possible to access the id2e sub-DB and query number of entries?
Something like
mdb_stat -s id2e -e <db-path> | grep Entries
but from Python with python-lmdb or a similar module. (Yes, I know subprocess module but I really hate invoking command-line tools from Python.)
It's pretty trivial in py-lmdb.
#### import lmdb
env = lmdb.open('/tmp/test', max_dbs=2) with env.begin() as txn: subdb = env.open_db('id2e', txn=txn, create=False) print txn.stat(subdb) ####
On 1/17/20 3:09 AM, Howard Chu wrote:
Michael Ströder wrote:
Is it easily possible to access the id2e sub-DB and query number of entries?
Something like
mdb_stat -s id2e -e <db-path> | grep Entries
but from Python with python-lmdb or a similar module.
It's pretty trivial in py-lmdb.
#### import lmdb
env = lmdb.open('/tmp/test', max_dbs=2) with env.begin() as txn: subdb = env.open_db('id2e', txn=txn, create=False) print txn.stat(subdb) ####
Thanks Howard!
Just for the records: With Python3 one has to pass the name of the sub-DB as byte-string.
subdb = env.open_db(b'id2e', txn=txn, create=False)
Changed slapdcheck:
https://gitlab.com/ae-dir/slapdcheck/commit/3c4757cbf8546c15ae33dd8de46c6e9b...
Ciao, Michael.
openldap-technical@openldap.org