1 /* overlay.c - deals with overlay subsystem */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2001-2004 The OpenLDAP Foundation.
5 * Portions Copyright 2001-2003 Pierangelo Masarati.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masarati for inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
28 #include "back-monitor.h"
31 * initializes overlay subentries
34 monitor_subsys_overlay_init(
38 struct monitorinfo *mi;
39 Entry *e, *e_overlay, *e_tmp;
41 struct monitorentrypriv *mp;
44 mi = ( struct monitorinfo * )be->be_private;
46 if ( monitor_cache_get( mi,
47 &monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn,
49 Debug( LDAP_DEBUG_ANY,
50 "monitor_subsys_overlay_init: "
51 "unable to get entry '%s'\n%s%s",
52 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
58 for ( on = overlay_next( NULL ), i = 0; on; on = overlay_next( on ), i++ ) {
59 char buf[ BACKMONITOR_BUFSIZE ];
63 snprintf( buf, sizeof( buf ),
64 "dn: cn=Overlay %d,%s\n"
66 "structuralObjectClass: %s\n"
70 "createTimestamp: %s\n"
71 "modifyTimestamp: %s\n",
73 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_dn.bv_val,
74 mi->mi_oc_monitoredObject->soc_cname.bv_val,
75 mi->mi_oc_monitoredObject->soc_cname.bv_val,
77 mi->mi_creatorsName.bv_val,
78 mi->mi_creatorsName.bv_val,
79 mi->mi_startTime.bv_val,
80 mi->mi_startTime.bv_val );
84 Debug( LDAP_DEBUG_ANY,
85 "monitor_subsys_overlay_init: "
86 "unable to create entry 'cn=Overlay %d,%s'\n%s",
88 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
93 bv.bv_val = on->on_bi.bi_type;
94 bv.bv_len = strlen( bv.bv_val );
96 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
98 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
101 for ( j = 0; j < nBackendDB; j++ ) {
102 BackendDB *be = &backendDB[j];
103 char buf[ SLAP_LDAPDN_MAXLEN ];
107 if ( strcmp( be->bd_info->bi_type, "over" ) != 0 ) {
111 on2 = ((slap_overinfo *)be->bd_info->bi_private)->oi_list;
112 for ( ; on2; on2 = on2->on_next ) {
113 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
122 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
123 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
125 dn.bv_len = strlen( buf );
127 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
131 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
132 e->e_private = ( void * )mp;
134 mp->mp_children = NULL;
135 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OVERLAY];
136 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_flags
139 if ( monitor_cache_add( mi, e ) ) {
140 Debug( LDAP_DEBUG_ANY,
141 "monitor_subsys_overlay_init: "
142 "unable to add entry 'cn=Overlay %d,%s'\n%s",
144 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
152 mp = ( struct monitorentrypriv * )e_overlay->e_private;
153 mp->mp_children = e_tmp;
155 monitor_cache_release( mi, e_overlay );