1 /* monitor.c - monitor ldap backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2003-2012 The OpenLDAP Foundation.
6 * Portions Copyright 1999-2003 Howard Chu.
7 * Portions Copyright 2000-2003 Pierangelo Masarati.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
19 * This work was initially developed by the Howard Chu for inclusion
20 * in OpenLDAP Software and subsequently enhanced by Pierangelo
27 #include <ac/string.h>
28 #include <ac/unistd.h>
29 #include <ac/stdlib.h>
33 #include "back-ldap.h"
37 static ObjectClass *oc_olmLDAPDatabase;
38 static ObjectClass *oc_olmLDAPConnection;
40 static AttributeDescription *ad_olmDbURIList;
41 static AttributeDescription *ad_olmDbOperations;
42 static AttributeDescription *ad_olmDbBoundDN;
43 static AttributeDescription *ad_olmDbConnFlags;
44 static AttributeDescription *ad_olmDbConnURI;
47 * Stolen from back-monitor/operations.c
48 * We don't need the normalized rdn's though.
50 struct ldap_back_monitor_ops_t {
52 } ldap_back_monitor_op[] = {
53 { BER_BVC( "cn=Bind" ) },
54 { BER_BVC( "cn=Unbind" ) },
55 { BER_BVC( "cn=Search" ) },
56 { BER_BVC( "cn=Compare" ) },
57 { BER_BVC( "cn=Modify" ) },
58 { BER_BVC( "cn=Modrdn" ) },
59 { BER_BVC( "cn=Add" ) },
60 { BER_BVC( "cn=Delete" ) },
61 { BER_BVC( "cn=Abandon" ) },
62 { BER_BVC( "cn=Extended" ) },
67 /* Corresponds to connection flags in back-ldap.h */
72 { LDAP_BACK_FCONN_ISBOUND, BER_BVC( "bound" ) },
73 { LDAP_BACK_FCONN_ISANON, BER_BVC( "anonymous" ) },
74 { LDAP_BACK_FCONN_ISPRIV, BER_BVC( "privileged" ) },
75 { LDAP_BACK_FCONN_ISTLS, BER_BVC( "TLS" ) },
76 { LDAP_BACK_FCONN_BINDING, BER_BVC( "binding" ) },
77 { LDAP_BACK_FCONN_TAINTED, BER_BVC( "tainted" ) },
78 { LDAP_BACK_FCONN_ABANDON, BER_BVC( "abandon" ) },
79 { LDAP_BACK_FCONN_ISIDASR, BER_BVC( "idassert" ) },
80 { LDAP_BACK_FCONN_CACHED, BER_BVC( "cached" ) },
87 * NOTE: there's some confusion in monitor OID arc;
88 * by now, let's consider:
90 * Subsystems monitor attributes 1.3.6.1.4.1.4203.666.1.55.0
91 * Databases monitor attributes 1.3.6.1.4.1.4203.666.1.55.0.1
92 * LDAP database monitor attributes 1.3.6.1.4.1.4203.666.1.55.0.1.2
94 * Subsystems monitor objectclasses 1.3.6.1.4.1.4203.666.3.16.0
95 * Databases monitor objectclasses 1.3.6.1.4.1.4203.666.3.16.0.1
96 * LDAP database monitor objectclasses 1.3.6.1.4.1.4203.666.3.16.0.1.2
103 { "olmLDAPAttributes", "olmDatabaseAttributes:2" },
104 { "olmLDAPObjectClasses", "olmDatabaseObjectClasses:2" },
111 AttributeDescription **ad;
113 { "( olmLDAPAttributes:1 "
114 "NAME ( 'olmDbURIList' ) "
115 "DESC 'List of URIs a proxy is serving; can be modified run-time' "
118 { "( olmLDAPAttributes:2 "
119 "NAME ( 'olmDbOperation' ) "
120 "DESC 'monitor operations performed' "
121 "SUP monitorCounter "
122 "NO-USER-MODIFICATION "
123 "USAGE dSAOperation )",
124 &ad_olmDbOperations },
125 { "( olmLDAPAttributes:3 "
126 "NAME ( 'olmDbBoundDN' ) "
127 "DESC 'monitor connection authorization DN' "
128 "SUP monitorConnectionAuthzDN "
129 "NO-USER-MODIFICATION "
130 "USAGE dSAOperation )",
132 { "( olmLDAPAttributes:4 "
133 "NAME ( 'olmDbConnFlags' ) "
134 "DESC 'monitor connection flags' "
136 "NO-USER-MODIFICATION "
137 "USAGE dSAOperation )",
138 &ad_olmDbConnFlags },
139 { "( olmLDAPAttributes:5 "
140 "NAME ( 'olmDbConnURI' ) "
141 "DESC 'monitor connection URI' "
142 "SUP monitorConnectionPeerAddress "
143 "NO-USER-MODIFICATION "
144 "USAGE dSAOperation )",
154 /* augments an existing object, so it must be AUXILIARY
155 * FIXME: derive from some ABSTRACT "monitoredEntity"? */
156 { "( olmLDAPObjectClasses:1 "
157 "NAME ( 'olmLDAPDatabase' ) "
162 &oc_olmLDAPDatabase },
163 { "( olmLDAPObjectClasses:2 "
164 "NAME ( 'olmLDAPConnection' ) "
165 "SUP monitorConnection STRUCTURAL "
171 &oc_olmLDAPConnection },
177 ldap_back_monitor_update(
183 ldapinfo_t *li = (ldapinfo_t *)priv;
187 /* update olmDbURIList */
188 a = attr_find( e->e_attrs, ad_olmDbURIList );
192 assert( a->a_vals != NULL );
193 assert( !BER_BVISNULL( &a->a_vals[ 0 ] ) );
194 assert( BER_BVISNULL( &a->a_vals[ 1 ] ) );
196 ldap_pvt_thread_mutex_lock( &li->li_uri_mutex );
198 ber_str2bv( li->li_uri, 0, 0, &bv );
199 if ( !bvmatch( &a->a_vals[ 0 ], &bv ) ) {
200 ber_bvreplace( &a->a_vals[ 0 ], &bv );
203 ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex );
206 return SLAP_CB_CONTINUE;
210 ldap_back_monitor_modify(
216 ldapinfo_t *li = (ldapinfo_t *) priv;
218 Attribute *save_attrs = NULL;
220 *ml_olmDbURIList = NULL;
221 struct berval ul = BER_BVNULL;
224 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
225 if ( ml->sml_desc == ad_olmDbURIList ) {
226 if ( ml_olmDbURIList != NULL ) {
227 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
228 rs->sr_text = "conflicting modifications";
232 if ( ml->sml_op != LDAP_MOD_REPLACE ) {
233 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
234 rs->sr_text = "modification not allowed";
238 ml_olmDbURIList = ml;
245 return SLAP_CB_CONTINUE;
248 save_attrs = attrs_dup( e->e_attrs );
250 if ( ml_olmDbURIList != NULL ) {
252 LDAPURLDesc *ludlist = NULL;
255 ml = ml_olmDbURIList;
256 assert( ml->sml_nvalues != NULL );
258 if ( BER_BVISNULL( &ml->sml_nvalues[ 0 ] ) ) {
259 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
260 rs->sr_text = "no value provided";
264 if ( !BER_BVISNULL( &ml->sml_nvalues[ 1 ] ) ) {
265 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
266 rs->sr_text = "multiple values provided";
270 rc = ldap_url_parselist_ext( &ludlist,
271 ml->sml_nvalues[ 0 ].bv_val, NULL,
272 LDAP_PVT_URL_PARSE_NOEMPTY_HOST
273 | LDAP_PVT_URL_PARSE_DEF_PORT );
274 if ( rc != LDAP_URL_SUCCESS ) {
275 rs->sr_err = LDAP_INVALID_SYNTAX;
276 rs->sr_text = "unable to parse URI list";
280 ul.bv_val = ldap_url_list2urls( ludlist );
281 ldap_free_urllist( ludlist );
282 if ( ul.bv_val == NULL ) {
283 rs->sr_err = LDAP_OTHER;
286 ul.bv_len = strlen( ul.bv_val );
288 a = attr_find( e->e_attrs, ad_olmDbURIList );
290 if ( a->a_nvals == a->a_vals ) {
291 a->a_nvals = ch_calloc( sizeof( struct berval ), 2 );
294 ber_bvreplace( &a->a_vals[ 0 ], &ul );
295 ber_bvreplace( &a->a_nvals[ 0 ], &ul );
298 attr_merge_normalize_one( e, ad_olmDbURIList, &ul, NULL );
303 if ( !BER_BVISNULL( &ul ) ) {
304 ldap_pvt_thread_mutex_lock( &li->li_uri_mutex );
306 ch_free( li->li_uri );
308 li->li_uri = ul.bv_val;
309 ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex );
315 if ( !BER_BVISNULL( &ul ) ) {
316 ldap_memfree( ul.bv_val );
319 if ( rs->sr_err == LDAP_SUCCESS ) {
320 attrs_free( save_attrs );
321 return SLAP_CB_CONTINUE;
324 attrs_free( e->e_attrs );
325 e->e_attrs = save_attrs;
331 ldap_back_monitor_free(
335 ldapinfo_t *li = (ldapinfo_t *)(*priv);
339 if ( !slapd_shutdown ) {
340 memset( &li->li_monitor_info, 0, sizeof( li->li_monitor_info ) );
343 return SLAP_CB_CONTINUE;
347 ldap_back_monitor_subsystem_destroy(
349 monitor_subsys_t *ms)
351 free(ms->mss_dn.bv_val);
352 BER_BVZERO(&ms->mss_dn);
354 free(ms->mss_ndn.bv_val);
355 BER_BVZERO(&ms->mss_ndn);
361 * Connection monitoring subsystem:
362 * Tries to mimick what the cn=connections,cn=monitor subsystem does
363 * by creating volatile entries for each connection and populating them
364 * according to the information attached to the connection.
365 * At this moment the only exposed information is the DN used to bind it.
366 * Also note that the connection IDs are not and probably never will be
370 struct ldap_back_monitor_conn_arg {
371 monitor_subsys_t *ms;
376 ldap_back_monitor_conn_entry(
378 struct ldap_back_monitor_conn_arg *arg )
382 char buf[SLAP_TEXT_BUFLEN];
384 struct berval bv, dn, ndn;
390 bv.bv_len = snprintf( bv.bv_val, SLAP_TEXT_BUFLEN,
391 "cn=Connection %lu", lc->lc_connid );
393 build_new_dn( &dn, &arg->ms->mss_dn, &bv, NULL );
394 build_new_dn( &ndn, &arg->ms->mss_ndn, &bv, NULL );
401 attr_merge_normalize_one( e, slap_schema.si_ad_cn, &bv, NULL );
403 BER_BVSTR( &bv, "monitorContainer" );
404 attr_merge_normalize_one( e, slap_schema.si_ad_objectClass, &bv, NULL );
406 attr_merge_normalize_one( e, ad_olmDbBoundDN, &lc->lc_bound_ndn, NULL );
408 for ( i = 0; s_flag[i].flag; i++ )
410 if ( lc->lc_flags & s_flag[i].flag )
412 attr_merge_normalize_one( e, ad_olmDbConnFlags, &s_flag[i].name, NULL );
416 ldap_get_option( lc->lc_ld, LDAP_OPT_URI, &bv.bv_val );
417 ptr = strchr( bv.bv_val, ' ' );
418 bv.bv_len = ptr ? ptr - bv.bv_val : strlen(bv.bv_val);
419 attr_merge_normalize_one( e, ad_olmDbConnURI, &bv, NULL );
420 ch_free( bv.bv_val );
422 mp = monitor_entrypriv_create();
424 mp->mp_info = arg->ms;
425 mp->mp_flags = MONITOR_F_SUB | MONITOR_F_VOLATILE;
428 arg->ep = &mp->mp_next;
434 ldap_back_monitor_conn_create(
441 monitor_entry_t *mp_parent;
442 monitor_subsys_t *ms;
446 struct ldap_back_monitor_conn_arg *arg;
449 assert( e_parent->e_private != NULL );
451 mp_parent = e_parent->e_private;
452 ms = (monitor_subsys_t *)mp_parent->mp_info;
453 li = (ldapinfo_t *)ms->mss_private;
455 arg = ch_calloc( 1, sizeof(struct ldap_back_monitor_conn_arg) );
459 for ( conn_type = LDAP_BACK_PCONN_FIRST;
460 conn_type < LDAP_BACK_PCONN_LAST;
463 LDAP_TAILQ_FOREACH( lc,
464 &li->li_conn_priv[ conn_type ].lic_priv,
467 ldap_back_monitor_conn_entry( lc, arg );
471 avl_apply( li->li_conninfo.lai_tree, ldap_back_monitor_conn_entry,
472 arg, -1, AVL_INORDER );
480 ldap_back_monitor_conn_init(
482 monitor_subsys_t *ms )
484 ldapinfo_t *li = (ldapinfo_t *) ms->mss_private;
486 monitor_extra_t *mbe;
491 assert( be != NULL );
492 mi = (monitor_info_t *) be->be_private;
493 mbe = (monitor_extra_t *) be->bd_info->bi_extra;
495 ms->mss_dn = ms->mss_ndn = li->li_monitor_info.lmi_ndn;
496 ms->mss_rdn = li->li_monitor_info.lmi_conn_rdn;
497 ms->mss_create = ldap_back_monitor_conn_create;
498 ms->mss_destroy = ldap_back_monitor_subsystem_destroy;
500 e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn,
502 mi->mi_oc_monitorContainer, mi, NULL, NULL );
504 Debug( LDAP_DEBUG_ANY,
505 "ldap_back_monitor_conn_init: "
506 "unable to create entry \"%s,%s\"\n",
507 li->li_monitor_info.lmi_conn_rdn.bv_val,
508 ms->mss_ndn.bv_val, 0 );
512 ber_dupbv( &ms->mss_dn, &e->e_name );
513 ber_dupbv( &ms->mss_ndn, &e->e_nname );
515 rc = mbe->register_entry( e, NULL, ms, MONITOR_F_VOLATILE_CH );
517 /* add labeledURI and special, modifiable URI value */
518 if ( rc == LDAP_SUCCESS && li->li_uri != NULL ) {
521 LDAPURLDesc *ludlist = NULL;
522 monitor_callback_t *cb = NULL;
524 a = attr_alloc( ad_olmDbURIList );
526 ber_str2bv( li->li_uri, 0, 0, &bv );
527 attr_valadd( a, &bv, NULL, 1 );
528 attr_normalize( a->a_desc, a->a_vals, &a->a_nvals, NULL );
530 rc = ldap_url_parselist_ext( &ludlist,
532 LDAP_PVT_URL_PARSE_NOEMPTY_HOST
533 | LDAP_PVT_URL_PARSE_DEF_PORT );
534 if ( rc != LDAP_URL_SUCCESS ) {
535 Debug( LDAP_DEBUG_ANY,
536 "ldap_back_monitor_db_open: "
537 "unable to parse URI list (ignored)\n",
540 Attribute *a2 = attr_alloc( slap_schema.si_ad_labeledURI );
544 for ( ; ludlist != NULL; ) {
545 LDAPURLDesc *next = ludlist->lud_next;
547 bv.bv_val = ldap_url_desc2str( ludlist );
548 assert( bv.bv_val != NULL );
549 ldap_free_urldesc( ludlist );
550 bv.bv_len = strlen( bv.bv_val );
551 attr_valadd( a2, &bv, NULL, 1 );
552 ch_free( bv.bv_val );
557 attr_normalize( a2->a_desc, a2->a_vals, &a2->a_nvals, NULL );
560 cb = ch_calloc( sizeof( monitor_callback_t ), 1 );
561 cb->mc_update = ldap_back_monitor_update;
562 cb->mc_modify = ldap_back_monitor_modify;
563 cb->mc_free = ldap_back_monitor_free;
564 cb->mc_private = (void *)li;
566 rc = mbe->register_entry_attrs( &ms->mss_ndn, a, cb, NULL, 0, NULL );
568 attr_free( a->a_next );
571 if ( rc != LDAP_SUCCESS )
583 * Operation monitoring subsystem:
584 * Looks a lot like the cn=operations,cn=monitor subsystem except that at this
585 * moment, only completed operations are counted. Each entry has a separate
586 * callback with all the needed information linked there in the structure
587 * below so that the callback need not locate it over and over again.
590 struct ldap_back_monitor_op_counter {
592 ldap_pvt_thread_mutex_t *mutex;
596 ldap_back_monitor_ops_dispose(
599 struct ldap_back_monitor_op_counter *counter = *priv;
606 ldap_back_monitor_ops_free(
610 ldap_back_monitor_ops_dispose( priv );
615 ldap_back_monitor_ops_update(
621 struct ldap_back_monitor_op_counter *counter = priv;
625 * what about initiated/completed?
627 a = attr_find( e->e_attrs, ad_olmDbOperations );
630 ldap_pvt_thread_mutex_lock( counter->mutex );
631 UI2BV( &a->a_vals[ 0 ], *counter->data );
632 ldap_pvt_thread_mutex_unlock( counter->mutex );
634 return SLAP_CB_CONTINUE;
638 ldap_back_monitor_ops_init(
640 monitor_subsys_t *ms )
642 ldapinfo_t *li = (ldapinfo_t *) ms->mss_private;
645 monitor_extra_t *mbe;
649 struct berval value = BER_BVC( "0" );
651 assert( be != NULL );
653 mi = (monitor_info_t *) be->be_private;
654 mbe = (monitor_extra_t *) be->bd_info->bi_extra;
656 ms->mss_dn = ms->mss_ndn = li->li_monitor_info.lmi_ndn;
657 ms->mss_rdn = li->li_monitor_info.lmi_ops_rdn;
658 ms->mss_destroy = ldap_back_monitor_subsystem_destroy;
660 parent = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn,
662 mi->mi_oc_monitorContainer, mi, NULL, NULL );
663 if ( parent == NULL ) {
664 Debug( LDAP_DEBUG_ANY,
665 "ldap_back_monitor_ops_init: "
666 "unable to create entry \"%s,%s\"\n",
667 li->li_monitor_info.lmi_ops_rdn.bv_val,
668 ms->mss_ndn.bv_val, 0 );
672 ber_dupbv( &ms->mss_dn, &parent->e_name );
673 ber_dupbv( &ms->mss_ndn, &parent->e_nname );
675 rc = mbe->register_entry( parent, NULL, ms, MONITOR_F_PERSISTENT_CH );
676 if ( rc != LDAP_SUCCESS )
678 Debug( LDAP_DEBUG_ANY,
679 "ldap_back_monitor_ops_init: "
680 "unable to register entry \"%s\" for monitoring\n",
681 parent->e_name.bv_val, 0, 0 );
685 for ( op = 0; op < SLAP_OP_LAST; op++ )
687 monitor_callback_t *cb;
688 struct ldap_back_monitor_op_counter *counter;
690 e = monitor_entry_stub( &parent->e_name, &parent->e_nname,
691 &ldap_back_monitor_op[op].rdn,
692 mi->mi_oc_monitorCounterObject, mi, NULL, NULL );
694 Debug( LDAP_DEBUG_ANY,
695 "ldap_back_monitor_ops_init: "
696 "unable to create entry \"%s,%s\"\n",
697 ldap_back_monitor_op[op].rdn.bv_val,
698 parent->e_nname.bv_val, 0 );
702 attr_merge_normalize_one( e, ad_olmDbOperations, &value, NULL );
704 counter = ch_malloc( sizeof( struct ldap_back_monitor_op_counter ) );
705 counter->data = &li->li_ops_completed[ op ];
706 counter->mutex = &li->li_counter_mutex;
709 * We cannot share a single callback between entries.
711 * monitor_cache_destroy() tries to free all callbacks and it's called
712 * before mss_destroy() so we have no chance of handling it ourselves
714 cb = ch_calloc( sizeof( monitor_callback_t ), 1 );
715 cb->mc_update = ldap_back_monitor_ops_update;
716 cb->mc_free = ldap_back_monitor_ops_free;
717 cb->mc_dispose = ldap_back_monitor_ops_dispose;
718 cb->mc_private = (void *)counter;
720 rc = mbe->register_entry( e, cb, ms, 0 );
722 /* TODO: register_entry has stored a duplicate so we might actually reuse it
723 * instead of recreating it every time... */
726 if ( rc != LDAP_SUCCESS )
728 Debug( LDAP_DEBUG_ANY,
729 "ldap_back_monitor_ops_init: "
730 "unable to register entry \"%s\" for monitoring\n",
731 e->e_name.bv_val, 0, 0 );
738 entry_free( parent );
744 * call from within ldap_back_initialize()
747 ldap_back_monitor_initialize( void )
753 static int ldap_back_monitor_initialized = 0;
755 /* set to 0 when successfully initialized; otherwise, remember failure */
756 static int ldap_back_monitor_initialized_failure = 1;
758 /* register schema here; if compiled as dynamic object,
759 * must be loaded __after__ back_monitor.la */
761 if ( ldap_back_monitor_initialized++ ) {
762 return ldap_back_monitor_initialized_failure;
765 if ( backend_info( "monitor" ) == NULL ) {
769 argv[ 0 ] = "back-ldap monitor";
773 for ( i = 0; s_oid[ i ].name; i++ ) {
775 argv[ 1 ] = s_oid[ i ].name;
776 argv[ 2 ] = s_oid[ i ].oid;
778 if ( parse_oidm( &c, 0, NULL ) != 0 ) {
779 Debug( LDAP_DEBUG_ANY,
780 "ldap_back_monitor_initialize: unable to add "
781 "objectIdentifier \"%s=%s\"\n",
782 s_oid[ i ].name, s_oid[ i ].oid, 0 );
787 for ( i = 0; s_at[ i ].desc != NULL; i++ ) {
788 code = register_at( s_at[ i ].desc, s_at[ i ].ad, 1 );
789 if ( code != LDAP_SUCCESS ) {
790 Debug( LDAP_DEBUG_ANY,
791 "ldap_back_monitor_initialize: register_at failed for attributeType (%s)\n",
792 s_at[ i ].desc, 0, 0 );
796 (*s_at[ i ].ad)->ad_type->sat_flags |= SLAP_AT_HIDE;
800 for ( i = 0; s_oc[ i ].desc != NULL; i++ ) {
801 code = register_oc( s_oc[ i ].desc, s_oc[ i ].oc, 1 );
802 if ( code != LDAP_SUCCESS ) {
803 Debug( LDAP_DEBUG_ANY,
804 "ldap_back_monitor_initialize: register_oc failed for objectClass (%s)\n",
805 s_oc[ i ].desc, 0, 0 );
809 (*s_oc[ i ].oc)->soc_flags |= SLAP_OC_HIDE;
813 return ( ldap_back_monitor_initialized_failure = LDAP_SUCCESS );
817 * call from within ldap_back_db_init()
820 ldap_back_monitor_db_init( BackendDB *be )
824 rc = ldap_back_monitor_initialize();
825 if ( rc != LDAP_SUCCESS ) {
829 #if 0 /* uncomment to turn monitoring on by default */
830 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_MONITORING;
837 * call from within ldap_back_db_open()
840 ldap_back_monitor_db_open( BackendDB *be )
842 ldapinfo_t *li = (ldapinfo_t *) be->be_private;
843 monitor_subsys_t *mss = li->li_monitor_info.lmi_mss;
846 monitor_extra_t *mbe;
848 if ( !SLAP_DBMONITORING( be ) ) {
852 /* check if monitor is configured and usable */
853 mi = backend_info( "monitor" );
854 if ( !mi || !mi->bi_extra ) {
855 SLAP_DBFLAGS( be ) ^= SLAP_DBFLAG_MONITORING;
860 /* don't bother if monitor is not configured */
861 if ( !mbe->is_configured() ) {
862 static int warning = 0;
864 if ( warning++ == 0 ) {
865 Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: "
866 "monitoring disabled; "
867 "configure monitor database to enable\n",
874 /* caller (e.g. an overlay based on back-ldap) may want to use
875 * a different DN and RDNs... */
876 if ( BER_BVISNULL( &li->li_monitor_info.lmi_ndn ) ) {
877 rc = mbe->register_database( be, &li->li_monitor_info.lmi_ndn );
879 Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: "
880 "failed to register the databse with back-monitor\n",
884 if ( BER_BVISNULL( &li->li_monitor_info.lmi_conn_rdn ) ) {
885 ber_str2bv( "cn=Connections", 0, 1,
886 &li->li_monitor_info.lmi_conn_rdn );
888 if ( BER_BVISNULL( &li->li_monitor_info.lmi_ops_rdn ) ) {
889 ber_str2bv( "cn=Operations", 0, 1,
890 &li->li_monitor_info.lmi_ops_rdn );
893 /* set up the subsystems used to create the operation and
894 * volatile connection entries */
896 mss->mss_name = "back-ldap connections";
897 mss->mss_flags = MONITOR_F_VOLATILE_CH;
898 mss->mss_open = ldap_back_monitor_conn_init;
899 mss->mss_private = li;
901 if ( mbe->register_subsys( mss ) )
903 Debug( LDAP_DEBUG_ANY,
904 "ldap_back_monitor_db_open: "
905 "failed to register connection subsystem", 0, 0, 0 );
911 mss->mss_name = "back-ldap operations";
912 mss->mss_flags = MONITOR_F_PERSISTENT_CH;
913 mss->mss_open = ldap_back_monitor_ops_init;
914 mss->mss_private = li;
916 if ( mbe->register_subsys( mss ) )
918 Debug( LDAP_DEBUG_ANY,
919 "ldap_back_monitor_db_open: "
920 "failed to register operation subsystem", 0, 0, 0 );
928 * call from within ldap_back_db_close()
931 ldap_back_monitor_db_close( BackendDB *be )
933 ldapinfo_t *li = (ldapinfo_t *) be->be_private;
935 if ( li && !BER_BVISNULL( &li->li_monitor_info.lmi_ndn ) ) {
937 monitor_extra_t *mbe;
939 /* check if monitor is configured and usable */
940 mi = backend_info( "monitor" );
941 if ( mi && mi->bi_extra ) {
945 * Unregister all entries our subsystems have created.
946 * Will only really be necessary when
947 * SLAPD_CONFIG_DELETE is enabled.
949 * Might need a way to unregister subsystems instead.
958 * call from within ldap_back_db_destroy()
961 ldap_back_monitor_db_destroy( BackendDB *be )
963 ldapinfo_t *li = (ldapinfo_t *) be->be_private;
966 memset( &li->li_monitor_info, 0, sizeof( li->li_monitor_info ) );