1 /* init.c - initialize monitor backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2003 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masarati for inclusion
18 * in OpenLDAP Software.
20 /* This is an altered version */
22 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
24 * This work has beed deveolped for the OpenLDAP Foundation
25 * in the hope that it may be useful to the Open Source community,
26 * but WITHOUT ANY WARRANTY.
28 * Permission is granted to anyone to use this software for any purpose
29 * on any computer system, and to alter it and redistribute it, subject
30 * to the following restrictions:
32 * 1. The author and SysNet s.n.c. are not responsible for the consequences
33 * of use of this software, no matter how awful, even if they arise from
36 * 2. The origin of this software must not be misrepresented, either by
37 * explicit claim or by omission. Since few users ever read sources,
38 * credits should appear in the documentation.
40 * 3. Altered versions must be plainly marked as such, and must not be
41 * misrepresented as being the original software. Since few users
42 * ever read sources, credits should appear in the documentation.
43 * SysNet s.n.c. cannot be responsible for the consequences of the
46 * 4. This notice may not be removed or altered.
52 #include <ac/string.h>
57 #include "back-monitor.h"
59 #undef INTEGRATE_CORE_SCHEMA
62 * used by many functions to add description to entries
64 BackendDB *be_monitor = NULL;
69 struct monitorsubsys monitor_subsys[] = {
71 SLAPD_MONITOR_LISTENER, SLAPD_MONITOR_LISTENER_NAME,
72 BER_BVNULL, BER_BVNULL, BER_BVNULL,
73 MONITOR_F_PERSISTENT_CH,
74 monitor_subsys_listener_init,
79 SLAPD_MONITOR_DATABASE, SLAPD_MONITOR_DATABASE_NAME,
80 BER_BVNULL, BER_BVNULL, BER_BVNULL,
81 MONITOR_F_PERSISTENT_CH,
82 monitor_subsys_database_init,
87 SLAPD_MONITOR_BACKEND, SLAPD_MONITOR_BACKEND_NAME,
88 BER_BVNULL, BER_BVNULL, BER_BVNULL,
89 MONITOR_F_PERSISTENT_CH,
90 monitor_subsys_backend_init,
95 SLAPD_MONITOR_THREAD, SLAPD_MONITOR_THREAD_NAME,
96 BER_BVNULL, BER_BVNULL, BER_BVNULL,
98 monitor_subsys_thread_init,
99 monitor_subsys_thread_update,
103 SLAPD_MONITOR_SASL, SLAPD_MONITOR_SASL_NAME,
104 BER_BVNULL, BER_BVNULL, BER_BVNULL,
111 SLAPD_MONITOR_TLS, SLAPD_MONITOR_TLS_NAME,
112 BER_BVNULL, BER_BVNULL, BER_BVNULL,
119 SLAPD_MONITOR_CONN, SLAPD_MONITOR_CONN_NAME,
120 BER_BVNULL, BER_BVNULL, BER_BVNULL,
121 MONITOR_F_VOLATILE_CH,
122 monitor_subsys_conn_init,
123 monitor_subsys_conn_update,
124 monitor_subsys_conn_create,
127 SLAPD_MONITOR_RWW, SLAPD_MONITOR_RWW_NAME,
128 BER_BVNULL, BER_BVNULL, BER_BVNULL,
129 MONITOR_F_PERSISTENT_CH,
130 monitor_subsys_rww_init,
131 monitor_subsys_rww_update,
135 SLAPD_MONITOR_LOG, SLAPD_MONITOR_LOG_NAME,
136 BER_BVNULL, BER_BVNULL, BER_BVNULL,
138 monitor_subsys_log_init,
141 monitor_subsys_log_modify
143 SLAPD_MONITOR_OPS, SLAPD_MONITOR_OPS_NAME,
144 BER_BVNULL, BER_BVNULL, BER_BVNULL,
145 MONITOR_F_PERSISTENT_CH,
146 monitor_subsys_ops_init,
147 monitor_subsys_ops_update,
151 SLAPD_MONITOR_SENT, SLAPD_MONITOR_SENT_NAME,
152 BER_BVNULL, BER_BVNULL, BER_BVNULL,
153 MONITOR_F_PERSISTENT_CH,
154 monitor_subsys_sent_init,
155 monitor_subsys_sent_update,
159 SLAPD_MONITOR_TIME, SLAPD_MONITOR_TIME_NAME,
160 BER_BVNULL, BER_BVNULL, BER_BVNULL,
161 MONITOR_F_PERSISTENT_CH,
162 monitor_subsys_time_init,
163 monitor_subsys_time_update,
169 #ifdef SLAPD_MONITOR_DYNAMIC
172 init_module( int argc, char *argv[] )
176 memset( &bi, '\0', sizeof(bi) );
177 bi.bi_type = "monitor";
178 bi.bi_init = monitor_back_initialize;
183 #endif /* SLAPD_MONITOR_DYNAMIC */
186 monitor_back_initialize(
190 static char *controls[] = {
191 LDAP_CONTROL_MANAGEDSAIT,
192 LDAP_CONTROL_VALUESRETURNFILTER,
196 bi->bi_controls = controls;
200 bi->bi_config = monitor_back_config;
204 bi->bi_db_init = monitor_back_db_init;
205 bi->bi_db_config = monitor_back_db_config;
206 bi->bi_db_open = monitor_back_db_open;
208 bi->bi_db_destroy = monitor_back_db_destroy;
210 bi->bi_op_bind = monitor_back_bind;
211 bi->bi_op_unbind = 0;
212 bi->bi_op_search = monitor_back_search;
213 bi->bi_op_compare = monitor_back_compare;
214 bi->bi_op_modify = monitor_back_modify;
215 bi->bi_op_modrdn = 0;
217 bi->bi_op_delete = 0;
218 bi->bi_op_abandon = 0;
222 bi->bi_entry_release_rw = 0;
223 bi->bi_chk_referrals = 0;
224 bi->bi_operational = monitor_back_operational;
227 * hooks for slap tools
229 bi->bi_tool_entry_open = 0;
230 bi->bi_tool_entry_close = 0;
231 bi->bi_tool_entry_first = 0;
232 bi->bi_tool_entry_next = 0;
233 bi->bi_tool_entry_get = 0;
234 bi->bi_tool_entry_put = 0;
235 bi->bi_tool_entry_reindex = 0;
236 bi->bi_tool_sync = 0;
237 bi->bi_tool_dn2id_get = 0;
238 bi->bi_tool_id2entry_get = 0;
239 bi->bi_tool_entry_modify = 0;
241 bi->bi_connection_init = 0;
242 bi->bi_connection_destroy = 0;
248 monitor_back_db_init(
252 struct monitorinfo *mi;
254 struct berval dn, ndn;
258 * database monitor can be defined once only
262 LDAP_LOG( OPERATION, CRIT,
263 "only one monitor backend is allowed\n", 0, 0, 0);
265 Debug( LDAP_DEBUG_ANY,
266 "only one monitor backend is allowed\n", 0, 0, 0 );
272 /* indicate system schema supported */
273 be->be_flags |= SLAP_BFLAG_MONITOR;
275 dn.bv_val = SLAPD_MONITOR_DN;
276 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
278 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
279 if( rc != LDAP_SUCCESS ) {
281 LDAP_LOG( OPERATION, CRIT,
282 "unable to normalize monitor DN \"%s\"\n",
283 SLAPD_MONITOR_DN, 0, 0 );
285 Debug( LDAP_DEBUG_ANY,
286 "unable to normalize monitor DN \"%s\"\n",
287 SLAPD_MONITOR_DN, 0, 0 );
292 ber_dupbv( &bv, &dn );
293 ber_bvarray_add( &be->be_suffix, &bv );
294 ber_bvarray_add( &be->be_nsuffix, &ndn );
296 mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
299 LDAP_LOG( OPERATION, CRIT,
300 "unable to initialize monitor backend\n", 0, 0, 0 );
302 Debug( LDAP_DEBUG_ANY,
303 "unable to initialize monitor backend\n", 0, 0, 0 );
308 memset( mi, 0, sizeof( struct monitorinfo ) );
310 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
318 monitor_back_db_open(
322 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
323 struct monitorsubsys *ms;
325 struct monitorentrypriv *mp;
327 char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
336 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
338 "DESC 'OpenLDAP system monitoring' "
339 "SUP top STRUCTURAL "
344 #if 0 /* temporarily disabled */
353 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
354 offsetof(struct monitorinfo, mi_oc_monitor) },
355 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
356 "NAME 'monitorServer' "
357 "DESC 'Server monitoring root entry' "
358 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
359 offsetof(struct monitorinfo, mi_oc_monitorServer) },
360 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
361 "NAME 'monitorContainer' "
362 "DESC 'monitor container class' "
363 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
364 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
365 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
366 "NAME 'monitorCounterObject' "
367 "DESC 'monitor counter class' "
368 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
369 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
370 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
371 "NAME 'monitorOperation' "
372 "DESC 'monitor operation class' "
373 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
374 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
375 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
376 "NAME 'monitorConnection' "
377 "DESC 'monitor connection class' "
378 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
379 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
380 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
381 "NAME 'managedObject' "
382 "DESC 'monitor managed entity class' "
383 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
384 offsetof(struct monitorinfo, mi_oc_managedObject) },
385 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
386 "NAME 'monitoredObject' "
387 "DESC 'monitor monitored entity class' "
388 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
389 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
390 { NULL, NULL, 0, -1 }
392 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
393 "NAME 'monitoredInfo' "
394 "DESC 'monitored info' "
396 "EQUALITY caseIgnoreMatch "
397 "SUBSTR caseIgnoreSubstringsMatch "
398 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
399 "NO-USER-MODIFICATION "
400 "USAGE directoryOperation )", SLAP_AT_HIDE,
401 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
402 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
403 "NAME 'managedInfo' "
404 "DESC 'monitor managed info' "
405 "SUP name )", SLAP_AT_HIDE,
406 offsetof(struct monitorinfo, mi_ad_managedInfo) },
407 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
408 "NAME 'monitorCounter' "
409 "DESC 'monitor counter' "
410 "EQUALITY integerMatch "
411 "ORDERING integerOrderingMatch "
412 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
413 "NO-USER-MODIFICATION "
414 "USAGE directoryOperation )", SLAP_AT_HIDE,
415 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
416 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
417 "NAME 'monitorOpCompleted' "
418 "DESC 'monitor completed operations' "
419 "SUP monitorCounter "
420 "NO-USER-MODIFICATION "
421 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
422 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
423 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
424 "NAME 'monitorOpInitiated' "
425 "DESC 'monitor initiated operations' "
426 "SUP monitorCounter "
427 "NO-USER-MODIFICATION "
428 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
429 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
430 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
431 "NAME 'monitorConnectionNumber' "
432 "DESC 'monitor connection number' "
433 "SUP monitorCounter "
434 "NO-USER-MODIFICATION "
435 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
436 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
437 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
438 "NAME 'monitorConnectionAuthzDN' "
439 "DESC 'monitor connection authorization DN' "
440 /* "SUP distinguishedName " */
441 "EQUALITY distinguishedNameMatch "
442 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
443 "NO-USER-MODIFICATION "
444 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
445 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
446 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
447 "NAME 'monitorConnectionLocalAddress' "
448 "DESC 'monitor connection local address' "
450 "NO-USER-MODIFICATION "
451 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
452 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
453 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
454 "NAME 'monitorConnectionPeerAddress' "
455 "DESC 'monitor connection peer address' "
457 "NO-USER-MODIFICATION "
458 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
459 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
460 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
461 "NAME 'monitorTimestamp' "
462 "DESC 'monitor timestamp' "
463 "EQUALITY generalizedTimeMatch "
464 "ORDERING generalizedTimeOrderingMatch "
465 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
467 "NO-USER-MODIFICATION "
468 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
469 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
470 #ifdef INTEGRATE_CORE_SCHEMA
471 { NULL, NULL, 0, -1 }, /* description */
472 { NULL, NULL, 0, -1 }, /* seeAlso */
473 { NULL, NULL, 0, -1 }, /* l */
474 #endif /* INTEGRATE_CORE_SCHEMA */
475 { NULL, NULL, 0, -1 }
477 { "description", "( 2.5.4.13 "
478 "NAME 'description' "
479 "DESC 'RFC2256: descriptive information' "
480 "EQUALITY caseIgnoreMatch "
481 "SUBSTR caseIgnoreSubstringsMatch "
482 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
483 offsetof(struct monitorinfo, mi_ad_description) },
484 { "seeAlso", "( 2.5.4.34 "
486 "DESC 'RFC2256: DN of related object' "
487 "SUP distinguishedName )", 0,
488 offsetof(struct monitorinfo, mi_ad_seeAlso) },
490 "NAME ( 'l' 'localityName' ) "
491 "DESC 'RFC2256: locality which this object resides in' "
493 offsetof(struct monitorinfo, mi_ad_l) },
494 { NULL, NULL, 0, -1 }
498 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
503 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
504 #ifdef HACK_LOCAL_TIME
505 tms = localtime( &starttime );
506 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
507 #else /* !HACK_LOCAL_TIME */
508 tms = gmtime( &starttime );
509 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
510 #endif /* !HACK_LOCAL_TIME */
511 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
513 mi->mi_startTime.bv_val = tmbuf;
514 mi->mi_startTime.bv_len = strlen( tmbuf );
516 #ifdef INTEGRATE_CORE_SCHEMA
517 /* prepare for schema integration */
518 for ( k = 0; mat[k].name != NULL; k++ );
519 #endif /* INTEGRATE_CORE_SCHEMA */
521 for ( i = 0; mat_core[i].name != NULL; i++ ) {
522 AttributeDescription **ad;
525 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
528 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
532 #ifdef INTEGRATE_CORE_SCHEMA
533 case LDAP_UNDEFINED_TYPE:
534 mat[k] = mat_core[i];
537 #endif /* INTEGRATE_CORE_SCHEMA */
541 LDAP_LOG( OPERATION, CRIT,
542 "monitor_back_db_init: %s: %s\n",
543 mat_core[i].name, text, 0 );
545 Debug( LDAP_DEBUG_ANY,
546 "monitor_back_db_init: %s: %s\n",
547 mat_core[i].name, text, 0 );
553 /* schema integration */
554 for ( i = 0; mat[i].name; i++ ) {
555 LDAPAttributeType *at;
558 AttributeDescription **ad;
560 at = ldap_str2attributetype( mat[i].schema, &code,
561 &err, LDAP_SCHEMA_ALLOW_ALL );
564 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
565 "in AttributeType '%s' %s before %s\n",
566 mat[i].name, ldap_scherr2str(code), err );
568 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
569 "in AttributeType '%s' %s before %s\n",
570 mat[i].name, ldap_scherr2str(code), err );
575 if ( at->at_oid == NULL ) {
577 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
578 "null OID for attributeType '%s'\n",
581 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
582 "null OID for attributeType '%s'\n",
588 code = at_add(at, &err);
591 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
592 "%s in attributeType '%s'\n",
593 scherr2str(code), mat[i].name, 0 );
595 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
596 "%s in attributeType '%s'\n",
597 scherr2str(code), mat[i].name, 0 );
603 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
605 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
607 LDAP_LOG( OPERATION, CRIT,
608 "monitor_back_db_init: %s\n", text, 0, 0 );
610 Debug( LDAP_DEBUG_ANY,
611 "monitor_back_db_init: %s\n", text, 0, 0 );
616 (*ad)->ad_type->sat_flags |= mat[i].flags;
619 for ( i = 0; moc[i].name; i++ ) {
625 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
626 LDAP_SCHEMA_ALLOW_ALL );
629 LDAP_LOG( OPERATION, CRIT,
630 "unable to parse monitor objectclass '%s': "
631 "%s before %s\n" , moc[i].name,
632 ldap_scherr2str(code), err );
634 Debug( LDAP_DEBUG_ANY,
635 "unable to parse monitor objectclass '%s': "
636 "%s before %s\n" , moc[i].name,
637 ldap_scherr2str(code), err );
642 if ( oc->oc_oid == NULL ) {
644 LDAP_LOG( OPERATION, CRIT,
645 "objectclass '%s' has no OID\n" ,
648 Debug( LDAP_DEBUG_ANY,
649 "objectclass '%s' has no OID\n" ,
655 code = oc_add(oc, 0, &err);
658 LDAP_LOG( OPERATION, CRIT,
659 "objectclass '%s': %s \"%s\"\n" ,
660 moc[i].name, scherr2str(code), err );
662 Debug( LDAP_DEBUG_ANY,
663 "objectclass '%s': %s \"%s\"\n" ,
664 moc[i].name, scherr2str(code), err );
671 Oc = oc_find( moc[i].name );
674 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
675 "unable to find objectClass %s "
676 "(just added)\n", moc[i].name, 0, 0 );
678 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
679 "unable to find objectClass %s "
680 "(just added)\n", moc[i].name, 0, 0 );
685 Oc->soc_flags |= moc[i].flags;
687 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
691 * Create all the subsystem specific entries
694 for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
695 int len = strlen( monitor_subsys[ i ].mss_name );
699 dn.bv_len = len + sizeof( "cn=" ) - 1;
700 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
701 strcpy( dn.bv_val, "cn=" );
702 strcat( dn.bv_val, monitor_subsys[ i ].mss_name );
703 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL );
705 if ( rc != LDAP_SUCCESS ) {
707 LDAP_LOG( OPERATION, CRIT,
708 "monitor RDN \"%s\" is invalid\n",
711 Debug( LDAP_DEBUG_ANY,
712 "monitor RDN \"%s\" is invalid\n",
718 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
719 dn.bv_val = ch_malloc( dn.bv_len + 1 );
720 strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn.bv_val );
721 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
722 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ].mss_dn,
723 &monitor_subsys[ i ].mss_ndn, NULL );
725 if ( rc != LDAP_SUCCESS ) {
727 LDAP_LOG( OPERATION, CRIT,
728 "monitor DN \"%s\" is invalid\n",
731 Debug( LDAP_DEBUG_ANY,
732 "monitor DN \"%s\" is invalid\n",
738 snprintf( buf, sizeof( buf ),
741 "structuralObjectClass: %s\n"
743 "createTimestamp: %s\n"
744 "modifyTimestamp: %s\n",
745 monitor_subsys[ i ].mss_dn.bv_val,
746 mi->mi_oc_monitorContainer->soc_cname.bv_val,
747 mi->mi_oc_monitorContainer->soc_cname.bv_val,
748 monitor_subsys[ i ].mss_name,
749 mi->mi_startTime.bv_val,
750 mi->mi_startTime.bv_val );
752 e = str2entry( buf );
756 LDAP_LOG( OPERATION, CRIT,
757 "unable to create '%s' entry\n",
758 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
760 Debug( LDAP_DEBUG_ANY,
761 "unable to create '%s' entry\n",
762 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
767 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
768 e->e_private = ( void * )mp;
769 mp->mp_info = &monitor_subsys[ i ];
770 mp->mp_children = NULL;
772 mp->mp_flags = monitor_subsys[ i ].mss_flags;
774 if ( monitor_cache_add( mi, e ) ) {
776 LDAP_LOG( OPERATION, CRIT,
777 "unable to add entry '%s' to cache\n",
778 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
780 Debug( LDAP_DEBUG_ANY,
781 "unable to add entry '%s' to cache\n",
782 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
791 * creates the "cn=Monitor" entry
793 snprintf( buf, sizeof( buf ),
796 "structuralObjectClass: %s\n"
798 "%s: This subtree contains monitoring/managing objects.\n"
799 "%s: This object contains information about this server.\n"
801 "%s: createTimestamp reflects the time this server instance was created.\n"
802 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
804 "createTimestamp: %s\n"
805 "modifyTimestamp: %s\n",
807 mi->mi_oc_monitorServer->soc_cname.bv_val,
808 mi->mi_oc_monitorServer->soc_cname.bv_val,
809 mi->mi_ad_description->ad_cname.bv_val,
810 mi->mi_ad_description->ad_cname.bv_val,
812 mi->mi_ad_description->ad_cname.bv_val,
813 mi->mi_ad_description->ad_cname.bv_val,
815 mi->mi_startTime.bv_val,
816 mi->mi_startTime.bv_val );
818 e = str2entry( buf );
821 LDAP_LOG( OPERATION, CRIT,
822 "unable to create '%s' entry\n",
823 SLAPD_MONITOR_DN, 0, 0 );
825 Debug( LDAP_DEBUG_ANY,
826 "unable to create '%s' entry\n",
827 SLAPD_MONITOR_DN, 0, 0 );
832 bv.bv_val = (char *) Versionstr;
833 end_of_line = strchr( Versionstr, '\n' );
835 bv.bv_len = end_of_line - Versionstr;
837 bv.bv_len = strlen( Versionstr );
840 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
843 LDAP_LOG( OPERATION, CRIT,
844 "unable to add monitoredInfo to '%s' entry\n",
845 SLAPD_MONITOR_DN, 0, 0 );
847 Debug( LDAP_DEBUG_ANY,
848 "unable to add monitoredInfo to '%s' entry\n",
849 SLAPD_MONITOR_DN, 0, 0 );
854 if ( mi->mi_l.bv_len ) {
855 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
857 LDAP_LOG( OPERATION, CRIT,
858 "unable to add locality to '%s' entry\n",
859 SLAPD_MONITOR_DN, 0, 0 );
861 Debug( LDAP_DEBUG_ANY,
862 "unable to add locality to '%s' entry\n",
863 SLAPD_MONITOR_DN, 0, 0 );
869 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
870 e->e_private = ( void * )mp;
873 mp->mp_children = e_tmp;
876 if ( monitor_cache_add( mi, e ) ) {
878 LDAP_LOG( OPERATION, CRIT,
879 "unable to add entry '%s' to cache\n",
880 SLAPD_MONITOR_DN, 0, 0 );
882 Debug( LDAP_DEBUG_ANY,
883 "unable to add entry '%s' to cache\n",
884 SLAPD_MONITOR_DN, 0, 0 );
894 * opens the monitor backend
896 for ( ms = monitor_subsys; ms->mss_name != NULL; ms++ ) {
897 if ( ms->mss_init && ( *ms->mss_init )( be ) ) {
915 * eventually, will hold backend specific configuration parameters
921 monitor_back_db_config(
929 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
932 * eventually, will hold database specific configuration parameters
934 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
939 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
943 LDAP_LOG( CONFIG, INFO,
944 "line %d of file '%s' will be ignored\n",
947 Debug( LDAP_DEBUG_CONFIG,
948 "line %d of file '%s' will be ignored\n",
957 monitor_back_db_destroy(
962 * FIXME: destroys all the data