You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by er...@apache.org on 2010/11/16 19:00:16 UTC
svn commit: r1035714 - in /trafficserver/plugins/stats: README stats.c
Author: ericb
Date: Tue Nov 16 18:00:16 2010
New Revision: 1035714
URL: http://svn.apache.org/viewvc?rev=1035714&view=rev
Log:
changes to the json stats plugin to simply look at request path rather than the host since we are now hooking at read_request
Modified:
trafficserver/plugins/stats/README
trafficserver/plugins/stats/stats.c
Modified: trafficserver/plugins/stats/README
URL: http://svn.apache.org/viewvc/trafficserver/plugins/stats/README?rev=1035714&r1=1035713&r2=1035714&view=diff
==============================================================================
--- trafficserver/plugins/stats/README (original)
+++ trafficserver/plugins/stats/README Tue Nov 16 18:00:16 2010
@@ -3,14 +3,8 @@ Compile:
Install:
sudo tsxs -o stats.so -i
-Add to the plugins.conf:
+Add to the plugin.conf:
stats.so
-Add to the remap.conf:
-
- regex_map http://[0-9.]+/_stats http://[stats]/_stats
-
-
-
start traffic server and visit http://IP:port/_stats
Modified: trafficserver/plugins/stats/stats.c
URL: http://svn.apache.org/viewvc/trafficserver/plugins/stats/stats.c?rev=1035714&r1=1035713&r2=1035714&view=diff
==============================================================================
--- trafficserver/plugins/stats/stats.c (original)
+++ trafficserver/plugins/stats/stats.c Tue Nov 16 18:00:16 2010
@@ -244,25 +244,25 @@ stats_origin(INKCont contp, INKEvent eve
stats_state *my_state;
INKHttpTxn txnp = (INKHttpTxn) edata;
INKMBuffer reqp;
- INKMLoc hdr_loc = NULL, field = NULL;
- int host_header_len;
- const char *host_header_ptr = NULL;
+ INKMLoc hdr_loc = NULL, url_loc = NULL;
INKEvent reenable = INK_EVENT_HTTP_CONTINUE;
INKDebug("istats", "in the read stuff");
if (!INKHttpTxnClientReqGet(txnp, &reqp, &hdr_loc))
goto cleanup;
-
- field = INKMimeHdrFieldFind(reqp, hdr_loc,
- INK_MIME_FIELD_HOST, INK_MIME_LEN_HOST);
- if(field) {
- if (INK_SUCCESS == INKMimeHdrFieldValueStringGet(reqp, hdr_loc, field, 0,
- &host_header_ptr, &host_header_len)) {
- if(host_header_len != 7 || memcmp(host_header_ptr, "[stats]", 7))
- goto notforme;
- }
+
+ url_loc = INKHttpHdrUrlGet(reqp, hdr_loc);
+
+ int path_len = 0;
+ const char * path = INKUrlPathGet(reqp,url_loc,&path_len);
+ INKDebug("istats","Path: %.*s",path_len,path);
+
+ if (! (path_len != 0 && path_len == 6 && !memcmp(path,"_stats",6)) ) {
+ goto notforme;
}
+
+ INKSkipRemappingSet(txnp,1); //not strictly necessary, but speed is everything these days
/* This is us -- register our intercept */
INKDebug("istats", "Intercepting request");
@@ -284,9 +284,9 @@ stats_origin(INKCont contp, INKEvent eve
notforme:
cleanup:
- if(host_header_ptr) INKHandleStringRelease(reqp, hdr_loc, host_header_ptr);
+ if(path) INKHandleStringRelease(reqp, url_loc, path);
+ if(url_loc) INKHandleMLocRelease(reqp, hdr_loc, url_loc);
if(hdr_loc) INKHandleMLocRelease(reqp, INK_NULL_MLOC, hdr_loc);
- if(field) INKHandleMLocRelease(reqp, INK_NULL_MLOC, field);
INKHttpTxnReenable(txnp, reenable);
return 0;