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 if ( op->o_tmpmemctx ) {
622 /* FIXME: connection_fake_init() calls slap_sl_mem_create, so we destroy it for now */
623 slap_sl_mem_destroy( NULL, op->o_tmpmemctx );
624 op->o_tmpmemctx = NULL;
626 op->o_tmpmfuncs = &ch_mfuncs;
628 op->o_bd = be_monitor;
629 if ( base == NULL || BER_BVISNULL( base ) ) {
630 ber_dupbv_x( &op->o_req_dn, &op->o_bd->be_suffix[ 0 ],
632 ber_dupbv_x( &op->o_req_ndn, &op->o_bd->be_nsuffix[ 0 ],
636 if ( dnPrettyNormal( NULL, base, &op->o_req_dn, &op->o_req_ndn,
637 op->o_tmpmemctx ) ) {
642 op->o_callback = &cb;
643 cb.sc_private = (void *)ndn;
645 op->ors_scope = scope;
646 ber_dupbv_x( &op->ors_filterstr, filter, op->o_tmpmemctx );
647 op->ors_filter = str2filter_x( op, filter->bv_val );
648 op->ors_attrs = slap_anlist_no_attrs;
649 op->ors_attrsonly = 0;
650 op->ors_tlimit = SLAP_NO_LIMIT;
652 op->ors_limit = NULL;
653 op->ors_deref = LDAP_DEREF_NEVER;
656 op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
658 op->o_dn = be_monitor->be_rootdn;
659 op->o_ndn = be_monitor->be_rootndn;
661 rc = op->o_bd->be_search( op, &rs );
663 filter_free_x( op, op->ors_filter );
664 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
665 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
666 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
672 switch ( rs.sr_err ) {
674 if ( BER_BVISNULL( ndn ) ) {
679 case LDAP_SIZELIMIT_EXCEEDED:
681 if ( !BER_BVISNULL( ndn ) ) {
682 ber_memfree( ndn->bv_val );
693 monitor_back_register_entry_attrs(
694 struct berval *ndn_in,
696 monitor_callback_t *cb,
699 struct berval *filter )
701 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
702 struct berval ndn = BER_BVNULL;
704 assert( mi != NULL );
706 if ( ndn_in != NULL ) {
710 if ( a == NULL && cb == NULL ) {
715 if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) )
716 && BER_BVISNULL( filter ) )
719 Debug( LDAP_DEBUG_ANY,
720 "monitor_back_register_entry_*(\"\"): "
721 "need a valid filter\n",
726 if ( monitor_subsys_opened ) {
728 Attribute **atp = NULL;
729 monitor_entry_t *mp = NULL;
730 monitor_callback_t **mcp = NULL;
734 if ( BER_BVISNULL( &ndn ) ) {
735 if ( monitor_filter2ndn( base, scope, filter, &ndn ) ) {
736 /* entry does not exist */
737 Debug( LDAP_DEBUG_ANY,
738 "monitor_back_register_entry_*(\"\"): "
739 "base=%s scope=%d filter=%s : "
740 "unable to find entry\n",
741 base->bv_val ? base->bv_val : "\"\"",
742 scope, filter->bv_val );
749 if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) {
750 /* entry does not exist */
751 Debug( LDAP_DEBUG_ANY,
752 "monitor_back_register_entry_*(\"%s\"): "
753 "entry does not exist\n",
759 assert( e->e_private != NULL );
760 mp = ( monitor_entry_t * )e->e_private;
762 if ( mp->mp_flags & MONITOR_F_VOLATILE ) {
763 /* entry is volatile; cannot append callback */
764 Debug( LDAP_DEBUG_ANY,
765 "monitor_back_register_entry_*(\"%s\"): "
766 "entry is volatile\n",
767 e->e_name.bv_val, 0, 0 );
773 for ( atp = &e->e_attrs; *atp; atp = &(*atp)->a_next )
774 /* just get to last */ ;
776 *atp = attrs_dup( a );
777 if ( *atp == NULL ) {
778 Debug( LDAP_DEBUG_ANY,
779 "monitor_back_register_entry_*(\"%s\"): "
780 "attrs_dup() failed\n",
781 e->e_name.bv_val, 0, 0 );
788 for ( mcp = &mp->mp_cb; *mcp; mcp = &(*mcp)->mc_next )
791 /* NOTE: we do not clear cb->mc_next, so this function
792 * can be used to append a list of callbacks */
805 ber_memfree( ndn.bv_val );
809 monitor_cache_release( mi, e );
813 entry_limbo_t **elpp, el = { 0 };
815 el.el_type = LIMBO_ATTRS;
816 if ( !BER_BVISNULL( &ndn ) ) {
817 ber_dupbv( &el.el_ndn, &ndn );
819 if ( !BER_BVISNULL( base ) ) {
820 ber_dupbv( &el.el_base, base);
823 if ( !BER_BVISNULL( filter ) ) {
824 ber_dupbv( &el.el_filter, filter );
827 el.el_a = attrs_dup( a );
830 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
832 elpp = &(*elpp)->el_next )
835 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
836 if ( *elpp == NULL ) {
837 el.el_e->e_private = NULL;
838 entry_free( el.el_e );
850 monitor_back_register_entry_callback(
852 monitor_callback_t *cb,
855 struct berval *filter )
857 return monitor_back_register_entry_attrs( ndn, NULL, cb,
858 base, scope, filter );
862 monitor_back_get_subsys( const char *name )
864 if ( monitor_subsys != NULL ) {
867 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
868 if ( strcasecmp( monitor_subsys[ i ]->mss_name, name ) == 0 ) {
869 return monitor_subsys[ i ];
878 monitor_back_get_subsys_by_dn(
882 if ( monitor_subsys != NULL ) {
886 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
887 if ( dnIsSuffix( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
888 return monitor_subsys[ i ];
893 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
894 if ( dn_match( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
895 return monitor_subsys[ i ];
905 monitor_back_initialize(
908 monitor_subsys_t *ms;
909 static char *controls[] = {
910 LDAP_CONTROL_MANAGEDSAIT,
913 monitor_info_t *mi = &monitor_info;
923 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
925 "DESC 'OpenLDAP system monitoring' "
926 "SUP top STRUCTURAL "
935 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
936 offsetof(monitor_info_t, mi_oc_monitor) },
937 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
938 "NAME 'monitorServer' "
939 "DESC 'Server monitoring root entry' "
940 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
941 offsetof(monitor_info_t, mi_oc_monitorServer) },
942 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
943 "NAME 'monitorContainer' "
944 "DESC 'monitor container class' "
945 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
946 offsetof(monitor_info_t, mi_oc_monitorContainer) },
947 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
948 "NAME 'monitorCounterObject' "
949 "DESC 'monitor counter class' "
950 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
951 offsetof(monitor_info_t, mi_oc_monitorCounterObject) },
952 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
953 "NAME 'monitorOperation' "
954 "DESC 'monitor operation class' "
955 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
956 offsetof(monitor_info_t, mi_oc_monitorOperation) },
957 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
958 "NAME 'monitorConnection' "
959 "DESC 'monitor connection class' "
960 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
961 offsetof(monitor_info_t, mi_oc_monitorConnection) },
962 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
963 "NAME 'managedObject' "
964 "DESC 'monitor managed entity class' "
965 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
966 offsetof(monitor_info_t, mi_oc_managedObject) },
967 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.14 "
968 "NAME 'monitoredObject' "
969 "DESC 'monitor monitored entity class' "
970 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
971 offsetof(monitor_info_t, mi_oc_monitoredObject) },
972 { NULL, NULL, 0, -1 }
974 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
975 "NAME 'monitoredInfo' "
976 "DESC 'monitored info' "
978 "EQUALITY caseIgnoreMatch "
979 "SUBSTR caseIgnoreSubstringsMatch "
980 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
981 "NO-USER-MODIFICATION "
982 "USAGE directoryOperation )", SLAP_AT_HIDE,
983 offsetof(monitor_info_t, mi_ad_monitoredInfo) },
984 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
985 "NAME 'managedInfo' "
986 "DESC 'monitor managed info' "
987 "SUP name )", SLAP_AT_HIDE,
988 offsetof(monitor_info_t, mi_ad_managedInfo) },
989 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
990 "NAME 'monitorCounter' "
991 "DESC 'monitor counter' "
992 "EQUALITY integerMatch "
993 "ORDERING integerOrderingMatch "
994 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
995 "NO-USER-MODIFICATION "
996 "USAGE directoryOperation )", SLAP_AT_HIDE,
997 offsetof(monitor_info_t, mi_ad_monitorCounter) },
998 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
999 "NAME 'monitorOpCompleted' "
1000 "DESC 'monitor completed operations' "
1001 "SUP monitorCounter "
1002 "NO-USER-MODIFICATION "
1003 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1004 offsetof(monitor_info_t, mi_ad_monitorOpCompleted) },
1005 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
1006 "NAME 'monitorOpInitiated' "
1007 "DESC 'monitor initiated operations' "
1008 "SUP monitorCounter "
1009 "NO-USER-MODIFICATION "
1010 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1011 offsetof(monitor_info_t, mi_ad_monitorOpInitiated) },
1012 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
1013 "NAME 'monitorConnectionNumber' "
1014 "DESC 'monitor connection number' "
1015 "SUP monitorCounter "
1016 "NO-USER-MODIFICATION "
1017 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1018 offsetof(monitor_info_t, mi_ad_monitorConnectionNumber) },
1019 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
1020 "NAME 'monitorConnectionAuthzDN' "
1021 "DESC 'monitor connection authorization DN' "
1022 /* "SUP distinguishedName " */
1023 "EQUALITY distinguishedNameMatch "
1024 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
1025 "NO-USER-MODIFICATION "
1026 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1027 offsetof(monitor_info_t, mi_ad_monitorConnectionAuthzDN) },
1028 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
1029 "NAME 'monitorConnectionLocalAddress' "
1030 "DESC 'monitor connection local address' "
1031 "SUP monitoredInfo "
1032 "NO-USER-MODIFICATION "
1033 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1034 offsetof(monitor_info_t, mi_ad_monitorConnectionLocalAddress) },
1035 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
1036 "NAME 'monitorConnectionPeerAddress' "
1037 "DESC 'monitor connection peer address' "
1038 "SUP monitoredInfo "
1039 "NO-USER-MODIFICATION "
1040 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1041 offsetof(monitor_info_t, mi_ad_monitorConnectionPeerAddress) },
1042 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
1043 "NAME 'monitorTimestamp' "
1044 "DESC 'monitor timestamp' "
1045 "EQUALITY generalizedTimeMatch "
1046 "ORDERING generalizedTimeOrderingMatch "
1047 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
1049 "NO-USER-MODIFICATION "
1050 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1051 offsetof(monitor_info_t, mi_ad_monitorTimestamp) },
1052 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
1053 "NAME 'monitorOverlay' "
1054 "DESC 'name of overlays defined for a given database' "
1055 "SUP monitoredInfo "
1056 "NO-USER-MODIFICATION "
1057 "USAGE directoryOperation )", SLAP_AT_HIDE,
1058 offsetof(monitor_info_t, mi_ad_monitorOverlay) },
1059 { "readOnly", "( 1.3.6.1.4.1.4203.666.1.31 "
1061 "DESC 'read/write status of a given database' "
1062 "EQUALITY booleanMatch "
1063 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
1065 "USAGE directoryOperation )", SLAP_AT_HIDE,
1066 offsetof(monitor_info_t, mi_ad_readOnly) },
1067 { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.32 "
1068 "NAME 'restrictedOperation' "
1069 "DESC 'name of restricted operation for a given database' "
1070 "SUP managedInfo )", SLAP_AT_HIDE,
1071 offsetof(monitor_info_t, mi_ad_restrictedOperation ) },
1072 { "monitorConnectionProtocol", "( 1.3.6.1.4.1.4203.666.1.39 "
1073 "NAME 'monitorConnectionProtocol' "
1074 "DESC 'monitor connection protocol' "
1075 "SUP monitoredInfo "
1076 "NO-USER-MODIFICATION "
1077 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1078 offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) },
1079 { "monitorConnectionOpsReceived", "( 1.3.6.1.4.1.4203.666.1.40 "
1080 "NAME 'monitorConnectionOpsReceived' "
1081 "DESC 'monitor number of operations received by the connection' "
1082 "SUP monitorCounter "
1083 "NO-USER-MODIFICATION "
1084 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1085 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) },
1086 { "monitorConnectionOpsExecuting", "( 1.3.6.1.4.1.4203.666.1.41 "
1087 "NAME 'monitorConnectionOpsExecuting' "
1088 "DESC 'monitor number of operations in execution within the connection' "
1089 "SUP monitorCounter "
1090 "NO-USER-MODIFICATION "
1091 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1092 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) },
1093 { "monitorConnectionOpsPending", "( 1.3.6.1.4.1.4203.666.1.42 "
1094 "NAME 'monitorConnectionOpsPending' "
1095 "DESC 'monitor number of pending operations within the connection' "
1096 "SUP monitorCounter "
1097 "NO-USER-MODIFICATION "
1098 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1099 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) },
1100 { "monitorConnectionOpsCompleted", "( 1.3.6.1.4.1.4203.666.1.43 "
1101 "NAME 'monitorConnectionOpsCompleted' "
1102 "DESC 'monitor number of operations completed within the connection' "
1103 "SUP monitorCounter "
1104 "NO-USER-MODIFICATION "
1105 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1106 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) },
1107 { "monitorConnectionGet", "( 1.3.6.1.4.1.4203.666.1.44 "
1108 "NAME 'monitorConnectionGet' "
1109 "DESC 'number of times connection_get() was called so far' "
1110 "SUP monitorCounter "
1111 "NO-USER-MODIFICATION "
1112 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1113 offsetof(monitor_info_t, mi_ad_monitorConnectionGet) },
1114 { "monitorConnectionRead", "( 1.3.6.1.4.1.4203.666.1.45 "
1115 "NAME 'monitorConnectionRead' "
1116 "DESC 'number of times connection_read() was called so far' "
1117 "SUP monitorCounter "
1118 "NO-USER-MODIFICATION "
1119 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1120 offsetof(monitor_info_t, mi_ad_monitorConnectionRead) },
1121 { "monitorConnectionWrite", "( 1.3.6.1.4.1.4203.666.1.46 "
1122 "NAME 'monitorConnectionWrite' "
1123 "DESC 'number of times connection_write() was called so far' "
1124 "SUP monitorCounter "
1125 "NO-USER-MODIFICATION "
1126 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1127 offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) },
1128 { "monitorConnectionMask", "( 1.3.6.1.4.1.4203.666.1.47 "
1129 "NAME 'monitorConnectionMask' "
1130 "DESC 'monitor connection mask' "
1131 "SUP monitoredInfo "
1132 "NO-USER-MODIFICATION "
1133 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1134 offsetof(monitor_info_t, mi_ad_monitorConnectionMask) },
1135 { "monitorConnectionListener", "( 1.3.6.1.4.1.4203.666.1.48 "
1136 "NAME 'monitorConnectionListener' "
1137 "DESC 'monitor connection listener' "
1138 "SUP monitoredInfo "
1139 "NO-USER-MODIFICATION "
1140 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1141 offsetof(monitor_info_t, mi_ad_monitorConnectionListener) },
1142 { "monitorConnectionPeerDomain", "( 1.3.6.1.4.1.4203.666.1.49 "
1143 "NAME 'monitorConnectionPeerDomain' "
1144 "DESC 'monitor connection peer domain' "
1145 "SUP monitoredInfo "
1146 "NO-USER-MODIFICATION "
1147 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1148 offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) },
1149 { "monitorConnectionStartTime", "( 1.3.6.1.4.1.4203.666.1.50 "
1150 "NAME 'monitorConnectionStartTime' "
1151 "DESC 'monitor connection start time' "
1152 "SUP monitorTimestamp "
1154 "NO-USER-MODIFICATION "
1155 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1156 offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) },
1157 { "monitorConnectionActivityTime", "( 1.3.6.1.4.1.4203.666.1.51 "
1158 "NAME 'monitorConnectionActivityTime' "
1159 "DESC 'monitor connection activity time' "
1160 "SUP monitorTimestamp "
1162 "NO-USER-MODIFICATION "
1163 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1164 offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) },
1165 { "monitorIsShadow", "( 1.3.6.1.4.1.4203.666.1.52 "
1166 "NAME 'monitorIsShadow' "
1167 "DESC 'TRUE if the database is shadow' "
1168 "EQUALITY booleanMatch "
1169 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
1171 "USAGE directoryOperation )", SLAP_AT_HIDE,
1172 offsetof(monitor_info_t, mi_ad_monitorIsShadow) },
1173 { "monitorUpdateRef", "( 1.3.6.1.4.1.4203.666.1.53 "
1174 "NAME 'monitorUpdateRef' "
1175 "DESC 'update referral for shadow databases' "
1176 "SUP monitoredInfo "
1178 "USAGE directoryOperation )", SLAP_AT_HIDE,
1179 offsetof(monitor_info_t, mi_ad_monitorUpdateRef) },
1180 { NULL, NULL, 0, -1 }
1183 bi->bi_controls = controls;
1187 bi->bi_config = monitor_back_config;
1191 bi->bi_db_init = monitor_back_db_init;
1192 bi->bi_db_config = monitor_back_db_config;
1193 bi->bi_db_open = monitor_back_db_open;
1194 bi->bi_db_close = 0;
1195 bi->bi_db_destroy = monitor_back_db_destroy;
1197 bi->bi_op_bind = monitor_back_bind;
1198 bi->bi_op_unbind = 0;
1199 bi->bi_op_search = monitor_back_search;
1200 bi->bi_op_compare = monitor_back_compare;
1201 bi->bi_op_modify = monitor_back_modify;
1202 bi->bi_op_modrdn = 0;
1204 bi->bi_op_delete = 0;
1205 bi->bi_op_abandon = 0;
1207 bi->bi_extended = 0;
1209 bi->bi_entry_release_rw = 0;
1210 bi->bi_chk_referrals = 0;
1211 bi->bi_operational = monitor_back_operational;
1214 * hooks for slap tools
1216 bi->bi_tool_entry_open = 0;
1217 bi->bi_tool_entry_close = 0;
1218 bi->bi_tool_entry_first = 0;
1219 bi->bi_tool_entry_next = 0;
1220 bi->bi_tool_entry_get = 0;
1221 bi->bi_tool_entry_put = 0;
1222 bi->bi_tool_entry_reindex = 0;
1223 bi->bi_tool_sync = 0;
1224 bi->bi_tool_dn2id_get = 0;
1225 bi->bi_tool_id2entry_get = 0;
1226 bi->bi_tool_entry_modify = 0;
1228 bi->bi_connection_init = 0;
1229 bi->bi_connection_destroy = 0;
1231 for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
1232 if ( monitor_back_register_subsys( ms ) ) {
1237 /* schema integration */
1238 for ( i = 0; mat[ i ].name; i++ ) {
1239 LDAPAttributeType *at;
1242 AttributeDescription **ad;
1244 at = ldap_str2attributetype( mat[ i ].schema, &code,
1245 &err, LDAP_SCHEMA_ALLOW_ALL );
1247 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1248 "in AttributeType \"%s\" %s before %s\n",
1249 mat[ i ].name, ldap_scherr2str(code), err );
1253 if ( at->at_oid == NULL ) {
1254 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1255 "null OID for attributeType \"%s\"\n",
1256 mat[ i ].name, 0, 0 );
1260 code = at_add(at, 0, NULL, &err);
1262 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1263 "%s in attributeType \"%s\"\n",
1264 scherr2str(code), mat[ i ].name, 0 );
1269 ad = ((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ]));
1271 if ( slap_str2ad( mat[ i ].name, ad, &text ) ) {
1272 Debug( LDAP_DEBUG_ANY,
1273 "monitor_back_db_init: %s\n", text, 0, 0 );
1277 (*ad)->ad_type->sat_flags |= mat[ i ].flags;
1280 for ( i = 0; moc[ i ].name; i++ ) {
1281 LDAPObjectClass *oc;
1286 oc = ldap_str2objectclass(moc[ i ].schema, &code, &err,
1287 LDAP_SCHEMA_ALLOW_ALL );
1289 Debug( LDAP_DEBUG_ANY,
1290 "unable to parse monitor objectclass \"%s\": "
1291 "%s before %s\n" , moc[ i ].name,
1292 ldap_scherr2str(code), err );
1296 if ( oc->oc_oid == NULL ) {
1297 Debug( LDAP_DEBUG_ANY,
1298 "objectclass \"%s\" has no OID\n" ,
1299 moc[ i ].name, 0, 0 );
1303 code = oc_add(oc, 0, NULL, &err);
1305 Debug( LDAP_DEBUG_ANY,
1306 "objectclass \"%s\": %s \"%s\"\n" ,
1307 moc[ i ].name, scherr2str(code), err );
1313 Oc = oc_find( moc[ i ].name );
1315 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1316 "unable to find objectClass %s "
1317 "(just added)\n", moc[ i ].name, 0, 0 );
1321 Oc->soc_flags |= moc[ i ].flags;
1323 ((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]))[ 0 ] = Oc;
1330 monitor_back_db_init(
1335 struct berval dn, ndn;
1339 * database monitor can be defined once only
1341 if ( be_monitor != NULL ) {
1342 Debug( LDAP_DEBUG_ANY,
1343 "only one monitor database is allowed\n", 0, 0, 0 );
1348 /* indicate system schema supported */
1349 SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
1351 dn.bv_val = SLAPD_MONITOR_DN;
1352 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
1354 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
1355 if( rc != LDAP_SUCCESS ) {
1356 Debug( LDAP_DEBUG_ANY,
1357 "unable to normalize monitor DN \"%s\"\n",
1358 SLAPD_MONITOR_DN, 0, 0 );
1362 ber_dupbv( &bv, &dn );
1363 ber_bvarray_add( &be->be_suffix, &bv );
1364 ber_bvarray_add( &be->be_nsuffix, &ndn );
1366 /* NOTE: only one monitor database is allowed,
1367 * so we use static storage */
1370 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
1372 be->be_private = mi;
1378 monitor_back_db_open(
1381 monitor_info_t *mi = (monitor_info_t *)be->be_private;
1382 struct monitor_subsys_t **ms;
1384 monitor_entry_t *mp;
1386 char buf[ BACKMONITOR_BUFSIZE ];
1389 #ifdef HAVE_GMTIME_R
1392 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
1394 assert( be_monitor != NULL );
1395 if ( be != be_monitor ) {
1402 #ifndef HAVE_GMTIME_R
1403 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
1405 #ifdef HACK_LOCAL_TIME
1406 # ifdef HAVE_LOCALTIME_R
1407 tms = localtime_r( &starttime, &tm_buf );
1409 tms = localtime( &starttime );
1410 # endif /* HAVE_LOCALTIME_R */
1411 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
1412 #else /* !HACK_LOCAL_TIME */
1413 # ifdef HAVE_GMTIME_R
1414 tms = gmtime_r( &starttime, &tm_buf );
1416 tms = gmtime( &starttime );
1417 # endif /* HAVE_GMTIME_R */
1418 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
1419 #endif /* !HACK_LOCAL_TIME */
1420 #ifndef HAVE_GMTIME_R
1421 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
1424 mi->mi_startTime.bv_val = tmbuf;
1425 mi->mi_startTime.bv_len = strlen( tmbuf );
1427 if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
1428 BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
1430 mi->mi_creatorsName = be->be_rootdn;
1434 * creates the "cn=Monitor" entry
1436 snprintf( buf, sizeof( buf ),
1439 "structuralObjectClass: %s\n"
1441 "description: This subtree contains monitoring/managing objects.\n"
1442 "description: This object contains information about this server.\n"
1443 "description: Most of the information is held in operational"
1444 " attributeTypes, which must be explicitly requested.\n"
1445 "creatorsName: %s\n"
1446 "modifiersName: %s\n"
1447 "createTimestamp: %s\n"
1448 "modifyTimestamp: %s\n",
1450 mi->mi_oc_monitorServer->soc_cname.bv_val,
1451 mi->mi_oc_monitorServer->soc_cname.bv_val,
1452 mi->mi_creatorsName.bv_val,
1453 mi->mi_creatorsName.bv_val,
1454 mi->mi_startTime.bv_val,
1455 mi->mi_startTime.bv_val );
1457 e = str2entry( buf );
1459 Debug( LDAP_DEBUG_ANY,
1460 "unable to create \"%s\" entry\n",
1461 SLAPD_MONITOR_DN, 0, 0 );
1465 bv.bv_val = strchr( (char *) Versionstr, '$' );
1466 if ( bv.bv_val != NULL ) {
1470 for ( ; bv.bv_val[ 0 ] == ' '; bv.bv_val++ )
1473 end = strchr( bv.bv_val, '$' );
1474 if ( end != NULL ) {
1477 for ( ; end > bv.bv_val && end[ 0 ] == ' '; end-- )
1482 bv.bv_len = end - bv.bv_val;
1485 bv.bv_len = strlen( bv.bv_val );
1488 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
1490 Debug( LDAP_DEBUG_ANY,
1491 "unable to add monitoredInfo to \"%s\" entry\n",
1492 SLAPD_MONITOR_DN, 0, 0 );
1497 mp = monitor_entrypriv_create();
1501 e->e_private = ( void * )mp;
1502 ep = &mp->mp_children;
1504 if ( monitor_cache_add( mi, e ) ) {
1505 Debug( LDAP_DEBUG_ANY,
1506 "unable to add entry \"%s\" to cache\n",
1507 SLAPD_MONITOR_DN, 0, 0 );
1512 * Create all the subsystem specific entries
1514 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
1515 int len = strlen( monitor_subsys[ i ]->mss_name );
1519 dn.bv_len = len + sizeof( "cn=" ) - 1;
1520 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
1521 strcpy( dn.bv_val, "cn=" );
1522 strcat( dn.bv_val, monitor_subsys[ i ]->mss_name );
1523 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL );
1525 if ( rc != LDAP_SUCCESS ) {
1526 Debug( LDAP_DEBUG_ANY,
1527 "monitor RDN \"%s\" is invalid\n",
1532 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
1533 dn.bv_val = ch_malloc( dn.bv_len + 1 );
1534 strcpy( dn.bv_val , monitor_subsys[ i ]->mss_rdn.bv_val );
1535 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
1536 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ]->mss_dn,
1537 &monitor_subsys[ i ]->mss_ndn, NULL );
1539 if ( rc != LDAP_SUCCESS ) {
1540 Debug( LDAP_DEBUG_ANY,
1541 "monitor DN \"%s\" is invalid\n",
1546 snprintf( buf, sizeof( buf ),
1549 "structuralObjectClass: %s\n"
1551 "creatorsName: %s\n"
1552 "modifiersName: %s\n"
1553 "createTimestamp: %s\n"
1554 "modifyTimestamp: %s\n",
1555 monitor_subsys[ i ]->mss_dn.bv_val,
1556 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1557 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1558 monitor_subsys[ i ]->mss_name,
1559 mi->mi_creatorsName.bv_val,
1560 mi->mi_creatorsName.bv_val,
1561 mi->mi_startTime.bv_val,
1562 mi->mi_startTime.bv_val );
1564 e = str2entry( buf );
1567 Debug( LDAP_DEBUG_ANY,
1568 "unable to create \"%s\" entry\n",
1569 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1573 if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_desc[ 0 ] ) ) {
1574 attr_merge_normalize( e, slap_schema.si_ad_description,
1575 monitor_subsys[ i ]->mss_desc, NULL );
1578 mp = monitor_entrypriv_create();
1582 e->e_private = ( void * )mp;
1583 mp->mp_info = monitor_subsys[ i ];
1584 mp->mp_flags = monitor_subsys[ i ]->mss_flags;
1586 if ( monitor_cache_add( mi, e ) ) {
1587 Debug( LDAP_DEBUG_ANY,
1588 "unable to add entry \"%s\" to cache\n",
1589 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1597 assert( be != NULL );
1599 be->be_private = mi;
1602 * opens the monitor backend subsystems
1604 for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) {
1605 if ( ms[ 0 ]->mss_open && ( *ms[ 0 ]->mss_open )( be, ms[ 0 ] ) )
1609 ms[ 0 ]->mss_flags |= MONITOR_F_OPENED;
1612 monitor_subsys_opened = 1;
1614 if ( mi->mi_entry_limbo ) {
1615 entry_limbo_t *el = (entry_limbo_t *)mi->mi_entry_limbo;
1620 switch ( el->el_type ) {
1622 monitor_back_register_entry(
1627 case LIMBO_ENTRY_PARENT:
1628 monitor_back_register_entry_parent(
1638 monitor_back_register_entry_attrs(
1648 monitor_back_register_entry_callback(
1661 entry_free( el->el_e );
1664 attrs_free( el->el_a );
1666 if ( !BER_BVISNULL( &el->el_ndn ) ) {
1667 ber_memfree( el->el_ndn.bv_val );
1669 if ( !BER_BVISNULL( &el->el_base ) ) {
1670 ber_memfree( el->el_base.bv_val );
1672 if ( !BER_BVISNULL( &el->el_filter ) ) {
1673 ber_memfree( el->el_filter.bv_val );
1681 mi->mi_entry_limbo = NULL;
1688 monitor_back_config(
1696 * eventually, will hold backend specific configuration parameters
1698 return SLAP_CONF_UNKNOWN;
1702 monitor_back_db_config(
1709 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1712 * eventually, will hold database specific configuration parameters
1714 return SLAP_CONF_UNKNOWN;
1718 monitor_back_db_destroy(
1721 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1724 * FIXME: destroys all the data
1726 /* NOTE: mi points to static storage; don't free it */
1731 #if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
1733 /* conditionally define the init_module() function */
1734 SLAP_BACKEND_INIT_MODULE( monitor )
1736 #endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */