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 != NULL );
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 { "monitorIsShadow", "( 1.3.6.1.4.1.4203.666.1.52 "
1162 "NAME 'monitorIsShadow' "
1163 "DESC 'TRUE if the database is shadow' "
1164 "EQUALITY booleanMatch "
1165 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
1167 "USAGE directoryOperation )", SLAP_AT_HIDE,
1168 offsetof(monitor_info_t, mi_ad_monitorIsShadow) },
1169 { "monitorUpdateRef", "( 1.3.6.1.4.1.4203.666.1.53 "
1170 "NAME 'monitorUpdateRef' "
1171 "DESC 'update referral for shadow databases' "
1172 "SUP monitoredInfo "
1174 "USAGE directoryOperation )", SLAP_AT_HIDE,
1175 offsetof(monitor_info_t, mi_ad_monitorUpdateRef) },
1176 { NULL, NULL, 0, -1 }
1179 bi->bi_controls = controls;
1183 bi->bi_config = monitor_back_config;
1187 bi->bi_db_init = monitor_back_db_init;
1188 bi->bi_db_config = monitor_back_db_config;
1189 bi->bi_db_open = monitor_back_db_open;
1190 bi->bi_db_close = 0;
1191 bi->bi_db_destroy = monitor_back_db_destroy;
1193 bi->bi_op_bind = monitor_back_bind;
1194 bi->bi_op_unbind = 0;
1195 bi->bi_op_search = monitor_back_search;
1196 bi->bi_op_compare = monitor_back_compare;
1197 bi->bi_op_modify = monitor_back_modify;
1198 bi->bi_op_modrdn = 0;
1200 bi->bi_op_delete = 0;
1201 bi->bi_op_abandon = 0;
1203 bi->bi_extended = 0;
1205 bi->bi_entry_release_rw = 0;
1206 bi->bi_chk_referrals = 0;
1207 bi->bi_operational = monitor_back_operational;
1210 * hooks for slap tools
1212 bi->bi_tool_entry_open = 0;
1213 bi->bi_tool_entry_close = 0;
1214 bi->bi_tool_entry_first = 0;
1215 bi->bi_tool_entry_next = 0;
1216 bi->bi_tool_entry_get = 0;
1217 bi->bi_tool_entry_put = 0;
1218 bi->bi_tool_entry_reindex = 0;
1219 bi->bi_tool_sync = 0;
1220 bi->bi_tool_dn2id_get = 0;
1221 bi->bi_tool_id2entry_get = 0;
1222 bi->bi_tool_entry_modify = 0;
1224 bi->bi_connection_init = 0;
1225 bi->bi_connection_destroy = 0;
1227 for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
1228 if ( monitor_back_register_subsys( ms ) ) {
1233 /* schema integration */
1234 for ( i = 0; mat[ i ].name; i++ ) {
1235 LDAPAttributeType *at;
1238 AttributeDescription **ad;
1240 at = ldap_str2attributetype( mat[ i ].schema, &code,
1241 &err, LDAP_SCHEMA_ALLOW_ALL );
1243 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1244 "in AttributeType \"%s\" %s before %s\n",
1245 mat[ i ].name, ldap_scherr2str(code), err );
1249 if ( at->at_oid == NULL ) {
1250 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1251 "null OID for attributeType \"%s\"\n",
1252 mat[ i ].name, 0, 0 );
1256 code = at_add(at, 0, NULL, &err);
1258 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1259 "%s in attributeType \"%s\"\n",
1260 scherr2str(code), mat[ i ].name, 0 );
1265 ad = ((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ]));
1267 if ( slap_str2ad( mat[ i ].name, ad, &text ) ) {
1268 Debug( LDAP_DEBUG_ANY,
1269 "monitor_back_db_init: %s\n", text, 0, 0 );
1273 (*ad)->ad_type->sat_flags |= mat[ i ].flags;
1276 for ( i = 0; moc[ i ].name; i++ ) {
1277 LDAPObjectClass *oc;
1282 oc = ldap_str2objectclass(moc[ i ].schema, &code, &err,
1283 LDAP_SCHEMA_ALLOW_ALL );
1285 Debug( LDAP_DEBUG_ANY,
1286 "unable to parse monitor objectclass \"%s\": "
1287 "%s before %s\n" , moc[ i ].name,
1288 ldap_scherr2str(code), err );
1292 if ( oc->oc_oid == NULL ) {
1293 Debug( LDAP_DEBUG_ANY,
1294 "objectclass \"%s\" has no OID\n" ,
1295 moc[ i ].name, 0, 0 );
1299 code = oc_add(oc, 0, NULL, &err);
1301 Debug( LDAP_DEBUG_ANY,
1302 "objectclass \"%s\": %s \"%s\"\n" ,
1303 moc[ i ].name, scherr2str(code), err );
1309 Oc = oc_find( moc[ i ].name );
1311 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1312 "unable to find objectClass %s "
1313 "(just added)\n", moc[ i ].name, 0, 0 );
1317 Oc->soc_flags |= moc[ i ].flags;
1319 ((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]))[ 0 ] = Oc;
1326 monitor_back_db_init(
1331 struct berval dn, ndn;
1335 * database monitor can be defined once only
1337 if ( be_monitor != NULL ) {
1338 Debug( LDAP_DEBUG_ANY,
1339 "only one monitor database is allowed\n", 0, 0, 0 );
1344 /* indicate system schema supported */
1345 SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
1347 dn.bv_val = SLAPD_MONITOR_DN;
1348 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
1350 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
1351 if( rc != LDAP_SUCCESS ) {
1352 Debug( LDAP_DEBUG_ANY,
1353 "unable to normalize monitor DN \"%s\"\n",
1354 SLAPD_MONITOR_DN, 0, 0 );
1358 ber_dupbv( &bv, &dn );
1359 ber_bvarray_add( &be->be_suffix, &bv );
1360 ber_bvarray_add( &be->be_nsuffix, &ndn );
1362 /* NOTE: only one monitor database is allowed,
1363 * so we use static storage */
1366 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
1368 be->be_private = mi;
1374 monitor_back_db_open(
1377 monitor_info_t *mi = (monitor_info_t *)be->be_private;
1378 struct monitor_subsys_t **ms;
1380 monitor_entry_t *mp;
1382 char buf[ BACKMONITOR_BUFSIZE ];
1385 #ifdef HAVE_GMTIME_R
1388 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
1390 assert( be_monitor != NULL );
1391 if ( be != be_monitor ) {
1398 #ifndef HAVE_GMTIME_R
1399 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
1401 #ifdef HACK_LOCAL_TIME
1402 # ifdef HAVE_LOCALTIME_R
1403 tms = localtime_r( &starttime, &tm_buf );
1405 tms = localtime( &starttime );
1406 # endif /* HAVE_LOCALTIME_R */
1407 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
1408 #else /* !HACK_LOCAL_TIME */
1409 # ifdef HAVE_GMTIME_R
1410 tms = gmtime_r( &starttime, &tm_buf );
1412 tms = gmtime( &starttime );
1413 # endif /* HAVE_GMTIME_R */
1414 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
1415 #endif /* !HACK_LOCAL_TIME */
1416 #ifndef HAVE_GMTIME_R
1417 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
1420 mi->mi_startTime.bv_val = tmbuf;
1421 mi->mi_startTime.bv_len = strlen( tmbuf );
1423 if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
1424 BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
1426 mi->mi_creatorsName = be->be_rootdn;
1430 * creates the "cn=Monitor" entry
1432 snprintf( buf, sizeof( buf ),
1435 "structuralObjectClass: %s\n"
1437 "description: This subtree contains monitoring/managing objects.\n"
1438 "description: This object contains information about this server.\n"
1439 "description: Most of the information is held in operational"
1440 " attributeTypes, which must be explicitly requested.\n"
1441 "creatorsName: %s\n"
1442 "modifiersName: %s\n"
1443 "createTimestamp: %s\n"
1444 "modifyTimestamp: %s\n",
1446 mi->mi_oc_monitorServer->soc_cname.bv_val,
1447 mi->mi_oc_monitorServer->soc_cname.bv_val,
1448 mi->mi_creatorsName.bv_val,
1449 mi->mi_creatorsName.bv_val,
1450 mi->mi_startTime.bv_val,
1451 mi->mi_startTime.bv_val );
1453 e = str2entry( buf );
1455 Debug( LDAP_DEBUG_ANY,
1456 "unable to create \"%s\" entry\n",
1457 SLAPD_MONITOR_DN, 0, 0 );
1461 bv.bv_val = strchr( (char *) Versionstr, '$' );
1462 if ( bv.bv_val != NULL ) {
1466 for ( ; bv.bv_val[ 0 ] == ' '; bv.bv_val++ )
1469 end = strchr( bv.bv_val, '$' );
1470 if ( end != NULL ) {
1473 for ( ; end > bv.bv_val && end[ 0 ] == ' '; end-- )
1478 bv.bv_len = end - bv.bv_val;
1481 bv.bv_len = strlen( bv.bv_val );
1484 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
1486 Debug( LDAP_DEBUG_ANY,
1487 "unable to add monitoredInfo to \"%s\" entry\n",
1488 SLAPD_MONITOR_DN, 0, 0 );
1493 mp = monitor_entrypriv_create();
1497 e->e_private = ( void * )mp;
1498 ep = &mp->mp_children;
1500 if ( monitor_cache_add( mi, e ) ) {
1501 Debug( LDAP_DEBUG_ANY,
1502 "unable to add entry \"%s\" to cache\n",
1503 SLAPD_MONITOR_DN, 0, 0 );
1508 * Create all the subsystem specific entries
1510 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
1511 int len = strlen( monitor_subsys[ i ]->mss_name );
1515 dn.bv_len = len + sizeof( "cn=" ) - 1;
1516 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
1517 strcpy( dn.bv_val, "cn=" );
1518 strcat( dn.bv_val, monitor_subsys[ i ]->mss_name );
1519 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL );
1521 if ( rc != LDAP_SUCCESS ) {
1522 Debug( LDAP_DEBUG_ANY,
1523 "monitor RDN \"%s\" is invalid\n",
1528 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
1529 dn.bv_val = ch_malloc( dn.bv_len + 1 );
1530 strcpy( dn.bv_val , monitor_subsys[ i ]->mss_rdn.bv_val );
1531 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
1532 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ]->mss_dn,
1533 &monitor_subsys[ i ]->mss_ndn, NULL );
1535 if ( rc != LDAP_SUCCESS ) {
1536 Debug( LDAP_DEBUG_ANY,
1537 "monitor DN \"%s\" is invalid\n",
1542 snprintf( buf, sizeof( buf ),
1545 "structuralObjectClass: %s\n"
1547 "creatorsName: %s\n"
1548 "modifiersName: %s\n"
1549 "createTimestamp: %s\n"
1550 "modifyTimestamp: %s\n",
1551 monitor_subsys[ i ]->mss_dn.bv_val,
1552 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1553 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1554 monitor_subsys[ i ]->mss_name,
1555 mi->mi_creatorsName.bv_val,
1556 mi->mi_creatorsName.bv_val,
1557 mi->mi_startTime.bv_val,
1558 mi->mi_startTime.bv_val );
1560 e = str2entry( buf );
1563 Debug( LDAP_DEBUG_ANY,
1564 "unable to create \"%s\" entry\n",
1565 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1569 if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_desc[ 0 ] ) ) {
1570 attr_merge_normalize( e, slap_schema.si_ad_description,
1571 monitor_subsys[ i ]->mss_desc, NULL );
1574 mp = monitor_entrypriv_create();
1578 e->e_private = ( void * )mp;
1579 mp->mp_info = monitor_subsys[ i ];
1580 mp->mp_flags = monitor_subsys[ i ]->mss_flags;
1582 if ( monitor_cache_add( mi, e ) ) {
1583 Debug( LDAP_DEBUG_ANY,
1584 "unable to add entry \"%s\" to cache\n",
1585 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1593 assert( be != NULL );
1595 be->be_private = mi;
1598 * opens the monitor backend subsystems
1600 for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) {
1601 if ( ms[ 0 ]->mss_open && ( *ms[ 0 ]->mss_open )( be, ms[ 0 ] ) )
1605 ms[ 0 ]->mss_flags |= MONITOR_F_OPENED;
1608 monitor_subsys_opened = 1;
1610 if ( mi->mi_entry_limbo ) {
1611 entry_limbo_t *el = (entry_limbo_t *)mi->mi_entry_limbo;
1616 switch ( el->el_type ) {
1618 monitor_back_register_entry(
1623 case LIMBO_ENTRY_PARENT:
1624 monitor_back_register_entry_parent(
1634 monitor_back_register_entry_attrs(
1644 monitor_back_register_entry_callback(
1657 entry_free( el->el_e );
1660 attrs_free( el->el_a );
1662 if ( !BER_BVISNULL( &el->el_ndn ) ) {
1663 ber_memfree( el->el_ndn.bv_val );
1665 if ( !BER_BVISNULL( &el->el_base ) ) {
1666 ber_memfree( el->el_base.bv_val );
1668 if ( !BER_BVISNULL( &el->el_filter ) ) {
1669 ber_memfree( el->el_filter.bv_val );
1677 mi->mi_entry_limbo = NULL;
1684 monitor_back_config(
1692 * eventually, will hold backend specific configuration parameters
1694 return SLAP_CONF_UNKNOWN;
1698 monitor_back_db_config(
1705 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1708 * eventually, will hold database specific configuration parameters
1710 return SLAP_CONF_UNKNOWN;
1714 monitor_back_db_destroy(
1717 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1720 * FIXME: destroys all the data
1722 /* NOTE: mi points to static storage; don't free it */
1727 #if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
1729 /* conditionally define the init_module() function */
1730 SLAP_BACKEND_INIT_MODULE( monitor )
1732 #endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */