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(
39 struct monitorinfo *mi;
40 Entry *e_overlay, **ep;
42 struct monitorentrypriv *mp;
44 monitorsubsys *ms_database;
46 mi = ( struct monitorinfo * )be->be_private;
48 ms_database = monitor_back_get_subsys( SLAPD_MONITOR_DATABASE_NAME );
49 if ( ms_database == NULL ) {
50 Debug( LDAP_DEBUG_ANY,
51 "monitor_subsys_backend_init: "
53 "\"" SLAPD_MONITOR_DATABASE_NAME "\" "
59 if ( monitor_cache_get( mi,
63 Debug( LDAP_DEBUG_ANY,
64 "monitor_subsys_overlay_init: "
65 "unable to get entry \"%s\"\n",
66 ms->mss_ndn.bv_val, 0, 0 );
70 mp = ( struct monitorentrypriv * )e_overlay->e_private;
71 mp->mp_children = NULL;
72 ep = &mp->mp_children;
74 for ( on = overlay_next( NULL ), i = 0; on; on = overlay_next( on ), i++ ) {
75 char buf[ BACKMONITOR_BUFSIZE ];
80 snprintf( buf, sizeof( buf ),
81 "dn: cn=Overlay %d,%s\n"
83 "structuralObjectClass: %s\n"
87 "createTimestamp: %s\n"
88 "modifyTimestamp: %s\n",
91 mi->mi_oc_monitoredObject->soc_cname.bv_val,
92 mi->mi_oc_monitoredObject->soc_cname.bv_val,
94 mi->mi_creatorsName.bv_val,
95 mi->mi_creatorsName.bv_val,
96 mi->mi_startTime.bv_val,
97 mi->mi_startTime.bv_val );
101 Debug( LDAP_DEBUG_ANY,
102 "monitor_subsys_overlay_init: "
103 "unable to create entry \"cn=Overlay %d,%s\"\n",
104 i, ms->mss_ndn.bv_val, 0 );
108 bv.bv_val = on->on_bi.bi_type;
109 bv.bv_len = strlen( bv.bv_val );
111 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
113 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
116 for ( j = 0; j < nBackendDB; j++ ) {
117 BackendDB *be = &backendDB[ j ];
118 char buf[ SLAP_LDAPDN_MAXLEN ];
122 if ( strcmp( be->bd_info->bi_type, "over" ) != 0 ) {
126 on2 = ((slap_overinfo *)be->bd_info->bi_private)->oi_list;
127 for ( ; on2; on2 = on2->on_next ) {
128 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
137 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
138 j, ms_database->mss_dn.bv_val );
140 dn.bv_len = strlen( buf );
142 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
146 mp = monitor_entrypriv_create();
150 e->e_private = ( void * )mp;
152 mp->mp_flags = ms->mss_flags
155 if ( monitor_cache_add( mi, e ) ) {
156 Debug( LDAP_DEBUG_ANY,
157 "monitor_subsys_overlay_init: "
158 "unable to add entry \"cn=Overlay %d,%s\"\n",
159 i, ms->mss_ndn.bv_val, 0 );
167 monitor_cache_release( mi, e_overlay );