]> git.sur5r.net Git - openldap/commitdiff
explode connection monitored info into dedicated attributes
authorPierangelo Masarati <ando@openldap.org>
Wed, 27 Apr 2005 17:51:54 +0000 (17:51 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 27 Apr 2005 17:51:54 +0000 (17:51 +0000)
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/init.c

index c98faa1c550c25b7e3b7710d87733aae5901638b..115d0246789a8db3ff930e3178bb511935ff7710 100644 (file)
@@ -108,6 +108,19 @@ typedef struct monitor_info_t {
        AttributeDescription    *mi_ad_monitorConnectionPeerAddress;
        AttributeDescription    *mi_ad_monitorTimestamp;
        AttributeDescription    *mi_ad_monitorOverlay;
+       AttributeDescription    *mi_ad_monitorConnectionProtocol;
+       AttributeDescription    *mi_ad_monitorConnectionOpsReceived;
+       AttributeDescription    *mi_ad_monitorConnectionOpsExecuting;
+       AttributeDescription    *mi_ad_monitorConnectionOpsPending;
+       AttributeDescription    *mi_ad_monitorConnectionOpsCompleted;
+       AttributeDescription    *mi_ad_monitorConnectionGet;
+       AttributeDescription    *mi_ad_monitorConnectionRead;
+       AttributeDescription    *mi_ad_monitorConnectionWrite;
+       AttributeDescription    *mi_ad_monitorConnectionMask;
+       AttributeDescription    *mi_ad_monitorConnectionListener;
+       AttributeDescription    *mi_ad_monitorConnectionPeerDomain;
+       AttributeDescription    *mi_ad_monitorConnectionStartTime;
+       AttributeDescription    *mi_ad_monitorConnectionActivityTime;
 
        /*
         * Generic description attribute
@@ -254,7 +267,7 @@ typedef struct monitor_subsys_t {
 extern BackendDB *be_monitor;
 
 /* increase this bufsize if entries in string form get too big */
-#define BACKMONITOR_BUFSIZE    1024
+#define BACKMONITOR_BUFSIZE    8192
 
 extern int
 monitor_back_register_entry(
index e6a240990dd9a78faf8b4e836449eb32510246b7..41c95343877d34414694bc6b348f7440915aba4e 100644 (file)
@@ -285,11 +285,74 @@ conn_create(
        ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
 #endif
 
+#ifndef HAVE_GMTIME_R
+       ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#endif
+
+#ifdef HAVE_GMTIME_R
+       ltm = gmtime_r( &c->c_starttime, &tm_buf );
+#else
+       ltm = gmtime( &c->c_starttime );
+#endif
+       lutil_gentime( buf2, sizeof( buf2 ), ltm );
+
+#ifdef HAVE_GMTIME_R
+       ltm = gmtime_r( &c->c_activitytime, &tm_buf );
+#else
+       ltm = gmtime( &c->c_activitytime );
+#endif
+       lutil_gentime( buf3, sizeof( buf3 ), ltm );
+
+#ifndef HAVE_GMTIME_R
+       ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif /* HAVE_GMTIME_R */
+
        snprintf( buf, sizeof( buf ),
                "dn: cn=Connection %ld,%s\n"
                "objectClass: %s\n"
                "structuralObjectClass: %s\n"
                "cn: Connection %ld\n"
+               
+               /* NOTE: this will disappear, as the exploded data
+                * has been moved to dedicated attributes */
+               "%s: "
+                       "%ld "
+                       ": %ld "
+                       ": %ld/%ld/%ld/%ld "
+                       ": %ld/%ld/%ld "
+                       ": %s%s%s%s%s%s "
+                       ": %s "
+                       ": %s "
+                       ": %s "
+                       ": %s "
+                       ": %s "
+                       ": %s "
+                       ": %s\n"
+
+               "%s: %lu\n"
+               "%s: %ld\n"
+
+               "%s: %ld\n"
+               "%s: %ld\n"
+               "%s: %ld\n"
+               "%s: %ld\n"
+
+               "%s: %ld\n"
+               "%s: %ld\n"
+               "%s: %ld\n"
+
+               "%s: %s%s%s%s%s%s\n"
+
+               "%s: %s\n"
+
+               "%s: %s\n"
+               "%s: %s\n"
+               "%s: %s\n"
+               "%s: %s\n"
+
+               "%s: %s\n"
+               "%s: %s\n"
+
                "creatorsName: %s\n"
                "modifiersName: %s\n"
                "createTimestamp: %s\n"
@@ -298,6 +361,79 @@ conn_create(
                mi->mi_oc_monitorConnection->soc_cname.bv_val,
                mi->mi_oc_monitorConnection->soc_cname.bv_val,
                c->c_connid,
+
+               mi->mi_ad_monitoredInfo->ad_cname.bv_val,
+                       c->c_connid,
+                       (long) c->c_protocol,
+                       c->c_n_ops_received, c->c_n_ops_executing,
+                               c->c_n_ops_pending, c->c_n_ops_completed,
+                       
+                       /* add low-level counters here */
+                       c->c_n_get, c->c_n_read, c->c_n_write,
+                       
+                       c->c_currentber ? "r" : "",
+                       c->c_writewaiter ? "w" : "",
+                       LDAP_STAILQ_EMPTY( &c->c_ops ) ? "" : "x",
+                       LDAP_STAILQ_EMPTY( &c->c_pending_ops ) ? "" : "p",
+                       connection_state2str( c->c_conn_state ),
+                       c->c_sasl_bind_in_progress ? "S" : "",
+                       
+                       c->c_dn.bv_len ? c->c_dn.bv_val : SLAPD_ANONYMOUS,
+                       
+                       c->c_listener_url.bv_val,
+                       c->c_peer_domain.bv_val,
+                       c->c_peer_name.bv_val,
+                       c->c_sock_name.bv_val,
+                       
+                       buf2,
+                       buf3,
+
+               mi->mi_ad_monitorConnectionNumber->ad_cname.bv_val,
+                       c->c_connid,
+               mi->mi_ad_monitorConnectionProtocol->ad_cname.bv_val,
+                       (long)c->c_protocol,
+
+               mi->mi_ad_monitorConnectionOpsReceived->ad_cname.bv_val,
+                       c->c_n_ops_received,
+               mi->mi_ad_monitorConnectionOpsExecuting->ad_cname.bv_val,
+                       c->c_n_ops_executing,
+               mi->mi_ad_monitorConnectionOpsPending->ad_cname.bv_val,
+                       c->c_n_ops_pending,
+               mi->mi_ad_monitorConnectionOpsCompleted->ad_cname.bv_val,
+                       c->c_n_ops_completed,
+
+               mi->mi_ad_monitorConnectionGet->ad_cname.bv_val,
+                       c->c_n_get,
+               mi->mi_ad_monitorConnectionRead->ad_cname.bv_val,
+                       c->c_n_read,
+               mi->mi_ad_monitorConnectionWrite->ad_cname.bv_val,
+                       c->c_n_write,
+
+               mi->mi_ad_monitorConnectionMask->ad_cname.bv_val,
+                       c->c_currentber ? "r" : "",
+                       c->c_writewaiter ? "w" : "",
+                       LDAP_STAILQ_EMPTY( &c->c_ops ) ? "" : "x",
+                       LDAP_STAILQ_EMPTY( &c->c_pending_ops ) ? "" : "p",
+                       connection_state2str( c->c_conn_state ),
+                       c->c_sasl_bind_in_progress ? "S" : "",
+               
+               mi->mi_ad_monitorConnectionAuthzDN->ad_cname.bv_val,
+                       c->c_dn.bv_len ? c->c_dn.bv_val : SLAPD_ANONYMOUS,
+
+               mi->mi_ad_monitorConnectionListener->ad_cname.bv_val,
+                       c->c_listener_url.bv_val,
+               mi->mi_ad_monitorConnectionPeerDomain->ad_cname.bv_val,
+                       c->c_peer_domain.bv_val,
+               mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
+                       c->c_peer_name.bv_val,
+               mi->mi_ad_monitorConnectionPeerAddress->ad_cname.bv_val,
+                       c->c_sock_name.bv_val,
+
+               mi->mi_ad_monitorConnectionStartTime->ad_cname.bv_val,
+                       buf2,
+               mi->mi_ad_monitorConnectionActivityTime->ad_cname.bv_val,
+                       buf3,
+
                mi->mi_creatorsName.bv_val,
                mi->mi_creatorsName.bv_val,
                ctmbuf,
@@ -315,88 +451,6 @@ conn_create(
                return( -1 );
        }
 
-#ifndef HAVE_GMTIME_R
-       ldap_pvt_thread_mutex_lock( &gmtime_mutex );
-#endif
-
-#ifdef HAVE_GMTIME_R
-       ltm = gmtime_r( &c->c_starttime, &tm_buf );
-#else
-       ltm = gmtime( &c->c_starttime );
-#endif
-       lutil_gentime( buf2, sizeof( buf2 ), ltm );
-
-#ifdef HAVE_GMTIME_R
-       ltm = gmtime_r( &c->c_activitytime, &tm_buf );
-#else
-       ltm = gmtime( &c->c_activitytime );
-#endif
-       lutil_gentime( buf3, sizeof( buf3 ), ltm );
-
-#ifndef HAVE_GMTIME_R
-       ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
-#endif /* HAVE_GMTIME_R */
-
-       /* monitored info */
-       sprintf( buf,
-               "%ld "
-               ": %ld "
-               ": %ld/%ld/%ld/%ld "
-               ": %ld/%ld/%ld "
-               ": %s%s%s%s%s%s "
-               ": %s "
-               ": %s "
-               ": %s "
-               ": %s "
-               ": %s "
-               ": %s "
-               ": %s",
-               c->c_connid,
-               (long) c->c_protocol,
-               c->c_n_ops_received, c->c_n_ops_executing,
-                       c->c_n_ops_pending, c->c_n_ops_completed,
-               
-               /* add low-level counters here */
-               c->c_n_get, c->c_n_read, c->c_n_write,
-               
-               c->c_currentber ? "r" : "",
-               c->c_writewaiter ? "w" : "",
-               LDAP_STAILQ_EMPTY( &c->c_ops ) ? "" : "x",
-               LDAP_STAILQ_EMPTY( &c->c_pending_ops ) ? "" : "p",
-               connection_state2str( c->c_conn_state ),
-               c->c_sasl_bind_in_progress ? "S" : "",
-               
-               c->c_dn.bv_len ? c->c_dn.bv_val : SLAPD_ANONYMOUS,
-               
-               c->c_listener_url.bv_val,
-               c->c_peer_domain.bv_val,
-               c->c_peer_name.bv_val,
-               c->c_sock_name.bv_val,
-               
-               buf2,
-               buf3
-               );
-
-       ber_str2bv( buf, 0, 0, &bv );
-       attr_merge_one( e, mi->mi_ad_monitoredInfo, &bv, &bv );
-
-       /* connection number */
-       snprintf( buf, sizeof( buf ), "%ld", c->c_connid );
-       ber_str2bv( buf, 0, 0, &bv );
-       attr_merge_one( e, mi->mi_ad_monitorConnectionNumber, &bv, &bv );
-
-       /* authz DN */
-       attr_merge_one( e, mi->mi_ad_monitorConnectionAuthzDN,
-                       &c->c_dn, &c->c_ndn );
-
-       /* local address */
-       attr_merge_one( e, mi->mi_ad_monitorConnectionLocalAddress,
-                       &c->c_sock_name, &c->c_sock_name );
-
-       /* peer address */
-       attr_merge_one( e, mi->mi_ad_monitorConnectionPeerAddress,
-                       &c->c_peer_name, &c->c_peer_name );
-
        mp = monitor_entrypriv_create();
        if ( mp == NULL ) {
                return -1;
index abbc20457b885e330a9092f13ac84c3a0162b782..65136ddcd2b4886a6d0f7e00ef8625e23168a69b 100644 (file)
@@ -1101,6 +1101,99 @@ monitor_back_db_init(
                        "DESC 'name of restricted operation for a given database' "
                        "SUP managedInfo )", SLAP_AT_HIDE,
                        offsetof(monitor_info_t, mi_ad_restrictedOperation ) },
+               { "monitorConnectionProtocol", "( 1.3.6.1.4.1.4203.666.1.39 "
+                       "NAME 'monitorConnectionProtocol' "
+                       "DESC 'monitor connection protocol' "
+                       "SUP monitoredInfo "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) },
+               { "monitorConnectionOpsReceived", "( 1.3.6.1.4.1.4203.666.1.40 "
+                       "NAME 'monitorConnectionOpsReceived' "
+                       "DESC 'monitor number of operations received by the connection' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) },
+               { "monitorConnectionOpsExecuting", "( 1.3.6.1.4.1.4203.666.1.41 "
+                       "NAME 'monitorConnectionOpsExecuting' "
+                       "DESC 'monitor number of operations in execution within the connection' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) },
+               { "monitorConnectionOpsPending", "( 1.3.6.1.4.1.4203.666.1.42 "
+                       "NAME 'monitorConnectionOpsPending' "
+                       "DESC 'monitor number of pending operations within the connection' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) },
+               { "monitorConnectionOpsCompleted", "( 1.3.6.1.4.1.4203.666.1.43 "
+                       "NAME 'monitorConnectionOpsCompleted' "
+                       "DESC 'monitor number of operations completed within the connection' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) },
+               { "monitorConnectionGet", "( 1.3.6.1.4.1.4203.666.1.44 "
+                       "NAME 'monitorConnectionGet' "
+                       "DESC 'monitor FIXME???' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionGet) },
+               { "monitorConnectionRead", "( 1.3.6.1.4.1.4203.666.1.45 "
+                       "NAME 'monitorConnectionRead' "
+                       "DESC 'monitor FIXME???' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionRead) },
+               { "monitorConnectionWrite", "( 1.3.6.1.4.1.4203.666.1.46 "
+                       "NAME 'monitorConnectionWrite' "
+                       "DESC 'monitor FIXME???' "
+                       "SUP monitorCounter "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) },
+               { "monitorConnectionMask", "( 1.3.6.1.4.1.4203.666.1.47 "
+                       "NAME 'monitorConnectionMask' "
+                       "DESC 'monitor connection mask' "
+                       "SUP monitoredInfo "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionMask) },
+               { "monitorConnectionListener", "( 1.3.6.1.4.1.4203.666.1.48 "
+                       "NAME 'monitorConnectionListener' "
+                       "DESC 'monitor connection listener' "
+                       "SUP monitoredInfo "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionListener) },
+               { "monitorConnectionPeerDomain", "( 1.3.6.1.4.1.4203.666.1.49 "
+                       "NAME 'monitorConnectionPeerDomain' "
+                       "DESC 'monitor connection peer domain' "
+                       "SUP monitoredInfo "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) },
+               { "monitorConnectionStartTime", "( 1.3.6.1.4.1.4203.666.1.50 "
+                       "NAME 'monitorConnectionStartTime' "
+                       "DESC 'monitor connection start time' "
+                       "SUP monitorTimestamp "
+                       "SINGLE-VALUE "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) },
+               { "monitorConnectionActivityTime", "( 1.3.6.1.4.1.4203.666.1.51 "
+                       "NAME 'monitorConnectionActivityTime' "
+                       "DESC 'monitor connection activity time' "
+                       "SUP monitorTimestamp "
+                       "SINGLE-VALUE "
+                       "NO-USER-MODIFICATION "
+                       "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
+                       offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) },
 #ifdef INTEGRATE_CORE_SCHEMA
                { NULL, NULL, 0, -1 },  /* description */
                { NULL, NULL, 0, -1 },  /* seeAlso */