1 /* init.c - initialize monitor backend */
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.
25 #include <ac/string.h>
30 #include "back-monitor.h"
32 #undef INTEGRATE_CORE_SCHEMA
35 * used by many functions to add description to entries
37 BackendDB *be_monitor = NULL;
42 struct monitorsubsys monitor_subsys[] = {
44 SLAPD_MONITOR_LISTENER, SLAPD_MONITOR_LISTENER_NAME,
45 BER_BVNULL, BER_BVNULL, BER_BVNULL,
46 MONITOR_F_PERSISTENT_CH,
47 monitor_subsys_listener_init,
52 SLAPD_MONITOR_DATABASE, SLAPD_MONITOR_DATABASE_NAME,
53 BER_BVNULL, BER_BVNULL, BER_BVNULL,
54 MONITOR_F_PERSISTENT_CH,
55 monitor_subsys_database_init,
58 monitor_subsys_database_modify
60 SLAPD_MONITOR_BACKEND, SLAPD_MONITOR_BACKEND_NAME,
61 BER_BVNULL, BER_BVNULL, BER_BVNULL,
62 MONITOR_F_PERSISTENT_CH,
63 monitor_subsys_backend_init,
68 SLAPD_MONITOR_THREAD, SLAPD_MONITOR_THREAD_NAME,
69 BER_BVNULL, BER_BVNULL, BER_BVNULL,
71 monitor_subsys_thread_init,
72 monitor_subsys_thread_update,
76 SLAPD_MONITOR_SASL, SLAPD_MONITOR_SASL_NAME,
77 BER_BVNULL, BER_BVNULL, BER_BVNULL,
84 SLAPD_MONITOR_TLS, SLAPD_MONITOR_TLS_NAME,
85 BER_BVNULL, BER_BVNULL, BER_BVNULL,
92 SLAPD_MONITOR_CONN, SLAPD_MONITOR_CONN_NAME,
93 BER_BVNULL, BER_BVNULL, BER_BVNULL,
94 MONITOR_F_VOLATILE_CH,
95 monitor_subsys_conn_init,
96 monitor_subsys_conn_update,
97 monitor_subsys_conn_create,
100 SLAPD_MONITOR_RWW, SLAPD_MONITOR_RWW_NAME,
101 BER_BVNULL, BER_BVNULL, BER_BVNULL,
102 MONITOR_F_PERSISTENT_CH,
103 monitor_subsys_rww_init,
104 monitor_subsys_rww_update,
108 SLAPD_MONITOR_LOG, SLAPD_MONITOR_LOG_NAME,
109 BER_BVNULL, BER_BVNULL, BER_BVNULL,
111 monitor_subsys_log_init,
114 monitor_subsys_log_modify
116 SLAPD_MONITOR_OPS, SLAPD_MONITOR_OPS_NAME,
117 BER_BVNULL, BER_BVNULL, BER_BVNULL,
118 MONITOR_F_PERSISTENT_CH,
119 monitor_subsys_ops_init,
120 monitor_subsys_ops_update,
124 SLAPD_MONITOR_SENT, SLAPD_MONITOR_SENT_NAME,
125 BER_BVNULL, BER_BVNULL, BER_BVNULL,
126 MONITOR_F_PERSISTENT_CH,
127 monitor_subsys_sent_init,
128 monitor_subsys_sent_update,
132 SLAPD_MONITOR_TIME, SLAPD_MONITOR_TIME_NAME,
133 BER_BVNULL, BER_BVNULL, BER_BVNULL,
134 MONITOR_F_PERSISTENT_CH,
135 monitor_subsys_time_init,
136 monitor_subsys_time_update,
140 SLAPD_MONITOR_OVERLAY, SLAPD_MONITOR_OVERLAY_NAME,
141 BER_BVNULL, BER_BVNULL, BER_BVNULL,
142 MONITOR_F_PERSISTENT_CH,
143 monitor_subsys_overlay_init,
150 #if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
153 init_module( int argc, char *argv[] )
157 memset( &bi, '\0', sizeof(bi) );
158 bi.bi_type = "monitor";
159 bi.bi_init = monitor_back_initialize;
164 #endif /* SLAPD_MONITOR */
167 monitor_back_initialize(
171 static char *controls[] = {
172 LDAP_CONTROL_MANAGEDSAIT,
173 LDAP_CONTROL_VALUESRETURNFILTER,
177 bi->bi_controls = controls;
181 bi->bi_config = monitor_back_config;
185 bi->bi_db_init = monitor_back_db_init;
186 bi->bi_db_config = monitor_back_db_config;
187 bi->bi_db_open = monitor_back_db_open;
189 bi->bi_db_destroy = monitor_back_db_destroy;
191 bi->bi_op_bind = monitor_back_bind;
192 bi->bi_op_unbind = 0;
193 bi->bi_op_search = monitor_back_search;
194 bi->bi_op_compare = monitor_back_compare;
195 bi->bi_op_modify = monitor_back_modify;
196 bi->bi_op_modrdn = 0;
198 bi->bi_op_delete = 0;
199 bi->bi_op_abandon = 0;
203 bi->bi_entry_release_rw = 0;
204 bi->bi_chk_referrals = 0;
205 bi->bi_operational = monitor_back_operational;
208 * hooks for slap tools
210 bi->bi_tool_entry_open = 0;
211 bi->bi_tool_entry_close = 0;
212 bi->bi_tool_entry_first = 0;
213 bi->bi_tool_entry_next = 0;
214 bi->bi_tool_entry_get = 0;
215 bi->bi_tool_entry_put = 0;
216 bi->bi_tool_entry_reindex = 0;
217 bi->bi_tool_sync = 0;
218 bi->bi_tool_dn2id_get = 0;
219 bi->bi_tool_id2entry_get = 0;
220 bi->bi_tool_entry_modify = 0;
222 bi->bi_connection_init = 0;
223 bi->bi_connection_destroy = 0;
229 monitor_back_db_init(
233 struct monitorinfo *mi;
235 struct berval dn, ndn;
245 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
247 "DESC 'OpenLDAP system monitoring' "
248 "SUP top STRUCTURAL "
253 #if 0 /* temporarily disabled */
264 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
265 offsetof(struct monitorinfo, mi_oc_monitor) },
266 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
267 "NAME 'monitorServer' "
268 "DESC 'Server monitoring root entry' "
269 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
270 offsetof(struct monitorinfo, mi_oc_monitorServer) },
271 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
272 "NAME 'monitorContainer' "
273 "DESC 'monitor container class' "
274 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
275 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
276 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
277 "NAME 'monitorCounterObject' "
278 "DESC 'monitor counter class' "
279 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
280 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
281 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
282 "NAME 'monitorOperation' "
283 "DESC 'monitor operation class' "
284 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
285 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
286 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
287 "NAME 'monitorConnection' "
288 "DESC 'monitor connection class' "
289 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
290 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
291 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
292 "NAME 'managedObject' "
293 "DESC 'monitor managed entity class' "
294 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
295 offsetof(struct monitorinfo, mi_oc_managedObject) },
296 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
297 "NAME 'monitoredObject' "
298 "DESC 'monitor monitored entity class' "
299 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
300 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
301 { NULL, NULL, 0, -1 }
303 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
304 "NAME 'monitoredInfo' "
305 "DESC 'monitored info' "
307 "EQUALITY caseIgnoreMatch "
308 "SUBSTR caseIgnoreSubstringsMatch "
309 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
310 "NO-USER-MODIFICATION "
311 "USAGE directoryOperation )", SLAP_AT_HIDE,
312 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
313 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
314 "NAME 'managedInfo' "
315 "DESC 'monitor managed info' "
316 "SUP name )", SLAP_AT_HIDE,
317 offsetof(struct monitorinfo, mi_ad_managedInfo) },
318 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
319 "NAME 'monitorCounter' "
320 "DESC 'monitor counter' "
321 "EQUALITY integerMatch "
322 "ORDERING integerOrderingMatch "
323 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
324 "NO-USER-MODIFICATION "
325 "USAGE directoryOperation )", SLAP_AT_HIDE,
326 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
327 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
328 "NAME 'monitorOpCompleted' "
329 "DESC 'monitor completed operations' "
330 "SUP monitorCounter "
331 "NO-USER-MODIFICATION "
332 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
333 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
334 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
335 "NAME 'monitorOpInitiated' "
336 "DESC 'monitor initiated operations' "
337 "SUP monitorCounter "
338 "NO-USER-MODIFICATION "
339 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
340 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
341 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
342 "NAME 'monitorConnectionNumber' "
343 "DESC 'monitor connection number' "
344 "SUP monitorCounter "
345 "NO-USER-MODIFICATION "
346 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
347 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
348 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
349 "NAME 'monitorConnectionAuthzDN' "
350 "DESC 'monitor connection authorization DN' "
351 /* "SUP distinguishedName " */
352 "EQUALITY distinguishedNameMatch "
353 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
354 "NO-USER-MODIFICATION "
355 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
356 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
357 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
358 "NAME 'monitorConnectionLocalAddress' "
359 "DESC 'monitor connection local address' "
361 "NO-USER-MODIFICATION "
362 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
363 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
364 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
365 "NAME 'monitorConnectionPeerAddress' "
366 "DESC 'monitor connection peer address' "
368 "NO-USER-MODIFICATION "
369 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
370 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
371 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
372 "NAME 'monitorTimestamp' "
373 "DESC 'monitor timestamp' "
374 "EQUALITY generalizedTimeMatch "
375 "ORDERING generalizedTimeOrderingMatch "
376 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
378 "NO-USER-MODIFICATION "
379 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
380 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
381 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
382 "NAME 'monitorOverlay' "
383 "DESC 'name of overlays defined for a give database' "
385 "NO-USER-MODIFICATION "
386 "USAGE directoryOperation )", SLAP_AT_HIDE,
387 offsetof(struct monitorinfo, mi_ad_monitorOverlay) },
388 { "readOnly", "( 1.3.6.1.4.1.4203.666.1.31 "
390 "DESC 'read/write status of a given database' "
391 "EQUALITY booleanMatch "
392 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
394 "USAGE directoryOperation )", SLAP_AT_HIDE,
395 offsetof(struct monitorinfo, mi_ad_readOnly) },
396 { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.32 "
397 "NAME 'restrictedOperation' "
398 "DESC 'name of restricted operation for a given database' "
399 "SUP managedInfo )", SLAP_AT_HIDE,
400 offsetof(struct monitorinfo, mi_ad_restrictedOperation ) },
401 #ifdef INTEGRATE_CORE_SCHEMA
402 { NULL, NULL, 0, -1 }, /* description */
403 { NULL, NULL, 0, -1 }, /* seeAlso */
404 { NULL, NULL, 0, -1 }, /* l */
405 { NULL, NULL, 0, -1 }, /* labeledURI */
406 #endif /* INTEGRATE_CORE_SCHEMA */
407 { NULL, NULL, 0, -1 }
409 { "description", "( 2.5.4.13 "
410 "NAME 'description' "
411 "DESC 'RFC2256: descriptive information' "
412 "EQUALITY caseIgnoreMatch "
413 "SUBSTR caseIgnoreSubstringsMatch "
414 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
415 offsetof(struct monitorinfo, mi_ad_description) },
416 { "seeAlso", "( 2.5.4.34 "
418 "DESC 'RFC2256: DN of related object' "
419 "SUP distinguishedName )", 0,
420 offsetof(struct monitorinfo, mi_ad_seeAlso) },
422 "NAME ( 'l' 'localityName' ) "
423 "DESC 'RFC2256: locality which this object resides in' "
425 offsetof(struct monitorinfo, mi_ad_l) },
426 { "labeledURI", "( 1.3.6.1.4.1.250.1.57 "
428 "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
429 "EQUALITY caseExactMatch "
430 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )", 0,
431 offsetof(struct monitorinfo, mi_ad_labeledURI) },
432 { NULL, NULL, 0, -1 }
436 * database monitor can be defined once only
440 LDAP_LOG( OPERATION, CRIT,
441 "only one monitor backend is allowed\n", 0, 0, 0);
443 Debug( LDAP_DEBUG_ANY,
444 "only one monitor backend is allowed\n", 0, 0, 0 );
450 /* indicate system schema supported */
451 SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
453 dn.bv_val = SLAPD_MONITOR_DN;
454 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
456 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
457 if( rc != LDAP_SUCCESS ) {
459 LDAP_LOG( OPERATION, CRIT,
460 "unable to normalize monitor DN \"%s\"\n",
461 SLAPD_MONITOR_DN, 0, 0 );
463 Debug( LDAP_DEBUG_ANY,
464 "unable to normalize monitor DN \"%s\"\n",
465 SLAPD_MONITOR_DN, 0, 0 );
470 ber_dupbv( &bv, &dn );
471 ber_bvarray_add( &be->be_suffix, &bv );
472 ber_bvarray_add( &be->be_nsuffix, &ndn );
474 mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
477 LDAP_LOG( OPERATION, CRIT,
478 "unable to initialize monitor backend\n", 0, 0, 0 );
480 Debug( LDAP_DEBUG_ANY,
481 "unable to initialize monitor backend\n", 0, 0, 0 );
486 memset( mi, 0, sizeof( struct monitorinfo ) );
488 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
492 #ifdef INTEGRATE_CORE_SCHEMA
493 /* prepare for schema integration */
494 for ( k = 0; mat[k].name != NULL; k++ );
495 #endif /* INTEGRATE_CORE_SCHEMA */
497 for ( i = 0; mat_core[i].name != NULL; i++ ) {
498 AttributeDescription **ad;
501 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
504 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
508 #ifdef INTEGRATE_CORE_SCHEMA
509 case LDAP_UNDEFINED_TYPE:
510 mat[k] = mat_core[i];
513 #endif /* INTEGRATE_CORE_SCHEMA */
517 LDAP_LOG( OPERATION, CRIT,
518 "monitor_back_db_init: %s: %s\n",
519 mat_core[i].name, text, 0 );
521 Debug( LDAP_DEBUG_ANY,
522 "monitor_back_db_init: %s: %s\n",
523 mat_core[i].name, text, 0 );
529 /* schema integration */
530 for ( i = 0; mat[i].name; i++ ) {
531 LDAPAttributeType *at;
534 AttributeDescription **ad;
536 at = ldap_str2attributetype( mat[i].schema, &code,
537 &err, LDAP_SCHEMA_ALLOW_ALL );
540 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
541 "in AttributeType '%s' %s before %s\n",
542 mat[i].name, ldap_scherr2str(code), err );
544 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
545 "in AttributeType '%s' %s before %s\n",
546 mat[i].name, ldap_scherr2str(code), err );
551 if ( at->at_oid == NULL ) {
553 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
554 "null OID for attributeType '%s'\n",
557 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
558 "null OID for attributeType '%s'\n",
564 code = at_add(at, &err);
567 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
568 "%s in attributeType '%s'\n",
569 scherr2str(code), mat[i].name, 0 );
571 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
572 "%s in attributeType '%s'\n",
573 scherr2str(code), mat[i].name, 0 );
579 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
581 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
583 LDAP_LOG( OPERATION, CRIT,
584 "monitor_back_db_init: %s\n", text, 0, 0 );
586 Debug( LDAP_DEBUG_ANY,
587 "monitor_back_db_init: %s\n", text, 0, 0 );
592 (*ad)->ad_type->sat_flags |= mat[i].flags;
595 for ( i = 0; moc[i].name; i++ ) {
601 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
602 LDAP_SCHEMA_ALLOW_ALL );
605 LDAP_LOG( OPERATION, CRIT,
606 "unable to parse monitor objectclass '%s': "
607 "%s before %s\n" , moc[i].name,
608 ldap_scherr2str(code), err );
610 Debug( LDAP_DEBUG_ANY,
611 "unable to parse monitor objectclass '%s': "
612 "%s before %s\n" , moc[i].name,
613 ldap_scherr2str(code), err );
618 if ( oc->oc_oid == NULL ) {
620 LDAP_LOG( OPERATION, CRIT,
621 "objectclass '%s' has no OID\n" ,
624 Debug( LDAP_DEBUG_ANY,
625 "objectclass '%s' has no OID\n" ,
631 code = oc_add(oc, 0, &err);
634 LDAP_LOG( OPERATION, CRIT,
635 "objectclass '%s': %s \"%s\"\n" ,
636 moc[i].name, scherr2str(code), err );
638 Debug( LDAP_DEBUG_ANY,
639 "objectclass '%s': %s \"%s\"\n" ,
640 moc[i].name, scherr2str(code), err );
647 Oc = oc_find( moc[i].name );
650 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
651 "unable to find objectClass %s "
652 "(just added)\n", moc[i].name, 0, 0 );
654 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
655 "unable to find objectClass %s "
656 "(just added)\n", moc[i].name, 0, 0 );
661 Oc->soc_flags |= moc[i].flags;
663 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
670 monitor_back_db_open(
674 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
675 struct monitorsubsys *ms;
677 struct monitorentrypriv *mp;
679 char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
685 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
690 #ifndef HAVE_GMTIME_R
691 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
693 #ifdef HACK_LOCAL_TIME
694 # ifdef HAVE_LOCALTIME_R
695 tms = localtime_r( &starttime, &tm_buf );
697 tms = localtime( &starttime );
698 # endif /* HAVE_LOCALTIME_R */
699 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
700 #else /* !HACK_LOCAL_TIME */
701 # ifdef HAVE_GMTIME_R
702 tms = gmtime_r( &starttime, &tm_buf );
704 tms = gmtime( &starttime );
705 # endif /* HAVE_GMTIME_R */
706 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
707 #endif /* !HACK_LOCAL_TIME */
708 #ifndef HAVE_GMTIME_R
709 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
712 mi->mi_startTime.bv_val = tmbuf;
713 mi->mi_startTime.bv_len = strlen( tmbuf );
715 if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
716 BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
718 mi->mi_creatorsName = be->be_rootdn;
722 * Create all the subsystem specific entries
725 for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
726 int len = strlen( monitor_subsys[ i ].mss_name );
730 dn.bv_len = len + sizeof( "cn=" ) - 1;
731 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
732 strcpy( dn.bv_val, "cn=" );
733 strcat( dn.bv_val, monitor_subsys[ i ].mss_name );
734 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL );
736 if ( rc != LDAP_SUCCESS ) {
738 LDAP_LOG( OPERATION, CRIT,
739 "monitor RDN \"%s\" is invalid\n",
742 Debug( LDAP_DEBUG_ANY,
743 "monitor RDN \"%s\" is invalid\n",
749 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
750 dn.bv_val = ch_malloc( dn.bv_len + 1 );
751 strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn.bv_val );
752 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
753 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ].mss_dn,
754 &monitor_subsys[ i ].mss_ndn, NULL );
756 if ( rc != LDAP_SUCCESS ) {
758 LDAP_LOG( OPERATION, CRIT,
759 "monitor DN \"%s\" is invalid\n",
762 Debug( LDAP_DEBUG_ANY,
763 "monitor DN \"%s\" is invalid\n",
769 snprintf( buf, sizeof( buf ),
772 "structuralObjectClass: %s\n"
775 "modifiersName: %s\n"
776 "createTimestamp: %s\n"
777 "modifyTimestamp: %s\n",
778 monitor_subsys[ i ].mss_dn.bv_val,
779 mi->mi_oc_monitorContainer->soc_cname.bv_val,
780 mi->mi_oc_monitorContainer->soc_cname.bv_val,
781 monitor_subsys[ i ].mss_name,
782 mi->mi_creatorsName.bv_val,
783 mi->mi_creatorsName.bv_val,
784 mi->mi_startTime.bv_val,
785 mi->mi_startTime.bv_val );
787 e = str2entry( buf );
791 LDAP_LOG( OPERATION, CRIT,
792 "unable to create '%s' entry\n",
793 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
795 Debug( LDAP_DEBUG_ANY,
796 "unable to create '%s' entry\n",
797 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
802 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
803 e->e_private = ( void * )mp;
804 mp->mp_info = &monitor_subsys[ i ];
805 mp->mp_children = NULL;
807 mp->mp_flags = monitor_subsys[ i ].mss_flags;
809 if ( monitor_cache_add( mi, e ) ) {
811 LDAP_LOG( OPERATION, CRIT,
812 "unable to add entry '%s' to cache\n",
813 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
815 Debug( LDAP_DEBUG_ANY,
816 "unable to add entry '%s' to cache\n",
817 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
826 * creates the "cn=Monitor" entry
828 snprintf( buf, sizeof( buf ),
831 "structuralObjectClass: %s\n"
833 "%s: This subtree contains monitoring/managing objects.\n"
834 "%s: This object contains information about this server.\n"
836 "%s: createTimestamp reflects the time this server instance was created.\n"
837 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
840 "modifiersName: %s\n"
841 "createTimestamp: %s\n"
842 "modifyTimestamp: %s\n",
844 mi->mi_oc_monitorServer->soc_cname.bv_val,
845 mi->mi_oc_monitorServer->soc_cname.bv_val,
846 mi->mi_ad_description->ad_cname.bv_val,
847 mi->mi_ad_description->ad_cname.bv_val,
849 mi->mi_ad_description->ad_cname.bv_val,
850 mi->mi_ad_description->ad_cname.bv_val,
852 mi->mi_creatorsName.bv_val,
853 mi->mi_creatorsName.bv_val,
854 mi->mi_startTime.bv_val,
855 mi->mi_startTime.bv_val );
857 e = str2entry( buf );
860 LDAP_LOG( OPERATION, CRIT,
861 "unable to create '%s' entry\n",
862 SLAPD_MONITOR_DN, 0, 0 );
864 Debug( LDAP_DEBUG_ANY,
865 "unable to create '%s' entry\n",
866 SLAPD_MONITOR_DN, 0, 0 );
871 bv.bv_val = (char *) Versionstr;
872 end_of_line = strchr( Versionstr, '\n' );
874 bv.bv_len = end_of_line - Versionstr;
876 bv.bv_len = strlen( Versionstr );
879 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
882 LDAP_LOG( OPERATION, CRIT,
883 "unable to add monitoredInfo to '%s' entry\n",
884 SLAPD_MONITOR_DN, 0, 0 );
886 Debug( LDAP_DEBUG_ANY,
887 "unable to add monitoredInfo to '%s' entry\n",
888 SLAPD_MONITOR_DN, 0, 0 );
893 if ( mi->mi_l.bv_len ) {
894 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
896 LDAP_LOG( OPERATION, CRIT,
897 "unable to add locality to '%s' entry\n",
898 SLAPD_MONITOR_DN, 0, 0 );
900 Debug( LDAP_DEBUG_ANY,
901 "unable to add locality to '%s' entry\n",
902 SLAPD_MONITOR_DN, 0, 0 );
908 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
909 e->e_private = ( void * )mp;
912 mp->mp_children = e_tmp;
915 if ( monitor_cache_add( mi, e ) ) {
917 LDAP_LOG( OPERATION, CRIT,
918 "unable to add entry '%s' to cache\n",
919 SLAPD_MONITOR_DN, 0, 0 );
921 Debug( LDAP_DEBUG_ANY,
922 "unable to add entry '%s' to cache\n",
923 SLAPD_MONITOR_DN, 0, 0 );
933 * opens the monitor backend
935 for ( ms = monitor_subsys; ms->mss_name != NULL; ms++ ) {
936 if ( ms->mss_init && ( *ms->mss_init )( be ) ) {
954 * eventually, will hold backend specific configuration parameters
956 return SLAP_CONF_UNKNOWN;
960 monitor_back_db_config(
968 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
971 * eventually, will hold database specific configuration parameters
973 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
978 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
981 return SLAP_CONF_UNKNOWN;
988 monitor_back_db_destroy(
993 * FIXME: destroys all the data