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_backend, **ep;
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 Debug( LDAP_DEBUG_ANY,
51 "monitor_subsys_backend_init: "
52 "unable to get entry \"%s\"\n",
53 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
57 mp = ( struct monitorentrypriv * )e_backend->e_private;
58 mp->mp_children = NULL;
59 ep = &mp->mp_children;
61 for ( i = 0; i < nBackendInfo; i++ ) {
62 char buf[ BACKMONITOR_BUFSIZE ];
70 snprintf( buf, sizeof( buf ),
71 "dn: cn=Backend %d,%s\n"
73 "structuralObjectClass: %s\n"
77 "createTimestamp: %s\n"
78 "modifyTimestamp: %s\n",
80 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
81 mi->mi_oc_monitoredObject->soc_cname.bv_val,
82 mi->mi_oc_monitoredObject->soc_cname.bv_val,
84 mi->mi_creatorsName.bv_val,
85 mi->mi_creatorsName.bv_val,
86 mi->mi_startTime.bv_val,
87 mi->mi_startTime.bv_val );
91 Debug( LDAP_DEBUG_ANY,
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 );
98 bv.bv_val = bi->bi_type;
99 bv.bv_len = strlen( bv.bv_val );
101 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
103 attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo,
106 if ( bi->bi_controls ) {
109 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
110 bv.bv_val = bi->bi_controls[ j ];
111 bv.bv_len = strlen( bv.bv_val );
112 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
116 for ( j = 0; j < nBackendDB; j++ ) {
117 BackendDB *be = &backendDB[j];
118 char buf[ SLAP_LDAPDN_MAXLEN ];
121 if ( be->bd_info != bi ) {
125 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
126 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
128 dn.bv_len = strlen( buf );
130 attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
134 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
135 e->e_private = ( void * )mp;
137 mp->mp_children = NULL;
138 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
139 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
142 if ( monitor_cache_add( mi, e ) ) {
143 Debug( LDAP_DEBUG_ANY,
144 "monitor_subsys_backend_init: "
145 "unable to add entry \"cn=Backend %d,%s\"\n",
147 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
155 monitor_cache_release( mi, e_backend );