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 static struct monitorsubsys known_monitor_subsys[] = {
44 SLAPD_MONITOR_BACKEND_NAME,
45 BER_BVNULL, BER_BVNULL, BER_BVNULL,
46 MONITOR_F_PERSISTENT_CH,
47 monitor_subsys_backend_init,
52 SLAPD_MONITOR_CONN_NAME,
53 BER_BVNULL, BER_BVNULL, BER_BVNULL,
54 MONITOR_F_VOLATILE_CH,
55 monitor_subsys_conn_init,
56 monitor_subsys_conn_update,
57 monitor_subsys_conn_create,
60 SLAPD_MONITOR_DATABASE_NAME,
61 BER_BVNULL, BER_BVNULL, BER_BVNULL,
62 MONITOR_F_PERSISTENT_CH,
63 monitor_subsys_database_init,
66 monitor_subsys_database_modify
68 SLAPD_MONITOR_LISTENER_NAME,
69 BER_BVNULL, BER_BVNULL, BER_BVNULL,
70 MONITOR_F_PERSISTENT_CH,
71 monitor_subsys_listener_init,
76 SLAPD_MONITOR_LOG_NAME,
77 BER_BVNULL, BER_BVNULL, BER_BVNULL,
79 monitor_subsys_log_init,
82 monitor_subsys_log_modify
84 SLAPD_MONITOR_OPS_NAME,
85 BER_BVNULL, BER_BVNULL, BER_BVNULL,
86 MONITOR_F_PERSISTENT_CH,
87 monitor_subsys_ops_init,
88 monitor_subsys_ops_update,
92 SLAPD_MONITOR_OVERLAY_NAME,
93 BER_BVNULL, BER_BVNULL, BER_BVNULL,
94 MONITOR_F_PERSISTENT_CH,
95 monitor_subsys_overlay_init,
100 SLAPD_MONITOR_SASL_NAME,
101 BER_BVNULL, BER_BVNULL, BER_BVNULL,
108 SLAPD_MONITOR_SENT_NAME,
109 BER_BVNULL, BER_BVNULL, BER_BVNULL,
110 MONITOR_F_PERSISTENT_CH,
111 monitor_subsys_sent_init,
112 monitor_subsys_sent_update,
116 SLAPD_MONITOR_THREAD_NAME,
117 BER_BVNULL, BER_BVNULL, BER_BVNULL,
118 MONITOR_F_PERSISTENT_CH,
119 monitor_subsys_thread_init,
120 monitor_subsys_thread_update,
124 SLAPD_MONITOR_TIME_NAME,
125 BER_BVNULL, BER_BVNULL, BER_BVNULL,
126 MONITOR_F_PERSISTENT_CH,
127 monitor_subsys_time_init,
128 monitor_subsys_time_update,
132 SLAPD_MONITOR_TLS_NAME,
133 BER_BVNULL, BER_BVNULL, BER_BVNULL,
140 SLAPD_MONITOR_RWW_NAME,
141 BER_BVNULL, BER_BVNULL, BER_BVNULL,
142 MONITOR_F_PERSISTENT_CH,
143 monitor_subsys_rww_init,
144 monitor_subsys_rww_update,
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 */
166 static struct monitorsubsys **monitor_subsys = NULL;
169 monitor_back_register_subsys( monitorsubsys *ms )
173 if ( monitor_subsys ) {
174 for ( ; monitor_subsys[ i ] != NULL; i++ )
175 /* just count'em */ ;
178 monitor_subsys = ch_realloc( monitor_subsys,
179 ( 2 + i ) * sizeof( monitorsubsys * ) );
181 if ( monitor_subsys == NULL ) {
185 monitor_subsys[ i ] = ms;
186 monitor_subsys[ i + 1 ] = NULL;
192 monitor_back_get_subsys( const char *name )
194 if ( monitor_subsys != NULL ) {
197 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
198 if ( strcasecmp( monitor_subsys[ i ]->mss_name, name ) == 0 ) {
199 return monitor_subsys[ i ];
208 monitor_back_get_subsys_by_dn( struct berval *ndn, int sub )
210 if ( monitor_subsys != NULL ) {
214 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
215 if ( dnIsSuffix( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
216 return monitor_subsys[ i ];
221 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
222 if ( dn_match( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
223 return monitor_subsys[ i ];
233 monitor_back_initialize(
238 static char *controls[] = {
239 LDAP_CONTROL_MANAGEDSAIT,
240 LDAP_CONTROL_VALUESRETURNFILTER,
244 bi->bi_controls = controls;
248 bi->bi_config = monitor_back_config;
252 bi->bi_db_init = monitor_back_db_init;
253 bi->bi_db_config = monitor_back_db_config;
254 bi->bi_db_open = monitor_back_db_open;
256 bi->bi_db_destroy = monitor_back_db_destroy;
258 bi->bi_op_bind = monitor_back_bind;
259 bi->bi_op_unbind = 0;
260 bi->bi_op_search = monitor_back_search;
261 bi->bi_op_compare = monitor_back_compare;
262 bi->bi_op_modify = monitor_back_modify;
263 bi->bi_op_modrdn = 0;
265 bi->bi_op_delete = 0;
266 bi->bi_op_abandon = 0;
270 bi->bi_entry_release_rw = 0;
271 bi->bi_chk_referrals = 0;
272 bi->bi_operational = monitor_back_operational;
275 * hooks for slap tools
277 bi->bi_tool_entry_open = 0;
278 bi->bi_tool_entry_close = 0;
279 bi->bi_tool_entry_first = 0;
280 bi->bi_tool_entry_next = 0;
281 bi->bi_tool_entry_get = 0;
282 bi->bi_tool_entry_put = 0;
283 bi->bi_tool_entry_reindex = 0;
284 bi->bi_tool_sync = 0;
285 bi->bi_tool_dn2id_get = 0;
286 bi->bi_tool_id2entry_get = 0;
287 bi->bi_tool_entry_modify = 0;
289 bi->bi_connection_init = 0;
290 bi->bi_connection_destroy = 0;
292 for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
293 if ( monitor_back_register_subsys( ms ) ) {
302 monitor_back_db_init(
306 struct monitorinfo *mi;
308 struct berval dn, ndn;
318 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
320 "DESC 'OpenLDAP system monitoring' "
321 "SUP top STRUCTURAL "
326 #if 0 /* temporarily disabled */
337 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
338 offsetof(struct monitorinfo, mi_oc_monitor) },
339 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
340 "NAME 'monitorServer' "
341 "DESC 'Server monitoring root entry' "
342 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
343 offsetof(struct monitorinfo, mi_oc_monitorServer) },
344 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
345 "NAME 'monitorContainer' "
346 "DESC 'monitor container class' "
347 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
348 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
349 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
350 "NAME 'monitorCounterObject' "
351 "DESC 'monitor counter class' "
352 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
353 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
354 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
355 "NAME 'monitorOperation' "
356 "DESC 'monitor operation class' "
357 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
358 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
359 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
360 "NAME 'monitorConnection' "
361 "DESC 'monitor connection class' "
362 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
363 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
364 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
365 "NAME 'managedObject' "
366 "DESC 'monitor managed entity class' "
367 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
368 offsetof(struct monitorinfo, mi_oc_managedObject) },
369 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
370 "NAME 'monitoredObject' "
371 "DESC 'monitor monitored entity class' "
372 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
373 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
374 { NULL, NULL, 0, -1 }
376 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
377 "NAME 'monitoredInfo' "
378 "DESC 'monitored info' "
380 "EQUALITY caseIgnoreMatch "
381 "SUBSTR caseIgnoreSubstringsMatch "
382 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
383 "NO-USER-MODIFICATION "
384 "USAGE directoryOperation )", SLAP_AT_HIDE,
385 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
386 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
387 "NAME 'managedInfo' "
388 "DESC 'monitor managed info' "
389 "SUP name )", SLAP_AT_HIDE,
390 offsetof(struct monitorinfo, mi_ad_managedInfo) },
391 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
392 "NAME 'monitorCounter' "
393 "DESC 'monitor counter' "
394 "EQUALITY integerMatch "
395 "ORDERING integerOrderingMatch "
396 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
397 "NO-USER-MODIFICATION "
398 "USAGE directoryOperation )", SLAP_AT_HIDE,
399 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
400 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
401 "NAME 'monitorOpCompleted' "
402 "DESC 'monitor completed operations' "
403 "SUP monitorCounter "
404 "NO-USER-MODIFICATION "
405 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
406 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
407 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
408 "NAME 'monitorOpInitiated' "
409 "DESC 'monitor initiated operations' "
410 "SUP monitorCounter "
411 "NO-USER-MODIFICATION "
412 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
413 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
414 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
415 "NAME 'monitorConnectionNumber' "
416 "DESC 'monitor connection number' "
417 "SUP monitorCounter "
418 "NO-USER-MODIFICATION "
419 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
420 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
421 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
422 "NAME 'monitorConnectionAuthzDN' "
423 "DESC 'monitor connection authorization DN' "
424 /* "SUP distinguishedName " */
425 "EQUALITY distinguishedNameMatch "
426 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
427 "NO-USER-MODIFICATION "
428 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
429 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
430 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
431 "NAME 'monitorConnectionLocalAddress' "
432 "DESC 'monitor connection local address' "
434 "NO-USER-MODIFICATION "
435 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
436 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
437 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
438 "NAME 'monitorConnectionPeerAddress' "
439 "DESC 'monitor connection peer address' "
441 "NO-USER-MODIFICATION "
442 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
443 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
444 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
445 "NAME 'monitorTimestamp' "
446 "DESC 'monitor timestamp' "
447 "EQUALITY generalizedTimeMatch "
448 "ORDERING generalizedTimeOrderingMatch "
449 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
451 "NO-USER-MODIFICATION "
452 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
453 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
454 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
455 "NAME 'monitorOverlay' "
456 "DESC 'name of overlays defined for a give database' "
458 "NO-USER-MODIFICATION "
459 "USAGE directoryOperation )", SLAP_AT_HIDE,
460 offsetof(struct monitorinfo, mi_ad_monitorOverlay) },
461 { "readOnly", "( 1.3.6.1.4.1.4203.666.1.31 "
463 "DESC 'read/write status of a given database' "
464 "EQUALITY booleanMatch "
465 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
467 "USAGE directoryOperation )", SLAP_AT_HIDE,
468 offsetof(struct monitorinfo, mi_ad_readOnly) },
469 { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.32 "
470 "NAME 'restrictedOperation' "
471 "DESC 'name of restricted operation for a given database' "
472 "SUP managedInfo )", SLAP_AT_HIDE,
473 offsetof(struct monitorinfo, mi_ad_restrictedOperation ) },
474 #ifdef INTEGRATE_CORE_SCHEMA
475 { NULL, NULL, 0, -1 }, /* description */
476 { NULL, NULL, 0, -1 }, /* seeAlso */
477 { NULL, NULL, 0, -1 }, /* l */
478 { NULL, NULL, 0, -1 }, /* labeledURI */
479 #endif /* INTEGRATE_CORE_SCHEMA */
480 { NULL, NULL, 0, -1 }
482 { "description", "( 2.5.4.13 "
483 "NAME 'description' "
484 "DESC 'RFC2256: descriptive information' "
485 "EQUALITY caseIgnoreMatch "
486 "SUBSTR caseIgnoreSubstringsMatch "
487 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
488 offsetof(struct monitorinfo, mi_ad_description) },
489 { "seeAlso", "( 2.5.4.34 "
491 "DESC 'RFC2256: DN of related object' "
492 "SUP distinguishedName )", 0,
493 offsetof(struct monitorinfo, mi_ad_seeAlso) },
495 "NAME ( 'l' 'localityName' ) "
496 "DESC 'RFC2256: locality which this object resides in' "
498 offsetof(struct monitorinfo, mi_ad_l) },
499 { "labeledURI", "( 1.3.6.1.4.1.250.1.57 "
501 "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
502 "EQUALITY caseExactMatch "
503 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )", 0,
504 offsetof(struct monitorinfo, mi_ad_labeledURI) },
505 { NULL, NULL, 0, -1 }
509 * database monitor can be defined once only
512 Debug( LDAP_DEBUG_ANY,
513 "only one monitor backend is allowed\n", 0, 0, 0 );
518 /* indicate system schema supported */
519 SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
521 dn.bv_val = SLAPD_MONITOR_DN;
522 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
524 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
525 if( rc != LDAP_SUCCESS ) {
526 Debug( LDAP_DEBUG_ANY,
527 "unable to normalize monitor DN \"%s\"\n",
528 SLAPD_MONITOR_DN, 0, 0 );
532 ber_dupbv( &bv, &dn );
533 ber_bvarray_add( &be->be_suffix, &bv );
534 ber_bvarray_add( &be->be_nsuffix, &ndn );
536 mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
538 Debug( LDAP_DEBUG_ANY,
539 "unable to initialize monitor backend\n", 0, 0, 0 );
543 memset( mi, 0, sizeof( struct monitorinfo ) );
545 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
549 #ifdef INTEGRATE_CORE_SCHEMA
550 /* prepare for schema integration */
551 for ( k = 0; mat[k].name != NULL; k++ );
552 #endif /* INTEGRATE_CORE_SCHEMA */
554 for ( i = 0; mat_core[i].name != NULL; i++ ) {
555 AttributeDescription **ad;
558 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
561 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
565 #ifdef INTEGRATE_CORE_SCHEMA
566 case LDAP_UNDEFINED_TYPE:
567 mat[k] = mat_core[i];
570 #endif /* INTEGRATE_CORE_SCHEMA */
573 Debug( LDAP_DEBUG_ANY,
574 "monitor_back_db_init: %s: %s\n",
575 mat_core[i].name, text, 0 );
580 /* schema integration */
581 for ( i = 0; mat[i].name; i++ ) {
582 LDAPAttributeType *at;
585 AttributeDescription **ad;
587 at = ldap_str2attributetype( mat[i].schema, &code,
588 &err, LDAP_SCHEMA_ALLOW_ALL );
590 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
591 "in AttributeType \"%s\" %s before %s\n",
592 mat[i].name, ldap_scherr2str(code), err );
596 if ( at->at_oid == NULL ) {
597 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
598 "null OID for attributeType \"%s\"\n",
603 code = at_add(at, &err);
605 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
606 "%s in attributeType \"%s\"\n",
607 scherr2str(code), mat[i].name, 0 );
612 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
614 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
615 Debug( LDAP_DEBUG_ANY,
616 "monitor_back_db_init: %s\n", text, 0, 0 );
620 (*ad)->ad_type->sat_flags |= mat[i].flags;
623 for ( i = 0; moc[i].name; i++ ) {
629 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
630 LDAP_SCHEMA_ALLOW_ALL );
632 Debug( LDAP_DEBUG_ANY,
633 "unable to parse monitor objectclass \"%s\": "
634 "%s before %s\n" , moc[i].name,
635 ldap_scherr2str(code), err );
639 if ( oc->oc_oid == NULL ) {
640 Debug( LDAP_DEBUG_ANY,
641 "objectclass \"%s\" has no OID\n" ,
646 code = oc_add(oc, 0, &err);
648 Debug( LDAP_DEBUG_ANY,
649 "objectclass \"%s\": %s \"%s\"\n" ,
650 moc[i].name, scherr2str(code), err );
656 Oc = oc_find( moc[i].name );
658 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
659 "unable to find objectClass %s "
660 "(just added)\n", moc[i].name, 0, 0 );
664 Oc->soc_flags |= moc[i].flags;
666 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
673 monitor_back_db_open(
677 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
678 struct monitorsubsys **ms;
680 struct monitorentrypriv *mp;
682 char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
688 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
693 #ifndef HAVE_GMTIME_R
694 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
696 #ifdef HACK_LOCAL_TIME
697 # ifdef HAVE_LOCALTIME_R
698 tms = localtime_r( &starttime, &tm_buf );
700 tms = localtime( &starttime );
701 # endif /* HAVE_LOCALTIME_R */
702 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
703 #else /* !HACK_LOCAL_TIME */
704 # ifdef HAVE_GMTIME_R
705 tms = gmtime_r( &starttime, &tm_buf );
707 tms = gmtime( &starttime );
708 # endif /* HAVE_GMTIME_R */
709 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
710 #endif /* !HACK_LOCAL_TIME */
711 #ifndef HAVE_GMTIME_R
712 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
715 mi->mi_startTime.bv_val = tmbuf;
716 mi->mi_startTime.bv_len = strlen( tmbuf );
718 if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
719 BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
721 mi->mi_creatorsName = be->be_rootdn;
725 * creates the "cn=Monitor" entry
727 snprintf( buf, sizeof( buf ),
730 "structuralObjectClass: %s\n"
732 "%s: This subtree contains monitoring/managing objects.\n"
733 "%s: This object contains information about this server.\n"
735 "%s: createTimestamp reflects the time this server instance was created.\n"
736 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
739 "modifiersName: %s\n"
740 "createTimestamp: %s\n"
741 "modifyTimestamp: %s\n",
743 mi->mi_oc_monitorServer->soc_cname.bv_val,
744 mi->mi_oc_monitorServer->soc_cname.bv_val,
745 mi->mi_ad_description->ad_cname.bv_val,
746 mi->mi_ad_description->ad_cname.bv_val,
748 mi->mi_ad_description->ad_cname.bv_val,
749 mi->mi_ad_description->ad_cname.bv_val,
751 mi->mi_creatorsName.bv_val,
752 mi->mi_creatorsName.bv_val,
753 mi->mi_startTime.bv_val,
754 mi->mi_startTime.bv_val );
756 e = str2entry( buf );
758 Debug( LDAP_DEBUG_ANY,
759 "unable to create \"%s\" entry\n",
760 SLAPD_MONITOR_DN, 0, 0 );
764 bv.bv_val = (char *) Versionstr;
765 end_of_line = strchr( Versionstr, '\n' );
767 bv.bv_len = end_of_line - Versionstr;
769 bv.bv_len = strlen( Versionstr );
772 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
774 Debug( LDAP_DEBUG_ANY,
775 "unable to add monitoredInfo to \"%s\" entry\n",
776 SLAPD_MONITOR_DN, 0, 0 );
780 if ( mi->mi_l.bv_len ) {
781 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
782 Debug( LDAP_DEBUG_ANY,
783 "unable to add locality to \"%s\" entry\n",
784 SLAPD_MONITOR_DN, 0, 0 );
789 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
790 e->e_private = ( void * )mp;
793 mp->mp_children = NULL;
796 ep = &mp->mp_children;
798 if ( monitor_cache_add( mi, e ) ) {
799 Debug( LDAP_DEBUG_ANY,
800 "unable to add entry \"%s\" to cache\n",
801 SLAPD_MONITOR_DN, 0, 0 );
806 * Create all the subsystem specific entries
808 for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
809 int len = strlen( monitor_subsys[ i ]->mss_name );
813 dn.bv_len = len + sizeof( "cn=" ) - 1;
814 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
815 strcpy( dn.bv_val, "cn=" );
816 strcat( dn.bv_val, monitor_subsys[ i ]->mss_name );
817 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL );
819 if ( rc != LDAP_SUCCESS ) {
820 Debug( LDAP_DEBUG_ANY,
821 "monitor RDN \"%s\" is invalid\n",
826 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
827 dn.bv_val = ch_malloc( dn.bv_len + 1 );
828 strcpy( dn.bv_val , monitor_subsys[ i ]->mss_rdn.bv_val );
829 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
830 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ]->mss_dn,
831 &monitor_subsys[ i ]->mss_ndn, NULL );
833 if ( rc != LDAP_SUCCESS ) {
834 Debug( LDAP_DEBUG_ANY,
835 "monitor DN \"%s\" is invalid\n",
840 snprintf( buf, sizeof( buf ),
843 "structuralObjectClass: %s\n"
846 "modifiersName: %s\n"
847 "createTimestamp: %s\n"
848 "modifyTimestamp: %s\n",
849 monitor_subsys[ i ]->mss_dn.bv_val,
850 mi->mi_oc_monitorContainer->soc_cname.bv_val,
851 mi->mi_oc_monitorContainer->soc_cname.bv_val,
852 monitor_subsys[ i ]->mss_name,
853 mi->mi_creatorsName.bv_val,
854 mi->mi_creatorsName.bv_val,
855 mi->mi_startTime.bv_val,
856 mi->mi_startTime.bv_val );
858 e = str2entry( buf );
861 Debug( LDAP_DEBUG_ANY,
862 "unable to create \"%s\" entry\n",
863 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
867 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
868 e->e_private = ( void * )mp;
870 mp->mp_info = monitor_subsys[ i ];
871 mp->mp_children = NULL;
872 mp->mp_flags = monitor_subsys[ i ]->mss_flags;
874 if ( monitor_cache_add( mi, e ) ) {
875 Debug( LDAP_DEBUG_ANY,
876 "unable to add entry \"%s\" to cache\n",
877 monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
890 * opens the monitor backend subsystems
892 for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) {
893 if ( ms[ 0 ]->mss_open && ( *ms[ 0 ]->mss_open )( be, ms[ 0 ] ) )
912 * eventually, will hold backend specific configuration parameters
914 return SLAP_CONF_UNKNOWN;
918 monitor_back_db_config(
926 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
929 * eventually, will hold database specific configuration parameters
931 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
936 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
939 return SLAP_CONF_UNKNOWN;
946 monitor_back_db_destroy(
951 * FIXME: destroys all the data