]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/monitor.c
fix substring_comp_candidates logic if intersection of candidates
[openldap] / servers / slapd / monitor.c
index c1ee2a993cfbfed78d48c018f14ab39272ed4400..855a2e8dc047852be6fd9064b114e79851f7c99a 100644 (file)
@@ -33,12 +33,10 @@ monitor_info( Connection *conn, Operation *op )
        int    nconns, nwritewaiters, nreadwaiters;
        struct tm       *ltm;
        char            *p;
-#ifdef LDAP_COUNTERS
-    int        i;
-    char       buf2[22]
+    char       buf2[22];
+    char       buf3[22];
        Connection *c;
        int                     connindex;
-#endif
     time_t             currenttime;
 
        vals[0] = &val;
@@ -70,7 +68,6 @@ monitor_info( Connection *conn, Operation *op )
        nwritewaiters = 0;
        nreadwaiters = 0;
 
-#ifdef LDAP_COUNTERS
        /* loop through the connections */
        for ( c = connection_first( &connindex );
                c != NULL;
@@ -88,19 +85,49 @@ monitor_info( Connection *conn, Operation *op )
 #ifndef LDAP_LOCALTIME
                ltm = gmtime( &c->c_starttime );
                strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
+
+               ltm = gmtime( &c->c_activitytime );
+               strftime( buf3, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
 #else
                ltm = localtime( &c->.c_starttime );
                strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
+
+               ltm = localtime( &c->c_activitytime );
+               strftime( buf3, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
 #endif
+
                ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
 
-               sprintf( buf, "%d : %s : %d : %d : %s : %s%s%s%s", i,
-                   buf2, c[i].c_n_ops_received, c[i].c_n_ops_completed,
-                   c[i].c_cdn ? c[i].c_cdn : "NULLDN",
-                   c[i].c_currentber ? "r" : "",
-                   c[i].c_writewaiter ? "w" : "",
-                   c[i].c_ops != NULL ? "x" : "",
-                   c[i].c_pending_ops != NULL ? "p" : ""
+               sprintf( buf,
+                       "%ld : %ld "
+                       ": %ld/%ld/%ld/%ld "
+                       ": %ld/%ld/%ld "
+                       ": %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" : "",
+                   c->c_ops != NULL ? "x" : "",
+                   c->c_pending_ops != NULL ? "p" : "",
+                       connection_state2str( c->c_conn_state ),
+                       c->c_bind_in_progress ? "S" : "",
+
+                   c->c_cdn ? c->c_cdn : "<anonymous>",
+                   c->c_client_addr ? c->c_client_addr : "unknown",
+                   c->c_client_name ? c->c_client_name : "unknown",
+
+                   buf2,
+                       buf3
                );
 
                val.bv_val = buf;
@@ -108,62 +135,73 @@ monitor_info( Connection *conn, Operation *op )
                attr_merge( e, "connection", vals );
        }
        connection_done(c);
-#endif
 
        sprintf( buf, "%d", nconns );
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "currentconnections", vals );
+       attr_merge( e, "currentConnections", vals );
 
        sprintf( buf, "%ld", connections_nextid() );
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "totalconnections", vals );
+       attr_merge( e, "totalConnections", vals );
 
-       sprintf( buf, "%d", dtblsize );
+       sprintf( buf, "%ld", (long) dtblsize );
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "dtablesize", vals );
+       attr_merge( e, "dTableSize", vals );
 
        sprintf( buf, "%d", nwritewaiters );
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "writewaiters", vals );
+       attr_merge( e, "writeWaiters", vals );
 
        sprintf( buf, "%d", nreadwaiters );
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "readwaiters", vals );
+       attr_merge( e, "readWaiters", vals );
 
-#ifdef LDAP_COUNTERS
        ldap_pvt_thread_mutex_lock(&num_ops_mutex);
        sprintf( buf, "%ld", num_ops_initiated );
        ldap_pvt_thread_mutex_unlock(&num_ops_mutex);
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "opsinitiated", vals );
+       attr_merge( e, "opsInitiated", vals );
 
        ldap_pvt_thread_mutex_lock(&num_ops_mutex);
        sprintf( buf, "%ld", num_ops_completed );
        ldap_pvt_thread_mutex_unlock(&num_ops_mutex);
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "opscompleted", vals );
+       attr_merge( e, "opsCompleted", vals );
 
        ldap_pvt_thread_mutex_lock(&num_sent_mutex);
        sprintf( buf, "%ld", num_entries_sent );
        ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "entriessent", vals );
+       attr_merge( e, "entriesSent", vals );
+
+       ldap_pvt_thread_mutex_lock(&num_sent_mutex);
+       sprintf( buf, "%ld", num_refs_sent );
+       ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
+       val.bv_val = buf;
+       val.bv_len = strlen( buf );
+       attr_merge( e, "referencesSent", vals );
+
+       ldap_pvt_thread_mutex_lock(&num_sent_mutex);
+       sprintf( buf, "%ld", num_pdu_sent );
+       ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
+       val.bv_val = buf;
+       val.bv_len = strlen( buf );
+       attr_merge( e, "pduSent", vals );
 
        ldap_pvt_thread_mutex_lock(&num_sent_mutex);
        sprintf( buf, "%ld", num_bytes_sent );
        ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
        val.bv_val = buf;
        val.bv_len = strlen( buf );
-       attr_merge( e, "bytessent", vals );
-#endif
+       attr_merge( e, "bytesSent", vals );
 
        currenttime = slap_get_time();
 
@@ -204,8 +242,10 @@ monitor_info( Connection *conn, Operation *op )
        attr_merge( e, "concurrency", vals );
 #endif
 
-       send_search_entry( &backends[0], conn, op, e, NULL, 0 );
-       send_ldap_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, 1 );
+       send_search_entry( &backends[0], conn, op, e,
+               NULL, 0, 1, NULL );
+       send_search_result( conn, op, LDAP_SUCCESS,
+               NULL, NULL, NULL, NULL, 1 );
 
        entry_free( e );
 }