Documentation Source Text

Check-in [faec8e5df4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add an extra column to the logfile output from althttpd. The 16th column gives the number of characters in the request URI that contribute to the script name. This is useful with substr() in doing queries against specific CGI scripts.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:faec8e5df42ab81b41add290e795e34b25ec7c18
User & Date: drh 2013-12-16 20:13:25
Context
2013-12-16
21:30
In althttpd, keep track of wall-clock time in milliseconds, not seconds. And for the user and system times, be sure to subtract out the user and system times for prior requests on the same connection. check-in: 333c090d36 user: drh tags: trunk
20:13
Add an extra column to the logfile output from althttpd. The 16th column gives the number of characters in the request URI that contribute to the script name. This is useful with substr() in doing queries against specific CGI scripts. check-in: faec8e5df4 user: drh tags: trunk
17:01
Improvements to the althttpd logic that redirects to the base document when there are surplus pathname elements in the request URI. check-in: 452b6e3c75 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to misc/althttpd.c.

183
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198
199
200
201
...
215
216
217
218
219
220
221
222
223
224

225
226

227
228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
    time_t now;
    struct tm *pTm;
    struct rusage self, children;
    int waitStatus;
    char zDate[200];
    char *zRM = zRemoteUser ? zRemoteUser : "";

    if( zScript==0 || zScript[0]==0 ) zScript = "";

    if( zRemoteAddr==0 || zRemoteAddr[0]==0 ) zRemoteAddr = "";
    if( zHttpHost==0 || zHttpHost[0]==0 ) zHttpHost = "";
    if( zReferer==0 || zReferer[0]==0 ) zReferer = "";
    if( zAgent==0 || zAgent[0]==0 ) zAgent = "";
    time(&now);
    pTm = localtime(&now);
    strftime(zDate, sizeof(zDate), "%Y-%m-%d %H:%M:%S", pTm);
    waitpid(-1, &waitStatus, WNOHANG);
    getrusage(RUSAGE_SELF, &self);
    getrusage(RUSAGE_CHILDREN, &children);
    if( (log = fopen(zLogFile,"a"))!=0 ){
................................................................................
      **  (6) Bytes received
      **  (7) Bytes sent
      **  (8) Self user time
      **  (9) Self system time
      ** (10) Children user time
      ** (11) Children system time
      ** (12) Total wall-clock time
      *  (13) Request number for same TCP/IP connection
      ** (14) User agent
      ** (15) Remote user

      */
      fprintf(log,

        "%s,%s,\"%s://%s%s\",\"%s\",%s,%d,%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\"\n",
        zDate, zRemoteAddr, zHttp, Escape(zHttpHost), Escape(zScript),
        Escape(zReferer), zReplyStatus, nIn, nOut,
        (int)(self.ru_utime.tv_sec*1000000 + self.ru_utime.tv_usec),
        (int)(self.ru_stime.tv_sec*1000000 + self.ru_stime.tv_usec),
        (int)(children.ru_utime.tv_sec*1000000 + children.ru_utime.tv_usec),
        (int)(children.ru_stime.tv_sec*1000000 + children.ru_stime.tv_usec),
        (int)(now - beginTime),
        nRequest, Escape(zAgent), Escape(zRM)

      );
#endif
      fclose(log);
      nIn = nOut = 0;
    }
  }
  if( closeConnection ){







|
>
|
|
|
|







 







|


>


>
|







|
>







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
    time_t now;
    struct tm *pTm;
    struct rusage self, children;
    int waitStatus;
    char zDate[200];
    char *zRM = zRemoteUser ? zRemoteUser : "";

    if( zScript==0 ) zScript = "";
    if( zRealScript==0 ) zRealScript = "";
    if( zRemoteAddr==0 ) zRemoteAddr = "";
    if( zHttpHost==0 ) zHttpHost = "";
    if( zReferer==0 ) zReferer = "";
    if( zAgent==0 ) zAgent = "";
    time(&now);
    pTm = localtime(&now);
    strftime(zDate, sizeof(zDate), "%Y-%m-%d %H:%M:%S", pTm);
    waitpid(-1, &waitStatus, WNOHANG);
    getrusage(RUSAGE_SELF, &self);
    getrusage(RUSAGE_CHILDREN, &children);
    if( (log = fopen(zLogFile,"a"))!=0 ){
................................................................................
      **  (6) Bytes received
      **  (7) Bytes sent
      **  (8) Self user time
      **  (9) Self system time
      ** (10) Children user time
      ** (11) Children system time
      ** (12) Total wall-clock time
      ** (13) Request number for same TCP/IP connection
      ** (14) User agent
      ** (15) Remote user
      ** (16) Bytes of URL that correspond to the SCRIPT_NAME
      */
      fprintf(log,
        "%s,%s,\"%s://%s%s\",\"%s\","
           "%s,%d,%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\",%d\n",
        zDate, zRemoteAddr, zHttp, Escape(zHttpHost), Escape(zScript),
        Escape(zReferer), zReplyStatus, nIn, nOut,
        (int)(self.ru_utime.tv_sec*1000000 + self.ru_utime.tv_usec),
        (int)(self.ru_stime.tv_sec*1000000 + self.ru_stime.tv_usec),
        (int)(children.ru_utime.tv_sec*1000000 + children.ru_utime.tv_usec),
        (int)(children.ru_stime.tv_sec*1000000 + children.ru_stime.tv_usec),
        (int)(now - beginTime),
        nRequest, Escape(zAgent), Escape(zRM),
        strlen(zHttp)+strlen(zHttpHost)+strlen(zRealScript)+3
      );
#endif
      fclose(log);
      nIn = nOut = 0;
    }
  }
  if( closeConnection ){