0

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!

  • 2
    See ["Stackoverflow: Is there a Unix utility to prepend timestamps to lines of text?"][1] [1]: stackoverflow.com/questions/21564/… – mschuett Sep 23 '15 at 15:28
  • @mschuett thank you. but this thread just provide datetime type not unix timestamp. – encodeflush 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
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.