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"
77 "createTimestamp: %s\n"
78 "modifyTimestamp: %s\n",
80 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_dn.bv_val,
81 mi->mi_oc_monitoredObject->soc_cname.bv_val,
82 mi->mi_oc_monitoredObject->soc_cname.bv_val,
84 mi->mi_creatorsName.bv_val,
85 mi->mi_creatorsName.bv_val,
86 mi->mi_startTime.bv_val,
87 mi->mi_startTime.bv_val );
92 LDAP_LOG( OPERATION, CRIT,
93 "monitor_subsys_overlay_init: "
94 "unable to create entry 'cn=Overlay %d,%s'\n",
95 i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
97 Debug( LDAP_DEBUG_ANY,
98 "monitor_subsys_overlay_init: "
99 "unable to create entry 'cn=Overlay %d,%s'\n%s",
101 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
107 bv.bv_val = on->on_bi.bi_type;
108 bv.bv_len = strlen( bv.bv_val );
110 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
112 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
115 for ( j = 0; j < nBackendDB; j++ ) {
116 BackendDB *be = &backendDB[j];
117 char buf[ SLAP_LDAPDN_MAXLEN ];
121 if ( strcmp( be->bd_info->bi_type, "over" ) != 0 ) {
125 on2 = ((slap_overinfo *)be->bd_info->bi_private)->oi_list;
126 for ( ; on2; on2 = on2->on_next ) {
127 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
136 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
137 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
139 dn.bv_len = strlen( buf );
141 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
145 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
146 e->e_private = ( void * )mp;
148 mp->mp_children = NULL;
149 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OVERLAY];
150 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_flags
153 if ( monitor_cache_add( mi, e ) ) {
155 LDAP_LOG( OPERATION, CRIT,
156 "monitor_subsys_overlay_init: "
157 "unable to add entry 'cn=Overlay %d,%s'\n",
158 i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
160 Debug( LDAP_DEBUG_ANY,
161 "monitor_subsys_overlay_init: "
162 "unable to add entry 'cn=Overlay %d,%s'\n%s",
164 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
173 mp = ( struct monitorentrypriv * )e_overlay->e_private;
174 mp->mp_children = e_tmp;
176 monitor_cache_release( mi, e_overlay );