Hi all,
This patch add logging of the local TCP port used by transactions with
http servers
The new log format code is "%<lp"
In the case there are several server-side connections logs the port of
the last connection.
This is a Measurement Factory project.
Regards,
Christos
=== modified file 'src/HierarchyLogEntry.h'
--- src/HierarchyLogEntry.h 2009-08-23 09:30:49 +0000
+++ src/HierarchyLogEntry.h 2010-06-02 05:59:20 +0000
@@ -64,6 +64,7 @@
int64_t peer_response_time; ///< last peer response delay
timeval first_conn_start; ///< first connection use among all peers
int64_t total_response_time; ///< cumulative for all peers
+ u_short peer_local_port; //< local port of the last server-side connection
};
extern void hierarchyNote(HierarchyLogEntry *, hier_code, const char *);
=== modified file 'src/cf.data.pre'
--- src/cf.data.pre 2010-05-26 02:03:36 +0000
+++ src/cf.data.pre 2010-06-02 06:00:48 +0000
@@ -2611,6 +2611,7 @@
<A Server IP address or peer name
la Local IP address (http_port)
lp Local port number (http_port)
+ <lp Local port number of the last server or peer connection
sn Unique sequence number per log line entry
ts Seconds since epoch
tu subsecond time (milliseconds)
=== modified file 'src/forward.cc'
--- src/forward.cc 2010-05-26 00:13:11 +0000
+++ src/forward.cc 2010-06-02 05:56:48 +0000
@@ -854,6 +854,9 @@
comm_add_close_handler(fd, fwdServerClosedWrapper, this);
+ // TODO: Avoid this if %<lp is not used? F->local_port is often cached.
+ request->hier.peer_local_port = comm_local_port(fd);
+
dispatch();
return;
@@ -895,6 +898,8 @@
if (!fs->_peer)
origin_tries++;
+ request->hier.peer_local_port = comm_local_port(fd);
+
/*
* stats.conn_open is used to account for the number of
* connections that we have open to the peer, so we can limit
=== modified file 'src/log/access_log.cc'
--- src/log/access_log.cc 2010-05-28 21:56:27 +0000
+++ src/log/access_log.cc 2010-06-02 05:58:01 +0000
@@ -344,6 +344,7 @@
LFT_LOCAL_IP,
LFT_LOCAL_PORT,
/*LFT_LOCAL_NAME, */
+ LFT_PEER_LOCAL_PORT,
LFT_TIME_SECONDS_SINCE_EPOCH,
LFT_TIME_SUBSECOND,
@@ -505,6 +506,7 @@
{"la", LFT_LOCAL_IP},
{"lp", LFT_LOCAL_PORT},
/*{ "lA", LFT_LOCAL_NAME }, */
+ {"<lp", LFT_PEER_LOCAL_PORT},
{"ts", LFT_TIME_SECONDS_SINCE_EPOCH},
{"tu", LFT_TIME_SUBSECOND},
@@ -692,6 +694,14 @@
break;
+ case LFT_PEER_LOCAL_PORT:
+ if (al->hier.peer_local_port) {
+ outint = al->hier.peer_local_port;
+ doint = 1;
+ }
+
+ break;
+
case LFT_TIME_SECONDS_SINCE_EPOCH:
// some platforms store time in 32-bit, some 64-bit...
outoff = static_cast<int64_t>(current_time.tv_sec);
@@ -2081,7 +2091,8 @@
n_ichoices(0),
peer_reply_status(HTTP_STATUS_NONE),
peer_response_time(-1),
- total_response_time(-1)
+ total_response_time(-1),
+ peer_local_port(0)
{
memset(host, '\0', SQUIDHOSTNAMELEN);
memset(cd_host, '\0', SQUIDHOSTNAMELEN);