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.
49 #ifndef _BACK_MONITOR_H_
50 #define _BACK_MONITOR_H_
53 #include <ldap_pvt_thread.h>
60 * The cache maps DNs to Entries.
62 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
64 * This work has beed deveolped for the OpenLDAP Foundation
65 * in the hope that it may be useful to the Open Source community,
66 * but WITHOUT ANY WARRANTY.
68 * Permission is granted to anyone to use this software for any purpose
69 * on any computer system, and to alter it and redistribute it, subject
70 * to the following restrictions:
72 * 1. The author and SysNet s.n.c. are not responsible for the consequences
73 * of use of this software, no matter how awful, even if they arise from
76 * 2. The origin of this software must not be misrepresented, either by
77 * explicit claim or by omission. Since few users ever read sources,
78 * credits should appear in the documentation.
80 * 3. Altered versions must be plainly marked as such, and must not be
81 * misrepresented as being the original software. Since few users
82 * ever read sources, credits should appear in the documentation.
83 * SysNet s.n.c. cannot be responsible for the consequences of the
86 * 4. This notice may not be removed or altered.
92 #include <ac/string.h>
97 #include "back-monitor.h"
99 #undef INTEGRATE_CORE_SCHEMA
102 * used by many functions to add description to entries
104 BackendDB *be_monitor = NULL;
109 struct monitorsubsys monitor_subsys[] = {
111 SLAPD_MONITOR_LISTENER, SLAPD_MONITOR_LISTENER_NAME,
112 BER_BVNULL, BER_BVNULL, BER_BVNULL,
113 MONITOR_F_PERSISTENT_CH,
114 monitor_subsys_listener_init,
119 SLAPD_MONITOR_DATABASE, SLAPD_MONITOR_DATABASE_NAME,
120 BER_BVNULL, BER_BVNULL, BER_BVNULL,
121 MONITOR_F_PERSISTENT_CH,
122 monitor_subsys_database_init,
127 SLAPD_MONITOR_BACKEND, SLAPD_MONITOR_BACKEND_NAME,
128 BER_BVNULL, BER_BVNULL, BER_BVNULL,
129 MONITOR_F_PERSISTENT_CH,
130 monitor_subsys_backend_init,
135 SLAPD_MONITOR_THREAD, SLAPD_MONITOR_THREAD_NAME,
136 BER_BVNULL, BER_BVNULL, BER_BVNULL,
138 monitor_subsys_thread_init,
139 monitor_subsys_thread_update,
143 SLAPD_MONITOR_SASL, SLAPD_MONITOR_SASL_NAME,
144 BER_BVNULL, BER_BVNULL, BER_BVNULL,
151 SLAPD_MONITOR_TLS, SLAPD_MONITOR_TLS_NAME,
152 BER_BVNULL, BER_BVNULL, BER_BVNULL,
159 SLAPD_MONITOR_CONN, SLAPD_MONITOR_CONN_NAME,
160 BER_BVNULL, BER_BVNULL, BER_BVNULL,
161 MONITOR_F_VOLATILE_CH,
162 monitor_subsys_conn_init,
163 monitor_subsys_conn_update,
164 monitor_subsys_conn_create,
167 SLAPD_MONITOR_RWW, SLAPD_MONITOR_RWW_NAME,
168 BER_BVNULL, BER_BVNULL, BER_BVNULL,
169 MONITOR_F_PERSISTENT_CH,
170 monitor_subsys_rww_init,
171 monitor_subsys_rww_update,
175 SLAPD_MONITOR_LOG, SLAPD_MONITOR_LOG_NAME,
176 BER_BVNULL, BER_BVNULL, BER_BVNULL,
178 monitor_subsys_log_init,
181 monitor_subsys_log_modify
183 SLAPD_MONITOR_OPS, SLAPD_MONITOR_OPS_NAME,
184 BER_BVNULL, BER_BVNULL, BER_BVNULL,
185 MONITOR_F_PERSISTENT_CH,
186 monitor_subsys_ops_init,
187 monitor_subsys_ops_update,
191 SLAPD_MONITOR_SENT, SLAPD_MONITOR_SENT_NAME,
192 BER_BVNULL, BER_BVNULL, BER_BVNULL,
193 MONITOR_F_PERSISTENT_CH,
194 monitor_subsys_sent_init,
195 monitor_subsys_sent_update,
199 SLAPD_MONITOR_TIME, SLAPD_MONITOR_TIME_NAME,
200 BER_BVNULL, BER_BVNULL, BER_BVNULL,
201 MONITOR_F_PERSISTENT_CH,
202 monitor_subsys_time_init,
203 monitor_subsys_time_update,
209 #ifdef SLAPD_MONITOR_DYNAMIC
212 init_module( int argc, char *argv[] )
216 memset( &bi, '\0', sizeof(bi) );
217 bi.bi_type = "monitor";
218 bi.bi_init = monitor_back_initialize;
223 #endif /* SLAPD_MONITOR_DYNAMIC */
226 monitor_back_initialize(
230 static char *controls[] = {
231 LDAP_CONTROL_MANAGEDSAIT,
232 LDAP_CONTROL_VALUESRETURNFILTER,
236 bi->bi_controls = controls;
240 bi->bi_config = monitor_back_config;
244 bi->bi_db_init = monitor_back_db_init;
245 bi->bi_db_config = monitor_back_db_config;
246 bi->bi_db_open = monitor_back_db_open;
248 bi->bi_db_destroy = monitor_back_db_destroy;
250 bi->bi_op_bind = monitor_back_bind;
251 bi->bi_op_unbind = 0;
252 bi->bi_op_search = monitor_back_search;
253 bi->bi_op_compare = monitor_back_compare;
254 bi->bi_op_modify = monitor_back_modify;
255 bi->bi_op_modrdn = 0;
257 bi->bi_op_delete = 0;
258 bi->bi_op_abandon = 0;
262 bi->bi_entry_release_rw = 0;
263 bi->bi_chk_referrals = 0;
264 bi->bi_operational = monitor_back_operational;
267 * hooks for slap tools
269 bi->bi_tool_entry_open = 0;
270 bi->bi_tool_entry_close = 0;
271 bi->bi_tool_entry_first = 0;
272 bi->bi_tool_entry_next = 0;
273 bi->bi_tool_entry_get = 0;
274 bi->bi_tool_entry_put = 0;
275 bi->bi_tool_entry_reindex = 0;
276 bi->bi_tool_sync = 0;
277 bi->bi_tool_dn2id_get = 0;
278 bi->bi_tool_id2entry_get = 0;
279 bi->bi_tool_entry_modify = 0;
281 bi->bi_connection_init = 0;
282 bi->bi_connection_destroy = 0;
288 monitor_back_db_init(
292 struct monitorinfo *mi;
294 struct berval dn, ndn;
298 * database monitor can be defined once only
302 LDAP_LOG( OPERATION, CRIT,
303 "only one monitor backend is allowed\n", 0, 0, 0);
305 Debug( LDAP_DEBUG_ANY,
306 "only one monitor backend is allowed\n", 0, 0, 0 );
312 /* indicate system schema supported */
313 be->be_flags |= SLAP_BFLAG_MONITOR;
315 dn.bv_val = SLAPD_MONITOR_DN;
316 dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
318 rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
319 if( rc != LDAP_SUCCESS ) {
321 LDAP_LOG( OPERATION, CRIT,
322 "unable to normalize monitor DN \"%s\"\n",
323 SLAPD_MONITOR_DN, 0, 0 );
325 Debug( LDAP_DEBUG_ANY,
326 "unable to normalize monitor DN \"%s\"\n",
327 SLAPD_MONITOR_DN, 0, 0 );
332 ber_dupbv( &bv, &dn );
333 ber_bvarray_add( &be->be_suffix, &bv );
334 ber_bvarray_add( &be->be_nsuffix, &ndn );
336 mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
339 LDAP_LOG( OPERATION, CRIT,
340 "unable to initialize monitor backend\n", 0, 0, 0 );
342 Debug( LDAP_DEBUG_ANY,
343 "unable to initialize monitor backend\n", 0, 0, 0 );
348 memset( mi, 0, sizeof( struct monitorinfo ) );
350 ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
358 monitor_back_db_open(
362 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
363 struct monitorsubsys *ms;
365 struct monitorentrypriv *mp;
367 char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
376 { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 "
378 "DESC 'OpenLDAP system monitoring' "
379 "SUP top STRUCTURAL "
384 #if 0 /* temporarily disabled */
393 ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
394 offsetof(struct monitorinfo, mi_oc_monitor) },
395 { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
396 "NAME 'monitorServer' "
397 "DESC 'Server monitoring root entry' "
398 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
399 offsetof(struct monitorinfo, mi_oc_monitorServer) },
400 { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 "
401 "NAME 'monitorContainer' "
402 "DESC 'monitor container class' "
403 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
404 offsetof(struct monitorinfo, mi_oc_monitorContainer) },
405 { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 "
406 "NAME 'monitorCounterObject' "
407 "DESC 'monitor counter class' "
408 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
409 offsetof(struct monitorinfo, mi_oc_monitorCounterObject) },
410 { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 "
411 "NAME 'monitorOperation' "
412 "DESC 'monitor operation class' "
413 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
414 offsetof(struct monitorinfo, mi_oc_monitorOperation) },
415 { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 "
416 "NAME 'monitorConnection' "
417 "DESC 'monitor connection class' "
418 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
419 offsetof(struct monitorinfo, mi_oc_monitorConnection) },
420 { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 "
421 "NAME 'managedObject' "
422 "DESC 'monitor managed entity class' "
423 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
424 offsetof(struct monitorinfo, mi_oc_managedObject) },
425 { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.13 "
426 "NAME 'monitoredObject' "
427 "DESC 'monitor monitored entity class' "
428 "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
429 offsetof(struct monitorinfo, mi_oc_monitoredObject) },
430 { NULL, NULL, 0, -1 }
432 { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 "
433 "NAME 'monitoredInfo' "
434 "DESC 'monitored info' "
436 "EQUALITY caseIgnoreMatch "
437 "SUBSTR caseIgnoreSubstringsMatch "
438 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
439 "NO-USER-MODIFICATION "
440 "USAGE directoryOperation )", SLAP_AT_HIDE,
441 offsetof(struct monitorinfo, mi_ad_monitoredInfo) },
442 { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 "
443 "NAME 'managedInfo' "
444 "DESC 'monitor managed info' "
445 "SUP name )", SLAP_AT_HIDE,
446 offsetof(struct monitorinfo, mi_ad_managedInfo) },
447 { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 "
448 "NAME 'monitorCounter' "
449 "DESC 'monitor counter' "
450 "EQUALITY integerMatch "
451 "ORDERING integerOrderingMatch "
452 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
453 "NO-USER-MODIFICATION "
454 "USAGE directoryOperation )", SLAP_AT_HIDE,
455 offsetof(struct monitorinfo, mi_ad_monitorCounter) },
456 { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 "
457 "NAME 'monitorOpCompleted' "
458 "DESC 'monitor completed operations' "
459 "SUP monitorCounter "
460 "NO-USER-MODIFICATION "
461 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
462 offsetof(struct monitorinfo, mi_ad_monitorOpCompleted) },
463 { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 "
464 "NAME 'monitorOpInitiated' "
465 "DESC 'monitor initiated operations' "
466 "SUP monitorCounter "
467 "NO-USER-MODIFICATION "
468 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
469 offsetof(struct monitorinfo, mi_ad_monitorOpInitiated) },
470 { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 "
471 "NAME 'monitorConnectionNumber' "
472 "DESC 'monitor connection number' "
473 "SUP monitorCounter "
474 "NO-USER-MODIFICATION "
475 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
476 offsetof(struct monitorinfo, mi_ad_monitorConnectionNumber) },
477 { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 "
478 "NAME 'monitorConnectionAuthzDN' "
479 "DESC 'monitor connection authorization DN' "
480 /* "SUP distinguishedName " */
481 "EQUALITY distinguishedNameMatch "
482 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
483 "NO-USER-MODIFICATION "
484 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
485 offsetof(struct monitorinfo, mi_ad_monitorConnectionAuthzDN) },
486 { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 "
487 "NAME 'monitorConnectionLocalAddress' "
488 "DESC 'monitor connection local address' "
490 "NO-USER-MODIFICATION "
491 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
492 offsetof(struct monitorinfo, mi_ad_monitorConnectionLocalAddress) },
493 { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 "
494 "NAME 'monitorConnectionPeerAddress' "
495 "DESC 'monitor connection peer address' "
497 "NO-USER-MODIFICATION "
498 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
499 offsetof(struct monitorinfo, mi_ad_monitorConnectionPeerAddress) },
500 { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
501 "NAME 'monitorTimestamp' "
502 "DESC 'monitor timestamp' "
503 "EQUALITY generalizedTimeMatch "
504 "ORDERING generalizedTimeOrderingMatch "
505 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
507 "NO-USER-MODIFICATION "
508 "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
509 offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
510 #ifdef INTEGRATE_CORE_SCHEMA
511 { NULL, NULL, 0, -1 }, /* description */
512 { NULL, NULL, 0, -1 }, /* seeAlso */
513 { NULL, NULL, 0, -1 }, /* l */
514 #endif /* INTEGRATE_CORE_SCHEMA */
515 { NULL, NULL, 0, -1 }
517 { "description", "( 2.5.4.13 "
518 "NAME 'description' "
519 "DESC 'RFC2256: descriptive information' "
520 "EQUALITY caseIgnoreMatch "
521 "SUBSTR caseIgnoreSubstringsMatch "
522 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )", 0,
523 offsetof(struct monitorinfo, mi_ad_description) },
524 { "seeAlso", "( 2.5.4.34 "
526 "DESC 'RFC2256: DN of related object' "
527 "SUP distinguishedName )", 0,
528 offsetof(struct monitorinfo, mi_ad_seeAlso) },
530 "NAME ( 'l' 'localityName' ) "
531 "DESC 'RFC2256: locality which this object resides in' "
533 offsetof(struct monitorinfo, mi_ad_l) },
534 { NULL, NULL, 0, -1 }
538 static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
543 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
544 #ifdef HACK_LOCAL_TIME
545 tms = localtime( &starttime );
546 lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
547 #else /* !HACK_LOCAL_TIME */
548 tms = gmtime( &starttime );
549 lutil_gentime( tmbuf, sizeof(tmbuf), tms );
550 #endif /* !HACK_LOCAL_TIME */
551 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
553 mi->mi_startTime.bv_val = tmbuf;
554 mi->mi_startTime.bv_len = strlen( tmbuf );
556 #ifdef INTEGRATE_CORE_SCHEMA
557 /* prepare for schema integration */
558 for ( k = 0; mat[k].name != NULL; k++ );
559 #endif /* INTEGRATE_CORE_SCHEMA */
561 for ( i = 0; mat_core[i].name != NULL; i++ ) {
562 AttributeDescription **ad;
565 ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset]));
568 switch (slap_str2ad( mat_core[i].name, ad, &text ) ) {
572 #ifdef INTEGRATE_CORE_SCHEMA
573 case LDAP_UNDEFINED_TYPE:
574 mat[k] = mat_core[i];
577 #endif /* INTEGRATE_CORE_SCHEMA */
581 LDAP_LOG( OPERATION, CRIT,
582 "monitor_back_db_init: %s: %s\n",
583 mat_core[i].name, text, 0 );
585 Debug( LDAP_DEBUG_ANY,
586 "monitor_back_db_init: %s: %s\n",
587 mat_core[i].name, text, 0 );
593 /* schema integration */
594 for ( i = 0; mat[i].name; i++ ) {
595 LDAPAttributeType *at;
598 AttributeDescription **ad;
600 at = ldap_str2attributetype( mat[i].schema, &code,
601 &err, LDAP_SCHEMA_ALLOW_ALL );
604 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
605 "in AttributeType '%s' %s before %s\n",
606 mat[i].name, ldap_scherr2str(code), err );
608 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
609 "in AttributeType '%s' %s before %s\n",
610 mat[i].name, ldap_scherr2str(code), err );
615 if ( at->at_oid == NULL ) {
617 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
618 "null OID for attributeType '%s'\n",
621 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
622 "null OID for attributeType '%s'\n",
628 code = at_add(at, &err);
631 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
632 "%s in attributeType '%s'\n",
633 scherr2str(code), mat[i].name, 0 );
635 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
636 "%s in attributeType '%s'\n",
637 scherr2str(code), mat[i].name, 0 );
643 ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
645 if ( slap_str2ad( mat[i].name, ad, &text ) ) {
647 LDAP_LOG( OPERATION, CRIT,
648 "monitor_back_db_init: %s\n", text, 0, 0 );
650 Debug( LDAP_DEBUG_ANY,
651 "monitor_back_db_init: %s\n", text, 0, 0 );
656 (*ad)->ad_type->sat_flags |= mat[i].flags;
659 for ( i = 0; moc[i].name; i++ ) {
665 oc = ldap_str2objectclass(moc[i].schema, &code, &err,
666 LDAP_SCHEMA_ALLOW_ALL );
669 LDAP_LOG( OPERATION, CRIT,
670 "unable to parse monitor objectclass '%s': "
671 "%s before %s\n" , moc[i].name,
672 ldap_scherr2str(code), err );
674 Debug( LDAP_DEBUG_ANY,
675 "unable to parse monitor objectclass '%s': "
676 "%s before %s\n" , moc[i].name,
677 ldap_scherr2str(code), err );
682 if ( oc->oc_oid == NULL ) {
684 LDAP_LOG( OPERATION, CRIT,
685 "objectclass '%s' has no OID\n" ,
688 Debug( LDAP_DEBUG_ANY,
689 "objectclass '%s' has no OID\n" ,
695 code = oc_add(oc, 0, &err);
698 LDAP_LOG( OPERATION, CRIT,
699 "objectclass '%s': %s \"%s\"\n" ,
700 moc[i].name, scherr2str(code), err );
702 Debug( LDAP_DEBUG_ANY,
703 "objectclass '%s': %s \"%s\"\n" ,
704 moc[i].name, scherr2str(code), err );
711 Oc = oc_find( moc[i].name );
714 LDAP_LOG( OPERATION, CRIT, "monitor_back_db_init: "
715 "unable to find objectClass %s "
716 "(just added)\n", moc[i].name, 0, 0 );
718 Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
719 "unable to find objectClass %s "
720 "(just added)\n", moc[i].name, 0, 0 );
725 Oc->soc_flags |= moc[i].flags;
727 ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
731 * Create all the subsystem specific entries
734 for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
735 int len = strlen( monitor_subsys[ i ].mss_name );
739 dn.bv_len = len + sizeof( "cn=" ) - 1;
740 dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 );
741 strcpy( dn.bv_val, "cn=" );
742 strcat( dn.bv_val, monitor_subsys[ i ].mss_name );
743 rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL );
745 if ( rc != LDAP_SUCCESS ) {
747 LDAP_LOG( OPERATION, CRIT,
748 "monitor RDN \"%s\" is invalid\n",
751 Debug( LDAP_DEBUG_ANY,
752 "monitor RDN \"%s\" is invalid\n",
758 dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
759 dn.bv_val = ch_malloc( dn.bv_len + 1 );
760 strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn.bv_val );
761 strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
762 rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ].mss_dn,
763 &monitor_subsys[ i ].mss_ndn, NULL );
765 if ( rc != LDAP_SUCCESS ) {
767 LDAP_LOG( OPERATION, CRIT,
768 "monitor DN \"%s\" is invalid\n",
771 Debug( LDAP_DEBUG_ANY,
772 "monitor DN \"%s\" is invalid\n",
778 snprintf( buf, sizeof( buf ),
781 "structuralObjectClass: %s\n"
783 "createTimestamp: %s\n"
784 "modifyTimestamp: %s\n",
785 monitor_subsys[ i ].mss_dn.bv_val,
786 mi->mi_oc_monitorContainer->soc_cname.bv_val,
787 mi->mi_oc_monitorContainer->soc_cname.bv_val,
788 monitor_subsys[ i ].mss_name,
789 mi->mi_startTime.bv_val,
790 mi->mi_startTime.bv_val );
792 e = str2entry( buf );
796 LDAP_LOG( OPERATION, CRIT,
797 "unable to create '%s' entry\n",
798 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
800 Debug( LDAP_DEBUG_ANY,
801 "unable to create '%s' entry\n",
802 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
807 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
808 e->e_private = ( void * )mp;
809 mp->mp_info = &monitor_subsys[ i ];
810 mp->mp_children = NULL;
812 mp->mp_flags = monitor_subsys[ i ].mss_flags;
814 if ( monitor_cache_add( mi, e ) ) {
816 LDAP_LOG( OPERATION, CRIT,
817 "unable to add entry '%s' to cache\n",
818 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
820 Debug( LDAP_DEBUG_ANY,
821 "unable to add entry '%s' to cache\n",
822 monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
831 * creates the "cn=Monitor" entry
833 snprintf( buf, sizeof( buf ),
836 "structuralObjectClass: %s\n"
838 "%s: This subtree contains monitoring/managing objects.\n"
839 "%s: This object contains information about this server.\n"
841 "%s: createTimestamp reflects the time this server instance was created.\n"
842 "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
844 "createTimestamp: %s\n"
845 "modifyTimestamp: %s\n",
847 mi->mi_oc_monitorServer->soc_cname.bv_val,
848 mi->mi_oc_monitorServer->soc_cname.bv_val,
849 mi->mi_ad_description->ad_cname.bv_val,
850 mi->mi_ad_description->ad_cname.bv_val,
852 mi->mi_ad_description->ad_cname.bv_val,
853 mi->mi_ad_description->ad_cname.bv_val,
855 mi->mi_startTime.bv_val,
856 mi->mi_startTime.bv_val );
858 e = str2entry( buf );
861 LDAP_LOG( OPERATION, CRIT,
862 "unable to create '%s' entry\n",
863 SLAPD_MONITOR_DN, 0, 0 );
865 Debug( LDAP_DEBUG_ANY,
866 "unable to create '%s' entry\n",
867 SLAPD_MONITOR_DN, 0, 0 );
872 bv.bv_val = (char *) Versionstr;
873 end_of_line = strchr( Versionstr, '\n' );
875 bv.bv_len = end_of_line - Versionstr;
877 bv.bv_len = strlen( Versionstr );
880 if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
883 LDAP_LOG( OPERATION, CRIT,
884 "unable to add monitoredInfo to '%s' entry\n",
885 SLAPD_MONITOR_DN, 0, 0 );
887 Debug( LDAP_DEBUG_ANY,
888 "unable to add monitoredInfo to '%s' entry\n",
889 SLAPD_MONITOR_DN, 0, 0 );
894 if ( mi->mi_l.bv_len ) {
895 if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
897 LDAP_LOG( OPERATION, CRIT,
898 "unable to add locality to '%s' entry\n",
899 SLAPD_MONITOR_DN, 0, 0 );
901 Debug( LDAP_DEBUG_ANY,
902 "unable to add locality to '%s' entry\n",
903 SLAPD_MONITOR_DN, 0, 0 );
909 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
910 e->e_private = ( void * )mp;
913 mp->mp_children = e_tmp;
916 if ( monitor_cache_add( mi, e ) ) {
918 LDAP_LOG( OPERATION, CRIT,
919 "unable to add entry '%s' to cache\n",
920 SLAPD_MONITOR_DN, 0, 0 );
922 Debug( LDAP_DEBUG_ANY,
923 "unable to add entry '%s' to cache\n",
924 SLAPD_MONITOR_DN, 0, 0 );
934 * opens the monitor backend
936 for ( ms = monitor_subsys; ms->mss_name != NULL; ms++ ) {
937 if ( ms->mss_init && ( *ms->mss_init )( be ) ) {
955 * eventually, will hold backend specific configuration parameters
961 monitor_back_db_config(
969 struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
972 * eventually, will hold database specific configuration parameters
974 if ( strcasecmp( argv[ 0 ], "l" ) == 0 ) {
979 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
983 LDAP_LOG( CONFIG, INFO,
984 "line %d of file '%s' will be ignored\n",
987 Debug( LDAP_DEBUG_CONFIG,
988 "line %d of file '%s' will be ignored\n",
997 monitor_back_db_destroy(
1002 * FIXME: destroys all the data