mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 16:19:35 -05:00
more cache monitoring (ITS#5178)
This commit is contained in:
parent
a688867cae
commit
afec8d12ad
1 changed files with 82 additions and 5 deletions
|
|
@ -251,6 +251,7 @@ static int privDB_cid;
|
||||||
static AttributeDescription *ad_queryId, *ad_cachedQueryURL;
|
static AttributeDescription *ad_queryId, *ad_cachedQueryURL;
|
||||||
|
|
||||||
#ifdef PCACHE_MONITOR
|
#ifdef PCACHE_MONITOR
|
||||||
|
static AttributeDescription *ad_numQueries, *ad_numEntries;
|
||||||
static ObjectClass *oc_olmPCache;
|
static ObjectClass *oc_olmPCache;
|
||||||
#endif /* PCACHE_MONITOR */
|
#endif /* PCACHE_MONITOR */
|
||||||
|
|
||||||
|
|
@ -285,6 +286,24 @@ static struct {
|
||||||
"NO-USER-MODIFICATION "
|
"NO-USER-MODIFICATION "
|
||||||
"USAGE directoryOperation )",
|
"USAGE directoryOperation )",
|
||||||
&ad_cachedQueryURL },
|
&ad_cachedQueryURL },
|
||||||
|
#ifdef PCACHE_MONITOR
|
||||||
|
{ "( PCacheAttributes:3 "
|
||||||
|
"NAME 'pcacheNumQueries' "
|
||||||
|
"DESC 'Number of cached queries' "
|
||||||
|
"EQUALITY integerMatch "
|
||||||
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
|
||||||
|
"NO-USER-MODIFICATION "
|
||||||
|
"USAGE directoryOperation )",
|
||||||
|
&ad_numQueries },
|
||||||
|
{ "( PCacheAttributes:4 "
|
||||||
|
"NAME 'pcacheNumEntries' "
|
||||||
|
"DESC 'Number of cached entries' "
|
||||||
|
"EQUALITY integerMatch "
|
||||||
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
|
||||||
|
"NO-USER-MODIFICATION "
|
||||||
|
"USAGE directoryOperation )",
|
||||||
|
&ad_numEntries },
|
||||||
|
#endif /* PCACHE_MONITOR */
|
||||||
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
@ -300,6 +319,8 @@ static struct {
|
||||||
"SUP top AUXILIARY "
|
"SUP top AUXILIARY "
|
||||||
"MAY ( "
|
"MAY ( "
|
||||||
"pcacheQueryURL "
|
"pcacheQueryURL "
|
||||||
|
"$ pcacheNumQueries "
|
||||||
|
"$ pcacheNumEntries "
|
||||||
" ) )",
|
" ) )",
|
||||||
&oc_olmPCache },
|
&oc_olmPCache },
|
||||||
#endif /* PCACHE_MONITOR */
|
#endif /* PCACHE_MONITOR */
|
||||||
|
|
@ -5176,8 +5197,6 @@ pcache_monitor_update(
|
||||||
CachedQuery *qc;
|
CachedQuery *qc;
|
||||||
BerVarray vals = NULL;
|
BerVarray vals = NULL;
|
||||||
|
|
||||||
assert( ad_cachedQueryURL != NULL );
|
|
||||||
|
|
||||||
attr_delete( &e->e_attrs, ad_cachedQueryURL );
|
attr_delete( &e->e_attrs, ad_cachedQueryURL );
|
||||||
if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || ad_inlist( ad_cachedQueryURL, rs->sr_attrs ) )
|
if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || ad_inlist( ad_cachedQueryURL, rs->sr_attrs ) )
|
||||||
&& qm->templates != NULL )
|
&& qm->templates != NULL )
|
||||||
|
|
@ -5201,6 +5220,36 @@ pcache_monitor_update(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Attribute *a;
|
||||||
|
char *buf[ SLAP_TEXT_BUFLEN ];
|
||||||
|
struct berval bv;
|
||||||
|
|
||||||
|
/* number of cached queries */
|
||||||
|
a = attr_find( e->e_attrs, ad_numQueries );
|
||||||
|
assert( a != NULL );
|
||||||
|
|
||||||
|
bv.bv_val = buf;
|
||||||
|
bv.bv_len = snprintf( buf, sizeof( buf ), "%lu", cm->num_cached_queries );
|
||||||
|
|
||||||
|
if ( a->a_nvals != a->a_vals ) {
|
||||||
|
ber_bvreplace( &a->a_nvals[ 0 ], &bv );
|
||||||
|
}
|
||||||
|
ber_bvreplace( &a->a_vals[ 0 ], &bv );
|
||||||
|
|
||||||
|
/* number of cached entries */
|
||||||
|
a = attr_find( e->e_attrs, ad_numEntries );
|
||||||
|
assert( a != NULL );
|
||||||
|
|
||||||
|
bv.bv_val = buf;
|
||||||
|
bv.bv_len = snprintf( buf, sizeof( buf ), "%d", cm->cur_entries );
|
||||||
|
|
||||||
|
if ( a->a_nvals != a->a_vals ) {
|
||||||
|
ber_bvreplace( &a->a_nvals[ 0 ], &bv );
|
||||||
|
}
|
||||||
|
ber_bvreplace( &a->a_vals[ 0 ], &bv );
|
||||||
|
}
|
||||||
|
|
||||||
return SLAP_CB_CONTINUE;
|
return SLAP_CB_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5240,6 +5289,22 @@ pcache_monitor_free(
|
||||||
textbuf, sizeof( textbuf ) );
|
textbuf, sizeof( textbuf ) );
|
||||||
/* don't care too much about return code... */
|
/* don't care too much about return code... */
|
||||||
|
|
||||||
|
/* remove attrs */
|
||||||
|
mod.sm_values = NULL;
|
||||||
|
mod.sm_desc = ad_numQueries;
|
||||||
|
mod.sm_numvals = 0;
|
||||||
|
rc = modify_delete_values( e, &mod, 1, &text,
|
||||||
|
textbuf, sizeof( textbuf ) );
|
||||||
|
/* don't care too much about return code... */
|
||||||
|
|
||||||
|
/* remove attrs */
|
||||||
|
mod.sm_values = NULL;
|
||||||
|
mod.sm_desc = ad_numEntries;
|
||||||
|
mod.sm_numvals = 0;
|
||||||
|
rc = modify_delete_values( e, &mod, 1, &text,
|
||||||
|
textbuf, sizeof( textbuf ) );
|
||||||
|
/* don't care too much about return code... */
|
||||||
|
|
||||||
return SLAP_CB_CONTINUE;
|
return SLAP_CB_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5310,7 +5375,7 @@ pcache_monitor_db_open( BackendDB *be )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* alloc as many as required (plus 1 for objectClass) */
|
/* alloc as many as required (plus 1 for objectClass) */
|
||||||
a = attrs_alloc( 1 + 0 );
|
a = attrs_alloc( 1 + 2 );
|
||||||
if ( a == NULL ) {
|
if ( a == NULL ) {
|
||||||
rc = 1;
|
rc = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
@ -5320,6 +5385,18 @@ pcache_monitor_db_open( BackendDB *be )
|
||||||
attr_valadd( a, &oc_olmPCache->soc_cname, NULL, 1 );
|
attr_valadd( a, &oc_olmPCache->soc_cname, NULL, 1 );
|
||||||
next = a->a_next;
|
next = a->a_next;
|
||||||
|
|
||||||
|
{
|
||||||
|
struct berval bv = BER_BVC( "0" );
|
||||||
|
|
||||||
|
next->a_desc = ad_numQueries;
|
||||||
|
attr_valadd( next, &bv, NULL, 1 );
|
||||||
|
next = next->a_next;
|
||||||
|
|
||||||
|
next->a_desc = ad_numEntries;
|
||||||
|
attr_valadd( next, &bv, NULL, 1 );
|
||||||
|
next = next->a_next;
|
||||||
|
}
|
||||||
|
|
||||||
cb = ch_calloc( sizeof( monitor_callback_t ), 1 );
|
cb = ch_calloc( sizeof( monitor_callback_t ), 1 );
|
||||||
cb->mc_update = pcache_monitor_update;
|
cb->mc_update = pcache_monitor_update;
|
||||||
cb->mc_free = pcache_monitor_free;
|
cb->mc_free = pcache_monitor_free;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue