1

I'm running the following command and storing the stdout into a text file. I need to add unix timestamp to each line output file to figure out start and end time of each operation.

$ ./bin/ycsb load mongodb -s -P workloads/workloada -p mongodb.url=mongodb://172.28.128.5:27017 -p mongodb.database=ycsb > outputLoad.txt

And the output:

$ cat outputLoad.txt 

mongo client connection created with mongodb://172.28.128.5:27017
[OVERALL], RunTime(ms), 65348.0
[OVERALL], Throughput(ops/sec), 1530.2687151863868
[CLEANUP], Operations, 1.0
[CLEANUP], AverageLatency(us), 9732.0
[CLEANUP], MinLatency(us), 9728.0
[CLEANUP], MaxLatency(us), 9735.0
[CLEANUP], 95thPercentileLatency(us), 9735.0
[CLEANUP], 99thPercentileLatency(us), 9735.0
[INSERT], Operations, 100000.0
[INSERT], AverageLatency(us), 634.39211
[INSERT], MinLatency(us), 83.0
[INSERT], MaxLatency(us), 434175.0
[INSERT], 95thPercentileLatency(us), 769.0
[INSERT], 99thPercentileLatency(us), 3417.0
[INSERT], Return=0, 100000

Thanks!

hossein
  • 181
  • 1
  • 1
  • 8
  • 3
    See ["Stackoverflow: Is there a Unix utility to prepend timestamps to lines of text?"][1] [1]: http://stackoverflow.com/questions/21564/is-there-a-unix-utility-to-prepend-timestamps-to-lines-of-text – mschuett Sep 23 '15 at 15:28
  • @mschuett thank you. but this thread just provide datetime type not unix timestamp. – hossein Sep 23 '15 at 15:50
  • 1
    Most of the solutions take a strftime parameter. '%s' yields a unix timestamp (seconds since the epoch). – mschuett Sep 23 '15 at 15:53
  • Another duplicate, with answers: https://unix.stackexchange.com/q/26728/52959 – David Balažic Apr 28 '20 at 10:26

1 Answers1

0

As @mschuett mentioned just added %s to the command as follow:

$ ./bin/ycsb load mongodb -s -P workloads/workloada -p mongodb.url=mongodb://172.28.128.5:27017 -p mongodb.database=ycsb | ts [%s] > outpuLoad.txt

And the output:

$ cat outputLoad.txt 

[1443106507] [INSERT], Operations, 10000.0
[1443106507] [INSERT], AverageLatency(us), 1114.4243
[1443106507] [INSERT], MinLatency(us), 379.0
[1443106507] [INSERT], MaxLatency(us), 550399.0
[1443106507] [INSERT], 95thPercentileLatency(us), 1288.0
[1443106507] [INSERT], 99thPercentileLatency(us), 8679.0
[1443106507] [INSERT], Return=0, 10000
hossein
  • 181
  • 1
  • 1
  • 8