Project

General

Profile

Bug #5865

snoop prints timestamps oddly

Added by David Pacheco over 5 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2015-04-23
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

With "snoop -t a", snoop prints absolute timestamps like "15:15:5.58921", which is missing the leading zero on the number of seconds. This isn't the way most software prints timestamps, and it makes all sorts of output not line up.

I believe the problem is in show_pktinfo in snoop.c, where the code does this:

 583         if (flags & F_TIME) {
 584                 if (flags & F_ATIME) {
 585                         (void) sprintf(lp, "%d:%02d:%d.%05d ",
 586                                 tm->tm_hour, tm->tm_min, tm->tm_sec,
 587                                 (int)tvp->tv_usec / 10);
 588                         lp += strlen(lp);

We should probably just use strftime(3C) here.

#1

Updated by Yuri Pankov over 3 years ago

  • Category set to cmd - userland programs
  • Status changed from New to In Progress
  • Assignee set to Yuri Pankov
  • % Done changed from 0 to 50
  • Tags deleted (needs-triage)

Hours field is affected as well - both are just "%d", as opposed to minutes field being properly padded using "%02d".

#2

Updated by Electric Monk over 3 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 50 to 100

git commit 4383d9578c9d399b19edc33e552a4c543ebf9468

commit  4383d9578c9d399b19edc33e552a4c543ebf9468
Author: Yuri Pankov <yuri.pankov@nexenta.com>
Date:   2017-03-29T15:34:31.000Z

    5865 snoop prints timestamps oddly
    Reviewed by: Marcel Telka <marcel@telka.sk>
    Reviewed by: Alexander Pyhalov <apyhalov@gmail.com>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Dan McDonald <danmcd@omniti.com>

Also available in: Atom PDF