1 /* backend.c - deals with backend subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2003 The OpenLDAP Foundation.
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.
20 /* This is an altered version */
22 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
24 * This work has beed deveolped for the OpenLDAP Foundation
25 * in the hope that it may be useful to the Open Source community,
26 * but WITHOUT ANY WARRANTY.
28 * Permission is granted to anyone to use this software for any purpose
29 * on any computer system, and to alter it and redistribute it, subject
30 * to the following restrictions:
32 * 1. The author and SysNet s.n.c. are not responsible for the consequences
33 * of use of this software, no matter how awful, even if they arise from
36 * 2. The origin of this software must not be misrepresented, either by
37 * explicit claim or by omission. Since few users ever read sources,
38 * credits should appear in the documentation.
40 * 3. Altered versions must be plainly marked as such, and must not be
41 * misrepresented as being the original software. Since few users
42 * ever read sources, credits should appear in the documentation.
43 * SysNet s.n.c. cannot be responsible for the consequences of the
46 * 4. This notice may not be removed or altered.
49 #ifndef _BACK_MONITOR_H_
50 #define _BACK_MONITOR_H_
53 #include <ldap_pvt_thread.h>
60 * The cache maps DNs to Entries.
62 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
64 * This work has beed deveolped for the OpenLDAP Foundation
65 * in the hope that it may be useful to the Open Source community,
66 * but WITHOUT ANY WARRANTY.
68 * Permission is granted to anyone to use this software for any purpose
69 * on any computer system, and to alter it and redistribute it, subject
70 * to the following restrictions:
72 * 1. The author and SysNet s.n.c. are not responsible for the consequences
73 * of use of this software, no matter how awful, even if they arise from
76 * 2. The origin of this software must not be misrepresented, either by
77 * explicit claim or by omission. Since few users ever read sources,
78 * credits should appear in the documentation.
80 * 3. Altered versions must be plainly marked as such, and must not be
81 * misrepresented as being the original software. Since few users
82 * ever read sources, credits should appear in the documentation.
83 * SysNet s.n.c. cannot be responsible for the consequences of the
86 * 4. This notice may not be removed or altered.
93 #include <ac/string.h>
96 #include "back-monitor.h"
99 * initializes backend subentries
102 monitor_subsys_backend_init(
106 struct monitorinfo *mi;
107 Entry *e, *e_backend, *e_tmp;
109 struct monitorentrypriv *mp;
111 mi = ( struct monitorinfo * )be->be_private;
113 if ( monitor_cache_get( mi,
114 &monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
117 LDAP_LOG( OPERATION, CRIT,
118 "monitor_subsys_backend_init: "
119 "unable to get entry '%s'\n",
120 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
122 Debug( LDAP_DEBUG_ANY,
123 "monitor_subsys_backend_init: "
124 "unable to get entry '%s'\n%s%s",
125 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
132 for ( i = nBackendInfo; i--; ) {
133 char buf[ BACKMONITOR_BUFSIZE ];
138 bi = &backendInfo[i];
140 snprintf( buf, sizeof( buf ),
141 "dn: cn=Backend %d,%s\n"
143 "structuralObjectClass: %s\n"
145 "createTimestamp: %s\n"
146 "modifyTimestamp: %s\n",
148 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
149 mi->mi_oc_monitoredObject->soc_cname.bv_val,
150 mi->mi_oc_monitoredObject->soc_cname.bv_val,
152 mi->mi_startTime.bv_val,
153 mi->mi_startTime.bv_val );
155 e = str2entry( buf );
158 LDAP_LOG( OPERATION, CRIT,
159 "monitor_subsys_backend_init: "
160 "unable to create entry 'cn=Backend %d,%s'\n",
161 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
163 Debug( LDAP_DEBUG_ANY,
164 "monitor_subsys_backend_init: "
165 "unable to create entry 'cn=Backend %d,%s'\n%s",
167 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
173 bv.bv_val = bi->bi_type;
174 bv.bv_len = strlen( bv.bv_val );
176 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
178 attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo,
181 if ( bi->bi_controls ) {
184 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
185 bv.bv_val = bi->bi_controls[ j ];
186 bv.bv_len = strlen( bv.bv_val );
187 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
191 for ( j = 0; j < nBackendDB; j++ ) {
192 BackendDB *be = &backendDB[j];
193 char buf[ SLAP_LDAPDN_MAXLEN ];
196 if ( be->bd_info != bi ) {
200 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
201 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
203 dn.bv_len = strlen( buf );
205 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
209 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
210 e->e_private = ( void * )mp;
212 mp->mp_children = NULL;
213 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
214 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
217 if ( monitor_cache_add( mi, e ) ) {
219 LDAP_LOG( OPERATION, CRIT,
220 "monitor_subsys_backend_init: "
221 "unable to add entry 'cn=Backend %d,%s'\n",
222 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
224 Debug( LDAP_DEBUG_ANY,
225 "monitor_subsys_backend_init: "
226 "unable to add entry 'cn=Backend %d,%s'\n%s",
228 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
237 mp = ( struct monitorentrypriv * )e_backend->e_private;
238 mp->mp_children = e_tmp;
240 monitor_cache_release( mi, e_backend );