mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
added operations and sent stats to back-monitor; minor cleanup
This commit is contained in:
parent
9705dcfcd6
commit
de903b65c9
@ -4,11 +4,13 @@ SRCS = init.c search.c compare.c abandon.c modify.c bind.c \
|
|||||||
operational.c \
|
operational.c \
|
||||||
cache.c entry.c \
|
cache.c entry.c \
|
||||||
backend.c database.c thread.c conn.c rww.c log.c \
|
backend.c database.c thread.c conn.c rww.c log.c \
|
||||||
|
operation.c sent.c \
|
||||||
dummy.c
|
dummy.c
|
||||||
OBJS = init.lo search.lo compare.lo abandon.lo modify.lo bind.lo \
|
OBJS = init.lo search.lo compare.lo abandon.lo modify.lo bind.lo \
|
||||||
operational.lo \
|
operational.lo \
|
||||||
cache.lo entry.lo \
|
cache.lo entry.lo \
|
||||||
backend.lo database.lo thread.lo conn.lo rww.lo log.lo \
|
backend.lo database.lo thread.lo conn.lo rww.lo log.lo \
|
||||||
|
operation.lo sent.lo \
|
||||||
dummy.lo
|
dummy.lo
|
||||||
|
|
||||||
LDAP_INCDIR= ../../../include
|
LDAP_INCDIR= ../../../include
|
||||||
|
@ -151,6 +151,20 @@ struct monitorinfo {
|
|||||||
#define SLAPD_MONITOR_LOG_DN \
|
#define SLAPD_MONITOR_LOG_DN \
|
||||||
SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
|
SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
|
||||||
|
|
||||||
|
#define SLAPD_MONITOR_OPS 10
|
||||||
|
#define SLAPD_MONITOR_OPS_NAME "Operations"
|
||||||
|
#define SLAPD_MONITOR_OPS_RDN \
|
||||||
|
"cn=" SLAPD_MONITOR_OPS_NAME
|
||||||
|
#define SLAPD_MONITOR_OPS_DN \
|
||||||
|
SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
|
||||||
|
|
||||||
|
#define SLAPD_MONITOR_SENT 11
|
||||||
|
#define SLAPD_MONITOR_SENT_NAME "Sent"
|
||||||
|
#define SLAPD_MONITOR_SENT_RDN \
|
||||||
|
"cn=" SLAPD_MONITOR_SENT_NAME
|
||||||
|
#define SLAPD_MONITOR_SENT_DN \
|
||||||
|
SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
|
||||||
|
|
||||||
struct monitorsubsys {
|
struct monitorsubsys {
|
||||||
int mss_type;
|
int mss_type;
|
||||||
char *mss_name;
|
char *mss_name;
|
||||||
|
@ -156,7 +156,7 @@ monitor_subsys_backend_init(
|
|||||||
mp = ( struct monitorentrypriv * )e_backend->e_private;
|
mp = ( struct monitorentrypriv * )e_backend->e_private;
|
||||||
mp->mp_children = e_tmp;
|
mp->mp_children = e_tmp;
|
||||||
|
|
||||||
monitor_cache_release( mi, e_backend);
|
monitor_cache_release( mi, e_backend );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -48,15 +48,17 @@ monitor_subsys_conn_init(
|
|||||||
{
|
{
|
||||||
struct monitorinfo *mi;
|
struct monitorinfo *mi;
|
||||||
|
|
||||||
Entry *e;
|
Entry *e, *e_tmp, *e_conn;
|
||||||
struct berval *bv[2], val;
|
struct monitorentrypriv *mp;
|
||||||
|
char buf[1024];
|
||||||
|
struct berval val, *bv[2] = { &val, NULL };
|
||||||
|
|
||||||
assert( be != NULL );
|
assert( be != NULL );
|
||||||
|
|
||||||
mi = ( struct monitorinfo * )be->be_private;
|
mi = ( struct monitorinfo * )be->be_private;
|
||||||
|
|
||||||
if ( monitor_cache_get( mi,
|
if ( monitor_cache_get( mi,
|
||||||
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e ) ) {
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e_conn ) ) {
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
"monitor_subsys_conn_init: "
|
"monitor_subsys_conn_init: "
|
||||||
@ -72,10 +74,134 @@ monitor_subsys_conn_init(
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bv[0] = &val;
|
e_tmp = NULL;
|
||||||
bv[1] = NULL;
|
|
||||||
|
|
||||||
monitor_cache_release( mi, e );
|
/*
|
||||||
|
* Total conns
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Total,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Total\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to create entry 'cn=Total,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to create entry 'cn=Total,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_CONN];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_CONN].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
mp->mp_flags &= ~MONITOR_F_VOLATILE_CH;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to add entry 'cn=Total,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to add entry 'cn=Total,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Current conns
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Current,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Current\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to create entry 'cn=Current,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to create entry 'cn=Current,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_CONN];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_CONN].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
mp->mp_flags &= ~MONITOR_F_VOLATILE_CH;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to add entry 'cn=Current,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_conn_init: "
|
||||||
|
"unable to add entry 'cn=Current,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )e_conn->e_private;
|
||||||
|
mp->mp_children = e_tmp;
|
||||||
|
|
||||||
|
monitor_cache_release( mi, e_conn );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -86,53 +212,41 @@ monitor_subsys_conn_update(
|
|||||||
Entry *e
|
Entry *e
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Connection *c;
|
long n = -1;
|
||||||
int connindex;
|
|
||||||
int nconns, nwritewaiters, nreadwaiters;
|
|
||||||
|
|
||||||
Attribute *a;
|
assert( mi );
|
||||||
struct berval *bv[2], val, **b = NULL;
|
assert( e );
|
||||||
char buf[1024];
|
|
||||||
|
|
||||||
assert( mi != NULL );
|
|
||||||
assert( e != NULL );
|
|
||||||
|
|
||||||
bv[0] = &val;
|
if ( strncasecmp( e->e_ndn, "CN=TOTAL",
|
||||||
bv[1] = NULL;
|
sizeof("CN=TOTAL")-1 ) == 0 ) {
|
||||||
|
n = connections_nextid();
|
||||||
|
|
||||||
nconns = nwritewaiters = nreadwaiters = 0;
|
} else if ( strncasecmp( e->e_ndn, "CN=CURRENT",
|
||||||
for ( c = connection_first( &connindex );
|
sizeof("CN=CURRENT")-1 ) == 0 ) {
|
||||||
c != NULL;
|
Connection *c;
|
||||||
c = connection_next( c, &connindex ), nconns++ ) {
|
int connindex;
|
||||||
if ( c->c_writewaiter ) {
|
|
||||||
nwritewaiters++;
|
|
||||||
}
|
|
||||||
if ( c->c_currentber != NULL ) {
|
|
||||||
nreadwaiters++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
connection_done(c);
|
|
||||||
|
|
||||||
#if 0
|
for ( n = 0, c = connection_first( &connindex );
|
||||||
snprintf( buf, sizeof( buf ), "readwaiters=%d", nreadwaiters );
|
c != NULL;
|
||||||
|
n++, c = connection_next( c, &connindex ) ) {
|
||||||
if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
|
/* No Op */ ;
|
||||||
for ( b = a->a_vals; b[0] != NULL; b++ ) {
|
|
||||||
if ( strncmp( b[0]->bv_val, "readwaiters=",
|
|
||||||
sizeof( "readwaiters=" ) - 1 ) == 0 ) {
|
|
||||||
free( b[0]->bv_val );
|
|
||||||
b[0] = ber_bvstrdup( buf );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
connection_done(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( b == NULL || b[0] == NULL ) {
|
if ( n != -1 ) {
|
||||||
val.bv_val = buf;
|
Attribute *a;
|
||||||
val.bv_len = strlen( buf );
|
char buf[16];
|
||||||
attr_merge( e, monitor_ad_desc, bv );
|
|
||||||
|
a = attr_find( e->e_attrs, monitor_ad_desc );
|
||||||
|
if ( a == NULL ) {
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf( buf, sizeof( buf ), "%ld", n );
|
||||||
|
ber_bvfree( a->a_vals[ 0 ] );
|
||||||
|
a->a_vals[ 0 ] = ber_bvstrdup( buf );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -149,7 +263,7 @@ conn_create(
|
|||||||
char buf2[22];
|
char buf2[22];
|
||||||
char buf3[22];
|
char buf3[22];
|
||||||
|
|
||||||
struct berval *bv[2], val;
|
struct berval val, *bv[2] = { &val, NULL };
|
||||||
|
|
||||||
Entry *e;
|
Entry *e;
|
||||||
|
|
||||||
@ -232,9 +346,6 @@ conn_create(
|
|||||||
buf3
|
buf3
|
||||||
);
|
);
|
||||||
|
|
||||||
bv[0] = &val;
|
|
||||||
bv[1] = NULL;
|
|
||||||
|
|
||||||
val.bv_val = buf;
|
val.bv_val = buf;
|
||||||
val.bv_len = strlen( buf );
|
val.bv_len = strlen( buf );
|
||||||
attr_merge( e, monitor_ad_desc, bv );
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
@ -276,7 +387,8 @@ monitor_subsys_conn_create(
|
|||||||
c != NULL;
|
c != NULL;
|
||||||
c = connection_next( c, &connindex )) {
|
c = connection_next( c, &connindex )) {
|
||||||
if ( conn_create( c, &e ) || e == NULL ) {
|
if ( conn_create( c, &e ) || e == NULL ) {
|
||||||
// error
|
connection_done(c);
|
||||||
|
return( -1 );
|
||||||
}
|
}
|
||||||
mp = ( struct monitorentrypriv * )e->e_private;
|
mp = ( struct monitorentrypriv * )e->e_private;
|
||||||
mp->mp_next = e_tmp;
|
mp->mp_next = e_tmp;
|
||||||
@ -301,7 +413,8 @@ monitor_subsys_conn_create(
|
|||||||
c = connection_next( c, &connindex )) {
|
c = connection_next( c, &connindex )) {
|
||||||
if ( c->c_connid == connid ) {
|
if ( c->c_connid == connid ) {
|
||||||
if ( conn_create( c, ep ) || *ep == NULL ) {
|
if ( conn_create( c, ep ) || *ep == NULL ) {
|
||||||
// error
|
connection_done(c);
|
||||||
|
return( -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ monitor_subsys_database_init(
|
|||||||
int i;
|
int i;
|
||||||
struct monitorentrypriv *mp;
|
struct monitorentrypriv *mp;
|
||||||
AttributeDescription *ad_nc = slap_schema.si_ad_namingContexts;
|
AttributeDescription *ad_nc = slap_schema.si_ad_namingContexts;
|
||||||
struct berval *bv[2], val;
|
struct berval val, *bv[2] = { &val, NULL };
|
||||||
|
|
||||||
assert( be != NULL );
|
assert( be != NULL );
|
||||||
assert( monitor_ad_desc != NULL );
|
assert( monitor_ad_desc != NULL );
|
||||||
@ -76,8 +76,6 @@ monitor_subsys_database_init(
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bv[0] = &val;
|
|
||||||
bv[1] = NULL;
|
|
||||||
e_tmp = NULL;
|
e_tmp = NULL;
|
||||||
for ( i = nBackendDB; i--; ) {
|
for ( i = nBackendDB; i--; ) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -130,6 +130,22 @@ struct monitorsubsys monitor_subsys[] = {
|
|||||||
NULL, /* update */
|
NULL, /* update */
|
||||||
NULL, /* create */
|
NULL, /* create */
|
||||||
monitor_subsys_log_modify
|
monitor_subsys_log_modify
|
||||||
|
}, {
|
||||||
|
SLAPD_MONITOR_OPS, SLAPD_MONITOR_OPS_NAME,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
MONITOR_F_NONE,
|
||||||
|
monitor_subsys_ops_init,
|
||||||
|
monitor_subsys_ops_update,
|
||||||
|
NULL, /* create */
|
||||||
|
NULL, /* modify */
|
||||||
|
}, {
|
||||||
|
SLAPD_MONITOR_SENT, SLAPD_MONITOR_SENT_NAME,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
MONITOR_F_NONE,
|
||||||
|
monitor_subsys_sent_init,
|
||||||
|
monitor_subsys_sent_update,
|
||||||
|
NULL, /* create */
|
||||||
|
NULL, /* modify */
|
||||||
}, { -1, NULL }
|
}, { -1, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
251
servers/slapd/back-monitor/operation.c
Normal file
251
servers/slapd/back-monitor/operation.c
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
/* operation.c - deal with operation subsystem */
|
||||||
|
/*
|
||||||
|
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
|
||||||
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
|
||||||
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||||
|
*
|
||||||
|
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
|
||||||
|
*
|
||||||
|
* This work has beed deveolped for the OpenLDAP Foundation
|
||||||
|
* in the hope that it may be useful to the Open Source community,
|
||||||
|
* but WITHOUT ANY WARRANTY.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose
|
||||||
|
* on any computer system, and to alter it and redistribute it, subject
|
||||||
|
* to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The author and SysNet s.n.c. are not responsible for the consequences
|
||||||
|
* of use of this software, no matter how awful, even if they arise from
|
||||||
|
* flaws in it.
|
||||||
|
*
|
||||||
|
* 2. The origin of this software must not be misrepresented, either by
|
||||||
|
* explicit claim or by omission. Since few users ever read sources,
|
||||||
|
* credits should appear in the documentation.
|
||||||
|
*
|
||||||
|
* 3. Altered versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software. Since few users
|
||||||
|
* ever read sources, credits should appear in the documentation.
|
||||||
|
* SysNet s.n.c. cannot be responsible for the consequences of the
|
||||||
|
* alterations.
|
||||||
|
*
|
||||||
|
* 4. This notice may not be removed or altered.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "portable.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "slap.h"
|
||||||
|
#include "back-monitor.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
monitor_subsys_ops_init(
|
||||||
|
BackendDB *be
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct monitorinfo *mi;
|
||||||
|
|
||||||
|
Entry *e, *e_tmp, *e_op;
|
||||||
|
struct monitorentrypriv *mp;
|
||||||
|
char buf[1024];
|
||||||
|
struct berval val, *bv[2] = { &val, NULL };
|
||||||
|
|
||||||
|
assert( be != NULL );
|
||||||
|
|
||||||
|
mi = ( struct monitorinfo * )be->be_private;
|
||||||
|
|
||||||
|
if ( monitor_cache_get( mi,
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, &e_op ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to get entry '%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to get entry '%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initiated ops
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Initiated,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Initiated\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to create entry 'cn=Initiated,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to create entry 'cn=Initiated,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OPS];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OPS].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to add entry 'cn=Initiated,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to add entry 'cn=Initiated,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Completed ops
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Completed,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Completed\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to create entry 'cn=Completed,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to create entry 'cn=Completed,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OPS];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OPS].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to add entry 'cn=Completed,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_ops_init: "
|
||||||
|
"unable to add entry 'cn=Completed,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )e_op->e_private;
|
||||||
|
mp->mp_children = e_tmp;
|
||||||
|
|
||||||
|
monitor_cache_release( mi, e_op );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
monitor_subsys_ops_update(
|
||||||
|
struct monitorinfo *mi,
|
||||||
|
Entry *e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
long n = -1;
|
||||||
|
|
||||||
|
assert( mi );
|
||||||
|
assert( e );
|
||||||
|
|
||||||
|
if ( strncasecmp( e->e_ndn, "CN=INITIATED",
|
||||||
|
sizeof("CN=INITIATED")-1 ) == 0 ) {
|
||||||
|
ldap_pvt_thread_mutex_lock(&num_ops_mutex);
|
||||||
|
n = num_ops_initiated;
|
||||||
|
ldap_pvt_thread_mutex_unlock(&num_ops_mutex);
|
||||||
|
|
||||||
|
} else if ( strncasecmp( e->e_ndn, "CN=COMPLETED",
|
||||||
|
sizeof("CN=COMPLETED")-1 ) == 0 ) {
|
||||||
|
ldap_pvt_thread_mutex_lock(&num_ops_mutex);
|
||||||
|
n = num_ops_completed;
|
||||||
|
ldap_pvt_thread_mutex_unlock(&num_ops_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( n != -1 ) {
|
||||||
|
Attribute *a;
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
|
a = attr_find( e->e_attrs, monitor_ad_desc );
|
||||||
|
if ( a == NULL ) {
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf( buf, sizeof( buf ), "%ld", n );
|
||||||
|
ber_bvfree( a->a_vals[ 0 ] );
|
||||||
|
a->a_vals[ 0 ] = ber_bvstrdup( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
@ -86,5 +86,17 @@ int monitor_subsys_writew_update LDAP_P(( struct monitorinfo *mi, Entry *e ));
|
|||||||
int monitor_subsys_log_init LDAP_P(( BackendDB *be ));
|
int monitor_subsys_log_init LDAP_P(( BackendDB *be ));
|
||||||
int monitor_subsys_log_modify LDAP_P(( struct monitorinfo *mi, Entry *e, Modifications *modlist ));
|
int monitor_subsys_log_modify LDAP_P(( struct monitorinfo *mi, Entry *e, Modifications *modlist ));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* operations
|
||||||
|
*/
|
||||||
|
int monitor_subsys_ops_init LDAP_P(( BackendDB *be ));
|
||||||
|
int monitor_subsys_ops_update LDAP_P(( struct monitorinfo *mi, Entry *e ));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sent
|
||||||
|
*/
|
||||||
|
int monitor_subsys_sent_init LDAP_P(( BackendDB *be ));
|
||||||
|
int monitor_subsys_sent_update LDAP_P(( struct monitorinfo *mi, Entry *e ));
|
||||||
|
|
||||||
LDAP_END_DECL
|
LDAP_END_DECL
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,7 +116,7 @@ monitor_subsys_readw_update_internal(
|
|||||||
if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
|
if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
|
||||||
for ( b = a->a_vals; b[0] != NULL; b++ ) {
|
for ( b = a->a_vals; b[0] != NULL; b++ ) {
|
||||||
if ( strncmp( b[0]->bv_val, str, strlen( str ) ) == 0 ) {
|
if ( strncmp( b[0]->bv_val, str, strlen( str ) ) == 0 ) {
|
||||||
free( b[0]->bv_val );
|
ber_bvfree( b[0] );
|
||||||
b[0] = ber_bvstrdup( buf );
|
b[0] = ber_bvstrdup( buf );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ monitor_send_children(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct monitorinfo *mi = (struct monitorinfo *) be->be_private;
|
struct monitorinfo *mi = (struct monitorinfo *) be->be_private;
|
||||||
Entry *e, *e_tmp;
|
Entry *e, *e_tmp, *e_ch;
|
||||||
struct monitorentrypriv *mp;
|
struct monitorentrypriv *mp;
|
||||||
int nentries;
|
int nentries;
|
||||||
int rc;
|
int rc;
|
||||||
@ -67,14 +67,42 @@ monitor_send_children(
|
|||||||
mp = ( struct monitorentrypriv * )e_parent->e_private;
|
mp = ( struct monitorentrypriv * )e_parent->e_private;
|
||||||
e = mp->mp_children;
|
e = mp->mp_children;
|
||||||
|
|
||||||
if ( e == NULL && MONITOR_HAS_VOLATILE_CH( mp ) ) {
|
if ( MONITOR_HAS_VOLATILE_CH( mp ) ) {
|
||||||
monitor_entry_create( mi, NULL, e_parent, &e );
|
monitor_entry_create( mi, NULL, e_parent, &e_ch );
|
||||||
if ( e != NULL) {
|
|
||||||
monitor_cache_lock( e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
monitor_cache_release( mi, e_parent );
|
monitor_cache_release( mi, e_parent );
|
||||||
|
|
||||||
|
/* no volatile entries? */
|
||||||
|
if ( e_ch == NULL ) {
|
||||||
|
/* no persistent entries? return */
|
||||||
|
if ( e == NULL ) {
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* volatile entries */
|
||||||
|
} else {
|
||||||
|
/* if no persistent, return only volatile */
|
||||||
|
if ( e == NULL ) {
|
||||||
|
e = e_ch;
|
||||||
|
monitor_cache_lock( e_ch );
|
||||||
|
|
||||||
|
/* else append persistent to volatile */
|
||||||
|
} else {
|
||||||
|
e_tmp = e_ch;
|
||||||
|
do {
|
||||||
|
mp = ( struct monitorentrypriv * )e_tmp->e_private;
|
||||||
|
e_tmp = mp->mp_next;
|
||||||
|
|
||||||
|
if ( e_tmp == NULL ) {
|
||||||
|
mp->mp_next = e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while ( e_tmp );
|
||||||
|
e = e_ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return entries */
|
||||||
for ( nentries = *nentriesp; e != NULL; ) {
|
for ( nentries = *nentriesp; e != NULL; ) {
|
||||||
mp = ( struct monitorentrypriv * )e->e_private;
|
mp = ( struct monitorentrypriv * )e->e_private;
|
||||||
|
|
||||||
|
387
servers/slapd/back-monitor/sent.c
Normal file
387
servers/slapd/back-monitor/sent.c
Normal file
@ -0,0 +1,387 @@
|
|||||||
|
/* sent.c - deal with data sent subsystem */
|
||||||
|
/*
|
||||||
|
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
|
||||||
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
|
||||||
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||||
|
*
|
||||||
|
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
|
||||||
|
*
|
||||||
|
* This work has beed deveolped for the OpenLDAP Foundation
|
||||||
|
* in the hope that it may be useful to the Open Source community,
|
||||||
|
* but WITHOUT ANY WARRANTY.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose
|
||||||
|
* on any computer system, and to alter it and redistribute it, subject
|
||||||
|
* to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The author and SysNet s.n.c. are not responsible for the consequences
|
||||||
|
* of use of this software, no matter how awful, even if they arise from
|
||||||
|
* flaws in it.
|
||||||
|
*
|
||||||
|
* 2. The origin of this software must not be misrepresented, either by
|
||||||
|
* explicit claim or by omission. Since few users ever read sources,
|
||||||
|
* credits should appear in the documentation.
|
||||||
|
*
|
||||||
|
* 3. Altered versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software. Since few users
|
||||||
|
* ever read sources, credits should appear in the documentation.
|
||||||
|
* SysNet s.n.c. cannot be responsible for the consequences of the
|
||||||
|
* alterations.
|
||||||
|
*
|
||||||
|
* 4. This notice may not be removed or altered.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "portable.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "slap.h"
|
||||||
|
#include "back-monitor.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
monitor_subsys_sent_init(
|
||||||
|
BackendDB *be
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct monitorinfo *mi;
|
||||||
|
|
||||||
|
Entry *e, *e_tmp, *e_sent;
|
||||||
|
struct monitorentrypriv *mp;
|
||||||
|
char buf[1024];
|
||||||
|
struct berval val, *bv[2] = { &val, NULL };
|
||||||
|
|
||||||
|
assert( be != NULL );
|
||||||
|
|
||||||
|
mi = ( struct monitorinfo * )be->be_private;
|
||||||
|
|
||||||
|
if ( monitor_cache_get( mi,
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, &e_sent ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to get entry '%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to get entry '%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Entries
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Entries,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Entries\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=Entries,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=Entries,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_SENT];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_SENT].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=Entries,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=Entries,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Referrals
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Referrals,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Referrals\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=Referrals,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=Referrals,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_SENT];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_SENT].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=Referrals,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=Referrals,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PDU
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=PDU,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: PDU\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=PDU,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=PDU,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_SENT];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_SENT].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=PDU,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=PDU,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bytes
|
||||||
|
*/
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"dn: cn=Bytes,%s\n"
|
||||||
|
"objectClass: top\n"
|
||||||
|
"objectClass: LDAPsubEntry\n"
|
||||||
|
#ifdef SLAPD_MONITORSUBENTRY
|
||||||
|
"objectClass: monitorSubEntry\n"
|
||||||
|
#else /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"objectClass: extensibleObject\n"
|
||||||
|
#endif /* !SLAPD_MONITORSUBENTRY */
|
||||||
|
"cn: Bytes\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn );
|
||||||
|
|
||||||
|
e = str2entry( buf );
|
||||||
|
if ( e == NULL ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=Bytes,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to create entry 'cn=Bytes,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
val.bv_val = "0";
|
||||||
|
val.bv_len = 1;
|
||||||
|
attr_merge( e, monitor_ad_desc, bv );
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
|
||||||
|
e->e_private = ( void * )mp;
|
||||||
|
mp->mp_next = e_tmp;
|
||||||
|
mp->mp_children = NULL;
|
||||||
|
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_SENT];
|
||||||
|
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_SENT].mss_flags \
|
||||||
|
| MONITOR_F_SUB | MONITOR_F_PERSISTENT;
|
||||||
|
|
||||||
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=Bytes,%s'\n",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn ));
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"monitor_subsys_sent_init: "
|
||||||
|
"unable to add entry 'cn=Bytes,%s'\n%s%s",
|
||||||
|
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn,
|
||||||
|
"", "" );
|
||||||
|
#endif
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
e_tmp = e;
|
||||||
|
|
||||||
|
mp = ( struct monitorentrypriv * )e_sent->e_private;
|
||||||
|
mp->mp_children = e_tmp;
|
||||||
|
|
||||||
|
monitor_cache_release( mi, e_sent );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
monitor_subsys_sent_update(
|
||||||
|
struct monitorinfo *mi,
|
||||||
|
Entry *e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
long n = -1;
|
||||||
|
|
||||||
|
assert( mi );
|
||||||
|
assert( e );
|
||||||
|
|
||||||
|
if ( strncasecmp( e->e_ndn, "CN=ENTRIES",
|
||||||
|
sizeof("CN=ENTRIES")-1 ) == 0 ) {
|
||||||
|
ldap_pvt_thread_mutex_lock(&num_sent_mutex);
|
||||||
|
n = num_entries_sent;
|
||||||
|
ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
|
||||||
|
|
||||||
|
} else if ( strncasecmp( e->e_ndn, "CN=REFERRALS",
|
||||||
|
sizeof("CN=REFERRALS")-1 ) == 0 ) {
|
||||||
|
ldap_pvt_thread_mutex_lock(&num_sent_mutex);
|
||||||
|
n = num_refs_sent;
|
||||||
|
ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
|
||||||
|
|
||||||
|
} else if ( strncasecmp( e->e_ndn, "CN=PDU",
|
||||||
|
sizeof("CN=PDU")-1 ) == 0 ) {
|
||||||
|
ldap_pvt_thread_mutex_lock(&num_sent_mutex);
|
||||||
|
n = num_pdu_sent;
|
||||||
|
ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
|
||||||
|
|
||||||
|
} else if ( strncasecmp( e->e_ndn, "CN=BYTES",
|
||||||
|
sizeof("CN=BYTES")-1 ) == 0 ) {
|
||||||
|
ldap_pvt_thread_mutex_lock(&num_sent_mutex);
|
||||||
|
n = num_bytes_sent;
|
||||||
|
ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( n != -1 ) {
|
||||||
|
Attribute *a;
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
|
a = attr_find( e->e_attrs, monitor_ad_desc );
|
||||||
|
if ( a == NULL ) {
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf( buf, sizeof( buf ), "%ld", n );
|
||||||
|
ber_bvfree( a->a_vals[ 0 ] );
|
||||||
|
a->a_vals[ 0 ] = ber_bvstrdup( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
@ -170,6 +170,11 @@ Connection * connection_next( Connection *c, ber_socket_t *b )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long connections_nextid(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void connection_done( Connection *c )
|
void connection_done( Connection *c )
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user