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"
78 "createTimestamp: %s\n"
79 "modifyTimestamp: %s\n",
81 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
82 mi->mi_oc_monitoredObject->soc_cname.bv_val,
83 mi->mi_oc_monitoredObject->soc_cname.bv_val,
85 mi->mi_startTime.bv_val,
86 mi->mi_startTime.bv_val );
91 LDAP_LOG( OPERATION, CRIT,
92 "monitor_subsys_backend_init: "
93 "unable to create entry 'cn=Backend %d,%s'\n",
94 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
96 Debug( LDAP_DEBUG_ANY,
97 "monitor_subsys_backend_init: "
98 "unable to create entry 'cn=Backend %d,%s'\n%s",
100 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
106 bv.bv_val = bi->bi_type;
107 bv.bv_len = strlen( bv.bv_val );
109 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
111 attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo,
114 if ( bi->bi_controls ) {
117 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
118 bv.bv_val = bi->bi_controls[ j ];
119 bv.bv_len = strlen( bv.bv_val );
120 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
124 for ( j = 0; j < nBackendDB; j++ ) {
125 BackendDB *be = &backendDB[j];
126 char buf[ SLAP_LDAPDN_MAXLEN ];
129 if ( be->bd_info != bi ) {
133 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
134 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
136 dn.bv_len = strlen( buf );
138 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
142 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
143 e->e_private = ( void * )mp;
145 mp->mp_children = NULL;
146 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
147 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
150 if ( monitor_cache_add( mi, e ) ) {
152 LDAP_LOG( OPERATION, CRIT,
153 "monitor_subsys_backend_init: "
154 "unable to add entry 'cn=Backend %d,%s'\n",
155 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
157 Debug( LDAP_DEBUG_ANY,
158 "monitor_subsys_backend_init: "
159 "unable to add entry 'cn=Backend %d,%s'\n%s",
161 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
170 mp = ( struct monitorentrypriv * )e_backend->e_private;
171 mp->mp_children = e_tmp;
173 monitor_cache_release( mi, e_backend );