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,
142 #ifdef SLAPD_MONITOR_DYNAMIC
145 init_module( int argc, char *argv[] )
149 memset( &bi, '\0', sizeof(bi) );
150 bi.bi_type = "monitor";
151 bi.bi_init = monitor_back_initialize;
156 #endif /* SLAPD_MONITOR_DYNAMIC */
159 monitor_back_initialize(
163 static char *controls[] = {
164 LDAP_CONTROL_MANAGEDSAIT,
165 LDAP_CONTROL_VALUESRETURNFILTER,
169 bi->bi_controls = controls;
173 bi->bi_config = monitor_back_config;
177 bi->bi_db_init = monitor_back_db_init;
178 bi->bi_db_config = monitor_back_db_config;
179 bi->bi_db_open = monitor_back_db_open;
181 bi->bi_db_destroy = monitor_back_db_destroy;
183 bi->bi_op_bind = monitor_back_bind;
184 bi->bi_op_unbind = 0;
185 bi->bi_op_search = monitor_back_search;
186 bi->bi_op_compare = monitor_back_compare;
187 bi->bi_op_modify = monitor_back_modify;
188 bi->bi_op_modrdn = 0;
190 bi->bi_op_delete = 0;
191 bi->bi_op_abandon = 0;
195 bi->bi_entry_release_rw = 0;
196 bi->bi_chk_referrals = 0;
197 bi->bi_operational = monitor_back_operational;
200 * hooks for slap tools
202 bi->bi_tool_entry_open = 0;
203 bi->bi_tool_entry_close = 0;
204 bi->bi_tool_entry_first = 0;
205 bi->bi_tool_entry_next = 0;
206 bi->bi_tool_entry_get = 0;
207 bi->bi_tool_entry_put = 0;
208 bi->bi_tool_entry_reindex = 0;
209 bi->bi_tool_sync = 0;
210 bi->bi_tool_dn2id_get = 0;
211 bi->bi_tool_id2entry_get = 0;
212 bi->bi_tool_entry_modify = 0;
214 bi->bi_connection_init = 0;
215 bi->bi_connection_destroy = 0;
221 monitor_back_db_init(
225 struct monitorinfo *mi;
227 struct berval dn, ndn;
231 * database monitor can be defined once only
235 LDAP_LOG( OPERATION, CRIT,
236 "only one monitor backend is allowed\n", 0, 0, 0);
238 Debug( LDAP_DEBUG_ANY,
239 "only one monitor backend is allowed\n", 0, 0, 0 );
245 /* indicate system schema supported */
246 be->be_flags |= SLAP_BFLAG_MONITOR;
248 dn.bv_val = SLAPD_MONITOR_DN;
249 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
251 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
252 if( rc != LDAP_SUCCESS ) {
254 LDAP_LOG( OPERATION, CRIT,
255 "unable to normalize monitor DN \"%s\"\n",
256 SLAPD_MONITOR_DN, 0, 0 );
258 Debug( LDAP_DEBUG_ANY,
259 "unable to normalize monitor DN \"%s\"\n",
260 SLAPD_MONITOR_DN, 0, 0 );
265 ber_dupbv( &bv, &dn );
266 ber_bvarray_add( &be->be_suffix, &bv );
267 ber_bvarray_add( &be->be_nsuffix, &ndn );
269 mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
272 LDAP_LOG( OPERATION, CRIT,
273 "unable to initialize monitor backend\n", 0, 0, 0 );
275 Debug( LDAP_DEBUG_ANY,
276 "unable to initialize monitor backend\n", 0, 0, 0 );
281 memset( mi, 0, sizeof( struct monitorinfo ) );
283 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
291 monitor_back_db_open(
295 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
296 struct monitorsubsys *ms;
298 struct monitorentrypriv *mp;
300 char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
309 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
311 "DESC 'OpenLDAP system monitoring' "
312 "SUP top STRUCTURAL "
317 #if 0 /* temporarily disabled */
327 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
328 offsetof(struct monitorinfo, mi_oc_monitor) },
329 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
330 "NAME 'monitorServer' "
331 "DESC 'Server monitoring root entry' "
332 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
333 offsetof(struct monitorinfo, mi_oc_monitorServer) },
334 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
335 "NAME 'monitorContainer' "
336 "DESC 'monitor container class' "
337 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
338 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
339 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
340 "NAME 'monitorCounterObject' "
341 "DESC 'monitor counter class' "
342 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
343 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
344 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
345 "NAME 'monitorOperation' "
346 "DESC 'monitor operation class' "
347 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
348 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
349 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
350 "NAME 'monitorConnection' "
351 "DESC 'monitor connection class' "
352 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
353 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
354 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
355 "NAME 'managedObject' "
356 "DESC 'monitor managed entity class' "
357 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
358 offsetof(struct monitorinfo, mi_oc_managedObject) },
359 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
360 "NAME 'monitoredObject' "
361 "DESC 'monitor monitored entity class' "
362 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
363 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
364 { NULL, NULL, 0, -1 }
366 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
367 "NAME 'monitoredInfo' "
368 "DESC 'monitored info' "
370 "EQUALITY caseIgnoreMatch "
371 "SUBSTR caseIgnoreSubstringsMatch "
372 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
373 "NO-USER-MODIFICATION "
374 "USAGE directoryOperation )", SLAP_AT_HIDE,
375 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
376 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
377 "NAME 'managedInfo' "
378 "DESC 'monitor managed info' "
379 "SUP name )", SLAP_AT_HIDE,
380 offsetof(struct monitorinfo, mi_ad_managedInfo) },
381 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
382 "NAME 'monitorCounter' "
383 "DESC 'monitor counter' "
384 "EQUALITY integerMatch "
385 "ORDERING integerOrderingMatch "
386 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
387 "NO-USER-MODIFICATION "
388 "USAGE directoryOperation )", SLAP_AT_HIDE,
389 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
390 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
391 "NAME 'monitorOpCompleted' "
392 "DESC 'monitor completed operations' "
393 "SUP monitorCounter "
394 "NO-USER-MODIFICATION "
395 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
396 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
397 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
398 "NAME 'monitorOpInitiated' "
399 "DESC 'monitor initiated operations' "
400 "SUP monitorCounter "
401 "NO-USER-MODIFICATION "
402 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
403 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
404 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
405 "NAME 'monitorConnectionNumber' "
406 "DESC 'monitor connection number' "
407 "SUP monitorCounter "
408 "NO-USER-MODIFICATION "
409 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
410 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
411 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
412 "NAME 'monitorConnectionAuthzDN' "
413 "DESC 'monitor connection authorization DN' "
414 /* "SUP distinguishedName " */
415 "EQUALITY distinguishedNameMatch "
416 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
417 "NO-USER-MODIFICATION "
418 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
419 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
420 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
421 "NAME 'monitorConnectionLocalAddress' "
422 "DESC 'monitor connection local address' "
424 "NO-USER-MODIFICATION "
425 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
426 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
427 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
428 "NAME 'monitorConnectionPeerAddress' "
429 "DESC 'monitor connection peer address' "
431 "NO-USER-MODIFICATION "
432 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
433 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
434 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
435 "NAME 'monitorTimestamp' "
436 "DESC 'monitor timestamp' "
437 "EQUALITY generalizedTimeMatch "
438 "ORDERING generalizedTimeOrderingMatch "
439 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
441 "NO-USER-MODIFICATION "
442 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
443 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
444 { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
445 "NAME 'monitorOverlay' "
446 "DESC 'name of overlays defined for a give database' "
448 "NO-USER-MODIFICATION "
449 "USAGE directoryOperation )", SLAP_AT_HIDE,
450 offsetof(struct monitorinfo, mi_ad_monitorOverlay) },
451 #ifdef INTEGRATE_CORE_SCHEMA
452 { NULL, NULL, 0, -1 }, /* description */
453 { NULL, NULL, 0, -1 }, /* seeAlso */
454 { NULL, NULL, 0, -1 }, /* l */
455 #endif /* INTEGRATE_CORE_SCHEMA */
456 { NULL, NULL, 0, -1 }
458 { "description", "( 2.5.4.13 "
459 "NAME 'description' "
460 "DESC 'RFC2256: descriptive information' "
461 "EQUALITY caseIgnoreMatch "
462 "SUBSTR caseIgnoreSubstringsMatch "
463 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
464 offsetof(struct monitorinfo, mi_ad_description) },
465 { "seeAlso", "( 2.5.4.34 "
467 "DESC 'RFC2256: DN of related object' "
468 "SUP distinguishedName )", 0,
469 offsetof(struct monitorinfo, mi_ad_seeAlso) },
471 "NAME ( 'l' 'localityName' ) "
472 "DESC 'RFC2256: locality which this object resides in' "
474 offsetof(struct monitorinfo, mi_ad_l) },
475 { NULL, NULL, 0, -1 }
482 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
487 #ifndef HAVE_GMTIME_R
488 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
490 #ifdef HACK_LOCAL_TIME
491 # ifdef HAVE_LOCALTIME_R
492 tms = localtime_r( &starttime, &tm_buf );
494 tms = localtime( &starttime );
495 # endif /* HAVE_LOCALTIME_R */
496 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
497 #else /* !HACK_LOCAL_TIME */
498 # ifdef HAVE_GMTIME_R
499 tms = gmtime_r( &starttime, &tm_buf );
501 tms = gmtime( &starttime );
502 # endif /* HAVE_GMTIME_R */
503 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
504 #endif /* !HACK_LOCAL_TIME */
505 #ifndef HAVE_GMTIME_R
506 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
509 mi->mi_startTime.bv_val = tmbuf;
510 mi->mi_startTime.bv_len = strlen( tmbuf );
512 #ifdef INTEGRATE_CORE_SCHEMA
513 /* prepare for schema integration */
514 for ( k = 0; mat[k].name != NULL; k++ );
515 #endif /* INTEGRATE_CORE_SCHEMA */
517 for ( i = 0; mat_core[i].name != NULL; i++ ) {
518 AttributeDescription **ad;
521 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
524 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
528 #ifdef INTEGRATE_CORE_SCHEMA
529 case LDAP_UNDEFINED_TYPE:
530 mat[k] = mat_core[i];
533 #endif /* INTEGRATE_CORE_SCHEMA */
537 LDAP_LOG( OPERATION, CRIT,
538 "monitor_back_db_init: %s: %s\n",
539 mat_core[i].name, text, 0 );
541 Debug( LDAP_DEBUG_ANY,
542 "monitor_back_db_init: %s: %s\n",
543 mat_core[i].name, text, 0 );
549 /* schema integration */
550 for ( i = 0; mat[i].name; i++ ) {
551 LDAPAttributeType *at;
554 AttributeDescription **ad;
556 at = ldap_str2attributetype( mat[i].schema, &code,
557 &err, LDAP_SCHEMA_ALLOW_ALL );
560 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
561 "in AttributeType '%s' %s before %s\n",
562 mat[i].name, ldap_scherr2str(code), err );
564 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
565 "in AttributeType '%s' %s before %s\n",
566 mat[i].name, ldap_scherr2str(code), err );
571 if ( at->at_oid == NULL ) {
573 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
574 "null OID for attributeType '%s'\n",
577 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
578 "null OID for attributeType '%s'\n",
584 code = at_add(at, &err);
587 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
588 "%s in attributeType '%s'\n",
589 scherr2str(code), mat[i].name, 0 );
591 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
592 "%s in attributeType '%s'\n",
593 scherr2str(code), mat[i].name, 0 );
599 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
601 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
603 LDAP_LOG( OPERATION, CRIT,
604 "monitor_back_db_init: %s\n", text, 0, 0 );
606 Debug( LDAP_DEBUG_ANY,
607 "monitor_back_db_init: %s\n", text, 0, 0 );
612 (*ad)->ad_type->sat_flags |= mat[i].flags;
615 for ( i = 0; moc[i].name; i++ ) {
621 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
622 LDAP_SCHEMA_ALLOW_ALL );
625 LDAP_LOG( OPERATION, CRIT,
626 "unable to parse monitor objectclass '%s': "
627 "%s before %s\n" , moc[i].name,
628 ldap_scherr2str(code), err );
630 Debug( LDAP_DEBUG_ANY,
631 "unable to parse monitor objectclass '%s': "
632 "%s before %s\n" , moc[i].name,
633 ldap_scherr2str(code), err );
638 if ( oc->oc_oid == NULL ) {
640 LDAP_LOG( OPERATION, CRIT,
641 "objectclass '%s' has no OID\n" ,
644 Debug( LDAP_DEBUG_ANY,
645 "objectclass '%s' has no OID\n" ,
651 code = oc_add(oc, 0, &err);
654 LDAP_LOG( OPERATION, CRIT,
655 "objectclass '%s': %s \"%s\"\n" ,
656 moc[i].name, scherr2str(code), err );
658 Debug( LDAP_DEBUG_ANY,
659 "objectclass '%s': %s \"%s\"\n" ,
660 moc[i].name, scherr2str(code), err );
667 Oc = oc_find( moc[i].name );
670 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
671 "unable to find objectClass %s "
672 "(just added)\n", moc[i].name, 0, 0 );
674 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
675 "unable to find objectClass %s "
676 "(just added)\n", moc[i].name, 0, 0 );
681 Oc->soc_flags |= moc[i].flags;
683 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
687 * Create all the subsystem specific entries
690 for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
691 int len = strlen( monitor_subsys[ i ].mss_name );
695 dn.bv_len = len + sizeof( "cn=" ) - 1;
696 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
697 strcpy( dn.bv_val, "cn=" );
698 strcat( dn.bv_val, monitor_subsys[ i ].mss_name );
699 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL );
701 if ( rc != LDAP_SUCCESS ) {
703 LDAP_LOG( OPERATION, CRIT,
704 "monitor RDN \"%s\" is invalid\n",
707 Debug( LDAP_DEBUG_ANY,
708 "monitor RDN \"%s\" is invalid\n",
714 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
715 dn.bv_val = ch_malloc( dn.bv_len + 1 );
716 strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn.bv_val );
717 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
718 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ].mss_dn,
719 &monitor_subsys[ i ].mss_ndn, NULL );
721 if ( rc != LDAP_SUCCESS ) {
723 LDAP_LOG( OPERATION, CRIT,
724 "monitor DN \"%s\" is invalid\n",
727 Debug( LDAP_DEBUG_ANY,
728 "monitor DN \"%s\" is invalid\n",
734 snprintf( buf, sizeof( buf ),
737 "structuralObjectClass: %s\n"
739 "createTimestamp: %s\n"
740 "modifyTimestamp: %s\n",
741 monitor_subsys[ i ].mss_dn.bv_val,
742 mi->mi_oc_monitorContainer->soc_cname.bv_val,
743 mi->mi_oc_monitorContainer->soc_cname.bv_val,
744 monitor_subsys[ i ].mss_name,
745 mi->mi_startTime.bv_val,
746 mi->mi_startTime.bv_val );
748 e = str2entry( buf );
752 LDAP_LOG( OPERATION, CRIT,
753 "unable to create '%s' entry\n",
754 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
756 Debug( LDAP_DEBUG_ANY,
757 "unable to create '%s' entry\n",
758 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
763 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
764 e->e_private = ( void * )mp;
765 mp->mp_info = &monitor_subsys[ i ];
766 mp->mp_children = NULL;
768 mp->mp_flags = monitor_subsys[ i ].mss_flags;
770 if ( monitor_cache_add( mi, e ) ) {
772 LDAP_LOG( OPERATION, CRIT,
773 "unable to add entry '%s' to cache\n",
774 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
776 Debug( LDAP_DEBUG_ANY,
777 "unable to add entry '%s' to cache\n",
778 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
787 * creates the "cn=Monitor" entry
789 snprintf( buf, sizeof( buf ),
792 "structuralObjectClass: %s\n"
794 "%s: This subtree contains monitoring/managing objects.\n"
795 "%s: This object contains information about this server.\n"
797 "%s: createTimestamp reflects the time this server instance was created.\n"
798 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
800 "createTimestamp: %s\n"
801 "modifyTimestamp: %s\n",
803 mi->mi_oc_monitorServer->soc_cname.bv_val,
804 mi->mi_oc_monitorServer->soc_cname.bv_val,
805 mi->mi_ad_description->ad_cname.bv_val,
806 mi->mi_ad_description->ad_cname.bv_val,
808 mi->mi_ad_description->ad_cname.bv_val,
809 mi->mi_ad_description->ad_cname.bv_val,
811 mi->mi_startTime.bv_val,
812 mi->mi_startTime.bv_val );
814 e = str2entry( buf );
817 LDAP_LOG( OPERATION, CRIT,
818 "unable to create '%s' entry\n",
819 SLAPD_MONITOR_DN, 0, 0 );
821 Debug( LDAP_DEBUG_ANY,
822 "unable to create '%s' entry\n",
823 SLAPD_MONITOR_DN, 0, 0 );
828 bv.bv_val = (char *) Versionstr;
829 end_of_line = strchr( Versionstr, '\n' );
831 bv.bv_len = end_of_line - Versionstr;
833 bv.bv_len = strlen( Versionstr );
836 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
839 LDAP_LOG( OPERATION, CRIT,
840 "unable to add monitoredInfo to '%s' entry\n",
841 SLAPD_MONITOR_DN, 0, 0 );
843 Debug( LDAP_DEBUG_ANY,
844 "unable to add monitoredInfo to '%s' entry\n",
845 SLAPD_MONITOR_DN, 0, 0 );
850 if ( mi->mi_l.bv_len ) {
851 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
853 LDAP_LOG( OPERATION, CRIT,
854 "unable to add locality to '%s' entry\n",
855 SLAPD_MONITOR_DN, 0, 0 );
857 Debug( LDAP_DEBUG_ANY,
858 "unable to add locality to '%s' entry\n",
859 SLAPD_MONITOR_DN, 0, 0 );
865 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
866 e->e_private = ( void * )mp;
869 mp->mp_children = e_tmp;
872 if ( monitor_cache_add( mi, e ) ) {
874 LDAP_LOG( OPERATION, CRIT,
875 "unable to add entry '%s' to cache\n",
876 SLAPD_MONITOR_DN, 0, 0 );
878 Debug( LDAP_DEBUG_ANY,
879 "unable to add entry '%s' to cache\n",
880 SLAPD_MONITOR_DN, 0, 0 );
890 * opens the monitor backend
892 for ( ms = monitor_subsys; ms->mss_name != NULL; ms++ ) {
893 if ( ms->mss_init && ( *ms->mss_init )( be ) ) {
911 * eventually, will hold backend specific configuration parameters
913 return SLAP_CONF_UNKNOWN;
917 monitor_back_db_config(
925 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
928 * eventually, will hold database specific configuration parameters
930 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
935 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
938 return SLAP_CONF_UNKNOWN;
945 monitor_back_db_destroy(
950 * FIXME: destroys all the data