LDAP_BEGIN_DECL
+#define MONITOR_DEVEL
+
/*
* The cache maps DNs to Entries.
* Each entry, on turn, holds the list of its children in the e_private field.
struct monitorinfo {
Avlnode *mi_cache;
ldap_pvt_thread_mutex_t mi_cache_mutex;
+
+ ObjectClass *monitor_oc_monitorServer;
+ ObjectClass *monitor_oc_monitorContainer;
+ ObjectClass *monitor_oc_monitorCounter;
+ ObjectClass *monitor_oc_monitorOperation;
+ ObjectClass *monitor_oc_monitorConnection;
+ ObjectClass *monitor_oc_managedObject;
+ ObjectClass *monitor_oc_monitoredObject;
+
+ AttributeDescription *monitor_ad_monitoredInfo;
+ AttributeDescription *monitor_ad_managedInfo;
+ AttributeDescription *monitor_ad_monitorCounter;
+ AttributeDescription *monitor_ad_monitorOpCompleted;
+ AttributeDescription *monitor_ad_monitorOpInitiated;
+ AttributeDescription *monitor_ad_monitorConnectionNumber;
+ AttributeDescription *monitor_ad_monitorConnectionAuthzDN;
+ AttributeDescription *monitor_ad_monitorConnectionLocalAddress;
+ AttributeDescription *monitor_ad_monitorConnectionPeerAddress;
+
+ AttributeDescription *monitor_ad_description;
};
/*
extern struct monitorsubsys monitor_subsys[];
-extern AttributeDescription *monitor_ad_desc;
extern BackendDB *be_monitor;
/*
bv.bv_val = bi->bi_type;
bv.bv_len = strlen( bv.bv_val );
- attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL );
- attr_merge_normalize_one( e_backend, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e, mi->monitor_ad_description,
+ &bv, NULL );
+ attr_merge_normalize_one( e_backend, mi->monitor_ad_description,
+ &bv, NULL );
if ( bi->bi_controls ) {
int j;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
Attribute *a;
char buf[16];
- a = attr_find( e->e_attrs, monitor_ad_desc );
+ a = attr_find( e->e_attrs, mi->monitor_ad_description );
if ( a == NULL ) {
return( -1 );
}
static int
conn_create(
+ struct monitorinfo *mi,
Connection *c,
Entry **ep
)
bv.bv_val = buf;
bv.bv_len = strlen( buf );
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
for ( c = connection_first( &connindex );
c != NULL;
c = connection_next( c, &connindex )) {
- if ( conn_create( c, &e ) || e == NULL ) {
+ if ( conn_create( mi, c, &e ) || e == NULL ) {
connection_done(c);
for ( ; e_tmp != NULL; ) {
mp = ( struct monitorentrypriv * )e_tmp->e_private;
c != NULL;
c = connection_next( c, &connindex )) {
if ( c->c_connid == connid ) {
- if ( conn_create( c, ep ) || *ep == NULL ) {
+ if ( conn_create( mi, c, ep ) || *ep == NULL ) {
connection_done(c);
return( -1 );
}
const char *text = NULL;
assert( be != NULL );
- assert( monitor_ad_desc != NULL );
mi = ( struct monitorinfo * )be->be_private;
{
Slapi_PBlock *pCurrentPB;
int i, rc = LDAP_SUCCESS;
+ struct monitorinfo *mi = ( struct monitorinfo * )be->be_private;
if ( slapi_x_pblock_get_first( be, &pCurrentPB ) != LDAP_SUCCESS ) {
/*
bv.bv_val = buf;
bv.bv_len = strlen( buf );
- attr_merge_normalize_one( e_database, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e_database,
+ mi->monitor_ad_description, &bv, NULL );
i++;
struct berval dn, ndn;
const char *text;
struct berval bv;
+ struct m_s {
+ char *name;
+ char *schema;
+ int offset;
+ } moc[] = {
+ { "monitorServer", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'monitorServer' "
+ "DESC 'Server monitoring root entry' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_monitorServer) },
+ { "monitorContainer", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'monitorContainer' "
+ "DESC 'monitor container class' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_monitorContainer) },
+ { "monitorCounter", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'monitorCounter' "
+ "DESC 'monitor counter class' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_monitorCounter) },
+ { "monitorOperation", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'monitorOperation' "
+ "DESC 'monitor operation class' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_monitorOperation) },
+ { "monitorConnection", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'monitorConnection' "
+ "DESC 'monitor connection class' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_monitorConnection) },
+ { "managedObject", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'managedObject' "
+ "DESC 'monitor managed entity class' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_managedObject) },
+ { "monitoredObject", "( 1.3.6.1.4.1.4203.666.XXX "
+ "NAME 'monitoredObject' "
+ "DESC 'monitor monitored entity class' "
+ "SUP monitor STRUCTURAL)",
+ offsetof(struct monitorinfo, monitor_oc_monitoredObject) },
+ { NULL, NULL, -1 }
+ }, mat[] = {
+ { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitoredInfo' "
+ "DESC 'monitored info' "
+ "SUP name )",
+ offsetof(struct monitorinfo, monitor_ad_monitoredInfo) },
+ { "managedInfo", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'managedInfo' "
+ "DESC 'monitor managed info' "
+ "SUP name )",
+ offsetof(struct monitorinfo, monitor_ad_managedInfo) },
+ { "monitorCounter", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorCounter' "
+ "DESC 'monitor counter' "
+ "EQUALITY integerMatch "
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
+ offsetof(struct monitorinfo, monitor_ad_monitorCounter) },
+ { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorOpCompleted' "
+ "DESC 'monitor completed operations' "
+ "SUP monitorCounter )",
+ offsetof(struct monitorinfo, monitor_ad_monitorOpCompleted) },
+ { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorOpInitiated' "
+ "DESC 'monitor initiated operations' "
+ "SUP monitorCounter )",
+ offsetof(struct monitorinfo, monitor_ad_monitorOpInitiated) },
+ { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorConnectionNumber' "
+ "DESC 'monitor connection number' "
+ "SUP monitorCounter )",
+ offsetof(struct monitorinfo, monitor_ad_monitorConnectionNumber) },
+ { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorConnectionAuthzDN' "
+ "DESC 'monitor connection authorization DN' "
+ "SUP distinguishedName)",
+ offsetof(struct monitorinfo, monitor_ad_monitorConnectionAuthzDN) },
+ { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorConnectionLocalAddress' "
+ "DESC 'monitor connection local address' "
+ "SUP monitoredInfo)",
+ offsetof(struct monitorinfo, monitor_ad_monitorConnectionLocalAddress) },
+ { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.XXX"
+ "NAME 'monitorConnectionPeerAddress' "
+ "DESC 'monitor connection peer address' "
+ "SUP monitoredInfo)",
+ offsetof(struct monitorinfo, monitor_ad_monitorConnectionPeerAddress) },
+ { NULL, NULL, -1 }
+ };
/*
* database monitor can be defined once only
if ( be_monitor ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, CRIT,
- "only one monitor backend is allowed\n" , 0, 0, 0);
+ "only one monitor backend is allowed\n", 0, 0, 0);
#else
Debug( LDAP_DEBUG_ANY,
- "only one monitor backend is allowed\n%s%s%s",
- "", "", "" );
+ "only one monitor backend is allowed\n", 0, 0, 0 );
#endif
return( -1 );
}
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, CRIT,
- "monitor DN \"" SLAPD_MONITOR_DN "\" backend is allowed\n" , 0, 0, 0 );
+ "unable to normalize monitor DN \"" SLAPD_MONITOR_DN
+ "\"\n" , 0, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
- "monitor DN \"" SLAPD_MONITOR_DN "\" backend is allowed\n",
- 0, 0, 0 );
+ "unable to normalize monitor DN \"" SLAPD_MONITOR_DN
+ "\"\n", 0, 0, 0 );
#endif
return -1;
}
ber_bvarray_add( &be->be_nsuffix, &ndn );
mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
+ if ( mi == NULL ) {
+ return -1;
+ }
+
ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
- if ( slap_str2ad( "description", &monitor_ad_desc, &text ) ) {
+ for ( i = 0; moc[i].name; i++ ) {
+ LDAPObjectClass *oc;
+ int code;
+ const char *err;
+ ObjectClass *Oc;
+
+ oc = ldap_str2objectclass(moc[i].schema, &code, &err,
+ LDAP_SCHEMA_ALLOW_ALL );
+ if ( !oc ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "unable to parse monitor objectclass '%s' "
+ "(%s before %s)\n" , moc[i].name,
+ ldap_scherr2str(code), err );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "unable to parse monitor objectclass '%s' "
+ "(%s before %s)\n" , moc[i].name,
+ ldap_scherr2str(code), err );
+#endif
+ return -1;
+ }
+
+ if ( oc->oc_oid == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "objectclass '%s' has no OID\n" ,
+ moc[i].name, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "objectclass '%s' has no OID\n" ,
+ moc[i].name, 0, 0 );
+#endif
+ return -1;
+ }
+
+ code = oc_add(oc,1,&err);
+ if ( code ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "objectclass '%s' (%s before %s)\n" ,
+ moc[i].name, scherr2str(code), err );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "objectclass '%s' (%s before %s)\n" ,
+ moc[i].name, scherr2str(code), err );
+#endif
+ return -1;
+ }
+
+ ldap_memfree(oc);
+
+ Oc = oc_find( moc[i].name );
+ if ( Oc == NULL ) {
+ return -1;
+ }
+
+ ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc;
+ }
+
+ for ( i = 0; mat[i].name; i++ ) {
+ LDAPAttributeType *at;
+ int code;
+ const char *err;
+ AttributeDescription **ad;
+
+ at = ldap_str2attributetype( mat[i].schema, &code,
+ &err, LDAP_SCHEMA_ALLOW_ALL );
+ if ( !at ) {
+ return 1;
+ }
+
+ if ( at->at_oid == NULL ) {
+ return 1;
+ }
+
+ /* operational attributes should be defined internally
+ if ( at->at_usage ) {
+ fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
+ fname, lineno, at->at_oid );
+ return 1;
+ } */
+
+ code = at_add(at,&err);
+ if ( code ) {
+ return 1;
+ }
+ ldap_memfree(at);
+
+ ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset]));
+ ad[0] = NULL;
+ if ( slap_str2ad( mat[i].name, ad, &text ) ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "monitor_back_db_init: %s\n", text, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_backend_init: %s\n%s%s",
+ text, "", "" );
+#endif
+ return -1;
+ }
+ }
+
+ if ( slap_str2ad( "description", &mi->monitor_ad_description, &text ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, CRIT,
"monitor_back_db_init: %s\n", text, 0, 0 );
Listener **l;
assert( be != NULL );
- assert( monitor_ad_desc != NULL );
mi = ( struct monitorinfo * )be->be_private;
bv.bv_val = "TLS";
bv.bv_len = sizeof("TLS")-1;
- attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e, mi->monitor_ad_description, &bv, NULL );
}
#endif /* HAVE_TLS */
#ifdef LDAP_CONNECTIONLESS
bv.bv_val = "UDP";
bv.bv_len = sizeof("UDP")-1;
- attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e, mi->monitor_ad_description, &bv, NULL );
}
#endif /* HAVE_TLS */
/* initialize the debug level(s) */
for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
- if ( monitor_ad_desc->ad_type->sat_equality->smr_normalize ) {
+ if ( mi->monitor_ad_description->ad_type->sat_equality->smr_normalize ) {
int rc;
- rc = (*monitor_ad_desc->ad_type->sat_equality->smr_normalize)(
+ rc = (*mi->monitor_ad_description->ad_type->sat_equality->smr_normalize)(
0,
- monitor_ad_desc->ad_type->sat_syntax,
- monitor_ad_desc->ad_type->sat_equality,
+ mi->monitor_ad_description->ad_type->sat_syntax,
+ mi->monitor_ad_description->ad_type->sat_equality,
&int_2_level[ i ].s,
&int_2_level[ i ].n, NULL );
if ( rc ) {
}
if ( int_2_level[ i ].i & ldap_syslog ) {
- attr_merge_one( e, monitor_ad_desc,
+ attr_merge_one( e, mi->monitor_ad_description,
&int_2_level[ i ].s,
&int_2_level[ i ].n );
}
Modifications *modlist
)
{
+ struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
int rc = LDAP_OTHER;
int newlevel = ldap_syslog;
Attribute *save_attrs;
/*
* only the monitor description attribute can be modified
*/
- } else if ( mod->sm_desc != monitor_ad_desc ) {
+ } else if ( mod->sm_desc != mi->monitor_ad_description ) {
rc = LDAP_UNWILLING_TO_PERFORM;
break;
}
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
Attribute *a;
char buf[16];
- a = attr_find( e->e_attrs, monitor_ad_desc );
+ a = attr_find( e->e_attrs, mi->monitor_ad_description );
if ( a == NULL ) {
return( -1 );
}
}
snprintf( buf, sizeof( buf ), "%s=%d", str, num );
- if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
+ a = attr_find( e->e_attrs, mi->monitor_ad_description );
+ if ( a != NULL ) {
for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
if ( strncmp( b[0].bv_val, str, strlen( str ) ) == 0 ) {
free( b[0].bv_val );
bv.bv_val = buf;
bv.bv_len = strlen( buf );
- attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e, mi->monitor_ad_description,
+ &bv, NULL );
}
return( 0 );
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
bv.bv_val = "0";
bv.bv_len = 1;
- attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_one( e, mi->monitor_ad_description, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
Attribute *a;
char buf[16];
- a = attr_find( e->e_attrs, monitor_ad_desc );
+ a = attr_find( e->e_attrs, mi->monitor_ad_description );
if ( a == NULL ) {
return( -1 );
}
bv.bv_val = buf;
bv.bv_len = strlen( bv.bv_val );
- attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e, mi->monitor_ad_description, &bv, NULL );
monitor_cache_release( mi, e );
snprintf( buf, sizeof( buf ), "backload=%d",
ldap_pvt_thread_pool_backload( &connection_pool ) );
- if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
-
+ a = attr_find( e->e_attrs, mi->monitor_ad_description );
+ if ( a != NULL ) {
for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
if ( strncmp( b[0].bv_val, "backload=",
sizeof( "backload=" ) - 1 ) == 0 ) {
bv.bv_val = buf;
bv.bv_len = strlen( buf );
- attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL );
+ attr_merge_normalize_one( e, mi->monitor_ad_description,
+ &bv, NULL );
}
return( 0 );