/*
* Config parameters
*/
- struct berval l;
+ struct berval mi_l;
+ struct berval mi_startTime; /* don't free it */
/*
* Specific schema entities
AttributeDescription *ad_monitorConnectionAuthzDN;
AttributeDescription *ad_monitorConnectionLocalAddress;
AttributeDescription *ad_monitorConnectionPeerAddress;
+ AttributeDescription *ad_monitorTimestamp;
/*
* Generic description attribute
"dn: cn=Backend %d,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Backend %d\n",
+ "cn: Backend %d\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
i,
monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
- i );
+ i,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"dn: cn=Total,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Total\n",
+ "cn: Total\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"dn: cn=Current,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Current\n",
+ "cn: Current\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_CONN].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
Entry *e;
+ struct tm *ctm;
+ char ctmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+ struct tm *mtm;
+ char mtmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+
assert( c != NULL );
assert( ep != NULL );
+ ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#ifdef HACK_LOCAL_TIME
+ ctm = localtime( &c->c_starttime );
+ lutil_localtime( ctmbuf, sizeof( ctmbuf ), ctm, -timezone );
+ mtm = localtime( &c->c_activitytime );
+ lutil_localtime( mtmbuf, sizeof( mtmbuf ), mtm, -timezone );
+#else /* !HACK_LOCAL_TIME */
+ ctm = gmtime( &c->c_starttime );
+ lutil_gentime( ctmbuf, sizeof( ctmbuf ), ctm );
+ mtm = gmtime( &c->c_activitytime );
+ lutil_gentime( mtmbuf, sizeof( mtmbuf ), mtm );
+#endif /* !HACK_LOCAL_TIME */
+ ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+
snprintf( buf, sizeof( buf ),
"dn: cn=" CONN_CN_PREFIX " %ld,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: " CONN_CN_PREFIX " %ld\n",
+ "cn: " CONN_CN_PREFIX " %ld\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
c->c_connid, monitor_subsys[SLAPD_MONITOR_CONN].mss_dn.bv_val,
mi->oc_monitorConnection->soc_cname.bv_val,
mi->oc_monitorConnection->soc_cname.bv_val,
- c->c_connid );
+ c->c_connid,
+ ctmbuf, mtmbuf );
+
e = str2entry( buf );
if ( e == NULL) {
Entry *e, *e_database, *e_tmp;
int i;
struct monitorentrypriv *mp;
- const char *text = NULL;
assert( be != NULL );
"structuralObjectClass: %s\n"
"cn: Database %d\n"
"description: This object contains the type of the database.\n"
- "%s: %s",
+ "%s: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
i,
monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
i,
mi->ad_monitoredInfo->ad_cname.bv_val,
- be->bd_info->bi_type );
+ be->bd_info->bi_type,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
#include <stdio.h>
#include <ac/string.h>
+#include <lutil.h>
#include "slap.h"
#include "lber_pvt.h"
#include "back-monitor.h"
"NO-USER-MODIFICATION "
"USAGE directoryOperation )",
offsetof(struct monitorinfo, ad_monitorConnectionPeerAddress) },
+ { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 "
+ "NAME 'monitorTimestamp' "
+ "DESC 'monitor timestamp' "
+ "EQUALITY generalizedTimeMatch "
+ "ORDERING generalizedTimeOrderingMatch "
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
+ "SINGLE-VALUE )",
+ offsetof(struct monitorinfo, ad_monitorTimestamp) },
{ NULL, NULL, -1 }
};
+ struct tm *tms;
+ static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+
+ /*
+ * Start
+ */
+ ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#ifdef HACK_LOCAL_TIME
+ tms = localtime( &starttime );
+ lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
+#else /* !HACK_LOCAL_TIME */
+ tms = gmtime( &starttime );
+ lutil_gentime( tmbuf, sizeof(tmbuf), tms );
+#endif /* !HACK_LOCAL_TIME */
+ ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+
+ mi->mi_startTime.bv_val = tmbuf;
+ mi->mi_startTime.bv_len = strlen( tmbuf );
+
for ( i = 0; mat[i].name; i++ ) {
- LDAPAttributeType *at;
- int code;
- const char *err;
- AttributeDescription **ad;
+ LDAPAttributeType *at;
+ int code;
+ const char *err;
+ AttributeDescription **ad;
at = ldap_str2attributetype( mat[i].schema, &code,
&err, LDAP_SCHEMA_ALLOW_ALL );
"dn: %s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: %s\n",
+ "cn: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[ i ].mss_dn.bv_val,
mi->oc_monitorContainer->soc_cname.bv_val,
mi->oc_monitorContainer->soc_cname.bv_val,
- monitor_subsys[ i ].mss_name );
+ monitor_subsys[ i ].mss_name,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
"cn: Monitor\n"
"%s: This subtree contains monitoring/managing objects.\n"
"%s: This object contains information about this server.\n"
- "%s: createTimeStamp reflects the time this server instance was created.\n"
- "%s: modifyTimeStamp reflects the current time.\n",
+ "%s: createTimestamp reflects the time this server instance was created.\n"
+ "%s: modifyTimestamp reflects the current time.\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
mi->oc_monitorServer->soc_cname.bv_val,
mi->oc_monitorServer->soc_cname.bv_val,
mi->ad_description->ad_cname.bv_val,
mi->ad_description->ad_cname.bv_val,
mi->ad_description->ad_cname.bv_val,
- mi->ad_description->ad_cname.bv_val );
+ mi->ad_description->ad_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL) {
return( -1 );
}
- if ( mi->l.bv_len ) {
+ if ( mi->mi_l.bv_len ) {
AttributeDescription *ad = NULL;
const char *text = NULL;
return( -1 );
}
- if ( attr_merge_normalize_one( e, ad, &mi->l, NULL ) ) {
+ if ( attr_merge_normalize_one( e, ad, &mi->mi_l, NULL ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, CRIT,
"unable to add locality to '%s' entry\n",
return 1;
}
- ber_str2bv( argv[ 1 ], 0, 1, &mi->l );
+ ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_l );
} else {
#ifdef NEW_LOGGING
"structuralObjectClass: %s\n"
"cn: Listener %d\n"
"%s: %s\n"
- "labeledURI: %s",
+ "labeledURI: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
i,
monitor_subsys[SLAPD_MONITOR_LISTENER].mss_dn.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
i,
mi->ad_monitorConnectionLocalAddress->ad_cname.bv_val,
l[i]->sl_name.bv_val,
- l[i]->sl_url.bv_val );
+ l[i]->sl_url.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
/* set the new debug level */
if ( rc == LDAP_SUCCESS ) {
- const char *text;
- static char textbuf[ BACKMONITOR_BUFSIZE ];
+ const char *text;
+ static char textbuf[ BACKMONITOR_BUFSIZE ];
/* check for abandon */
if ( op->o_abandon ) {
BER_BVC( "Compare" ),
BER_BVC( "Search" ),
BER_BVC( "Abandon" ),
- BER_BVC( "Extended" )
+ BER_BVC( "Extended" ),
+ { 0, NULL }
};
int
"structuralObjectClass: %s\n"
"cn: %s\n"
"%s: 0\n"
- "%s: 0\n",
+ "%s: 0\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
bv_op[ i ].bv_val,
monitor_subsys[SLAPD_MONITOR_OPS].mss_dn.bv_val,
mi->oc_monitorOperation->soc_cname.bv_val,
mi->oc_monitorOperation->soc_cname.bv_val,
bv_op[ i ].bv_val,
mi->ad_monitorOpInitiated->ad_cname.bv_val,
- mi->ad_monitorOpCompleted->ad_cname.bv_val );
+ mi->ad_monitorOpCompleted->ad_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
long nInitiated = -1, nCompleted = -1;
char *rdnvalue;
int i;
- ber_len_t len;
Attribute *a;
char buf[] = "+9223372036854775807L";
rdnvalue = e->e_dn + ( sizeof( "cn=" ) - 1 );
for (i = 0; i < SLAP_OP_LAST; i++ ) {
- len = bv_op[ i ].bv_len;
-
- if ( strncmp( rdnvalue, bv_op[ i ].bv_val, len ) == 0 ) {
+ if ( strncmp( rdnvalue, bv_op[ i ].bv_val,
+ bv_op[ i ].bv_len ) == 0 ) {
nInitiated = num_ops_initiated_[ i ];
nCompleted = num_ops_completed_[ i ];
break;
"dn: cn=Read,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Read\n",
+ "cn: Read\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_RWW].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"dn: cn=Write,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Write\n",
+ "cn: Write\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_RWW].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
int type = RWW_NONE;
Attribute *a;
- struct berval *b = NULL;
char buf[] = "+9223372036854775807L";
-
- char *str = NULL;
long num = 0;
assert( mi != NULL );
"dn: cn=Entries,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Entries\n",
+ "cn: Entries\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"dn: cn=Referrals,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Referrals\n",
+ "cn: Referrals\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"dn: cn=PDU,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: PDU\n",
+ "cn: PDU\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"dn: cn=Bytes,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: Bytes\n",
+ "cn: Bytes\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
mi->oc_monitorCounterObject->soc_cname.bv_val,
- mi->oc_monitorCounterObject->soc_cname.bv_val );
+ mi->oc_monitorCounterObject->soc_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
#include "proto-slap.h"
#include "back-monitor.h"
-#ifdef HACK_LOCAL_TIME
-static int
-local_time( const struct tm *ztm, long delta, char *buf, size_t len );
-#endif /* HACK_LOCAL_TIME */
-
int
monitor_subsys_time_init(
BackendDB *be
Entry *e, *e_tmp, *e_time;
struct monitorentrypriv *mp;
char buf[ BACKMONITOR_BUFSIZE ];
- struct tm *tms;
- char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
-
- /*
- * Note: ltmbuf, ltm are used only if HACK_LOCAL_TIME is defined
- */
assert( be != NULL );
e_tmp = NULL;
- /*
- * Start
- */
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
-#ifdef HACK_LOCAL_TIME
- tms = localtime( &starttime );
- local_time( tms, -timezone, tmbuf, sizeof( tmbuf ) );
-#else /* !HACK_LOCAL_TIME */
- tms = gmtime( &starttime );
- lutil_gentime( tmbuf, sizeof(tmbuf), tms );
-#endif /* !HACK_LOCAL_TIME */
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
snprintf( buf, sizeof( buf ),
"dn: cn=Start,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
"cn: Start\n"
- "createTimestamp: %s",
+ "%s: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_TIME].mss_dn.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
- tmbuf );
+ mi->ad_monitorTimestamp->ad_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
"objectClass: %s\n"
"structuralObjectClass: %s\n"
"cn: Current\n"
+ "%s: %s\n"
"createTimestamp: %s\n"
"modifyTimestamp: %s\n",
monitor_subsys[SLAPD_MONITOR_TIME].mss_dn.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
mi->oc_monitoredObject->soc_cname.bv_val,
- tmbuf, tmbuf );
+ mi->ad_monitorTimestamp->ad_cname.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
e = str2entry( buf );
if ( e == NULL ) {
)
{
struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
- char stmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ],
- ctmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
- struct tm *stm, *ctm;
- Attribute *a;
- ber_len_t len;
-
- static int init_start = 0, init_current = 0;
-#define ENTRY_TIME 0
-#define ENTRY_START 1
-#define ENTRY_CURRENT 2
- int entry = ENTRY_TIME;
assert( mi );
assert( e );
- if ( strncmp( e->e_nname.bv_val, "cn=start",
- sizeof("cn=start")-1 ) == 0 ) {
- entry = ENTRY_START;
- if ( init_start == 1 ) {
- return( 0 );
- }
+ if ( strncmp( e->e_nname.bv_val, "cn=current",
+ sizeof("cn=current") - 1 ) == 0 ) {
+ struct tm *tm;
+ char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+ Attribute *a;
+ ber_len_t len;
+ time_t currtime;
- } else if ( strncmp( e->e_nname.bv_val, "cn=current",
- sizeof("cn=current")-1 ) == 0 ) {
- entry = ENTRY_CURRENT;
- }
-
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
- if ( init_start == 0 ) {
-#ifdef HACK_LOCAL_TIME
- stm = localtime( &starttime );
- local_time( stm, -timezone, stmbuf, sizeof( stmbuf ) );
-#else /* !HACK_LOCAL_TIME */
- stm = gmtime( &starttime );
- lutil_gentime( stmbuf, sizeof( stmbuf ), stm );
-#endif /* !HACK_LOCAL_TIME */
- }
+ currtime = slap_get_time();
- if ( entry == ENTRY_CURRENT ) {
- time_t currentTime = slap_get_time();
+ ldap_pvt_thread_mutex_lock( &gmtime_mutex );
#ifdef HACK_LOCAL_TIME
- ctm = localtime( ¤tTime );
- local_time( ctm, -timezone, ctmbuf, sizeof( ctmbuf ) );
+ tm = localtime( &currtime );
+ lutil_localtime( tmbuf, sizeof( tmbuf ), tm, -timezone );
#else /* !HACK_LOCAL_TIME */
- ctm = gmtime( ¤tTime );
- lutil_gentime( ctmbuf, sizeof( ctmbuf ), ctm );
+ tm = gmtime( &currtime );
+ lutil_gentime( tmbuf, sizeof( tmbuf ), tm );
#endif /* !HACK_LOCAL_TIME */
- }
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+ ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
- if ( ( entry == ENTRY_START && init_start == 0 )
- || ( entry == ENTRY_CURRENT && init_current == 0 ) ) {
- a = attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp );
- if ( a == NULL ) {
- return( -1 );
- }
-
- len = strlen( stmbuf );
- assert( len == a->a_vals[0].bv_len );
- AC_MEMCPY( a->a_vals[0].bv_val, stmbuf, len );
-
- if ( entry == ENTRY_START ) {
- init_start = 1;
- } else if ( entry == ENTRY_CURRENT ) {
- init_current = 1;
- }
- }
+ len = strlen( tmbuf );
- if ( entry == ENTRY_CURRENT ) {
- a = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp );
+ a = attr_find( e->e_attrs, mi->ad_monitorTimestamp );
if ( a == NULL ) {
return( -1 );
}
- len = strlen( ctmbuf );
assert( len == a->a_vals[0].bv_len );
- AC_MEMCPY( a->a_vals[0].bv_val, ctmbuf, len );
+ AC_MEMCPY( a->a_vals[0].bv_val, tmbuf, len );
}
return( 0 );
}
-#ifdef HACK_LOCAL_TIME
-/*
- * assumes gmtime_mutex is locked
- */
-static int
-local_time( const struct tm *ltm, long delta, char *buf, size_t len )
-{
- char *p;
-
- if ( len < 20 ) {
- return -1;
- }
- strftime( buf, len, "%Y%m%d%H%M%S", ltm );
-
- p = buf + 14;
-
- if ( delta < 0 ) {
- p[ 0 ] = '-';
- delta = -delta;
- } else {
- p[ 0 ] = '+';
- }
- p++;
-
- snprintf( p, len - 15, "%02ld%02ld", delta / 3600, delta % 3600 );
-
- return 0;
-}
-#endif /* HACK_LOCAL_TIME */
-