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 = NULL;
43 static struct monitor_subsys_t **monitor_subsys = NULL;
44 static int monitor_subsys_opened = 0;
49 * the known subsystems are added to the subsystems
50 * array at backend initialization; other subsystems
51 * may be added by calling monitor_back_register_subsys()
52 * before the database is opened (e.g. by other backends
53 * or by overlays or modules).
55 static struct monitor_subsys_t known_monitor_subsys[] = {
57 SLAPD_MONITOR_BACKEND_NAME,
58 BER_BVNULL, BER_BVNULL, BER_BVNULL,
59 MONITOR_F_PERSISTENT_CH,
60 monitor_subsys_backend_init,
65 SLAPD_MONITOR_CONN_NAME,
66 BER_BVNULL, BER_BVNULL, BER_BVNULL,
67 MONITOR_F_VOLATILE_CH,
68 monitor_subsys_conn_init,
69 monitor_subsys_conn_update,
70 monitor_subsys_conn_create,
73 SLAPD_MONITOR_DATABASE_NAME,
74 BER_BVNULL, BER_BVNULL, BER_BVNULL,
75 MONITOR_F_PERSISTENT_CH,
76 monitor_subsys_database_init,
79 monitor_subsys_database_modify
81 SLAPD_MONITOR_LISTENER_NAME,
82 BER_BVNULL, BER_BVNULL, BER_BVNULL,
83 MONITOR_F_PERSISTENT_CH,
84 monitor_subsys_listener_init,
89 SLAPD_MONITOR_LOG_NAME,
90 BER_BVNULL, BER_BVNULL, BER_BVNULL,
92 monitor_subsys_log_init,
95 monitor_subsys_log_modify
97 SLAPD_MONITOR_OPS_NAME,
98 BER_BVNULL, BER_BVNULL, BER_BVNULL,
99 MONITOR_F_PERSISTENT_CH,
100 monitor_subsys_ops_init,
101 monitor_subsys_ops_update,
105 SLAPD_MONITOR_OVERLAY_NAME,
106 BER_BVNULL, BER_BVNULL, BER_BVNULL,
107 MONITOR_F_PERSISTENT_CH,
108 monitor_subsys_overlay_init,
113 SLAPD_MONITOR_SASL_NAME,
114 BER_BVNULL, BER_BVNULL, BER_BVNULL,
121 SLAPD_MONITOR_SENT_NAME,
122 BER_BVNULL, BER_BVNULL, BER_BVNULL,
123 MONITOR_F_PERSISTENT_CH,
124 monitor_subsys_sent_init,
125 monitor_subsys_sent_update,
129 SLAPD_MONITOR_THREAD_NAME,
130 BER_BVNULL, BER_BVNULL, BER_BVNULL,
131 MONITOR_F_PERSISTENT_CH,
132 monitor_subsys_thread_init,
133 monitor_subsys_thread_update,
137 SLAPD_MONITOR_TIME_NAME,
138 BER_BVNULL, BER_BVNULL, BER_BVNULL,
139 MONITOR_F_PERSISTENT_CH,
140 monitor_subsys_time_init,
141 monitor_subsys_time_update,
145 SLAPD_MONITOR_TLS_NAME,
146 BER_BVNULL, BER_BVNULL, BER_BVNULL,
153 SLAPD_MONITOR_RWW_NAME,
154 BER_BVNULL, BER_BVNULL, BER_BVNULL,
155 MONITOR_F_PERSISTENT_CH,
156 monitor_subsys_rww_init,
157 monitor_subsys_rww_update,
164 monitor_back_register_subsys(
165 monitor_subsys_t *ms )
169 if ( monitor_subsys ) {
170 for ( ; monitor_subsys[ i ] != NULL; i++ )
171 /* just count'em */ ;
174 monitor_subsys = ch_realloc( monitor_subsys,
175 ( 2 + i ) * sizeof( monitor_subsys_t * ) );
177 if ( monitor_subsys == NULL ) {
181 monitor_subsys[ i ] = ms;
182 monitor_subsys[ i + 1 ] = NULL;
184 /* if a subsystem is registered __AFTER__ subsystem
185 * initialization (depending on the sequence the databases
186 * are listed in slapd.conf), init it */
187 if ( monitor_subsys_opened ) {
189 /* FIXME: this should only be possible
190 * if be_monitor is already initialized */
191 assert( be_monitor );
193 if ( ms->mss_open && ( *ms->mss_open )( be_monitor, ms ) ) {
197 ms->mss_flags |= MONITOR_F_OPENED;
210 typedef struct entry_limbo_t {
214 struct berval el_ndn;
215 struct berval el_base;
217 struct berval el_filter;
218 monitor_callback_t *el_cb;
219 struct entry_limbo_t *el_next;
223 monitor_back_register_entry(
225 monitor_callback_t *cb )
227 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
229 assert( mi != NULL );
231 assert( e->e_private == NULL );
233 if ( monitor_subsys_opened ) {
234 Entry *e_parent = NULL,
237 struct berval pdn = BER_BVNULL;
238 monitor_entry_t *mp = NULL,
242 if ( monitor_cache_get( mi, &e->e_nname, &e_parent ) == 0 ) {
244 Debug( LDAP_DEBUG_ANY,
245 "monitor_back_register_entry(\"%s\"): "
247 e->e_name.bv_val, 0, 0 );
248 monitor_cache_release( mi, e_parent );
252 dnParent( &e->e_nname, &pdn );
253 if ( monitor_cache_get( mi, &pdn, &e_parent ) != 0 ) {
254 /* parent does not exist */
255 Debug( LDAP_DEBUG_ANY,
256 "monitor_back_register_entry(\"%s\"): "
257 "parent \"%s\" not found\n",
258 e->e_name.bv_val, pdn.bv_val, 0 );
262 assert( e_parent->e_private != NULL );
263 mp_parent = ( monitor_entry_t * )e_parent->e_private;
265 if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) {
266 /* entry is volatile; cannot append children */
267 Debug( LDAP_DEBUG_ANY,
268 "monitor_back_register_entry(\"%s\"): "
269 "parent \"%s\" is volatile\n",
270 e->e_name.bv_val, e_parent->e_name.bv_val, 0 );
275 mp = monitor_entrypriv_create();
277 Debug( LDAP_DEBUG_ANY,
278 "monitor_back_register_entry(\"%s\"): "
279 "monitor_entrypriv_create() failed\n",
280 e->e_name.bv_val, 0, 0 );
285 e_new = entry_dup( e );
286 if ( e_new == NULL ) {
287 Debug( LDAP_DEBUG_ANY,
288 "monitor_back_register_entry(\"%s\"): "
289 "entry_dup() failed\n",
290 e->e_name.bv_val, 0, 0 );
295 e_new->e_private = ( void * )mp;
296 mp->mp_info = mp_parent->mp_info;
297 mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB;
300 ep = &mp_parent->mp_children;
302 mp_parent = ( monitor_entry_t * )(*ep)->e_private;
303 ep = &mp_parent->mp_next;
307 if ( monitor_cache_add( mi, e_new ) ) {
308 Debug( LDAP_DEBUG_ANY,
309 "monitor_back_register_entry(\"%s\"): "
310 "unable to add entry\n",
311 e->e_name.bv_val, 0, 0 );
322 e_new->e_private = NULL;
328 monitor_cache_release( mi, e_parent );
332 entry_limbo_t **elpp, el = { 0 };
334 el.el_type = LIMBO_ENTRY;
336 el.el_e = entry_dup( e );
337 if ( el.el_e == NULL ) {
338 Debug( LDAP_DEBUG_ANY,
339 "monitor_back_register_entry(\"%s\"): "
340 "entry_dup() failed\n",
341 e->e_name.bv_val, 0, 0 );
347 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
349 elpp = &(*elpp)->el_next )
352 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
353 if ( *elpp == NULL ) {
354 el.el_e->e_private = NULL;
355 entry_free( el.el_e );
367 monitor_back_register_entry_parent(
369 monitor_callback_t *cb,
372 struct berval *filter )
374 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
375 struct berval ndn = BER_BVNULL;
377 assert( mi != NULL );
379 assert( e->e_private == NULL );
381 if ( BER_BVISNULL( filter ) ) {
383 Debug( LDAP_DEBUG_ANY,
384 "monitor_back_register_entry_parent(\"\"): "
385 "need a valid filter\n",
390 if ( monitor_subsys_opened ) {
391 Entry *e_parent = NULL,
394 struct berval e_name = BER_BVNULL,
395 e_nname = BER_BVNULL;
396 monitor_entry_t *mp = NULL,
400 if ( monitor_filter2ndn( base, scope, filter, &ndn ) ) {
401 /* entry does not exist */
402 Debug( LDAP_DEBUG_ANY,
403 "monitor_back_register_entry_*(\"\"): "
404 "base=%s scope=%d filter=%s : "
405 "unable to find entry\n",
406 base->bv_val ? base->bv_val : "\"\"",
407 scope, filter->bv_val );
411 if ( monitor_cache_get( mi, &ndn, &e_parent ) != 0 ) {
412 /* entry does not exist */
413 Debug( LDAP_DEBUG_ANY,
414 "monitor_back_register_entry_parent(\"%s\"): "
415 "parent entry does not exist\n",
421 assert( e_parent->e_private != NULL );
422 mp_parent = ( monitor_entry_t * )e_parent->e_private;
424 if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) {
425 /* entry is volatile; cannot append callback */
426 Debug( LDAP_DEBUG_ANY,
427 "monitor_back_register_entry_*(\"%s\"): "
428 "entry is volatile\n",
429 e_parent->e_name.bv_val, 0, 0 );
434 build_new_dn( &e_name, &e_parent->e_name, &e->e_name, NULL );
435 build_new_dn( &e_nname, &e_parent->e_nname, &e->e_nname, NULL );
437 if ( monitor_cache_get( mi, &e_nname, &e_new ) == 0 ) {
438 /* entry already exists */
439 Debug( LDAP_DEBUG_ANY,
440 "monitor_back_register_entry_parent(\"%s\"): "
441 "entry already exists\n",
442 e_name.bv_val, 0, 0 );
443 monitor_cache_release( mi, e_new );
448 mp = monitor_entrypriv_create();
450 Debug( LDAP_DEBUG_ANY,
451 "monitor_back_register_entry_parent(\"%s\"): "
452 "monitor_entrypriv_create() failed\n",
453 e->e_name.bv_val, 0, 0 );
458 e_new = entry_dup( e );
459 if ( e_new == NULL ) {
460 Debug( LDAP_DEBUG_ANY,
461 "monitor_back_register_entry(\"%s\"): "
462 "entry_dup() failed\n",
463 e->e_name.bv_val, 0, 0 );
467 ch_free( e_new->e_name.bv_val );
468 ch_free( e_new->e_nname.bv_val );
469 e_new->e_name = e_name;
470 e_new->e_nname = e_nname;
472 e_new->e_private = ( void * )mp;
473 mp->mp_info = mp_parent->mp_info;
474 mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB;
477 ep = &mp_parent->mp_children;
479 mp_parent = ( monitor_entry_t * )(*ep)->e_private;
480 ep = &mp_parent->mp_next;
484 if ( monitor_cache_add( mi, e_new ) ) {
485 Debug( LDAP_DEBUG_ANY,
486 "monitor_back_register_entry(\"%s\"): "
487 "unable to add entry\n",
488 e->e_name.bv_val, 0, 0 );
494 if ( !BER_BVISNULL( &ndn ) ) {
495 ch_free( ndn.bv_val );
503 e_new->e_private = NULL;
509 monitor_cache_release( mi, e_parent );
513 entry_limbo_t **elpp, el = { 0 };
515 el.el_type = LIMBO_ENTRY_PARENT;
517 el.el_e = entry_dup( e );
518 if ( el.el_e == NULL ) {
519 Debug( LDAP_DEBUG_ANY,
520 "monitor_back_register_entry(\"%s\"): "
521 "entry_dup() failed\n",
522 e->e_name.bv_val, 0, 0 );
526 if ( !BER_BVISNULL( base ) ) {
527 ber_dupbv( &el.el_base, base );
530 if ( !BER_BVISNULL( filter ) ) {
531 ber_dupbv( &el.el_filter, filter );
536 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
538 elpp = &(*elpp)->el_next )
541 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
542 if ( *elpp == NULL ) {
543 el.el_e->e_private = NULL;
544 entry_free( el.el_e );
556 monitor_filter2ndn_cb( Operation *op, SlapReply *rs )
558 if ( rs->sr_type == REP_SEARCH ) {
559 struct berval *ndn = op->o_callback->sc_private;
561 ber_dupbv( ndn, &rs->sr_entry->e_nname );
571 struct berval *filter,
574 Connection conn = { 0 };
575 char opbuf[OPERATION_BUFFER_SIZE];
577 SlapReply rs = { 0 };
578 slap_callback cb = { NULL, monitor_filter2ndn_cb, NULL, NULL };
583 if ( be_monitor == NULL ) {
587 op = (Operation *)opbuf;
588 connection_fake_init( &conn, op, &conn );
590 op->o_tag = LDAP_REQ_SEARCH;
592 /* use global malloc for now */
593 op->o_tmpmemctx = NULL;
594 op->o_tmpmfuncs = &ch_mfuncs;
596 op->o_bd = be_monitor;
597 if ( base == NULL || BER_BVISNULL( base ) ) {
598 ber_dupbv_x( &op->o_req_dn, &op->o_bd->be_suffix[ 0 ],
600 ber_dupbv_x( &op->o_req_ndn, &op->o_bd->be_nsuffix[ 0 ],
604 if ( dnPrettyNormal( NULL, base, &op->o_req_dn, &op->o_req_ndn,
605 op->o_tmpmemctx ) ) {
610 op->o_callback = &cb;
611 cb.sc_private = (void *)ndn;
613 op->ors_scope = scope;
614 ber_dupbv_x( &op->ors_filterstr, filter, op->o_tmpmemctx );
615 op->ors_filter = str2filter_x( op, filter->bv_val );
616 op->ors_attrs = slap_anlist_no_attrs;
617 op->ors_attrsonly = 0;
618 op->ors_tlimit = SLAP_NO_LIMIT;
620 op->ors_limit = NULL;
621 op->ors_deref = LDAP_DEREF_NEVER;
624 op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
626 rc = op->o_bd->be_search( op, &rs );
628 filter_free_x( op, op->ors_filter );
629 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
630 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
631 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
637 switch ( rs.sr_err ) {
639 if ( BER_BVISNULL( ndn ) ) {
644 case LDAP_SIZELIMIT_EXCEEDED:
646 if ( !BER_BVISNULL( ndn ) ) {
647 ber_memfree( ndn->bv_val );
658 monitor_back_register_entry_attrs(
659 struct berval *ndn_in,
661 monitor_callback_t *cb,
664 struct berval *filter )
666 monitor_info_t *mi = ( monitor_info_t * )be_monitor->be_private;
667 struct berval ndn = BER_BVNULL;
669 assert( mi != NULL );
671 if ( ndn_in != NULL ) {
675 if ( a == NULL && cb == NULL ) {
680 if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) )
681 && BER_BVISNULL( filter ) )
684 Debug( LDAP_DEBUG_ANY,
685 "monitor_back_register_entry_*(\"\"): "
686 "need a valid filter\n",
691 if ( monitor_subsys_opened ) {
693 Attribute **atp = NULL;
694 monitor_entry_t *mp = NULL;
695 monitor_callback_t **mcp = NULL;
699 if ( BER_BVISNULL( &ndn ) ) {
700 if ( monitor_filter2ndn( base, scope, filter, &ndn ) ) {
701 /* entry does not exist */
702 Debug( LDAP_DEBUG_ANY,
703 "monitor_back_register_entry_*(\"\"): "
704 "base=%s scope=%d filter=%s : "
705 "unable to find entry\n",
706 base->bv_val ? base->bv_val : "\"\"",
707 scope, filter->bv_val );
714 if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) {
715 /* entry does not exist */
716 Debug( LDAP_DEBUG_ANY,
717 "monitor_back_register_entry_*(\"%s\"): "
718 "entry does not exist\n",
724 assert( e->e_private != NULL );
725 mp = ( monitor_entry_t * )e->e_private;
727 if ( mp->mp_flags & MONITOR_F_VOLATILE ) {
728 /* entry is volatile; cannot append callback */
729 Debug( LDAP_DEBUG_ANY,
730 "monitor_back_register_entry_*(\"%s\"): "
731 "entry is volatile\n",
732 e->e_name.bv_val, 0, 0 );
738 for ( atp = &e->e_attrs; *atp; atp = &(*atp)->a_next )
739 /* just get to last */ ;
741 *atp = attrs_dup( a );
742 if ( *atp == NULL ) {
743 Debug( LDAP_DEBUG_ANY,
744 "monitor_back_register_entry_*(\"%s\"): "
745 "attrs_dup() failed\n",
746 e->e_name.bv_val, 0, 0 );
753 for ( mcp = &mp->mp_cb; *mcp; mcp = &(*mcp)->mc_next )
756 /* NOTE: we do not clear cb->mc_next, so this function
757 * can be used to append a list of callbacks */
770 ber_memfree( ndn.bv_val );
774 monitor_cache_release( mi, e );
778 entry_limbo_t **elpp, el = { 0 };
780 el.el_type = LIMBO_ATTRS;
781 if ( !BER_BVISNULL( &ndn ) ) {
782 ber_dupbv( &el.el_ndn, &ndn );
784 if ( !BER_BVISNULL( base ) ) {
785 ber_dupbv( &el.el_base, base);
788 if ( !BER_BVISNULL( filter ) ) {
789 ber_dupbv( &el.el_filter, filter );
792 el.el_a = attrs_dup( a );
795 for ( elpp = (entry_limbo_t **)&mi->mi_entry_limbo;
797 elpp = &(*elpp)->el_next )
800 *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
801 if ( *elpp == NULL ) {
802 el.el_e->e_private = NULL;
803 entry_free( el.el_e );
815 monitor_back_register_entry_callback(
817 monitor_callback_t *cb,
820 struct berval *filter )
822 return monitor_back_register_entry_attrs( ndn, NULL, cb,
823 base, scope, filter );
827 monitor_back_get_subsys( const char *name )
829 if ( monitor_subsys != NULL ) {
832 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
833 if ( strcasecmp( monitor_subsys[ i ]->mss_name, name ) == 0 ) {
834 return monitor_subsys[ i ];
843 monitor_back_get_subsys_by_dn(
847 if ( monitor_subsys != NULL ) {
851 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
852 if ( dnIsSuffix( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
853 return monitor_subsys[ i ];
858 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
859 if ( dn_match( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
860 return monitor_subsys[ i ];
870 monitor_back_initialize(
873 monitor_subsys_t *ms;
874 static char *controls[] = {
875 LDAP_CONTROL_MANAGEDSAIT,
879 bi->bi_controls = controls;
883 bi->bi_config = monitor_back_config;
887 bi->bi_db_init = monitor_back_db_init;
888 bi->bi_db_config = monitor_back_db_config;
889 bi->bi_db_open = monitor_back_db_open;
891 bi->bi_db_destroy = monitor_back_db_destroy;
893 bi->bi_op_bind = monitor_back_bind;
894 bi->bi_op_unbind = 0;
895 bi->bi_op_search = monitor_back_search;
896 bi->bi_op_compare = monitor_back_compare;
897 bi->bi_op_modify = monitor_back_modify;
898 bi->bi_op_modrdn = 0;
900 bi->bi_op_delete = 0;
901 bi->bi_op_abandon = 0;
905 bi->bi_entry_release_rw = 0;
906 bi->bi_chk_referrals = 0;
907 bi->bi_operational = monitor_back_operational;
910 * hooks for slap tools
912 bi->bi_tool_entry_open = 0;
913 bi->bi_tool_entry_close = 0;
914 bi->bi_tool_entry_first = 0;
915 bi->bi_tool_entry_next = 0;
916 bi->bi_tool_entry_get = 0;
917 bi->bi_tool_entry_put = 0;
918 bi->bi_tool_entry_reindex = 0;
919 bi->bi_tool_sync = 0;
920 bi->bi_tool_dn2id_get = 0;
921 bi->bi_tool_id2entry_get = 0;
922 bi->bi_tool_entry_modify = 0;
924 bi->bi_connection_init = 0;
925 bi->bi_connection_destroy = 0;
927 for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
928 if ( monitor_back_register_subsys( ms ) ) {
937 monitor_back_db_init(
942 struct berval dn, ndn;
952 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
954 "DESC 'OpenLDAP system monitoring' "
955 "SUP top STRUCTURAL "
960 #if 0 /* temporarily disabled */
971 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
972 offsetof(monitor_info_t, mi_oc_monitor) },
973 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
974 "NAME 'monitorServer' "
975 "DESC 'Server monitoring root entry' "
976 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
977 offsetof(monitor_info_t, mi_oc_monitorServer) },
978 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
979 "NAME 'monitorContainer' "
980 "DESC 'monitor container class' "
981 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
982 offsetof(monitor_info_t, mi_oc_monitorContainer) },
983 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
984 "NAME 'monitorCounterObject' "
985 "DESC 'monitor counter class' "
986 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
987 offsetof(monitor_info_t, mi_oc_monitorCounterObject) },
988 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
989 "NAME 'monitorOperation' "
990 "DESC 'monitor operation class' "
991 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
992 offsetof(monitor_info_t, mi_oc_monitorOperation) },
993 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
994 "NAME 'monitorConnection' "
995 "DESC 'monitor connection class' "
996 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
997 offsetof(monitor_info_t, mi_oc_monitorConnection) },
998 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
999 "NAME 'managedObject' "
1000 "DESC 'monitor managed entity class' "
1001 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
1002 offsetof(monitor_info_t, mi_oc_managedObject) },
1003 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.14 "
1004 "NAME 'monitoredObject' "
1005 "DESC 'monitor monitored entity class' "
1006 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
1007 offsetof(monitor_info_t, mi_oc_monitoredObject) },
1008 { NULL, NULL, 0, -1 }
1010 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
1011 "NAME 'monitoredInfo' "
1012 "DESC 'monitored info' "
1014 "EQUALITY caseIgnoreMatch "
1015 "SUBSTR caseIgnoreSubstringsMatch "
1016 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
1017 "NO-USER-MODIFICATION "
1018 "USAGE directoryOperation )", SLAP_AT_HIDE,
1019 offsetof(monitor_info_t, mi_ad_monitoredInfo) },
1020 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
1021 "NAME 'managedInfo' "
1022 "DESC 'monitor managed info' "
1023 "SUP name )", SLAP_AT_HIDE,
1024 offsetof(monitor_info_t, mi_ad_managedInfo) },
1025 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
1026 "NAME 'monitorCounter' "
1027 "DESC 'monitor counter' "
1028 "EQUALITY integerMatch "
1029 "ORDERING integerOrderingMatch "
1030 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
1031 "NO-USER-MODIFICATION "
1032 "USAGE directoryOperation )", SLAP_AT_HIDE,
1033 offsetof(monitor_info_t, mi_ad_monitorCounter) },
1034 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
1035 "NAME 'monitorOpCompleted' "
1036 "DESC 'monitor completed operations' "
1037 "SUP monitorCounter "
1038 "NO-USER-MODIFICATION "
1039 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1040 offsetof(monitor_info_t, mi_ad_monitorOpCompleted) },
1041 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
1042 "NAME 'monitorOpInitiated' "
1043 "DESC 'monitor initiated operations' "
1044 "SUP monitorCounter "
1045 "NO-USER-MODIFICATION "
1046 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1047 offsetof(monitor_info_t, mi_ad_monitorOpInitiated) },
1048 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
1049 "NAME 'monitorConnectionNumber' "
1050 "DESC 'monitor connection number' "
1051 "SUP monitorCounter "
1052 "NO-USER-MODIFICATION "
1053 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1054 offsetof(monitor_info_t, mi_ad_monitorConnectionNumber) },
1055 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
1056 "NAME 'monitorConnectionAuthzDN' "
1057 "DESC 'monitor connection authorization DN' "
1058 /* "SUP distinguishedName " */
1059 "EQUALITY distinguishedNameMatch "
1060 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
1061 "NO-USER-MODIFICATION "
1062 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1063 offsetof(monitor_info_t, mi_ad_monitorConnectionAuthzDN) },
1064 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
1065 "NAME 'monitorConnectionLocalAddress' "
1066 "DESC 'monitor connection local address' "
1067 "SUP monitoredInfo "
1068 "NO-USER-MODIFICATION "
1069 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1070 offsetof(monitor_info_t, mi_ad_monitorConnectionLocalAddress) },
1071 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
1072 "NAME 'monitorConnectionPeerAddress' "
1073 "DESC 'monitor connection peer address' "
1074 "SUP monitoredInfo "
1075 "NO-USER-MODIFICATION "
1076 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1077 offsetof(monitor_info_t, mi_ad_monitorConnectionPeerAddress) },
1078 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
1079 "NAME 'monitorTimestamp' "
1080 "DESC 'monitor timestamp' "
1081 "EQUALITY generalizedTimeMatch "
1082 "ORDERING generalizedTimeOrderingMatch "
1083 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
1085 "NO-USER-MODIFICATION "
1086 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1087 offsetof(monitor_info_t, mi_ad_monitorTimestamp) },
1088 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
1089 "NAME 'monitorOverlay' "
1090 "DESC 'name of overlays defined for a given database' "
1091 "SUP monitoredInfo "
1092 "NO-USER-MODIFICATION "
1093 "USAGE directoryOperation )", SLAP_AT_HIDE,
1094 offsetof(monitor_info_t, mi_ad_monitorOverlay) },
1095 { "readOnly", "( 1.3.6.1.4.1.4203.666.1.31 "
1097 "DESC 'read/write status of a given database' "
1098 "EQUALITY booleanMatch "
1099 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
1101 "USAGE directoryOperation )", SLAP_AT_HIDE,
1102 offsetof(monitor_info_t, mi_ad_readOnly) },
1103 { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.32 "
1104 "NAME 'restrictedOperation' "
1105 "DESC 'name of restricted operation for a given database' "
1106 "SUP managedInfo )", SLAP_AT_HIDE,
1107 offsetof(monitor_info_t, mi_ad_restrictedOperation ) },
1108 { "monitorConnectionProtocol", "( 1.3.6.1.4.1.4203.666.1.39 "
1109 "NAME 'monitorConnectionProtocol' "
1110 "DESC 'monitor connection protocol' "
1111 "SUP monitoredInfo "
1112 "NO-USER-MODIFICATION "
1113 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1114 offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) },
1115 { "monitorConnectionOpsReceived", "( 1.3.6.1.4.1.4203.666.1.40 "
1116 "NAME 'monitorConnectionOpsReceived' "
1117 "DESC 'monitor number of operations received by the connection' "
1118 "SUP monitorCounter "
1119 "NO-USER-MODIFICATION "
1120 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1121 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) },
1122 { "monitorConnectionOpsExecuting", "( 1.3.6.1.4.1.4203.666.1.41 "
1123 "NAME 'monitorConnectionOpsExecuting' "
1124 "DESC 'monitor number of operations in execution within the connection' "
1125 "SUP monitorCounter "
1126 "NO-USER-MODIFICATION "
1127 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1128 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) },
1129 { "monitorConnectionOpsPending", "( 1.3.6.1.4.1.4203.666.1.42 "
1130 "NAME 'monitorConnectionOpsPending' "
1131 "DESC 'monitor number of pending operations within the connection' "
1132 "SUP monitorCounter "
1133 "NO-USER-MODIFICATION "
1134 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1135 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) },
1136 { "monitorConnectionOpsCompleted", "( 1.3.6.1.4.1.4203.666.1.43 "
1137 "NAME 'monitorConnectionOpsCompleted' "
1138 "DESC 'monitor number of operations completed within the connection' "
1139 "SUP monitorCounter "
1140 "NO-USER-MODIFICATION "
1141 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1142 offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) },
1143 { "monitorConnectionGet", "( 1.3.6.1.4.1.4203.666.1.44 "
1144 "NAME 'monitorConnectionGet' "
1145 "DESC 'number of times connection_get() was called so far' "
1146 "SUP monitorCounter "
1147 "NO-USER-MODIFICATION "
1148 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1149 offsetof(monitor_info_t, mi_ad_monitorConnectionGet) },
1150 { "monitorConnectionRead", "( 1.3.6.1.4.1.4203.666.1.45 "
1151 "NAME 'monitorConnectionRead' "
1152 "DESC 'number of times connection_read() was called so far' "
1153 "SUP monitorCounter "
1154 "NO-USER-MODIFICATION "
1155 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1156 offsetof(monitor_info_t, mi_ad_monitorConnectionRead) },
1157 { "monitorConnectionWrite", "( 1.3.6.1.4.1.4203.666.1.46 "
1158 "NAME 'monitorConnectionWrite' "
1159 "DESC 'number of times connection_write() was called so far' "
1160 "SUP monitorCounter "
1161 "NO-USER-MODIFICATION "
1162 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1163 offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) },
1164 { "monitorConnectionMask", "( 1.3.6.1.4.1.4203.666.1.47 "
1165 "NAME 'monitorConnectionMask' "
1166 "DESC 'monitor connection mask' "
1167 "SUP monitoredInfo "
1168 "NO-USER-MODIFICATION "
1169 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1170 offsetof(monitor_info_t, mi_ad_monitorConnectionMask) },
1171 { "monitorConnectionListener", "( 1.3.6.1.4.1.4203.666.1.48 "
1172 "NAME 'monitorConnectionListener' "
1173 "DESC 'monitor connection listener' "
1174 "SUP monitoredInfo "
1175 "NO-USER-MODIFICATION "
1176 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1177 offsetof(monitor_info_t, mi_ad_monitorConnectionListener) },
1178 { "monitorConnectionPeerDomain", "( 1.3.6.1.4.1.4203.666.1.49 "
1179 "NAME 'monitorConnectionPeerDomain' "
1180 "DESC 'monitor connection peer domain' "
1181 "SUP monitoredInfo "
1182 "NO-USER-MODIFICATION "
1183 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1184 offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) },
1185 { "monitorConnectionStartTime", "( 1.3.6.1.4.1.4203.666.1.50 "
1186 "NAME 'monitorConnectionStartTime' "
1187 "DESC 'monitor connection start time' "
1188 "SUP monitorTimestamp "
1190 "NO-USER-MODIFICATION "
1191 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1192 offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) },
1193 { "monitorConnectionActivityTime", "( 1.3.6.1.4.1.4203.666.1.51 "
1194 "NAME 'monitorConnectionActivityTime' "
1195 "DESC 'monitor connection activity time' "
1196 "SUP monitorTimestamp "
1198 "NO-USER-MODIFICATION "
1199 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
1200 offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) },
1201 #ifdef INTEGRATE_CORE_SCHEMA
1202 { NULL, NULL, 0, -1 }, /* description */
1203 { NULL, NULL, 0, -1 }, /* seeAlso */
1204 { NULL, NULL, 0, -1 }, /* l */
1205 { NULL, NULL, 0, -1 }, /* labeledURI */
1206 #endif /* INTEGRATE_CORE_SCHEMA */
1207 { NULL, NULL, 0, -1 }
1209 { "description", "( 2.5.4.13 "
1210 "NAME 'description' "
1211 "DESC 'RFC2256: descriptive information' "
1212 "EQUALITY caseIgnoreMatch "
1213 "SUBSTR caseIgnoreSubstringsMatch "
1214 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
1215 offsetof(monitor_info_t, mi_ad_description) },
1216 { "seeAlso", "( 2.5.4.34 "
1218 "DESC 'RFC2256: DN of related object' "
1219 "SUP distinguishedName )", 0,
1220 offsetof(monitor_info_t, mi_ad_seeAlso) },
1222 "NAME ( 'l' 'localityName' ) "
1223 "DESC 'RFC2256: locality which this object resides in' "
1225 offsetof(monitor_info_t, mi_ad_l) },
1226 #ifdef MONITOR_DEFINE_LABELEDURI
1227 { "labeledURI", "( 1.3.6.1.4.1.250.1.57 "
1228 "NAME 'labeledURI' "
1229 "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
1230 "EQUALITY caseExactMatch "
1231 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )", 0,
1232 offsetof(monitor_info_t, mi_ad_labeledURI) },
1233 #endif /* MONITOR_DEFINE_LABELEDURI */
1234 { NULL, NULL, 0, -1 }
1238 * database monitor can be defined once only
1241 Debug( LDAP_DEBUG_ANY,
1242 "only one monitor backend is allowed\n", 0, 0, 0 );
1247 /* indicate system schema supported */
1248 SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
1250 dn.bv_val = SLAPD_MONITOR_DN;
1251 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
1253 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
1254 if( rc != LDAP_SUCCESS ) {
1255 Debug( LDAP_DEBUG_ANY,
1256 "unable to normalize monitor DN \"%s\"\n",
1257 SLAPD_MONITOR_DN, 0, 0 );
1261 ber_dupbv( &bv, &dn );
1262 ber_bvarray_add( &be->be_suffix, &bv );
1263 ber_bvarray_add( &be->be_nsuffix, &ndn );
1265 mi = ( monitor_info_t * )ch_calloc( sizeof( monitor_info_t ), 1 );
1267 Debug( LDAP_DEBUG_ANY,
1268 "unable to initialize monitor backend\n", 0, 0, 0 );
1272 memset( mi, 0, sizeof( monitor_info_t ) );
1274 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
1276 be->be_private = mi;
1278 #ifdef INTEGRATE_CORE_SCHEMA
1279 /* prepare for schema integration */
1280 for ( k = 0; mat[ k ].name != NULL; k++ );
1281 #endif /* INTEGRATE_CORE_SCHEMA */
1283 for ( i = 0; mat_core[ i ].name != NULL; i++ ) {
1284 AttributeDescription **ad;
1287 ad = ((AttributeDescription **)&(((char *)mi)[ mat_core[ i ].offset ]));
1290 switch (slap_str2ad( mat_core[ i ].name, ad, &text ) ) {
1294 #ifdef INTEGRATE_CORE_SCHEMA
1295 case LDAP_UNDEFINED_TYPE:
1296 mat[ k ] = mat_core[ i ];
1299 #endif /* INTEGRATE_CORE_SCHEMA */
1302 Debug( LDAP_DEBUG_ANY,
1303 "monitor_back_db_init: %s: %s\n",
1304 mat_core[ i ].name, text, 0 );
1309 /* schema integration */
1310 for ( i = 0; mat[ i ].name; i++ ) {
1311 LDAPAttributeType *at;
1314 AttributeDescription **ad;
1316 at = ldap_str2attributetype( mat[ i ].schema, &code,
1317 &err, LDAP_SCHEMA_ALLOW_ALL );
1319 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1320 "in AttributeType \"%s\" %s before %s\n",
1321 mat[ i ].name, ldap_scherr2str(code), err );
1325 if ( at->at_oid == NULL ) {
1326 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1327 "null OID for attributeType \"%s\"\n",
1328 mat[ i ].name, 0, 0 );
1332 code = at_add(at, 0, NULL, &err);
1334 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1335 "%s in attributeType \"%s\"\n",
1336 scherr2str(code), mat[ i ].name, 0 );
1341 ad = ((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ]));
1343 if ( slap_str2ad( mat[ i ].name, ad, &text ) ) {
1344 Debug( LDAP_DEBUG_ANY,
1345 "monitor_back_db_init: %s\n", text, 0, 0 );
1349 (*ad)->ad_type->sat_flags |= mat[ i ].flags;
1352 for ( i = 0; moc[ i ].name; i++ ) {
1353 LDAPObjectClass *oc;
1358 oc = ldap_str2objectclass(moc[ i ].schema, &code, &err,
1359 LDAP_SCHEMA_ALLOW_ALL );
1361 Debug( LDAP_DEBUG_ANY,
1362 "unable to parse monitor objectclass \"%s\": "
1363 "%s before %s\n" , moc[ i ].name,
1364 ldap_scherr2str(code), err );
1368 if ( oc->oc_oid == NULL ) {
1369 Debug( LDAP_DEBUG_ANY,
1370 "objectclass \"%s\" has no OID\n" ,
1371 moc[ i ].name, 0, 0 );
1375 code = oc_add(oc, 0, NULL, &err);
1377 Debug( LDAP_DEBUG_ANY,
1378 "objectclass \"%s\": %s \"%s\"\n" ,
1379 moc[ i ].name, scherr2str(code), err );
1385 Oc = oc_find( moc[ i ].name );
1387 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
1388 "unable to find objectClass %s "
1389 "(just added)\n", moc[ i ].name, 0, 0 );
1393 Oc->soc_flags |= moc[ i ].flags;
1395 ((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]))[ 0 ] = Oc;
1402 monitor_back_db_open(
1405 monitor_info_t *mi = (monitor_info_t *)be->be_private;
1406 struct monitor_subsys_t **ms;
1408 monitor_entry_t *mp;
1410 char buf[ BACKMONITOR_BUFSIZE ],
1414 #ifdef HAVE_GMTIME_R
1417 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
1419 assert( be_monitor );
1420 if ( be != be_monitor ) {
1427 #ifndef HAVE_GMTIME_R
1428 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
1430 #ifdef HACK_LOCAL_TIME
1431 # ifdef HAVE_LOCALTIME_R
1432 tms = localtime_r( &starttime, &tm_buf );
1434 tms = localtime( &starttime );
1435 # endif /* HAVE_LOCALTIME_R */
1436 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
1437 #else /* !HACK_LOCAL_TIME */
1438 # ifdef HAVE_GMTIME_R
1439 tms = gmtime_r( &starttime, &tm_buf );
1441 tms = gmtime( &starttime );
1442 # endif /* HAVE_GMTIME_R */
1443 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
1444 #endif /* !HACK_LOCAL_TIME */
1445 #ifndef HAVE_GMTIME_R
1446 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
1449 mi->mi_startTime.bv_val = tmbuf;
1450 mi->mi_startTime.bv_len = strlen( tmbuf );
1452 if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
1453 BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
1455 mi->mi_creatorsName = be->be_rootdn;
1459 * creates the "cn=Monitor" entry
1461 snprintf( buf, sizeof( buf ),
1464 "structuralObjectClass: %s\n"
1466 "%s: This subtree contains monitoring/managing objects.\n"
1467 "%s: This object contains information about this server.\n"
1469 "%s: createTimestamp reflects the time this server instance was created.\n"
1470 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
1472 "creatorsName: %s\n"
1473 "modifiersName: %s\n"
1474 "createTimestamp: %s\n"
1475 "modifyTimestamp: %s\n",
1477 mi->mi_oc_monitorServer->soc_cname.bv_val,
1478 mi->mi_oc_monitorServer->soc_cname.bv_val,
1479 mi->mi_ad_description->ad_cname.bv_val,
1480 mi->mi_ad_description->ad_cname.bv_val,
1482 mi->mi_ad_description->ad_cname.bv_val,
1483 mi->mi_ad_description->ad_cname.bv_val,
1485 mi->mi_creatorsName.bv_val,
1486 mi->mi_creatorsName.bv_val,
1487 mi->mi_startTime.bv_val,
1488 mi->mi_startTime.bv_val );
1490 e = str2entry( buf );
1492 Debug( LDAP_DEBUG_ANY,
1493 "unable to create \"%s\" entry\n",
1494 SLAPD_MONITOR_DN, 0, 0 );
1498 bv.bv_val = (char *) Versionstr;
1499 end_of_line = strchr( Versionstr, '\n' );
1500 if ( end_of_line ) {
1501 bv.bv_len = end_of_line - Versionstr;
1503 bv.bv_len = strlen( Versionstr );
1506 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
1508 Debug( LDAP_DEBUG_ANY,
1509 "unable to add monitoredInfo to \"%s\" entry\n",
1510 SLAPD_MONITOR_DN, 0, 0 );
1514 if ( mi->mi_l.bv_len ) {
1515 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
1516 Debug( LDAP_DEBUG_ANY,
1517 "unable to add locality to \"%s\" entry\n",
1518 SLAPD_MONITOR_DN, 0, 0 );
1523 mp = monitor_entrypriv_create();
1527 e->e_private = ( void * )mp;
1528 ep = &mp->mp_children;
1530 if ( monitor_cache_add( mi, e ) ) {
1531 Debug( LDAP_DEBUG_ANY,
1532 "unable to add entry \"%s\" to cache\n",
1533 SLAPD_MONITOR_DN, 0, 0 );
1538 * Create all the subsystem specific entries
1540 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
1541 int len = strlen( monitor_subsys[ i ]->mss_name );
1545 dn.bv_len = len + sizeof( "cn=" ) - 1;
1546 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
1547 strcpy( dn.bv_val, "cn=" );
1548 strcat( dn.bv_val, monitor_subsys[ i ]->mss_name );
1549 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL );
1551 if ( rc != LDAP_SUCCESS ) {
1552 Debug( LDAP_DEBUG_ANY,
1553 "monitor RDN \"%s\" is invalid\n",
1558 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
1559 dn.bv_val = ch_malloc( dn.bv_len + 1 );
1560 strcpy( dn.bv_val , monitor_subsys[ i ]->mss_rdn.bv_val );
1561 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
1562 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ]->mss_dn,
1563 &monitor_subsys[ i ]->mss_ndn, NULL );
1565 if ( rc != LDAP_SUCCESS ) {
1566 Debug( LDAP_DEBUG_ANY,
1567 "monitor DN \"%s\" is invalid\n",
1572 snprintf( buf, sizeof( buf ),
1575 "structuralObjectClass: %s\n"
1577 "creatorsName: %s\n"
1578 "modifiersName: %s\n"
1579 "createTimestamp: %s\n"
1580 "modifyTimestamp: %s\n",
1581 monitor_subsys[ i ]->mss_dn.bv_val,
1582 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1583 mi->mi_oc_monitorContainer->soc_cname.bv_val,
1584 monitor_subsys[ i ]->mss_name,
1585 mi->mi_creatorsName.bv_val,
1586 mi->mi_creatorsName.bv_val,
1587 mi->mi_startTime.bv_val,
1588 mi->mi_startTime.bv_val );
1590 e = str2entry( buf );
1593 Debug( LDAP_DEBUG_ANY,
1594 "unable to create \"%s\" entry\n",
1595 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1599 mp = monitor_entrypriv_create();
1603 e->e_private = ( void * )mp;
1604 mp->mp_info = monitor_subsys[ i ];
1605 mp->mp_flags = monitor_subsys[ i ]->mss_flags;
1607 if ( monitor_cache_add( mi, e ) ) {
1608 Debug( LDAP_DEBUG_ANY,
1609 "unable to add entry \"%s\" to cache\n",
1610 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
1620 be->be_private = mi;
1623 * opens the monitor backend subsystems
1625 for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) {
1626 if ( ms[ 0 ]->mss_open && ( *ms[ 0 ]->mss_open )( be, ms[ 0 ] ) )
1630 ms[ 0 ]->mss_flags |= MONITOR_F_OPENED;
1633 monitor_subsys_opened = 1;
1635 if ( mi->mi_entry_limbo ) {
1636 entry_limbo_t *el = (entry_limbo_t *)mi->mi_entry_limbo;
1641 switch ( el->el_type ) {
1643 monitor_back_register_entry(
1648 case LIMBO_ENTRY_PARENT:
1649 monitor_back_register_entry_parent(
1659 monitor_back_register_entry_attrs(
1669 monitor_back_register_entry_callback(
1682 entry_free( el->el_e );
1685 attrs_free( el->el_a );
1687 if ( !BER_BVISNULL( &el->el_ndn ) ) {
1688 ber_memfree( el->el_ndn.bv_val );
1690 if ( !BER_BVISNULL( &el->el_base ) ) {
1691 ber_memfree( el->el_base.bv_val );
1693 if ( !BER_BVISNULL( &el->el_filter ) ) {
1694 ber_memfree( el->el_filter.bv_val );
1702 mi->mi_entry_limbo = NULL;
1709 monitor_back_config(
1717 * eventually, will hold backend specific configuration parameters
1719 return SLAP_CONF_UNKNOWN;
1723 monitor_back_db_config(
1730 monitor_info_t *mi = ( monitor_info_t * )be->be_private;
1733 * eventually, will hold database specific configuration parameters
1735 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
1740 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
1743 return SLAP_CONF_UNKNOWN;
1750 monitor_back_db_destroy(
1754 * FIXME: destroys all the data
1759 #if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
1761 /* conditionally define the init_module() function */
1762 SLAP_BACKEND_INIT_MODULE( monitor )
1764 #endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */