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_overlay, **ep;
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 Debug( LDAP_DEBUG_ANY,
51 "monitor_subsys_overlay_init: "
52 "unable to get entry \"%s\"\n",
53 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0, 0 );
57 mp = ( struct monitorentrypriv * )e_overlay->e_private;
58 mp->mp_children = NULL;
59 ep = &mp->mp_children;
61 for ( on = overlay_next( NULL ), i = 0; on; on = overlay_next( on ), i++ ) {
62 char buf[ BACKMONITOR_BUFSIZE ];
67 snprintf( buf, sizeof( buf ),
68 "dn: cn=Overlay %d,%s\n"
70 "structuralObjectClass: %s\n"
74 "createTimestamp: %s\n"
75 "modifyTimestamp: %s\n",
77 monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_dn.bv_val,
78 mi->mi_oc_monitoredObject->soc_cname.bv_val,
79 mi->mi_oc_monitoredObject->soc_cname.bv_val,
81 mi->mi_creatorsName.bv_val,
82 mi->mi_creatorsName.bv_val,
83 mi->mi_startTime.bv_val,
84 mi->mi_startTime.bv_val );
88 Debug( LDAP_DEBUG_ANY,
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 );
95 bv.bv_val = on->on_bi.bi_type;
96 bv.bv_len = strlen( bv.bv_val );
98 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
100 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
103 for ( j = 0; j < nBackendDB; j++ ) {
104 BackendDB *be = &backendDB[j];
105 char buf[ SLAP_LDAPDN_MAXLEN ];
109 if ( strcmp( be->bd_info->bi_type, "over" ) != 0 ) {
113 on2 = ((slap_overinfo *)be->bd_info->bi_private)->oi_list;
114 for ( ; on2; on2 = on2->on_next ) {
115 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
124 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
125 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
127 dn.bv_len = strlen( buf );
129 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
133 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
134 e->e_private = ( void * )mp;
136 mp->mp_children = NULL;
137 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OVERLAY];
138 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_flags
141 if ( monitor_cache_add( mi, e ) ) {
142 Debug( LDAP_DEBUG_ANY,
143 "monitor_subsys_overlay_init: "
144 "unable to add entry \"cn=Overlay %d,%s\"\n",
145 i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
153 monitor_cache_release( mi, e_overlay );