1 /* init.c - initialize monitor backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2005 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
25 #include <ac/string.h>
30 #include "back-monitor.h"
32 #undef INTEGRATE_CORE_SCHEMA
35 * used by many functions to add description to entries
37 * WARNING: be_monitor may change as new databases are added,
38 * so it should not be used outside monitor_back_db_init()
39 * until monitor_back_db_open is called.
41 BackendDB *be_monitor;
43 static struct monitor_subsys_t **monitor_subsys;
44 static int monitor_subsys_opened;
45 static monitor_info_t monitor_info;
50 * the known subsystems are added to the subsystems
51 * array at backend initialization; other subsystems
52 * may be added by calling monitor_back_register_subsys()
53 * before the database is opened (e.g. by other backends
54 * or by overlays or modules).
56 static struct monitor_subsys_t known_monitor_subsys[] = {
58 SLAPD_MONITOR_BACKEND_NAME,
59 BER_BVNULL, BER_BVNULL, BER_BVNULL,
60 { BER_BVC( "This subsystem contains information about available backends." ),
62 MONITOR_F_PERSISTENT_CH,
63 monitor_subsys_backend_init,
68 SLAPD_MONITOR_CONN_NAME,
69 BER_BVNULL, BER_BVNULL, BER_BVNULL,
70 { BER_BVC( "This subsystem contains information about connections." ),
72 MONITOR_F_VOLATILE_CH,
73 monitor_subsys_conn_init,
74 monitor_subsys_conn_update,
75 monitor_subsys_conn_create,
78 SLAPD_MONITOR_DATABASE_NAME,
79 BER_BVNULL, BER_BVNULL, BER_BVNULL,
80 { BER_BVC( "This subsystem contains information about configured databases." ),
82 MONITOR_F_PERSISTENT_CH,
83 monitor_subsys_database_init,
86 monitor_subsys_database_modify
88 SLAPD_MONITOR_LISTENER_NAME,
89 BER_BVNULL, BER_BVNULL, BER_BVNULL,
90 { BER_BVC( "This subsystem contains information about active listeners." ),
92 MONITOR_F_PERSISTENT_CH,
93 monitor_subsys_listener_init,
98 SLAPD_MONITOR_LOG_NAME,
99 BER_BVNULL, BER_BVNULL, BER_BVNULL,
100 { BER_BVC( "This subsystem contains information about logging." ),
101 BER_BVC( "Set the attribute \"managedInfo\" to the desired log levels." ),
104 monitor_subsys_log_init,
107 monitor_subsys_log_modify
109 SLAPD_MONITOR_OPS_NAME,
110 BER_BVNULL, BER_BVNULL, BER_BVNULL,
111 { BER_BVC( "This subsystem contains information about performed operations." ),
113 MONITOR_F_PERSISTENT_CH,
114 monitor_subsys_ops_init,
115 monitor_subsys_ops_update,
119 SLAPD_MONITOR_OVERLAY_NAME,
120 BER_BVNULL, BER_BVNULL, BER_BVNULL,
121 { BER_BVC( "This subsystem contains information about available overlays." ),
123 MONITOR_F_PERSISTENT_CH,
124 monitor_subsys_overlay_init,
129 SLAPD_MONITOR_SASL_NAME,
130 BER_BVNULL, BER_BVNULL, BER_BVNULL,
131 { BER_BVC( "This subsystem contains information about SASL." ),
139 SLAPD_MONITOR_SENT_NAME,
140 BER_BVNULL, BER_BVNULL, BER_BVNULL,
141 { BER_BVC( "This subsystem contains statistics." ),
143 MONITOR_F_PERSISTENT_CH,
144 monitor_subsys_sent_init,
145 monitor_subsys_sent_update,
149 SLAPD_MONITOR_THREAD_NAME,
150 BER_BVNULL, BER_BVNULL, BER_BVNULL,
151 { BER_BVC( "This subsystem contains information about threads." ),
153 MONITOR_F_PERSISTENT_CH,
154 monitor_subsys_thread_init,
155 monitor_subsys_thread_update,
159 SLAPD_MONITOR_TIME_NAME,
160 BER_BVNULL, BER_BVNULL, BER_BVNULL,
161 { BER_BVC( "This subsystem contains information about time." ),
163 MONITOR_F_PERSISTENT_CH,
164 monitor_subsys_time_init,
165 monitor_subsys_time_update,
169 SLAPD_MONITOR_TLS_NAME,
170 BER_BVNULL, BER_BVNULL, BER_BVNULL,
171 { BER_BVC( "This subsystem contains information about TLS." ),
179 SLAPD_MONITOR_RWW_NAME,
180 BER_BVNULL, BER_BVNULL, BER_BVNULL,
181 { BER_BVC( "This subsystem contains information about read/write waiters." ),
183 MONITOR_F_PERSISTENT_CH,
184 monitor_subsys_rww_init,
185 monitor_subsys_rww_update,
192 monitor_back_register_subsys(
193 monitor_subsys_t *ms )
197 if ( monitor_subsys ) {
198 for ( ; monitor_subsys[ i ] != NULL; i++ )
199 /* just count'em */ ;
202 monitor_subsys = ch_realloc( monitor_subsys,
203 ( 2 + i ) * sizeof( monitor_subsys_t * ) );
205 if ( monitor_subsys == NULL ) {
209 monitor_subsys[ i ] = ms;
210 monitor_subsys[ i + 1 ] = NULL;
212 /* if a subsystem is registered __AFTER__ subsystem
213 * initialization (depending on the sequence the databases
214 * are listed in slapd.conf), init it */
215 if ( monitor_subsys_opened ) {
217 /* FIXME: this should only be possible
218 * if be_monitor is already initialized */
219 assert( be_monitor );
221 if ( ms->mss_open && ( *ms->mss_open )( be_monitor, ms ) ) {
225 ms->mss_flags |= MONITOR_F_OPENED;
238 typedef struct entry_limbo_t {
242 struct berval el_ndn;
243 struct berval el_base;
245 struct berval el_filter;
246 monitor_callback_t *el_cb;
247 struct entry_limbo_t *el_next;
251 monitor_back_register_entry(
253 monitor_callback_t *cb )
255 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
257 assert( mi != NULL );
259 assert( e->e_private == NULL );
261 if ( monitor_subsys_opened ) {
262 Entry *e_parent = NULL,
265 struct berval pdn = BER_BVNULL;
266 monitor_entry_t *mp = NULL,
270 if ( monitor_cache_get( mi, &e->e_nname, &e_parent ) == 0 ) {
272 Debug( LDAP_DEBUG_ANY,
273 "monitor_back_register_entry(\"%s\"): "
275 e->e_name.bv_val, 0, 0 );
276 monitor_cache_release( mi, e_parent );
280 dnParent( &e->e_nname, &pdn );
281 if ( monitor_cache_get( mi, &pdn, &e_parent ) != 0 ) {
282 /* parent does not exist */
283 Debug( LDAP_DEBUG_ANY,
284 "monitor_back_register_entry(\"%s\"): "
285 "parent \"%s\" not found\n",
286 e->e_name.bv_val, pdn.bv_val, 0 );
290 assert( e_parent->e_private != NULL );
291 mp_parent = ( monitor_entry_t * )e_parent->e_private;
293 if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) {
294 /* entry is volatile; cannot append children */
295 Debug( LDAP_DEBUG_ANY,
296 "monitor_back_register_entry(\"%s\"): "
297 "parent \"%s\" is volatile\n",
298 e->e_name.bv_val, e_parent->e_name.bv_val, 0 );
303 mp = monitor_entrypriv_create();
305 Debug( LDAP_DEBUG_ANY,
306 "monitor_back_register_entry(\"%s\"): "
307 "monitor_entrypriv_create() failed\n",
308 e->e_name.bv_val, 0, 0 );
313 e_new = entry_dup( e );
314 if ( e_new == NULL ) {
315 Debug( LDAP_DEBUG_ANY,
316 "monitor_back_register_entry(\"%s\"): "
317 "entry_dup() failed\n",
318 e->e_name.bv_val, 0, 0 );
323 e_new->e_private = ( void * )mp;
324 mp->mp_info = mp_parent->mp_info;
325 mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB;
328 ep = &mp_parent->mp_children;
330 mp_parent = ( monitor_entry_t * )(*ep)->e_private;
331 ep = &mp_parent->mp_next;
335 if ( monitor_cache_add( mi, e_new ) ) {
336 Debug( LDAP_DEBUG_ANY,
337 "monitor_back_register_entry(\"%s\"): "
338 "unable to add entry\n",
339 e->e_name.bv_val, 0, 0 );
350 e_new->e_private = NULL;
356 monitor_cache_release( mi, e_parent );
360 entry_limbo_t **elpp, el = { 0 };
362 el.el_type = LIMBO_ENTRY;
364 el.el_e = entry_dup( e );
365 if ( el.el_e == NULL ) {
366 Debug( LDAP_DEBUG_ANY,
367 "monitor_back_register_entry(\"%s\"): "
368 "entry_dup() failed\n",
369 e->e_name.bv_val, 0, 0 );
375 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
377 elpp = &(*elpp)->el_next )
380 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
381 if ( *elpp == NULL ) {
382 el.el_e->e_private = NULL;
383 entry_free( el.el_e );
395 monitor_back_register_entry_parent(
397 monitor_callback_t *cb,
400 struct berval *filter )
402 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
403 struct berval ndn = BER_BVNULL;
405 assert( mi != NULL );
407 assert( e->e_private == NULL );
409 if ( BER_BVISNULL( filter ) ) {
411 Debug( LDAP_DEBUG_ANY,
412 "monitor_back_register_entry_parent(\"\"): "
413 "need a valid filter\n",
418 if ( monitor_subsys_opened ) {
419 Entry *e_parent = NULL,
422 struct berval e_name = BER_BVNULL,
423 e_nname = BER_BVNULL;
424 monitor_entry_t *mp = NULL,
428 if ( monitor_filter2ndn( base, scope, filter, &ndn ) ) {
429 /* entry does not exist */
430 Debug( LDAP_DEBUG_ANY,
431 "monitor_back_register_entry_parent(\"\"): "
432 "base=%s scope=%d filter=%s : "
433 "unable to find entry\n",
434 base->bv_val ? base->bv_val : "\"\"",
435 scope, filter->bv_val );
439 if ( monitor_cache_get( mi, &ndn, &e_parent ) != 0 ) {
440 /* entry does not exist */
441 Debug( LDAP_DEBUG_ANY,
442 "monitor_back_register_entry_parent(\"%s\"): "
443 "parent entry does not exist\n",
449 assert( e_parent->e_private != NULL );
450 mp_parent = ( monitor_entry_t * )e_parent->e_private;
452 if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) {
453 /* entry is volatile; cannot append callback */
454 Debug( LDAP_DEBUG_ANY,
455 "monitor_back_register_entry_parent(\"%s\"): "
456 "entry is volatile\n",
457 e_parent->e_name.bv_val, 0, 0 );
462 build_new_dn( &e_name, &e_parent->e_name, &e->e_name, NULL );
463 build_new_dn( &e_nname, &e_parent->e_nname, &e->e_nname, NULL );
465 if ( monitor_cache_get( mi, &e_nname, &e_new ) == 0 ) {
466 /* entry already exists */
467 Debug( LDAP_DEBUG_ANY,
468 "monitor_back_register_entry_parent(\"%s\"): "
469 "entry already exists\n",
470 e_name.bv_val, 0, 0 );
471 monitor_cache_release( mi, e_new );
476 mp = monitor_entrypriv_create();
478 Debug( LDAP_DEBUG_ANY,
479 "monitor_back_register_entry_parent(\"%s\"): "
480 "monitor_entrypriv_create() failed\n",
481 e->e_name.bv_val, 0, 0 );
486 e_new = entry_dup( e );
487 if ( e_new == NULL ) {
488 Debug( LDAP_DEBUG_ANY,
489 "monitor_back_register_entry(\"%s\"): "
490 "entry_dup() failed\n",
491 e->e_name.bv_val, 0, 0 );
495 ch_free( e_new->e_name.bv_val );
496 ch_free( e_new->e_nname.bv_val );
497 e_new->e_name = e_name;
498 e_new->e_nname = e_nname;
500 e_new->e_private = ( void * )mp;
501 mp->mp_info = mp_parent->mp_info;
502 mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB;
505 ep = &mp_parent->mp_children;
507 mp_parent = ( monitor_entry_t * )(*ep)->e_private;
508 ep = &mp_parent->mp_next;
512 if ( monitor_cache_add( mi, e_new ) ) {
513 Debug( LDAP_DEBUG_ANY,
514 "monitor_back_register_entry(\"%s\"): "
515 "unable to add entry\n",
516 e->e_name.bv_val, 0, 0 );
522 if ( !BER_BVISNULL( &ndn ) ) {
523 ch_free( ndn.bv_val );
531 e_new->e_private = NULL;
537 monitor_cache_release( mi, e_parent );
541 entry_limbo_t **elpp, el = { 0 };
543 el.el_type = LIMBO_ENTRY_PARENT;
545 el.el_e = entry_dup( e );
546 if ( el.el_e == NULL ) {
547 Debug( LDAP_DEBUG_ANY,
548 "monitor_back_register_entry(\"%s\"): "
549 "entry_dup() failed\n",
550 e->e_name.bv_val, 0, 0 );
554 if ( !BER_BVISNULL( base ) ) {
555 ber_dupbv( &el.el_base, base );
558 if ( !BER_BVISNULL( filter ) ) {
559 ber_dupbv( &el.el_filter, filter );
564 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
566 elpp = &(*elpp)->el_next )
569 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
570 if ( *elpp == NULL ) {
571 el.el_e->e_private = NULL;
572 entry_free( el.el_e );
584 monitor_filter2ndn_cb( Operation *op, SlapReply *rs )
586 if ( rs->sr_type == REP_SEARCH ) {
587 struct berval *ndn = op->o_callback->sc_private;
589 ber_dupbv( ndn, &rs->sr_entry->e_nname );
599 struct berval *filter,
602 Connection conn = { 0 };
603 char opbuf[OPERATION_BUFFER_SIZE];
605 SlapReply rs = { 0 };
606 slap_callback cb = { NULL, monitor_filter2ndn_cb, NULL, NULL };
611 if ( be_monitor == NULL ) {
615 op = (Operation *)opbuf;
616 connection_fake_init( &conn, op, &conn );
618 op->o_tag = LDAP_REQ_SEARCH;
620 /* use global malloc for now */
621 op->o_tmpmemctx = NULL;
622 op->o_tmpmfuncs = &ch_mfuncs;
624 op->o_bd = be_monitor;
625 if ( base == NULL || BER_BVISNULL( base ) ) {
626 ber_dupbv_x( &op->o_req_dn, &op->o_bd->be_suffix[ 0 ],
628 ber_dupbv_x( &op->o_req_ndn, &op->o_bd->be_nsuffix[ 0 ],
632 if ( dnPrettyNormal( NULL, base, &op->o_req_dn, &op->o_req_ndn,
633 op->o_tmpmemctx ) ) {
638 op->o_callback = &cb;
639 cb.sc_private = (void *)ndn;
641 op->ors_scope = scope;
642 ber_dupbv_x( &op->ors_filterstr, filter, op->o_tmpmemctx );
643 op->ors_filter = str2filter_x( op, filter->bv_val );
644 op->ors_attrs = slap_anlist_no_attrs;
645 op->ors_attrsonly = 0;
646 op->ors_tlimit = SLAP_NO_LIMIT;
648 op->ors_limit = NULL;
649 op->ors_deref = LDAP_DEREF_NEVER;
652 op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
654 op->o_dn = be_monitor->be_rootdn;
655 op->o_ndn = be_monitor->be_rootndn;
657 rc = op->o_bd->be_search( op, &rs );
659 filter_free_x( op, op->ors_filter );
660 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
661 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
662 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
668 switch ( rs.sr_err ) {
670 if ( BER_BVISNULL( ndn ) ) {
675 case LDAP_SIZELIMIT_EXCEEDED:
677 if ( !BER_BVISNULL( ndn ) ) {
678 ber_memfree( ndn->bv_val );
689 monitor_back_register_entry_attrs(
690 struct berval *ndn_in,
692 monitor_callback_t *cb,
695 struct berval *filter )
697 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
698 struct berval ndn = BER_BVNULL;
700 assert( mi != NULL );
702 if ( ndn_in != NULL ) {
706 if ( a == NULL && cb == NULL ) {
711 if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) )
712 && BER_BVISNULL( filter ) )
715 Debug( LDAP_DEBUG_ANY,
716 "monitor_back_register_entry_*(\"\"): "
717 "need a valid filter\n",
722 if ( monitor_subsys_opened ) {
724 Attribute **atp = NULL;
725 monitor_entry_t *mp = NULL;
726 monitor_callback_t **mcp = NULL;
730 if ( BER_BVISNULL( &ndn ) ) {
731 if ( monitor_filter2ndn( base, scope, filter, &ndn ) ) {
732 /* entry does not exist */
733 Debug( LDAP_DEBUG_ANY,
734 "monitor_back_register_entry_*(\"\"): "
735 "base=%s scope=%d filter=%s : "
736 "unable to find entry\n",
737 base->bv_val ? base->bv_val : "\"\"",
738 scope, filter->bv_val );
745 if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) {
746 /* entry does not exist */
747 Debug( LDAP_DEBUG_ANY,
748 "monitor_back_register_entry_*(\"%s\"): "
749 "entry does not exist\n",
755 assert( e->e_private != NULL );
756 mp = ( monitor_entry_t * )e->e_private;
758 if ( mp->mp_flags & MONITOR_F_VOLATILE ) {
759 /* entry is volatile; cannot append callback */
760 Debug( LDAP_DEBUG_ANY,
761 "monitor_back_register_entry_*(\"%s\"): "
762 "entry is volatile\n",
763 e->e_name.bv_val, 0, 0 );
769 for ( atp = &e->e_attrs; *atp; atp = &(*atp)->a_next )
770 /* just get to last */ ;
772 *atp = attrs_dup( a );
773 if ( *atp == NULL ) {
774 Debug( LDAP_DEBUG_ANY,
775 "monitor_back_register_entry_*(\"%s\"): "
776 "attrs_dup() failed\n",
777 e->e_name.bv_val, 0, 0 );
784 for ( mcp = &mp->mp_cb; *mcp; mcp = &(*mcp)->mc_next )
787 /* NOTE: we do not clear cb->mc_next, so this function
788 * can be used to append a list of callbacks */
801 ber_memfree( ndn.bv_val );
805 monitor_cache_release( mi, e );
809 entry_limbo_t **elpp, el = { 0 };
811 el.el_type = LIMBO_ATTRS;
812 if ( !BER_BVISNULL( &ndn ) ) {
813 ber_dupbv( &el.el_ndn, &ndn );
815 if ( !BER_BVISNULL( base ) ) {
816 ber_dupbv( &el.el_base, base);
819 if ( !BER_BVISNULL( filter ) ) {
820 ber_dupbv( &el.el_filter, filter );
823 el.el_a = attrs_dup( a );
826 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
828 elpp = &(*elpp)->el_next )
831 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
832 if ( *elpp == NULL ) {
833 el.el_e->e_private = NULL;
834 entry_free( el.el_e );
846 monitor_back_register_entry_callback(
848 monitor_callback_t *cb,
851 struct berval *filter )
853 return monitor_back_register_entry_attrs( ndn, NULL, cb,
854 base, scope, filter );
858 monitor_back_get_subsys( const char *name )
860 if ( monitor_subsys != NULL ) {
863 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
864 if ( strcasecmp( monitor_subsys[ i ]->mss_name, name ) == 0 ) {
865 return monitor_subsys[ i ];
874 monitor_back_get_subsys_by_dn(
878 if ( monitor_subsys != NULL ) {
882 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
883 if ( dnIsSuffix( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
884 return monitor_subsys[ i ];
889 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
890 if ( dn_match( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
891 return monitor_subsys[ i ];
901 monitor_back_initialize(
904 monitor_subsys_t *ms;
905 static char *controls[] = {
906 LDAP_CONTROL_MANAGEDSAIT,
909 monitor_info_t *mi = &monitor_info;
919 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
921 "DESC 'OpenLDAP system monitoring' "
922 "SUP top STRUCTURAL "
931 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
932 offsetof(monitor_info_t, mi_oc_monitor) },
933 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
934 "NAME 'monitorServer' "
935 "DESC 'Server monitoring root entry' "
936 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
937 offsetof(monitor_info_t, mi_oc_monitorServer) },
938 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
939 "NAME 'monitorContainer' "
940 "DESC 'monitor container class' "
941 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
942 offsetof(monitor_info_t, mi_oc_monitorContainer) },
943 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
944 "NAME 'monitorCounterObject' "
945 "DESC 'monitor counter class' "
946 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
947 offsetof(monitor_info_t, mi_oc_monitorCounterObject) },
948 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
949 "NAME 'monitorOperation' "
950 "DESC 'monitor operation class' "
951 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
952 offsetof(monitor_info_t, mi_oc_monitorOperation) },
953 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
954 "NAME 'monitorConnection' "
955 "DESC 'monitor connection class' "
956 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
957 offsetof(monitor_info_t, mi_oc_monitorConnection) },
958 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
959 "NAME 'managedObject' "
960 "DESC 'monitor managed entity class' "
961 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
962 offsetof(monitor_info_t, mi_oc_managedObject) },
963 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.14 "
964 "NAME 'monitoredObject' "
965 "DESC 'monitor monitored entity class' "
966 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
967 offsetof(monitor_info_t, mi_oc_monitoredObject) },
968 { NULL, NULL, 0, -1 }
970 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
971 "NAME 'monitoredInfo' "
972 "DESC 'monitored info' "
974 "EQUALITY caseIgnoreMatch "
975 "SUBSTR caseIgnoreSubstringsMatch "
976 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
977 "NO-USER-MODIFICATION "
978 "USAGE directoryOperation )", SLAP_AT_HIDE,
979 offsetof(monitor_info_t, mi_ad_monitoredInfo) },
980 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
981 "NAME 'managedInfo' "
982 "DESC 'monitor managed info' "
983 "SUP name )", SLAP_AT_HIDE,
984 offsetof(monitor_info_t, mi_ad_managedInfo) },
985 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
986 "NAME 'monitorCounter' "
987 "DESC 'monitor counter' "
988 "EQUALITY integerMatch "
989 "ORDERING integerOrderingMatch "
990 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
991 "NO-USER-MODIFICATION "
992 "USAGE directoryOperation )", SLAP_AT_HIDE,
993 offsetof(monitor_info_t, mi_ad_monitorCounter) },
994 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
995 "NAME 'monitorOpCompleted' "
996 "DESC 'monitor completed operations' "
997 "SUP monitorCounter "
998 "NO-USER-MODIFICATION "
999 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1000 offsetof(monitor_info_t, mi_ad_monitorOpCompleted) },
1001 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
1002 "NAME 'monitorOpInitiated' "
1003 "DESC 'monitor initiated operations' "
1004 "SUP monitorCounter "
1005 "NO-USER-MODIFICATION "
1006 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1007 offsetof(monitor_info_t, mi_ad_monitorOpInitiated) },
1008 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
1009 "NAME 'monitorConnectionNumber' "
1010 "DESC 'monitor connection number' "
1011 "SUP monitorCounter "
1012 "NO-USER-MODIFICATION "
1013 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1014 offsetof(monitor_info_t, mi_ad_monitorConnectionNumber) },
1015 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
1016 "NAME 'monitorConnectionAuthzDN' "
1017 "DESC 'monitor connection authorization DN' "
1018 /* "SUP distinguishedName " */
1019 "EQUALITY distinguishedNameMatch "
1020 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
1021 "NO-USER-MODIFICATION "
1022 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1023 offsetof(monitor_info_t, mi_ad_monitorConnectionAuthzDN) },
1024 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
1025 "NAME 'monitorConnectionLocalAddress' "
1026 "DESC 'monitor connection local address' "
1027 "SUP monitoredInfo "
1028 "NO-USER-MODIFICATION "
1029 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1030 offsetof(monitor_info_t, mi_ad_monitorConnectionLocalAddress) },
1031 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
1032 "NAME 'monitorConnectionPeerAddress' "
1033 "DESC 'monitor connection peer address' "
1034 "SUP monitoredInfo "
1035 "NO-USER-MODIFICATION "
1036 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1037 offsetof(monitor_info_t, mi_ad_monitorConnectionPeerAddress) },
1038 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
1039 "NAME 'monitorTimestamp' "
1040 "DESC 'monitor timestamp' "
1041 "EQUALITY generalizedTimeMatch "
1042 "ORDERING generalizedTimeOrderingMatch "
1043 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
1045 "NO-USER-MODIFICATION "
1046 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1047 offsetof(monitor_info_t, mi_ad_monitorTimestamp) },
1048 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
1049 "NAME 'monitorOverlay' "
1050 "DESC 'name of overlays defined for a given database' "
1051 "SUP monitoredInfo "
1052 "NO-USER-MODIFICATION "
1053 "USAGE directoryOperation )", SLAP_AT_HIDE,
1054 offsetof(monitor_info_t, mi_ad_monitorOverlay) },
1055 { "readOnly", "( 1.3.6.1.4.1.4203.666.1.31 "
1057 "DESC 'read/write status of a given database' "
1058 "EQUALITY booleanMatch "
1059 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
1061 "USAGE directoryOperation )", SLAP_AT_HIDE,
1062 offsetof(monitor_info_t, mi_ad_readOnly) },
1063 { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.32 "
1064 "NAME 'restrictedOperation' "
1065 "DESC 'name of restricted operation for a given database' "
1066 "SUP managedInfo )", SLAP_AT_HIDE,
1067 offsetof(monitor_info_t, mi_ad_restrictedOperation ) },
1068 { "monitorConnectionProtocol", "( 1.3.6.1.4.1.4203.666.1.39 "
1069 "NAME 'monitorConnectionProtocol' "
1070 "DESC 'monitor connection protocol' "
1071 "SUP monitoredInfo "
1072 "NO-USER-MODIFICATION "
1073 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1074 offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) },
1075 { "monitorConnectionOpsReceived", "( 1.3.6.1.4.1.4203.666.1.40 "
1076 "NAME 'monitorConnectionOpsReceived' "
1077 "DESC 'monitor number of operations received by the connection' "
1078 "SUP monitorCounter "
1079 "NO-USER-MODIFICATION "
1080 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1081 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) },
1082 { "monitorConnectionOpsExecuting", "( 1.3.6.1.4.1.4203.666.1.41 "
1083 "NAME 'monitorConnectionOpsExecuting' "
1084 "DESC 'monitor number of operations in execution within the connection' "
1085 "SUP monitorCounter "
1086 "NO-USER-MODIFICATION "
1087 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1088 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) },
1089 { "monitorConnectionOpsPending", "( 1.3.6.1.4.1.4203.666.1.42 "
1090 "NAME 'monitorConnectionOpsPending' "
1091 "DESC 'monitor number of pending operations within the connection' "
1092 "SUP monitorCounter "
1093 "NO-USER-MODIFICATION "
1094 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1095 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) },
1096 { "monitorConnectionOpsCompleted", "( 1.3.6.1.4.1.4203.666.1.43 "
1097 "NAME 'monitorConnectionOpsCompleted' "
1098 "DESC 'monitor number of operations completed within the connection' "
1099 "SUP monitorCounter "
1100 "NO-USER-MODIFICATION "
1101 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1102 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) },
1103 { "monitorConnectionGet", "( 1.3.6.1.4.1.4203.666.1.44 "
1104 "NAME 'monitorConnectionGet' "
1105 "DESC 'number of times connection_get() was called so far' "
1106 "SUP monitorCounter "
1107 "NO-USER-MODIFICATION "
1108 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1109 offsetof(monitor_info_t, mi_ad_monitorConnectionGet) },
1110 { "monitorConnectionRead", "( 1.3.6.1.4.1.4203.666.1.45 "
1111 "NAME 'monitorConnectionRead' "
1112 "DESC 'number of times connection_read() was called so far' "
1113 "SUP monitorCounter "
1114 "NO-USER-MODIFICATION "
1115 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1116 offsetof(monitor_info_t, mi_ad_monitorConnectionRead) },
1117 { "monitorConnectionWrite", "( 1.3.6.1.4.1.4203.666.1.46 "
1118 "NAME 'monitorConnectionWrite' "
1119 "DESC 'number of times connection_write() was called so far' "
1120 "SUP monitorCounter "
1121 "NO-USER-MODIFICATION "
1122 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1123 offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) },
1124 { "monitorConnectionMask", "( 1.3.6.1.4.1.4203.666.1.47 "
1125 "NAME 'monitorConnectionMask' "
1126 "DESC 'monitor connection mask' "
1127 "SUP monitoredInfo "
1128 "NO-USER-MODIFICATION "
1129 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1130 offsetof(monitor_info_t, mi_ad_monitorConnectionMask) },
1131 { "monitorConnectionListener", "( 1.3.6.1.4.1.4203.666.1.48 "
1132 "NAME 'monitorConnectionListener' "
1133 "DESC 'monitor connection listener' "
1134 "SUP monitoredInfo "
1135 "NO-USER-MODIFICATION "
1136 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1137 offsetof(monitor_info_t, mi_ad_monitorConnectionListener) },
1138 { "monitorConnectionPeerDomain", "( 1.3.6.1.4.1.4203.666.1.49 "
1139 "NAME 'monitorConnectionPeerDomain' "
1140 "DESC 'monitor connection peer domain' "
1141 "SUP monitoredInfo "
1142 "NO-USER-MODIFICATION "
1143 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1144 offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) },
1145 { "monitorConnectionStartTime", "( 1.3.6.1.4.1.4203.666.1.50 "
1146 "NAME 'monitorConnectionStartTime' "
1147 "DESC 'monitor connection start time' "
1148 "SUP monitorTimestamp "
1150 "NO-USER-MODIFICATION "
1151 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1152 offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) },
1153 { "monitorConnectionActivityTime", "( 1.3.6.1.4.1.4203.666.1.51 "
1154 "NAME 'monitorConnectionActivityTime' "
1155 "DESC 'monitor connection activity time' "
1156 "SUP monitorTimestamp "
1158 "NO-USER-MODIFICATION "
1159 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1160 offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) },
1161 { NULL, NULL, 0, -1 }
1164 bi->bi_controls = controls;
1168 bi->bi_config = monitor_back_config;
1172 bi->bi_db_init = monitor_back_db_init;
1173 bi->bi_db_config = monitor_back_db_config;
1174 bi->bi_db_open = monitor_back_db_open;
1175 bi->bi_db_close = 0;
1176 bi->bi_db_destroy = monitor_back_db_destroy;
1178 bi->bi_op_bind = monitor_back_bind;
1179 bi->bi_op_unbind = 0;
1180 bi->bi_op_search = monitor_back_search;
1181 bi->bi_op_compare = monitor_back_compare;
1182 bi->bi_op_modify = monitor_back_modify;
1183 bi->bi_op_modrdn = 0;
1185 bi->bi_op_delete = 0;
1186 bi->bi_op_abandon = 0;
1188 bi->bi_extended = 0;
1190 bi->bi_entry_release_rw = 0;
1191 bi->bi_chk_referrals = 0;
1192 bi->bi_operational = monitor_back_operational;
1195 * hooks for slap tools
1197 bi->bi_tool_entry_open = 0;
1198 bi->bi_tool_entry_close = 0;
1199 bi->bi_tool_entry_first = 0;
1200 bi->bi_tool_entry_next = 0;
1201 bi->bi_tool_entry_get = 0;
1202 bi->bi_tool_entry_put = 0;
1203 bi->bi_tool_entry_reindex = 0;
1204 bi->bi_tool_sync = 0;
1205 bi->bi_tool_dn2id_get = 0;
1206 bi->bi_tool_id2entry_get = 0;
1207 bi->bi_tool_entry_modify = 0;
1209 bi->bi_connection_init = 0;
1210 bi->bi_connection_destroy = 0;
1212 for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
1213 if ( monitor_back_register_subsys( ms ) ) {
1218 /* schema integration */
1219 for ( i = 0; mat[ i ].name; i++ ) {
1220 LDAPAttributeType *at;
1223 AttributeDescription **ad;
1225 at = ldap_str2attributetype( mat[ i ].schema, &code,
1226 &err, LDAP_SCHEMA_ALLOW_ALL );
1228 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1229 "in AttributeType \"%s\" %s before %s\n",
1230 mat[ i ].name, ldap_scherr2str(code), err );
1234 if ( at->at_oid == NULL ) {
1235 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1236 "null OID for attributeType \"%s\"\n",
1237 mat[ i ].name, 0, 0 );
1241 code = at_add(at, 0, NULL, &err);
1243 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1244 "%s in attributeType \"%s\"\n",
1245 scherr2str(code), mat[ i ].name, 0 );
1250 ad = ((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ]));
1252 if ( slap_str2ad( mat[ i ].name, ad, &text ) ) {
1253 Debug( LDAP_DEBUG_ANY,
1254 "monitor_back_db_init: %s\n", text, 0, 0 );
1258 (*ad)->ad_type->sat_flags |= mat[ i ].flags;
1261 for ( i = 0; moc[ i ].name; i++ ) {
1262 LDAPObjectClass *oc;
1267 oc = ldap_str2objectclass(moc[ i ].schema, &code, &err,
1268 LDAP_SCHEMA_ALLOW_ALL );
1270 Debug( LDAP_DEBUG_ANY,
1271 "unable to parse monitor objectclass \"%s\": "
1272 "%s before %s\n" , moc[ i ].name,
1273 ldap_scherr2str(code), err );
1277 if ( oc->oc_oid == NULL ) {
1278 Debug( LDAP_DEBUG_ANY,
1279 "objectclass \"%s\" has no OID\n" ,
1280 moc[ i ].name, 0, 0 );
1284 code = oc_add(oc, 0, NULL, &err);
1286 Debug( LDAP_DEBUG_ANY,
1287 "objectclass \"%s\": %s \"%s\"\n" ,
1288 moc[ i ].name, scherr2str(code), err );
1294 Oc = oc_find( moc[ i ].name );
1296 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1297 "unable to find objectClass %s "
1298 "(just added)\n", moc[ i ].name, 0, 0 );
1302 Oc->soc_flags |= moc[ i ].flags;
1304 ((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]))[ 0 ] = Oc;
1311 monitor_back_db_init(
1316 struct berval dn, ndn;
1320 * database monitor can be defined once only
1322 if ( be_monitor != NULL ) {
1323 Debug( LDAP_DEBUG_ANY,
1324 "only one monitor database is allowed\n", 0, 0, 0 );
1329 /* indicate system schema supported */
1330 SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
1332 dn.bv_val = SLAPD_MONITOR_DN;
1333 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
1335 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
1336 if( rc != LDAP_SUCCESS ) {
1337 Debug( LDAP_DEBUG_ANY,
1338 "unable to normalize monitor DN \"%s\"\n",
1339 SLAPD_MONITOR_DN, 0, 0 );
1343 ber_dupbv( &bv, &dn );
1344 ber_bvarray_add( &be->be_suffix, &bv );
1345 ber_bvarray_add( &be->be_nsuffix, &ndn );
1347 /* NOTE: only one monitor database is allowed,
1348 * so we use static storage */
1351 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
1353 be->be_private = mi;
1359 monitor_back_db_open(
1362 monitor_info_t *mi = (monitor_info_t *)be->be_private;
1363 struct monitor_subsys_t **ms;
1365 monitor_entry_t *mp;
1367 char buf[ BACKMONITOR_BUFSIZE ],
1371 #ifdef HAVE_GMTIME_R
1374 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
1376 assert( be_monitor );
1377 if ( be != be_monitor ) {
1384 #ifndef HAVE_GMTIME_R
1385 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
1387 #ifdef HACK_LOCAL_TIME
1388 # ifdef HAVE_LOCALTIME_R
1389 tms = localtime_r( &starttime, &tm_buf );
1391 tms = localtime( &starttime );
1392 # endif /* HAVE_LOCALTIME_R */
1393 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
1394 #else /* !HACK_LOCAL_TIME */
1395 # ifdef HAVE_GMTIME_R
1396 tms = gmtime_r( &starttime, &tm_buf );
1398 tms = gmtime( &starttime );
1399 # endif /* HAVE_GMTIME_R */
1400 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
1401 #endif /* !HACK_LOCAL_TIME */
1402 #ifndef HAVE_GMTIME_R
1403 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
1406 mi->mi_startTime.bv_val = tmbuf;
1407 mi->mi_startTime.bv_len = strlen( tmbuf );
1409 if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
1410 BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
1412 mi->mi_creatorsName = be->be_rootdn;
1416 * creates the "cn=Monitor" entry
1418 snprintf( buf, sizeof( buf ),
1421 "structuralObjectClass: %s\n"
1423 "description: This subtree contains monitoring/managing objects.\n"
1424 "description: This object contains information about this server.\n"
1425 "description: Most of the information is contained in operational\n"
1426 "description: attributeTypes, which must be explicitly requested.\n"
1427 "creatorsName: %s\n"
1428 "modifiersName: %s\n"
1429 "createTimestamp: %s\n"
1430 "modifyTimestamp: %s\n",
1432 mi->mi_oc_monitorServer->soc_cname.bv_val,
1433 mi->mi_oc_monitorServer->soc_cname.bv_val,
1434 mi->mi_creatorsName.bv_val,
1435 mi->mi_creatorsName.bv_val,
1436 mi->mi_startTime.bv_val,
1437 mi->mi_startTime.bv_val );
1439 e = str2entry( buf );
1441 Debug( LDAP_DEBUG_ANY,
1442 "unable to create \"%s\" entry\n",
1443 SLAPD_MONITOR_DN, 0, 0 );
1447 bv.bv_val = (char *) Versionstr;
1448 end_of_line = strchr( Versionstr, '\n' );
1449 if ( end_of_line ) {
1450 bv.bv_len = end_of_line - Versionstr;
1452 bv.bv_len = strlen( Versionstr );
1455 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
1457 Debug( LDAP_DEBUG_ANY,
1458 "unable to add monitoredInfo to \"%s\" entry\n",
1459 SLAPD_MONITOR_DN, 0, 0 );
1463 mp = monitor_entrypriv_create();
1467 e->e_private = ( void * )mp;
1468 ep = &mp->mp_children;
1470 if ( monitor_cache_add( mi, e ) ) {
1471 Debug( LDAP_DEBUG_ANY,
1472 "unable to add entry \"%s\" to cache\n",
1473 SLAPD_MONITOR_DN, 0, 0 );
1478 * Create all the subsystem specific entries
1480 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
1481 int len = strlen( monitor_subsys[ i ]->mss_name );
1485 dn.bv_len = len + sizeof( "cn=" ) - 1;
1486 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
1487 strcpy( dn.bv_val, "cn=" );
1488 strcat( dn.bv_val, monitor_subsys[ i ]->mss_name );
1489 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL );
1491 if ( rc != LDAP_SUCCESS ) {
1492 Debug( LDAP_DEBUG_ANY,
1493 "monitor RDN \"%s\" is invalid\n",
1498 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
1499 dn.bv_val = ch_malloc( dn.bv_len + 1 );
1500 strcpy( dn.bv_val , monitor_subsys[ i ]->mss_rdn.bv_val );
1501 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
1502 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ]->mss_dn,
1503 &monitor_subsys[ i ]->mss_ndn, NULL );
1505 if ( rc != LDAP_SUCCESS ) {
1506 Debug( LDAP_DEBUG_ANY,
1507 "monitor DN \"%s\" is invalid\n",
1512 snprintf( buf, sizeof( buf ),
1515 "structuralObjectClass: %s\n"
1517 "creatorsName: %s\n"
1518 "modifiersName: %s\n"
1519 "createTimestamp: %s\n"
1520 "modifyTimestamp: %s\n",
1521 monitor_subsys[ i ]->mss_dn.bv_val,
1522 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1523 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1524 monitor_subsys[ i ]->mss_name,
1525 mi->mi_creatorsName.bv_val,
1526 mi->mi_creatorsName.bv_val,
1527 mi->mi_startTime.bv_val,
1528 mi->mi_startTime.bv_val );
1530 e = str2entry( buf );
1533 Debug( LDAP_DEBUG_ANY,
1534 "unable to create \"%s\" entry\n",
1535 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1539 if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_desc[ 0 ] ) ) {
1540 attr_merge_normalize( e, slap_schema.si_ad_description,
1541 monitor_subsys[ i ]->mss_desc, NULL );
1544 mp = monitor_entrypriv_create();
1548 e->e_private = ( void * )mp;
1549 mp->mp_info = monitor_subsys[ i ];
1550 mp->mp_flags = monitor_subsys[ i ]->mss_flags;
1552 if ( monitor_cache_add( mi, e ) ) {
1553 Debug( LDAP_DEBUG_ANY,
1554 "unable to add entry \"%s\" to cache\n",
1555 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1565 be->be_private = mi;
1568 * opens the monitor backend subsystems
1570 for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) {
1571 if ( ms[ 0 ]->mss_open && ( *ms[ 0 ]->mss_open )( be, ms[ 0 ] ) )
1575 ms[ 0 ]->mss_flags |= MONITOR_F_OPENED;
1578 monitor_subsys_opened = 1;
1580 if ( mi->mi_entry_limbo ) {
1581 entry_limbo_t *el = (entry_limbo_t *)mi->mi_entry_limbo;
1586 switch ( el->el_type ) {
1588 monitor_back_register_entry(
1593 case LIMBO_ENTRY_PARENT:
1594 monitor_back_register_entry_parent(
1604 monitor_back_register_entry_attrs(
1614 monitor_back_register_entry_callback(
1627 entry_free( el->el_e );
1630 attrs_free( el->el_a );
1632 if ( !BER_BVISNULL( &el->el_ndn ) ) {
1633 ber_memfree( el->el_ndn.bv_val );
1635 if ( !BER_BVISNULL( &el->el_base ) ) {
1636 ber_memfree( el->el_base.bv_val );
1638 if ( !BER_BVISNULL( &el->el_filter ) ) {
1639 ber_memfree( el->el_filter.bv_val );
1647 mi->mi_entry_limbo = NULL;
1654 monitor_back_config(
1662 * eventually, will hold backend specific configuration parameters
1664 return SLAP_CONF_UNKNOWN;
1668 monitor_back_db_config(
1675 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1678 * eventually, will hold database specific configuration parameters
1680 return SLAP_CONF_UNKNOWN;
1684 monitor_back_db_destroy(
1687 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1690 * FIXME: destroys all the data
1692 /* NOTE: mi points to static storage; don't free it */
1697 #if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
1699 /* conditionally define the init_module() function */
1700 SLAP_BACKEND_INIT_MODULE( monitor )
1702 #endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */