Codebase list httping / 4ef038d
added --ts/--timestamp folkert 11 years ago
2 changed file(s) with 25 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
122122 .B "\-\-offset\-show x"
123123 If the measured offset is higher than x, then the result is shown (default is show always). The value x is in ms.
124124 .TP
125 .B "\-\-timestamp" or "\-\-ts"
126 Put a timestamp before the result-lines. Use -v to also show a date.
127 .TP
125128 .B "\-W"
126129 Do not abort program if resolving fails.
127130 .TP
131131 fprintf(stderr, "-m give machine parseable output (see\n");
132132 fprintf(stderr, " also -o and -e)\n");
133133 fprintf(stderr, "-o rc,rc,... what http results codes indicate 'ok'\n");
134 fprintf(stderr, " coma seperated WITHOUT spaces inbetween\n");
134 fprintf(stderr, " comma seperated WITHOUT spaces inbetween\n");
135135 fprintf(stderr, " default is 200, use with -e\n");
136136 fprintf(stderr, "-e str string to display when http result code\n");
137137 fprintf(stderr, " doesn't match\n");
320320 char colors = 0;
321321 int verbose = 0;
322322 double offset_show = -1.0;
323 char show_ts = 0;
323324
324325 static struct option long_options[] =
325326 {
365366 {"offset-red", 1, NULL, 2 },
366367 {"offset-show", 1, NULL, 3 },
367368 {"show-offset", 1, NULL, 3 },
369 {"timestamp", 0, NULL, 4 },
370 {"ts", 0, NULL, 4 },
368371 {"version", 0, NULL, 'V' },
369372 {"help", 0, NULL, 'H' },
370373 {NULL, 0, NULL, 0 }
395398
396399 case 3:
397400 offset_show = atof(optarg);
401 break;
402
403 case 4:
404 show_ts = 1;
398405 break;
399406
400407 case 'Y':
12551262 char *operation = !persistent_connections ? "connected to" : "pinged host";
12561263 const char *sep = c_bright, *unsep = c_normal;
12571264
1265 if (show_ts)
1266 {
1267 struct timeval tv;
1268
1269 (void)gettimeofday(&tv, NULL);
1270
1271 struct tm *tvm = localtime(&tv.tv_sec);
1272
1273 if (verbose)
1274 printf("%04d/%02d/%02d ", tvm -> tm_year + 1900, tvm -> tm_mon + 1, tvm -> tm_mday);
1275
1276 printf("%02d:%02d:%02d.%03d ", tvm -> tm_hour, tvm -> tm_min, tvm -> tm_sec, (int)(tv.tv_usec / 1000));
1277 }
1278
12581279 if (curncount & 1)
12591280 {
12601281 printf("%s", c_bright);