Commit 55e251e6 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

lots of cleanup; few improvements; fix RDN selection bug when creating...

lots of cleanup; few improvements; fix RDN selection bug when creating connection dynamic entries; rework entries ordering - now it's more intuitive and regular; optimize counters update
parent 8b684d71
......@@ -20,7 +20,7 @@ configure directive
The suffix "cn=Monitor" is implicitly activated (it cannot be given
as a suffix of the database as usually done for conventional backends).
Note that the "cn=Monitor" naming context appears in the rootDSE
(FIXME: do we really want this?)
in the attribute monitorContext
A bind operation is provided; at present it allows to bind as the
backend rootdn. As a result, the backend supports the rootdn/rootpw
......@@ -81,34 +81,19 @@ partially useful information is provided.
The subsystems are:
Listener
Databases
Backends
Threads
SASL
TLS
Connections
Read Waiters
Write Waiters
Databases
Listener
Log
Operations
Overlays
SASL
Statistics
Threads
Time
LISTENER SUBSYSTEM
It contains the description of the devices the server is currently
listening on
DATABASES SUBSYSTEM
The main entry contains the naming context of each configured database;
the subentries contain, for each database, the type and the naming
context.
TLS
Read/Write Waiters
......@@ -121,25 +106,6 @@ backends are enabled.
THREADS SUBSYSTEM
It contains the maximum number of threads enabled at startup and the
current backload.
SASL
Currently empty.
TLS
Currently empty.
CONNECTIONS
The main entry is empty; it should contain some statistics on the number
......@@ -151,15 +117,18 @@ current connections respectively.
READ WAITERS SUBSYSTEM
DATABASES SUBSYSTEM
It contains the number of current read waiters.
The main entry contains the naming context of each configured database;
the subentries contain, for each database, the type and the naming
context.
WRITE WAITERS SUBSYSTEM
LISTENER SUBSYSTEM
It contains the number of current write waiters.
It contains the description of the devices the server is currently
listening on
......@@ -196,16 +165,51 @@ It shows some statistics on the operations performed by the server:
Initiated
Completed
and for each operation type, i.e.:
Bind
Unbind
Add
Delete
Modrdn
Modify
Compare
Search
Abandon
Extended
OVERLAYS SUBSYSTEM
The main entry contains the type of overlays available at run-time;
the subentries, for each overlay, contain the type of the overlay.
It should also contain the modules that have been loaded if dynamic
overlays are enabled.
SASL
Currently empty.
SENT SUBSYSTEM
STATISTICS SUBSYSTEM
It shows some statistics on the data sent by the server:
Bytes
PDU
Referrals
Entries
Referrals
THREADS SUBSYSTEM
It contains the maximum number of threads enabled at startup and the
current backload.
......@@ -216,6 +220,18 @@ of the server.
TLS
Currently empty.
READ/WRITE WAITERS SUBSYSTEM
It contains the number of current read waiters.
NOTES
This document is in a very early stage of maturity and will
......
......@@ -112,101 +112,105 @@ struct monitorinfo {
* DNs
*/
#define SLAPD_MONITOR_AT "cn"
#define SLAPD_MONITOR_LISTENER 0
#define SLAPD_MONITOR_LISTENER_NAME "Listeners"
#define SLAPD_MONITOR_LISTENER_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
#define SLAPD_MONITOR_LISTENER_DN \
SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
enum {
SLAPD_MONITOR_BACKEND = 0,
SLAPD_MONITOR_CONN,
SLAPD_MONITOR_DATABASE,
SLAPD_MONITOR_LISTENER,
SLAPD_MONITOR_LOG,
SLAPD_MONITOR_OPS,
SLAPD_MONITOR_OVERLAY,
SLAPD_MONITOR_SASL,
SLAPD_MONITOR_SENT,
SLAPD_MONITOR_THREAD,
SLAPD_MONITOR_TIME,
SLAPD_MONITOR_TLS,
SLAPD_MONITOR_RWW,
SLAPD_MONITOR_LAST
};
#define SLAPD_MONITOR_DATABASE 1
#define SLAPD_MONITOR_DATABASE_NAME "Databases"
#define SLAPD_MONITOR_DATABASE_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
#define SLAPD_MONITOR_DATABASE_DN \
SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_AT "cn"
#define SLAPD_MONITOR_BACKEND 2
#define SLAPD_MONITOR_BACKEND_NAME "Backends"
#define SLAPD_MONITOR_BACKEND_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
#define SLAPD_MONITOR_BACKEND_DN \
SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_THREAD 3
#define SLAPD_MONITOR_THREAD_NAME "Threads"
#define SLAPD_MONITOR_THREAD_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
#define SLAPD_MONITOR_THREAD_DN \
SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_SASL 4
#define SLAPD_MONITOR_SASL_NAME "SASL"
#define SLAPD_MONITOR_SASL_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
#define SLAPD_MONITOR_SASL_DN \
SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_TLS 5
#define SLAPD_MONITOR_TLS_NAME "TLS"
#define SLAPD_MONITOR_TLS_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
#define SLAPD_MONITOR_TLS_DN \
SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_CONN 6
#define SLAPD_MONITOR_CONN_NAME "Connections"
#define SLAPD_MONITOR_CONN_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
#define SLAPD_MONITOR_CONN_DN \
SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_RWW 7
#define SLAPD_MONITOR_RWW_NAME "Waiters"
#define SLAPD_MONITOR_RWW_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
#define SLAPD_MONITOR_RWW_DN \
SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_DATABASE_NAME "Databases"
#define SLAPD_MONITOR_DATABASE_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
#define SLAPD_MONITOR_DATABASE_DN \
SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_LISTENER_NAME "Listeners"
#define SLAPD_MONITOR_LISTENER_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
#define SLAPD_MONITOR_LISTENER_DN \
SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_LOG 8
#define SLAPD_MONITOR_LOG_NAME "Log"
#define SLAPD_MONITOR_LOG_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
#define SLAPD_MONITOR_LOG_DN \
SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_OPS 9
#define SLAPD_MONITOR_OPS_NAME "Operations"
#define SLAPD_MONITOR_OPS_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
#define SLAPD_MONITOR_OPS_DN \
SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_SENT 10
#define SLAPD_MONITOR_OVERLAY_NAME "Overlay"
#define SLAPD_MONITOR_OVERLAY_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
#define SLAPD_MONITOR_OVERLAY_DN \
SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_SASL_NAME "SASL"
#define SLAPD_MONITOR_SASL_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
#define SLAPD_MONITOR_SASL_DN \
SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_SENT_NAME "Statistics"
#define SLAPD_MONITOR_SENT_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
#define SLAPD_MONITOR_SENT_DN \
SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_TIME 11
#define SLAPD_MONITOR_THREAD_NAME "Threads"
#define SLAPD_MONITOR_THREAD_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
#define SLAPD_MONITOR_THREAD_DN \
SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_TIME_NAME "Time"
#define SLAPD_MONITOR_TIME_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
#define SLAPD_MONITOR_TIME_DN \
SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_OVERLAY 12
#define SLAPD_MONITOR_OVERLAY_NAME "Overlay"
#define SLAPD_MONITOR_OVERLAY_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
#define SLAPD_MONITOR_OVERLAY_DN \
SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_TLS_NAME "TLS"
#define SLAPD_MONITOR_TLS_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
#define SLAPD_MONITOR_TLS_DN \
SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_RWW_NAME "Waiters"
#define SLAPD_MONITOR_RWW_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
#define SLAPD_MONITOR_RWW_DN \
SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
struct monitorsubsys {
int mss_type;
char *mss_name;
struct berval mss_rdn;
struct berval mss_dn;
......
......@@ -37,7 +37,7 @@ monitor_subsys_backend_init(
)
{
struct monitorinfo *mi;
Entry *e, *e_backend, *e_tmp;
Entry *e_backend, **ep;
int i;
struct monitorentrypriv *mp;
......@@ -45,21 +45,25 @@ monitor_subsys_backend_init(
if ( monitor_cache_get( mi,
&monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
&e_backend ) ) {
&e_backend ) )
{
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_backend_init: "
"unable to get entry '%s'\n%s%s",
monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
"", "" );
"unable to get entry \"%s\"\n",
monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
e_tmp = NULL;
for ( i = nBackendInfo; i--; ) {
mp = ( struct monitorentrypriv * )e_backend->e_private;
mp->mp_children = NULL;
ep = &mp->mp_children;
for ( i = 0; i < nBackendInfo; i++ ) {
char buf[ BACKMONITOR_BUFSIZE ];
BackendInfo *bi;
struct berval bv;
int j;
Entry *e;
bi = &backendInfo[i];
......@@ -86,10 +90,8 @@ monitor_subsys_backend_init(
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_backend_init: "
"unable to create entry 'cn=Backend %d,%s'\n%s",
i,
monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
"" );
"unable to create entry \"cn=Backend %d,%s\"\n",
i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
return( -1 );
}
......@@ -131,7 +133,7 @@ monitor_subsys_backend_init(
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
mp->mp_next = e_tmp;
mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
......@@ -140,19 +142,16 @@ monitor_subsys_backend_init(
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_backend_init: "
"unable to add entry 'cn=Backend %d,%s'\n%s",
"unable to add entry \"cn=Backend %d,%s\"\n",
i,
monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
"" );
monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
return( -1 );
}
e_tmp = e;
*ep = e;
ep = &mp->mp_next;
}
mp = ( struct monitorentrypriv * )e_backend->e_private;
mp->mp_children = e_tmp;
monitor_cache_release( mi, e_backend );
return( 0 );
......
......@@ -22,6 +22,7 @@
#include "portable.h"
#include <stdio.h>
#include "ac/string.h"
#include "slap.h"
......@@ -165,7 +166,7 @@ monitor_cache_dn2entry(
{
struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
int rc;
struct berval p_ndn = { 0L, NULL };
struct berval p_ndn = BER_BVNULL;
Entry *e_parent;
struct monitorentrypriv *mp;
......@@ -182,21 +183,15 @@ monitor_cache_dn2entry(
}
/* try with parent/ancestors */
if ( ndn->bv_len ) {
dnParent( ndn, &p_ndn );
}
if ( BER_BVISNULL( ndn ) ) {
BER_BVSTR( &p_ndn, "" );
if ( p_ndn.bv_val == NULL ) {
p_ndn.bv_val = "";
p_ndn.bv_len = 0;
} else {
p_ndn.bv_len = ndn->bv_len
- ( ber_len_t ) ( p_ndn.bv_val - ndn->bv_val );
dnParent( ndn, &p_ndn );
}
rc = monitor_cache_dn2entry( op, &p_ndn, &e_parent, matched );
if ( rc || e_parent == NULL) {
if ( rc || e_parent == NULL ) {
return( -1 );
}
......
......@@ -28,8 +28,6 @@
#include "lutil.h"
#include "back-monitor.h"
#define CONN_CN_PREFIX "Connection"
int
monitor_subsys_conn_init(
BackendDB *be
......@@ -37,7 +35,7 @@ monitor_subsys_conn_init(
{
struct monitorinfo *mi;
Entry *e, *e_tmp, *e_conn;
Entry *e, **ep, *e_conn;
struct monitorentrypriv *mp;
char buf[ BACKMONITOR_BUFSIZE ];
struct berval bv;
......@@ -47,16 +45,18 @@ monitor_subsys_conn_init(
mi = ( struct monitorinfo * )be->be_private;
if ( monitor_cache_get( mi,
&monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e_conn ) ) {
&monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e_conn ) )
{
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_init: "
"unable to get entry '%s'\n%s%s",
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val,
"", "" );
"unable to get entry \"%s\"\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
e_tmp = NULL;
mp = ( struct monitorentrypriv * )e_conn->e_private;
mp->mp_children = NULL;
ep = &mp->mp_children;
/*
* Total conns
......@@ -82,19 +82,17 @@ monitor_subsys_conn_init(
if ( e == NULL ) {
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.bv_val,
"", "" );
"unable to create entry \"cn=Total,%s\"\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
bv.bv_val = "0";
bv.bv_len = 1;
BER_BVSTR( &bv, "0" );
attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
mp->mp_next = e_tmp;
mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_CONN];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_CONN].mss_flags \
......@@ -104,14 +102,14 @@ monitor_subsys_conn_init(
if ( monitor_cache_add( mi, e ) ) {
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.bv_val,
"", "" );
"unable to add entry \"cn=Total,%s\"\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
e_tmp = e;
*ep = e;
ep = &mp->mp_next;
/*
* Current conns
*/
......@@ -136,19 +134,17 @@ monitor_subsys_conn_init(
if ( e == NULL ) {
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.bv_val,
"", "" );
"unable to create entry \"cn=Current,%s\"\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
bv.bv_val = "0";
bv.bv_len = 1;
BER_BVSTR( &bv, "0" );
attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
mp->mp_next = e_tmp;
mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_CONN];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_CONN].mss_flags \
......@@ -158,16 +154,13 @@ monitor_subsys_conn_init(
if ( monitor_cache_add( mi, e ) ) {
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.bv_val,
"", "" );
"unable to add entry \"cn=Current,%s\"\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
e_tmp = e;
mp = ( struct monitorentrypriv * )e_conn->e_private;
mp->mp_children = e_tmp;
*ep = e;
ep = &mp->mp_next;
monitor_cache_release( mi, e_conn );
......@@ -180,18 +173,23 @@ monitor_subsys_conn_update(
Entry *e
)
{
struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
long n = -1;
struct monitorinfo *mi =
(struct monitorinfo *)op->o_bd->be_private;
long n = -1;
static struct berval total_bv = BER_BVC( "cn=total" ),
current_bv = BER_BVC( "cn=current" );
struct berval rdn;
assert( mi );
assert( e );
dnRdn( &e->e_nname, &rdn );
if ( strncasecmp( e->e_ndn, "cn=total",
sizeof("cn=total")-1 ) == 0 ) {
if ( dn_match( &rdn, &total_bv ) ) {
n = connections_nextid();
} else if ( strncasecmp( e->e_ndn, "cn=current",
sizeof("cn=current")-1 ) == 0 ) {
} else if ( dn_match( &rdn, &current_bv ) ) {
Connection *c;
int connindex;
......@@ -200,12 +198,13 @@ monitor_subsys_conn_update(
n++, c = connection_next( c, &connindex ) ) {
/* No Op */ ;
}
connection_done(c);
connection_done( c );
}
if ( n != -1 ) {
Attribute *a;
char buf[]</