]> git.sur5r.net Git - openldap/commitdiff
further improve monitoring setup and cleanup
authorPierangelo Masarati <ando@openldap.org>
Sat, 9 Sep 2006 16:24:35 +0000 (16:24 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 9 Sep 2006 16:24:35 +0000 (16:24 +0000)
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/monitor.c

index a5601bf556f815e6cffce88daf6ee0a3c0ae39d6..7b85509c7b1a1fae7602e6f8e420f04af44cffab 100644 (file)
@@ -45,6 +45,7 @@ static int
 bdb_db_init( BackendDB *be )
 {
        struct bdb_info *bdb;
+       int rc;
 
        Debug( LDAP_DEBUG_TRACE,
                LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
@@ -80,7 +81,9 @@ bdb_db_init( BackendDB *be )
        be->be_private = bdb;
        be->be_cf_ocs = be->bd_info->bi_cf_ocs;
 
-       return 0;
+       rc = bdb_monitor_init( be );
+
+       return rc;
 }
 
 static int
@@ -447,7 +450,7 @@ bdb_db_close( BackendDB *be )
        struct bdb_db_info *db;
        bdb_idl_cache_entry_t *entry, *next_entry;
 
-       /* monitor setup */
+       /* monitor handling */
        (void)bdb_monitor_close( be );
 
        bdb->bi_flags &= ~BDB_IS_OPEN;
index 734e6e2b3e3dabe00db02fa76f3ab78e1c2cc966..237dfc4d0467cd54270c8bf33881c48a194c2f05 100644 (file)
@@ -330,6 +330,8 @@ done_oc:;
 int
 bdb_monitor_init( BackendDB *be )
 {
+       SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_MONITORING;
+
        return 0;
 }
 
@@ -364,11 +366,7 @@ bdb_monitor_open( BackendDB *be )
                return 0;
        }
 
-       /* monitor_back_register_entry_attrs() with a NULL ndn,
-        * base="cn=Databases,cn=Monitor", scope=LDAP_SCOPE_ONE 
-        * and filter="(namingContexts:distinguishedNameMatch:=<suffix>)" */
-
-       bdb->bi_monitor.bdm_scope = LDAP_SCOPE_ONELEVEL;
+       bdb->bi_monitor.bdm_scope = LDAP_SCOPE_SUBORDINATE;
        base = &bdb->bi_monitor.bdm_nbase;
        BER_BVSTR( base, "cn=databases,cn=monitor" );
        filter = &bdb->bi_monitor.bdm_filter;
@@ -382,12 +380,16 @@ bdb_monitor_open( BackendDB *be )
                ldap_bv2escaped_filter_value( &be->be_nsuffix[ 0 ], &suffix );
        }
        
-       filter->bv_len = STRLENOF( "(namingContexts:distinguishedNameMatch:=)" ) + suffix.bv_len;
+       filter->bv_len = STRLENOF( "(&(monitoredInfo=" )
+               + strlen( be->bd_info->bi_type )
+               + STRLENOF( ")(namingContexts:distinguishedNameMatch:=" )
+               + suffix.bv_len + STRLENOF( "))" );
        ptr = filter->bv_val = ch_malloc( filter->bv_len + 1 );
-       ptr = lutil_strcopy( ptr, "(namingContexts:distinguishedNameMatch:=" );
+       ptr = lutil_strcopy( ptr, "(&(monitoredInfo=" );
+       ptr = lutil_strcopy( ptr, be->bd_info->bi_type );
+       ptr = lutil_strcopy( ptr, ")(namingContexts:distinguishedNameMatch:=" );
        ptr = lutil_strncopy( ptr, suffix.bv_val, suffix.bv_len );
-       ptr[ 0 ] = ')';
-       ptr++;
+       ptr = lutil_strcopy( ptr, "))" );
        ptr[ 0 ] = '\0';
        assert( filter->bv_len == ptr - filter->bv_val );
        
@@ -483,7 +485,7 @@ bdb_monitor_open( BackendDB *be )
        cb->mc_private = (void *)bdb;
 
        rc = monitor_back_register_entry_attrs( NULL, a, cb,
-               base, LDAP_SCOPE_ONELEVEL, filter );
+               base, LDAP_SCOPE_SUBORDINATE, filter );
 
 cleanup:;
        if ( rc != 0 ) {