1 /* init.c - initialize monitor backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2003 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 */
326 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
327 offsetof(struct monitorinfo, mi_oc_monitor) },
328 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
329 "NAME 'monitorServer' "
330 "DESC 'Server monitoring root entry' "
331 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
332 offsetof(struct monitorinfo, mi_oc_monitorServer) },
333 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
334 "NAME 'monitorContainer' "
335 "DESC 'monitor container class' "
336 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
337 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
338 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
339 "NAME 'monitorCounterObject' "
340 "DESC 'monitor counter class' "
341 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
342 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
343 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
344 "NAME 'monitorOperation' "
345 "DESC 'monitor operation class' "
346 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
347 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
348 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
349 "NAME 'monitorConnection' "
350 "DESC 'monitor connection class' "
351 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
352 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
353 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
354 "NAME 'managedObject' "
355 "DESC 'monitor managed entity class' "
356 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
357 offsetof(struct monitorinfo, mi_oc_managedObject) },
358 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
359 "NAME 'monitoredObject' "
360 "DESC 'monitor monitored entity class' "
361 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
362 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
363 { NULL, NULL, 0, -1 }
365 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
366 "NAME 'monitoredInfo' "
367 "DESC 'monitored info' "
369 "EQUALITY caseIgnoreMatch "
370 "SUBSTR caseIgnoreSubstringsMatch "
371 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
372 "NO-USER-MODIFICATION "
373 "USAGE directoryOperation )", SLAP_AT_HIDE,
374 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
375 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
376 "NAME 'managedInfo' "
377 "DESC 'monitor managed info' "
378 "SUP name )", SLAP_AT_HIDE,
379 offsetof(struct monitorinfo, mi_ad_managedInfo) },
380 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
381 "NAME 'monitorCounter' "
382 "DESC 'monitor counter' "
383 "EQUALITY integerMatch "
384 "ORDERING integerOrderingMatch "
385 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
386 "NO-USER-MODIFICATION "
387 "USAGE directoryOperation )", SLAP_AT_HIDE,
388 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
389 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
390 "NAME 'monitorOpCompleted' "
391 "DESC 'monitor completed operations' "
392 "SUP monitorCounter "
393 "NO-USER-MODIFICATION "
394 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
395 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
396 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
397 "NAME 'monitorOpInitiated' "
398 "DESC 'monitor initiated operations' "
399 "SUP monitorCounter "
400 "NO-USER-MODIFICATION "
401 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
402 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
403 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
404 "NAME 'monitorConnectionNumber' "
405 "DESC 'monitor connection number' "
406 "SUP monitorCounter "
407 "NO-USER-MODIFICATION "
408 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
409 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
410 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
411 "NAME 'monitorConnectionAuthzDN' "
412 "DESC 'monitor connection authorization DN' "
413 /* "SUP distinguishedName " */
414 "EQUALITY distinguishedNameMatch "
415 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
416 "NO-USER-MODIFICATION "
417 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
418 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
419 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
420 "NAME 'monitorConnectionLocalAddress' "
421 "DESC 'monitor connection local address' "
423 "NO-USER-MODIFICATION "
424 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
425 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
426 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
427 "NAME 'monitorConnectionPeerAddress' "
428 "DESC 'monitor connection peer address' "
430 "NO-USER-MODIFICATION "
431 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
432 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
433 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
434 "NAME 'monitorTimestamp' "
435 "DESC 'monitor timestamp' "
436 "EQUALITY generalizedTimeMatch "
437 "ORDERING generalizedTimeOrderingMatch "
438 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
440 "NO-USER-MODIFICATION "
441 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
442 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
443 #ifdef INTEGRATE_CORE_SCHEMA
444 { NULL, NULL, 0, -1 }, /* description */
445 { NULL, NULL, 0, -1 }, /* seeAlso */
446 { NULL, NULL, 0, -1 }, /* l */
447 #endif /* INTEGRATE_CORE_SCHEMA */
448 { NULL, NULL, 0, -1 }
450 { "description", "( 2.5.4.13 "
451 "NAME 'description' "
452 "DESC 'RFC2256: descriptive information' "
453 "EQUALITY caseIgnoreMatch "
454 "SUBSTR caseIgnoreSubstringsMatch "
455 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
456 offsetof(struct monitorinfo, mi_ad_description) },
457 { "seeAlso", "( 2.5.4.34 "
459 "DESC 'RFC2256: DN of related object' "
460 "SUP distinguishedName )", 0,
461 offsetof(struct monitorinfo, mi_ad_seeAlso) },
463 "NAME ( 'l' 'localityName' ) "
464 "DESC 'RFC2256: locality which this object resides in' "
466 offsetof(struct monitorinfo, mi_ad_l) },
467 { NULL, NULL, 0, -1 }
474 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
479 #ifndef HAVE_GMTIME_R
480 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
482 #ifdef HACK_LOCAL_TIME
483 # ifdef HAVE_LOCALTIME_R
484 tms = localtime_r( &starttime, &tm_buf );
486 tms = localtime( &starttime );
487 # endif /* HAVE_LOCALTIME_R */
488 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
489 #else /* !HACK_LOCAL_TIME */
490 # ifdef HAVE_GMTIME_R
491 tms = gmtime_r( &starttime, &tm_buf );
493 tms = gmtime( &starttime );
494 # endif /* HAVE_GMTIME_R */
495 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
496 #endif /* !HACK_LOCAL_TIME */
497 #ifndef HAVE_GMTIME_R
498 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
501 mi->mi_startTime.bv_val = tmbuf;
502 mi->mi_startTime.bv_len = strlen( tmbuf );
504 #ifdef INTEGRATE_CORE_SCHEMA
505 /* prepare for schema integration */
506 for ( k = 0; mat[k].name != NULL; k++ );
507 #endif /* INTEGRATE_CORE_SCHEMA */
509 for ( i = 0; mat_core[i].name != NULL; i++ ) {
510 AttributeDescription **ad;
513 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
516 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
520 #ifdef INTEGRATE_CORE_SCHEMA
521 case LDAP_UNDEFINED_TYPE:
522 mat[k] = mat_core[i];
525 #endif /* INTEGRATE_CORE_SCHEMA */
529 LDAP_LOG( OPERATION, CRIT,
530 "monitor_back_db_init: %s: %s\n",
531 mat_core[i].name, text, 0 );
533 Debug( LDAP_DEBUG_ANY,
534 "monitor_back_db_init: %s: %s\n",
535 mat_core[i].name, text, 0 );
541 /* schema integration */
542 for ( i = 0; mat[i].name; i++ ) {
543 LDAPAttributeType *at;
546 AttributeDescription **ad;
548 at = ldap_str2attributetype( mat[i].schema, &code,
549 &err, LDAP_SCHEMA_ALLOW_ALL );
552 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
553 "in AttributeType '%s' %s before %s\n",
554 mat[i].name, ldap_scherr2str(code), err );
556 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
557 "in AttributeType '%s' %s before %s\n",
558 mat[i].name, ldap_scherr2str(code), err );
563 if ( at->at_oid == NULL ) {
565 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
566 "null OID for attributeType '%s'\n",
569 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
570 "null OID for attributeType '%s'\n",
576 code = at_add(at, &err);
579 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
580 "%s in attributeType '%s'\n",
581 scherr2str(code), mat[i].name, 0 );
583 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
584 "%s in attributeType '%s'\n",
585 scherr2str(code), mat[i].name, 0 );
591 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
593 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
595 LDAP_LOG( OPERATION, CRIT,
596 "monitor_back_db_init: %s\n", text, 0, 0 );
598 Debug( LDAP_DEBUG_ANY,
599 "monitor_back_db_init: %s\n", text, 0, 0 );
604 (*ad)->ad_type->sat_flags |= mat[i].flags;
607 for ( i = 0; moc[i].name; i++ ) {
613 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
614 LDAP_SCHEMA_ALLOW_ALL );
617 LDAP_LOG( OPERATION, CRIT,
618 "unable to parse monitor objectclass '%s': "
619 "%s before %s\n" , moc[i].name,
620 ldap_scherr2str(code), err );
622 Debug( LDAP_DEBUG_ANY,
623 "unable to parse monitor objectclass '%s': "
624 "%s before %s\n" , moc[i].name,
625 ldap_scherr2str(code), err );
630 if ( oc->oc_oid == NULL ) {
632 LDAP_LOG( OPERATION, CRIT,
633 "objectclass '%s' has no OID\n" ,
636 Debug( LDAP_DEBUG_ANY,
637 "objectclass '%s' has no OID\n" ,
643 code = oc_add(oc, 0, &err);
646 LDAP_LOG( OPERATION, CRIT,
647 "objectclass '%s': %s \"%s\"\n" ,
648 moc[i].name, scherr2str(code), err );
650 Debug( LDAP_DEBUG_ANY,
651 "objectclass '%s': %s \"%s\"\n" ,
652 moc[i].name, scherr2str(code), err );
659 Oc = oc_find( moc[i].name );
662 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
663 "unable to find objectClass %s "
664 "(just added)\n", moc[i].name, 0, 0 );
666 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
667 "unable to find objectClass %s "
668 "(just added)\n", moc[i].name, 0, 0 );
673 Oc->soc_flags |= moc[i].flags;
675 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
679 * Create all the subsystem specific entries
682 for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
683 int len = strlen( monitor_subsys[ i ].mss_name );
687 dn.bv_len = len + sizeof( "cn=" ) - 1;
688 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
689 strcpy( dn.bv_val, "cn=" );
690 strcat( dn.bv_val, monitor_subsys[ i ].mss_name );
691 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL );
693 if ( rc != LDAP_SUCCESS ) {
695 LDAP_LOG( OPERATION, CRIT,
696 "monitor RDN \"%s\" is invalid\n",
699 Debug( LDAP_DEBUG_ANY,
700 "monitor RDN \"%s\" is invalid\n",
706 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
707 dn.bv_val = ch_malloc( dn.bv_len + 1 );
708 strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn.bv_val );
709 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
710 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ].mss_dn,
711 &monitor_subsys[ i ].mss_ndn, NULL );
713 if ( rc != LDAP_SUCCESS ) {
715 LDAP_LOG( OPERATION, CRIT,
716 "monitor DN \"%s\" is invalid\n",
719 Debug( LDAP_DEBUG_ANY,
720 "monitor DN \"%s\" is invalid\n",
726 snprintf( buf, sizeof( buf ),
729 "structuralObjectClass: %s\n"
731 "createTimestamp: %s\n"
732 "modifyTimestamp: %s\n",
733 monitor_subsys[ i ].mss_dn.bv_val,
734 mi->mi_oc_monitorContainer->soc_cname.bv_val,
735 mi->mi_oc_monitorContainer->soc_cname.bv_val,
736 monitor_subsys[ i ].mss_name,
737 mi->mi_startTime.bv_val,
738 mi->mi_startTime.bv_val );
740 e = str2entry( buf );
744 LDAP_LOG( OPERATION, CRIT,
745 "unable to create '%s' entry\n",
746 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
748 Debug( LDAP_DEBUG_ANY,
749 "unable to create '%s' entry\n",
750 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
755 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
756 e->e_private = ( void * )mp;
757 mp->mp_info = &monitor_subsys[ i ];
758 mp->mp_children = NULL;
760 mp->mp_flags = monitor_subsys[ i ].mss_flags;
762 if ( monitor_cache_add( mi, e ) ) {
764 LDAP_LOG( OPERATION, CRIT,
765 "unable to add entry '%s' to cache\n",
766 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
768 Debug( LDAP_DEBUG_ANY,
769 "unable to add entry '%s' to cache\n",
770 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
779 * creates the "cn=Monitor" entry
781 snprintf( buf, sizeof( buf ),
784 "structuralObjectClass: %s\n"
786 "%s: This subtree contains monitoring/managing objects.\n"
787 "%s: This object contains information about this server.\n"
789 "%s: createTimestamp reflects the time this server instance was created.\n"
790 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
792 "createTimestamp: %s\n"
793 "modifyTimestamp: %s\n",
795 mi->mi_oc_monitorServer->soc_cname.bv_val,
796 mi->mi_oc_monitorServer->soc_cname.bv_val,
797 mi->mi_ad_description->ad_cname.bv_val,
798 mi->mi_ad_description->ad_cname.bv_val,
800 mi->mi_ad_description->ad_cname.bv_val,
801 mi->mi_ad_description->ad_cname.bv_val,
803 mi->mi_startTime.bv_val,
804 mi->mi_startTime.bv_val );
806 e = str2entry( buf );
809 LDAP_LOG( OPERATION, CRIT,
810 "unable to create '%s' entry\n",
811 SLAPD_MONITOR_DN, 0, 0 );
813 Debug( LDAP_DEBUG_ANY,
814 "unable to create '%s' entry\n",
815 SLAPD_MONITOR_DN, 0, 0 );
820 bv.bv_val = (char *) Versionstr;
821 end_of_line = strchr( Versionstr, '\n' );
823 bv.bv_len = end_of_line - Versionstr;
825 bv.bv_len = strlen( Versionstr );
828 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
831 LDAP_LOG( OPERATION, CRIT,
832 "unable to add monitoredInfo to '%s' entry\n",
833 SLAPD_MONITOR_DN, 0, 0 );
835 Debug( LDAP_DEBUG_ANY,
836 "unable to add monitoredInfo to '%s' entry\n",
837 SLAPD_MONITOR_DN, 0, 0 );
842 if ( mi->mi_l.bv_len ) {
843 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
845 LDAP_LOG( OPERATION, CRIT,
846 "unable to add locality to '%s' entry\n",
847 SLAPD_MONITOR_DN, 0, 0 );
849 Debug( LDAP_DEBUG_ANY,
850 "unable to add locality to '%s' entry\n",
851 SLAPD_MONITOR_DN, 0, 0 );
857 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
858 e->e_private = ( void * )mp;
861 mp->mp_children = e_tmp;
864 if ( monitor_cache_add( mi, e ) ) {
866 LDAP_LOG( OPERATION, CRIT,
867 "unable to add entry '%s' to cache\n",
868 SLAPD_MONITOR_DN, 0, 0 );
870 Debug( LDAP_DEBUG_ANY,
871 "unable to add entry '%s' to cache\n",
872 SLAPD_MONITOR_DN, 0, 0 );
882 * opens the monitor backend
884 for ( ms = monitor_subsys; ms->mss_name != NULL; ms++ ) {
885 if ( ms->mss_init && ( *ms->mss_init )( be ) ) {
903 * eventually, will hold backend specific configuration parameters
905 return SLAP_CONF_UNKNOWN;
909 monitor_back_db_config(
917 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
920 * eventually, will hold database specific configuration parameters
922 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
927 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
930 return SLAP_CONF_UNKNOWN;
937 monitor_back_db_destroy(
942 * FIXME: destroys all the data