This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch master
in repository 389-ds-base.
commit 4940c5fd06389267ed65156ada9a16170e5a5cea
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jul 12 12:00:57 2017 -0400
Ticket 48210 - Add IP addr and connid to monitor output
Description: Add the IP address and connection id to the "connection"
attribute under cn=monitor:
Previous "connection" format:
FD:DATE:OPS_INITIATED:OPS_COMPLETE:GET_BER:BIND_DN:MAX_THREAD_STATE:MAXTHREAD_COUNT:MAX_THREAD_BLOCKED
connection: 64:20170711175127Z:1:1:-:cn=dm:0:0:0
New "connection" format:
FD:DATE:OPS_INITIATED:OPS_COMPLETE:GET_BER:BIND_DN:MAX_THREAD_STATE:MAXTHREAD_COUNT:MAX_THREAD_BLOCKED:CONNID:ip=IP_ADDR
connection: 64:20170711175127Z:1:1:-:cn=dm:0:0:0:1:ip=127.0.0.1
connection: 65:20170711200508Z:2:1:-:cn=dm:0:0:0:5:ip=::1
https://pagure.io/389-ds-base/issue/48210
Reviewed by: firstyear(Thanks!)
---
ldap/servers/slapd/connection.c | 2 ++
ldap/servers/slapd/conntable.c | 35 ++++++++++++++++++++++++++---------
ldap/servers/slapd/slap.h | 1 +
3 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index d3b0f7e..ccd70ad 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -207,6 +207,7 @@ connection_cleanup(Connection *conn)
conn->c_isreplication_session = 0;
slapi_ch_free((void**)&conn->cin_addr );
slapi_ch_free((void**)&conn->cin_destaddr );
+ slapi_ch_free_string(&conn->c_ipaddr);
if ( conn->c_domain != NULL )
{
ber_bvecfree( conn->c_domain );
@@ -422,6 +423,7 @@ connection_reset(Connection* conn, int ns, PRNetAddr * from, int
fromLen __attri
* yet, which prevents us from getting the effective key length. */
conn->c_ssl_ssf = 0;
conn->c_local_ssf = 0;
+ conn->c_ipaddr = slapi_ch_strdup(str_ip);
}
/* Create a pool of threads for handling the operations */
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index 1c6757d..e36b94e 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -365,11 +365,20 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
if ( ct->c[i].c_sd != SLAPD_INVALID_SOCKET )
{
char buf2[20];
- int lendn = ct->c[i].c_dn ? strlen(ct->c[i].c_dn) : 6; /* "NULLDN" */
+ size_t lendn = ct->c[i].c_dn ? strlen(ct->c[i].c_dn) : 6; /* "NULLDN"
*/
+ size_t lenip = ct->c[i].c_ipaddr ? strlen(ct->c[i].c_ipaddr) : 0;
+ size_t lenconn = 1;
+ uint64_t connid = ct->c[i].c_connid;
char *bufptr = &buf[0];
char *newbuf = NULL;
int maxthreadstate = 0;
+ /* Get the connid length */
+ while (connid > 9) {
+ lenconn++;
+ connid /= 10;
+ }
+
if(ct->c[i].c_flags & CONN_FLAG_MAX_THREADS){
maxthreadstate = 1;
}
@@ -397,25 +406,33 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
maxthreadstate, ct->c[i].c_maxthreadscount,
ct->c[i].c_maxthreadsblocked);
- if ((lendn + strlen(maxthreadbuf)) > (BUFSIZ - 46)) {
+ if ((lenconn + lenip + lendn + strlen(maxthreadbuf)) > (BUFSIZ - 54)) {
/*
- * 46 = 4 for the "i" couter + 20 for buf2 +
- * 10 for c_opsinitiated + 10 for c_opscompleted +
- * 1 for c_gettingber + 1
+ * 54 = 8 for the colon separators +
+ * 6 for the "i" counter +
+ * 15 for buf2 (date) +
+ * 10 for c_opsinitiated +
+ * 10 for c_opscompleted +
+ * 1 for c_gettingber +
+ * 3 for "ip=" +
+ * 1 for NULL terminator
*/
- newbuf = (char *) slapi_ch_malloc(lendn + strlen(maxthreadbuf) + 46);
+ newbuf = (char *) slapi_ch_malloc(lenconn + lendn + lenip + strlen(maxthreadbuf) +
54);
bufptr = newbuf;
}
- sprintf( bufptr, "%d:%s:%d:%d:%s%s:%s:%s", i,
+ sprintf( bufptr, "%d:%s:%d:%d:%s%s:%s:%s:%lu:ip=%s",
+ i,
buf2,
ct->c[i].c_opsinitiated,
ct->c[i].c_opscompleted,
ct->c[i].c_gettingber ? "r" : "-",
"",
ct->c[i].c_dn ? ct->c[i].c_dn : "NULLDN",
- maxthreadbuf
- );
+ maxthreadbuf,
+ ct->c[i].c_connid,
+ ct->c[i].c_ipaddr
+ );
val.bv_val = bufptr;
val.bv_len = strlen( bufptr );
attrlist_merge( &e->e_attrs, "connection", vals );
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 5edaf43..d26a792 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1605,6 +1605,7 @@ typedef struct conn {
struct connection_table *c_ct; /* connection table that this connection belongs
to */
ns_thrpool_t *c_tp; /* thread pool for this connection */
int c_ns_close_jobs; /* number of current close jobs */
+ char *c_ipaddr; /* ip address str - used by monitor */
} Connection;
#define CONN_FLAG_SSL 1 /* Is this connection an SSL connection or not ?
* Used to direct I/O code when SSL is handled differently
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.