3 # Copyright (c) 2002-2003
\r
4 # The President and Fellows of Harvard College.
\r
6 # Redistribution and use in source and binary forms, with or without
\r
7 # modification, are permitted provided that the following conditions
\r
9 # 1. Redistributions of source code must retain the above copyright
\r
10 # notice, this list of conditions and the following disclaimer.
\r
11 # 2. Redistributions in binary form must reproduce the above copyright
\r
12 # notice, this list of conditions and the following disclaimer in the
\r
13 # documentation and/or other materials provided with the distribution.
\r
14 # 3. Neither the name of the University nor the names of its contributors
\r
15 # may be used to endorse or promote products derived from this software
\r
16 # without specific prior written permission.
\r
18 # THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
\r
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
\r
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\r
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\r
30 # $Id: ns_loc2gmt,v 1.6 2003/07/28 14:27:16 ellard Exp $
\r
32 # A helper application used by ns_quickview to convert from local time
\r
33 # to GMT. nfsdump records time as localtime, but gnuplot only know
\r
34 # how to deal with dates expressed as Greenwich Mean Time (which it
\r
35 # then displays using the local time, for some reason).
\r
37 # This is a fragile tool -- it must be run in the same time zone in
\r
38 # which the data was collected via nfsdump, or else it will not do the
\r
39 # proper conversion. Improvements welcomed!
\r
41 # The 'C' (count) and 'L' (latency) records use the second column for
\r
42 # dates, expressed as seconds.microseconds in localtime. The seconds
\r
43 # portion is the only part of the data modified by this program.
\r
44 # Comment lines are passed through unaltered.
\r
46 # There is no error checking. Garbage in, garbage out.
\r
48 # Note - we're throwing the microseconds away.
\r
52 require 'timelocal.pl';
\r
56 Usage: $0 [options] [table1.ns [table2.ns ... ]]
\r
58 If no table files are specified, then the input is read from stdin.
\r
60 Command line options:
\r
62 -h Print usage message and exit.
\r
64 -d secs Time offset, in seconds, to subtract from each time
\r
65 in the input tables. Note that all times are rounded
\r
66 down to the nearest second.
\r
68 IMPORTANT NOTE: this must be run in the same time zone in which the
\r
69 data was collected via nfsdump, or else it will not do the proper
\r
70 conversion unless the -d option is used.
\r
75 if (! getopts ($Options)) {
\r
76 print STDERR "$0: Incorrect usage.\n";
\r
77 print STDERR $Usage;
\r
80 if (defined $opt_h) {
\r
86 if (defined $opt_d) {
\r
87 $TimeOffset = int ($opt_d);
\r
90 while ($line = <>) {
\r
91 if ($line =~ /^#/) {
\r
96 @arr = split (' ', $line);
\r
98 ($secs, $usec) = split (/\./, $arr[1]);
\r
99 $secs -= $TimeOffset;
\r
101 $arr[1] = &timegm (localtime ($secs));
\r
103 print join (' ', @arr);
\r