1 /* backend.c - deals with backend subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2004 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
26 #include <ac/string.h>
29 #include "back-monitor.h"
32 * initializes backend subentries
35 monitor_subsys_backend_init(
39 struct monitorinfo *mi;
40 Entry *e, *e_backend, *e_tmp;
42 struct monitorentrypriv *mp;
44 mi = ( struct monitorinfo * )be->be_private;
46 if ( monitor_cache_get( mi,
47 &monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
50 LDAP_LOG( OPERATION, CRIT,
51 "monitor_subsys_backend_init: "
52 "unable to get entry '%s'\n",
53 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
55 Debug( LDAP_DEBUG_ANY,
56 "monitor_subsys_backend_init: "
57 "unable to get entry '%s'\n%s%s",
58 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
65 for ( i = nBackendInfo; i--; ) {
66 char buf[ BACKMONITOR_BUFSIZE ];
73 snprintf( buf, sizeof( buf ),
74 "dn: cn=Backend %d,%s\n"
76 "structuralObjectClass: %s\n"
80 "createTimestamp: %s\n"
81 "modifyTimestamp: %s\n",
83 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
84 mi->mi_oc_monitoredObject->soc_cname.bv_val,
85 mi->mi_oc_monitoredObject->soc_cname.bv_val,
87 mi->mi_creatorsName.bv_val,
88 mi->mi_creatorsName.bv_val,
89 mi->mi_startTime.bv_val,
90 mi->mi_startTime.bv_val );
95 LDAP_LOG( OPERATION, CRIT,
96 "monitor_subsys_backend_init: "
97 "unable to create entry 'cn=Backend %d,%s'\n",
98 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
100 Debug( LDAP_DEBUG_ANY,
101 "monitor_subsys_backend_init: "
102 "unable to create entry 'cn=Backend %d,%s'\n%s",
104 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
110 bv.bv_val = bi->bi_type;
111 bv.bv_len = strlen( bv.bv_val );
113 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
115 attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo,
118 if ( bi->bi_controls ) {
121 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
122 bv.bv_val = bi->bi_controls[ j ];
123 bv.bv_len = strlen( bv.bv_val );
124 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
128 for ( j = 0; j < nBackendDB; j++ ) {
129 BackendDB *be = &backendDB[j];
130 char buf[ SLAP_LDAPDN_MAXLEN ];
133 if ( be->bd_info != bi ) {
137 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
138 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
140 dn.bv_len = strlen( buf );
142 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
146 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
147 e->e_private = ( void * )mp;
149 mp->mp_children = NULL;
150 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
151 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
154 if ( monitor_cache_add( mi, e ) ) {
156 LDAP_LOG( OPERATION, CRIT,
157 "monitor_subsys_backend_init: "
158 "unable to add entry 'cn=Backend %d,%s'\n",
159 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
161 Debug( LDAP_DEBUG_ANY,
162 "monitor_subsys_backend_init: "
163 "unable to add entry 'cn=Backend %d,%s'\n%s",
165 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
174 mp = ( struct monitorentrypriv * )e_backend->e_private;
175 mp->mp_children = e_tmp;
177 monitor_cache_release( mi, e_backend );