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,
50 LDAP_LOG( OPERATION, CRIT,
51 "monitor_subsys_overlay_init: "
52 "unable to get entry '%s'\n",
53 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0, 0 );
55 Debug( LDAP_DEBUG_ANY,
56 "monitor_subsys_overlay_init: "
57 "unable to get entry '%s'\n%s%s",
58 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
65 for ( on = overlay_next( NULL ), i = 0; on; on = overlay_next( on ), i++ ) {
66 char buf[ BACKMONITOR_BUFSIZE ];
70 snprintf( buf, sizeof( buf ),
71 "dn: cn=Overlay %d,%s\n"
73 "structuralObjectClass: %s\n"
75 "createTimestamp: %s\n"
76 "modifyTimestamp: %s\n",
78 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_dn.bv_val,
79 mi->mi_oc_monitoredObject->soc_cname.bv_val,
80 mi->mi_oc_monitoredObject->soc_cname.bv_val,
82 mi->mi_startTime.bv_val,
83 mi->mi_startTime.bv_val );
88 LDAP_LOG( OPERATION, CRIT,
89 "monitor_subsys_overlay_init: "
90 "unable to create entry 'cn=Overlay %d,%s'\n",
91 i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
93 Debug( LDAP_DEBUG_ANY,
94 "monitor_subsys_overlay_init: "
95 "unable to create entry 'cn=Overlay %d,%s'\n%s",
97 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
103 bv.bv_val = on->on_bi.bi_type;
104 bv.bv_len = strlen( bv.bv_val );
106 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
108 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
111 for ( j = 0; j < nBackendDB; j++ ) {
112 BackendDB *be = &backendDB[j];
113 char buf[ SLAP_LDAPDN_MAXLEN ];
117 if ( strcmp( be->bd_info->bi_type, "over" ) != 0 ) {
121 on2 = ((slap_overinfo *)be->bd_info->bi_private)->oi_list;
122 for ( ; on2; on2 = on2->on_next ) {
123 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
132 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
133 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
135 dn.bv_len = strlen( buf );
137 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
141 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
142 e->e_private = ( void * )mp;
144 mp->mp_children = NULL;
145 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OVERLAY];
146 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_flags
149 if ( monitor_cache_add( mi, e ) ) {
151 LDAP_LOG( OPERATION, CRIT,
152 "monitor_subsys_overlay_init: "
153 "unable to add entry 'cn=Overlay %d,%s'\n",
154 i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
156 Debug( LDAP_DEBUG_ANY,
157 "monitor_subsys_overlay_init: "
158 "unable to add entry 'cn=Overlay %d,%s'\n%s",
160 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
169 mp = ( struct monitorentrypriv * )e_overlay->e_private;
170 mp->mp_children = e_tmp;
172 monitor_cache_release( mi, e_overlay );