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,
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 #ifdef SLAPD_MONITOR_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_DYNAMIC */
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;
239 * database monitor can be defined once only
243 LDAP_LOG( OPERATION, CRIT,
244 "only one monitor backend is allowed\n", 0, 0, 0);
246 Debug( LDAP_DEBUG_ANY,
247 "only one monitor backend is allowed\n", 0, 0, 0 );
253 /* indicate system schema supported */
254 be->be_flags |= SLAP_BFLAG_MONITOR;
256 dn.bv_val = SLAPD_MONITOR_DN;
257 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
259 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
260 if( rc != LDAP_SUCCESS ) {
262 LDAP_LOG( OPERATION, CRIT,
263 "unable to normalize monitor DN \"%s\"\n",
264 SLAPD_MONITOR_DN, 0, 0 );
266 Debug( LDAP_DEBUG_ANY,
267 "unable to normalize monitor DN \"%s\"\n",
268 SLAPD_MONITOR_DN, 0, 0 );
273 ber_dupbv( &bv, &dn );
274 ber_bvarray_add( &be->be_suffix, &bv );
275 ber_bvarray_add( &be->be_nsuffix, &ndn );
277 mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
280 LDAP_LOG( OPERATION, CRIT,
281 "unable to initialize monitor backend\n", 0, 0, 0 );
283 Debug( LDAP_DEBUG_ANY,
284 "unable to initialize monitor backend\n", 0, 0, 0 );
289 memset( mi, 0, sizeof( struct monitorinfo ) );
291 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
299 monitor_back_db_open(
303 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
304 struct monitorsubsys *ms;
306 struct monitorentrypriv *mp;
308 char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
317 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
319 "DESC 'OpenLDAP system monitoring' "
320 "SUP top STRUCTURAL "
325 #if 0 /* temporarily disabled */
335 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
336 offsetof(struct monitorinfo, mi_oc_monitor) },
337 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
338 "NAME 'monitorServer' "
339 "DESC 'Server monitoring root entry' "
340 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
341 offsetof(struct monitorinfo, mi_oc_monitorServer) },
342 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
343 "NAME 'monitorContainer' "
344 "DESC 'monitor container class' "
345 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
346 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
347 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
348 "NAME 'monitorCounterObject' "
349 "DESC 'monitor counter class' "
350 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
351 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
352 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
353 "NAME 'monitorOperation' "
354 "DESC 'monitor operation class' "
355 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
356 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
357 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
358 "NAME 'monitorConnection' "
359 "DESC 'monitor connection class' "
360 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
361 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
362 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
363 "NAME 'managedObject' "
364 "DESC 'monitor managed entity class' "
365 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
366 offsetof(struct monitorinfo, mi_oc_managedObject) },
367 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
368 "NAME 'monitoredObject' "
369 "DESC 'monitor monitored entity class' "
370 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
371 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
372 { NULL, NULL, 0, -1 }
374 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
375 "NAME 'monitoredInfo' "
376 "DESC 'monitored info' "
378 "EQUALITY caseIgnoreMatch "
379 "SUBSTR caseIgnoreSubstringsMatch "
380 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
381 "NO-USER-MODIFICATION "
382 "USAGE directoryOperation )", SLAP_AT_HIDE,
383 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
384 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
385 "NAME 'managedInfo' "
386 "DESC 'monitor managed info' "
387 "SUP name )", SLAP_AT_HIDE,
388 offsetof(struct monitorinfo, mi_ad_managedInfo) },
389 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
390 "NAME 'monitorCounter' "
391 "DESC 'monitor counter' "
392 "EQUALITY integerMatch "
393 "ORDERING integerOrderingMatch "
394 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
395 "NO-USER-MODIFICATION "
396 "USAGE directoryOperation )", SLAP_AT_HIDE,
397 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
398 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
399 "NAME 'monitorOpCompleted' "
400 "DESC 'monitor completed operations' "
401 "SUP monitorCounter "
402 "NO-USER-MODIFICATION "
403 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
404 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
405 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
406 "NAME 'monitorOpInitiated' "
407 "DESC 'monitor initiated operations' "
408 "SUP monitorCounter "
409 "NO-USER-MODIFICATION "
410 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
411 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
412 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
413 "NAME 'monitorConnectionNumber' "
414 "DESC 'monitor connection number' "
415 "SUP monitorCounter "
416 "NO-USER-MODIFICATION "
417 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
418 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
419 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
420 "NAME 'monitorConnectionAuthzDN' "
421 "DESC 'monitor connection authorization DN' "
422 /* "SUP distinguishedName " */
423 "EQUALITY distinguishedNameMatch "
424 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
425 "NO-USER-MODIFICATION "
426 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
427 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
428 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
429 "NAME 'monitorConnectionLocalAddress' "
430 "DESC 'monitor connection local address' "
432 "NO-USER-MODIFICATION "
433 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
434 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
435 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
436 "NAME 'monitorConnectionPeerAddress' "
437 "DESC 'monitor connection peer address' "
439 "NO-USER-MODIFICATION "
440 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
441 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
442 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
443 "NAME 'monitorTimestamp' "
444 "DESC 'monitor timestamp' "
445 "EQUALITY generalizedTimeMatch "
446 "ORDERING generalizedTimeOrderingMatch "
447 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
449 "NO-USER-MODIFICATION "
450 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
451 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
452 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
453 "NAME 'monitorOverlay' "
454 "DESC 'name of overlays defined for a give database' "
456 "NO-USER-MODIFICATION "
457 "USAGE directoryOperation )", SLAP_AT_HIDE,
458 offsetof(struct monitorinfo, mi_ad_monitorOverlay) },
459 #ifdef INTEGRATE_CORE_SCHEMA
460 { NULL, NULL, 0, -1 }, /* description */
461 { NULL, NULL, 0, -1 }, /* seeAlso */
462 { NULL, NULL, 0, -1 }, /* l */
463 #endif /* INTEGRATE_CORE_SCHEMA */
464 { NULL, NULL, 0, -1 }
466 { "description", "( 2.5.4.13 "
467 "NAME 'description' "
468 "DESC 'RFC2256: descriptive information' "
469 "EQUALITY caseIgnoreMatch "
470 "SUBSTR caseIgnoreSubstringsMatch "
471 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
472 offsetof(struct monitorinfo, mi_ad_description) },
473 { "seeAlso", "( 2.5.4.34 "
475 "DESC 'RFC2256: DN of related object' "
476 "SUP distinguishedName )", 0,
477 offsetof(struct monitorinfo, mi_ad_seeAlso) },
479 "NAME ( 'l' 'localityName' ) "
480 "DESC 'RFC2256: locality which this object resides in' "
482 offsetof(struct monitorinfo, mi_ad_l) },
483 { NULL, NULL, 0, -1 }
490 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
495 #ifndef HAVE_GMTIME_R
496 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
498 #ifdef HACK_LOCAL_TIME
499 # ifdef HAVE_LOCALTIME_R
500 tms = localtime_r( &starttime, &tm_buf );
502 tms = localtime( &starttime );
503 # endif /* HAVE_LOCALTIME_R */
504 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
505 #else /* !HACK_LOCAL_TIME */
506 # ifdef HAVE_GMTIME_R
507 tms = gmtime_r( &starttime, &tm_buf );
509 tms = gmtime( &starttime );
510 # endif /* HAVE_GMTIME_R */
511 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
512 #endif /* !HACK_LOCAL_TIME */
513 #ifndef HAVE_GMTIME_R
514 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
517 mi->mi_startTime.bv_val = tmbuf;
518 mi->mi_startTime.bv_len = strlen( tmbuf );
520 #ifdef INTEGRATE_CORE_SCHEMA
521 /* prepare for schema integration */
522 for ( k = 0; mat[k].name != NULL; k++ );
523 #endif /* INTEGRATE_CORE_SCHEMA */
525 for ( i = 0; mat_core[i].name != NULL; i++ ) {
526 AttributeDescription **ad;
529 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
532 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
536 #ifdef INTEGRATE_CORE_SCHEMA
537 case LDAP_UNDEFINED_TYPE:
538 mat[k] = mat_core[i];
541 #endif /* INTEGRATE_CORE_SCHEMA */
545 LDAP_LOG( OPERATION, CRIT,
546 "monitor_back_db_init: %s: %s\n",
547 mat_core[i].name, text, 0 );
549 Debug( LDAP_DEBUG_ANY,
550 "monitor_back_db_init: %s: %s\n",
551 mat_core[i].name, text, 0 );
557 /* schema integration */
558 for ( i = 0; mat[i].name; i++ ) {
559 LDAPAttributeType *at;
562 AttributeDescription **ad;
564 at = ldap_str2attributetype( mat[i].schema, &code,
565 &err, LDAP_SCHEMA_ALLOW_ALL );
568 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
569 "in AttributeType '%s' %s before %s\n",
570 mat[i].name, ldap_scherr2str(code), err );
572 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
573 "in AttributeType '%s' %s before %s\n",
574 mat[i].name, ldap_scherr2str(code), err );
579 if ( at->at_oid == NULL ) {
581 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
582 "null OID for attributeType '%s'\n",
585 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
586 "null OID for attributeType '%s'\n",
592 code = at_add(at, &err);
595 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
596 "%s in attributeType '%s'\n",
597 scherr2str(code), mat[i].name, 0 );
599 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
600 "%s in attributeType '%s'\n",
601 scherr2str(code), mat[i].name, 0 );
607 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
609 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
611 LDAP_LOG( OPERATION, CRIT,
612 "monitor_back_db_init: %s\n", text, 0, 0 );
614 Debug( LDAP_DEBUG_ANY,
615 "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 );
633 LDAP_LOG( OPERATION, CRIT,
634 "unable to parse monitor objectclass '%s': "
635 "%s before %s\n" , moc[i].name,
636 ldap_scherr2str(code), err );
638 Debug( LDAP_DEBUG_ANY,
639 "unable to parse monitor objectclass '%s': "
640 "%s before %s\n" , moc[i].name,
641 ldap_scherr2str(code), err );
646 if ( oc->oc_oid == NULL ) {
648 LDAP_LOG( OPERATION, CRIT,
649 "objectclass '%s' has no OID\n" ,
652 Debug( LDAP_DEBUG_ANY,
653 "objectclass '%s' has no OID\n" ,
659 code = oc_add(oc, 0, &err);
662 LDAP_LOG( OPERATION, CRIT,
663 "objectclass '%s': %s \"%s\"\n" ,
664 moc[i].name, scherr2str(code), err );
666 Debug( LDAP_DEBUG_ANY,
667 "objectclass '%s': %s \"%s\"\n" ,
668 moc[i].name, scherr2str(code), err );
675 Oc = oc_find( moc[i].name );
678 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
679 "unable to find objectClass %s "
680 "(just added)\n", moc[i].name, 0, 0 );
682 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
683 "unable to find objectClass %s "
684 "(just added)\n", moc[i].name, 0, 0 );
689 Oc->soc_flags |= moc[i].flags;
691 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
695 * Create all the subsystem specific entries
698 for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
699 int len = strlen( monitor_subsys[ i ].mss_name );
703 dn.bv_len = len + sizeof( "cn=" ) - 1;
704 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
705 strcpy( dn.bv_val, "cn=" );
706 strcat( dn.bv_val, monitor_subsys[ i ].mss_name );
707 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL );
709 if ( rc != LDAP_SUCCESS ) {
711 LDAP_LOG( OPERATION, CRIT,
712 "monitor RDN \"%s\" is invalid\n",
715 Debug( LDAP_DEBUG_ANY,
716 "monitor RDN \"%s\" is invalid\n",
722 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
723 dn.bv_val = ch_malloc( dn.bv_len + 1 );
724 strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn.bv_val );
725 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
726 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ].mss_dn,
727 &monitor_subsys[ i ].mss_ndn, NULL );
729 if ( rc != LDAP_SUCCESS ) {
731 LDAP_LOG( OPERATION, CRIT,
732 "monitor DN \"%s\" is invalid\n",
735 Debug( LDAP_DEBUG_ANY,
736 "monitor DN \"%s\" is invalid\n",
742 snprintf( buf, sizeof( buf ),
745 "structuralObjectClass: %s\n"
747 "createTimestamp: %s\n"
748 "modifyTimestamp: %s\n",
749 monitor_subsys[ i ].mss_dn.bv_val,
750 mi->mi_oc_monitorContainer->soc_cname.bv_val,
751 mi->mi_oc_monitorContainer->soc_cname.bv_val,
752 monitor_subsys[ i ].mss_name,
753 mi->mi_startTime.bv_val,
754 mi->mi_startTime.bv_val );
756 e = str2entry( buf );
760 LDAP_LOG( OPERATION, CRIT,
761 "unable to create '%s' entry\n",
762 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
764 Debug( LDAP_DEBUG_ANY,
765 "unable to create '%s' entry\n",
766 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
771 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
772 e->e_private = ( void * )mp;
773 mp->mp_info = &monitor_subsys[ i ];
774 mp->mp_children = NULL;
776 mp->mp_flags = monitor_subsys[ i ].mss_flags;
778 if ( monitor_cache_add( mi, e ) ) {
780 LDAP_LOG( OPERATION, CRIT,
781 "unable to add entry '%s' to cache\n",
782 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
784 Debug( LDAP_DEBUG_ANY,
785 "unable to add entry '%s' to cache\n",
786 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
795 * creates the "cn=Monitor" entry
797 snprintf( buf, sizeof( buf ),
800 "structuralObjectClass: %s\n"
802 "%s: This subtree contains monitoring/managing objects.\n"
803 "%s: This object contains information about this server.\n"
805 "%s: createTimestamp reflects the time this server instance was created.\n"
806 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
808 "createTimestamp: %s\n"
809 "modifyTimestamp: %s\n",
811 mi->mi_oc_monitorServer->soc_cname.bv_val,
812 mi->mi_oc_monitorServer->soc_cname.bv_val,
813 mi->mi_ad_description->ad_cname.bv_val,
814 mi->mi_ad_description->ad_cname.bv_val,
816 mi->mi_ad_description->ad_cname.bv_val,
817 mi->mi_ad_description->ad_cname.bv_val,
819 mi->mi_startTime.bv_val,
820 mi->mi_startTime.bv_val );
822 e = str2entry( buf );
825 LDAP_LOG( OPERATION, CRIT,
826 "unable to create '%s' entry\n",
827 SLAPD_MONITOR_DN, 0, 0 );
829 Debug( LDAP_DEBUG_ANY,
830 "unable to create '%s' entry\n",
831 SLAPD_MONITOR_DN, 0, 0 );
836 bv.bv_val = (char *) Versionstr;
837 end_of_line = strchr( Versionstr, '\n' );
839 bv.bv_len = end_of_line - Versionstr;
841 bv.bv_len = strlen( Versionstr );
844 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
847 LDAP_LOG( OPERATION, CRIT,
848 "unable to add monitoredInfo to '%s' entry\n",
849 SLAPD_MONITOR_DN, 0, 0 );
851 Debug( LDAP_DEBUG_ANY,
852 "unable to add monitoredInfo to '%s' entry\n",
853 SLAPD_MONITOR_DN, 0, 0 );
858 if ( mi->mi_l.bv_len ) {
859 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
861 LDAP_LOG( OPERATION, CRIT,
862 "unable to add locality to '%s' entry\n",
863 SLAPD_MONITOR_DN, 0, 0 );
865 Debug( LDAP_DEBUG_ANY,
866 "unable to add locality to '%s' entry\n",
867 SLAPD_MONITOR_DN, 0, 0 );
873 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
874 e->e_private = ( void * )mp;
877 mp->mp_children = e_tmp;
880 if ( monitor_cache_add( mi, e ) ) {
882 LDAP_LOG( OPERATION, CRIT,
883 "unable to add entry '%s' to cache\n",
884 SLAPD_MONITOR_DN, 0, 0 );
886 Debug( LDAP_DEBUG_ANY,
887 "unable to add entry '%s' to cache\n",
888 SLAPD_MONITOR_DN, 0, 0 );
898 * opens the monitor backend
900 for ( ms = monitor_subsys; ms->mss_name != NULL; ms++ ) {
901 if ( ms->mss_init && ( *ms->mss_init )( be ) ) {
919 * eventually, will hold backend specific configuration parameters
921 return SLAP_CONF_UNKNOWN;
925 monitor_back_db_config(
933 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
936 * eventually, will hold database specific configuration parameters
938 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
943 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
946 return SLAP_CONF_UNKNOWN;
953 monitor_back_db_destroy(
958 * FIXME: destroys all the data