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,
49 Debug( LDAP_DEBUG_ANY,
50 "monitor_subsys_backend_init: "
51 "unable to get entry '%s'\n%s%s",
52 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
58 for ( i = nBackendInfo; i--; ) {
59 char buf[ BACKMONITOR_BUFSIZE ];
66 snprintf( buf, sizeof( buf ),
67 "dn: cn=Backend %d,%s\n"
69 "structuralObjectClass: %s\n"
73 "createTimestamp: %s\n"
74 "modifyTimestamp: %s\n",
76 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
77 mi->mi_oc_monitoredObject->soc_cname.bv_val,
78 mi->mi_oc_monitoredObject->soc_cname.bv_val,
80 mi->mi_creatorsName.bv_val,
81 mi->mi_creatorsName.bv_val,
82 mi->mi_startTime.bv_val,
83 mi->mi_startTime.bv_val );
87 Debug( LDAP_DEBUG_ANY,
88 "monitor_subsys_backend_init: "
89 "unable to create entry 'cn=Backend %d,%s'\n%s",
91 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
96 bv.bv_val = bi->bi_type;
97 bv.bv_len = strlen( bv.bv_val );
99 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
101 attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo,
104 if ( bi->bi_controls ) {
107 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
108 bv.bv_val = bi->bi_controls[ j ];
109 bv.bv_len = strlen( bv.bv_val );
110 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
114 for ( j = 0; j < nBackendDB; j++ ) {
115 BackendDB *be = &backendDB[j];
116 char buf[ SLAP_LDAPDN_MAXLEN ];
119 if ( be->bd_info != bi ) {
123 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
124 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
126 dn.bv_len = strlen( buf );
128 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
132 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
133 e->e_private = ( void * )mp;
135 mp->mp_children = NULL;
136 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
137 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
140 if ( monitor_cache_add( mi, e ) ) {
141 Debug( LDAP_DEBUG_ANY,
142 "monitor_subsys_backend_init: "
143 "unable to add entry 'cn=Backend %d,%s'\n%s",
145 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
153 mp = ( struct monitorentrypriv * )e_backend->e_private;
154 mp->mp_children = e_tmp;
156 monitor_cache_release( mi, e_backend );