Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Aug 2014 10:52:54 -0400
From:      "Kendrick, Stuart" <Stuart.Kendrick@emc.com>
To:        "freebsd-dtrace@freebsd.org" <freebsd-dtrace@freebsd.org>
Subject:   printing time
Message-ID:  <D0249056.15458%stuart.kendrick@emc.com>

next in thread | raw e-mail | index | archive | help
How else might I print a timestamp, other than using =91printf =85 walltime=
stamp=92?

I=92m running dtrace on a platform (modified version of FreeBSD 7) where =
=91printf %Y=92 only ever returns the one timestamp:  1969 Dec 31 18:00:00

So I=92m casting around for another approach:  suggestions?

My script =91watch-file.d=92:


# pragma D option quiet


BEGIN

{

printf("\n   Timestamp           gid   uid   pid  ppid execname   function\=
n\n");

}


syscall::open*:entry, syscall::unlink:entry, syscall::rename:entry

/strstr(stringof(copyinstr(arg0)), $1) !=3D NULL/

{

       printf("%Y %5d %5d %5d %5d %-12s %-10s %s\n",

            walltimestamp, gid, uid, pid, ppid, execname, probefunc, string=
of(copyinstr(arg0)));

}

Typically run as follows:
./watch-file.d =91=93/etc/foo=94=92 | tee /var/tmp/foo.log
where /etc/foo is the file I want to watch =97 i.e. something is updating t=
his file at awkward moments, and I want to identify what process does this.



[...]

1969 Dec 31 18:00:00    0       0  2739 1 isi_rpc_d     open    /etc/ifs/lo=
cal.xml
1969 Dec 31 18:00:00    0       0  2739 1 isi_rpc_d     open    /etc/ifs/lo=
cal.xml
1969 Dec 31 18:00:00    0       0  2739 1 isi_rpc_d     open    /etc/ifs/lo=
cal.xml
1969 Dec 31 18:00:00    0       0  3131 1 isi_celog_monitor open        /et=
c/ifs/local.xml
1969 Dec 31 18:00:00    0       0  3131 1 isi_celog_monitor open        /et=
c/ifs/local.xml
1969 Dec 31 18:00:00    0       0  3131 1 isi_celog_monitor open        /et=
c/ifs/local.xml
1969 Dec 31 18:00:00    0       0  3099 1 isi_celog_coalescer open      /et=
c/ifs/local.xml
1969 Dec 31 18:00:00    0       0  3099 1 isi_celog_coalescer open      /et=
c/ifs/local.xml
1969 Dec 31 18:00:00    0       0  3099 1 isi_celog_coalescer open      /et=
c/ifs/local.xml
1969 Dec 31 18:00:00    0       0  3099 1 isi_celog_coalescer open      /et=
c/ifs/local.xml
~


=97sk

Stuart Kendrick
EMC Isilon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D0249056.15458%stuart.kendrick>