1 /* overlay.c - deals with overlay subsystem */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2001-2005 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(
40 Entry *e_overlay, **ep;
44 monitor_subsys_t *ms_database;
46 mi = ( monitor_info_t * )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, &ms->mss_ndn, &e_overlay ) ) {
60 Debug( LDAP_DEBUG_ANY,
61 "monitor_subsys_overlay_init: "
62 "unable to get entry \"%s\"\n",
63 ms->mss_ndn.bv_val, 0, 0 );
67 mp = ( monitor_entry_t * )e_overlay->e_private;
68 mp->mp_children = NULL;
69 ep = &mp->mp_children;
71 for ( on = overlay_next( NULL ), i = 0; on; on = overlay_next( on ), i++ ) {
72 char buf[ BACKMONITOR_BUFSIZE ];
77 snprintf( buf, sizeof( buf ),
78 "dn: cn=Overlay %d,%s\n"
80 "structuralObjectClass: %s\n"
84 "createTimestamp: %s\n"
85 "modifyTimestamp: %s\n",
88 mi->mi_oc_monitoredObject->soc_cname.bv_val,
89 mi->mi_oc_monitoredObject->soc_cname.bv_val,
91 mi->mi_creatorsName.bv_val,
92 mi->mi_creatorsName.bv_val,
93 mi->mi_startTime.bv_val,
94 mi->mi_startTime.bv_val );
98 Debug( LDAP_DEBUG_ANY,
99 "monitor_subsys_overlay_init: "
100 "unable to create entry \"cn=Overlay %d,%s\"\n",
101 i, ms->mss_ndn.bv_val, 0 );
105 bv.bv_val = on->on_bi.bi_type;
106 bv.bv_len = strlen( bv.bv_val );
108 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
110 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
113 for ( j = 0; j < nBackendDB; j++ ) {
114 BackendDB *be = &backendDB[ j ];
115 char buf[ SLAP_LDAPDN_MAXLEN ];
118 if ( !overlay_is_inst( be, on->on_bi.bi_type ) ) {
122 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
123 j, ms_database->mss_dn.bv_val );
125 dn.bv_len = strlen( buf );
127 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
131 mp = monitor_entrypriv_create();
135 e->e_private = ( void * )mp;
137 mp->mp_flags = ms->mss_flags
140 if ( monitor_cache_add( mi, e ) ) {
141 Debug( LDAP_DEBUG_ANY,
142 "monitor_subsys_overlay_init: "
143 "unable to add entry \"cn=Overlay %d,%s\"\n",
144 i, ms->mss_ndn.bv_val, 0 );
152 monitor_cache_release( mi, e_overlay );