Help us understand the problem. What is going on with this article?

awkを使ってvmstatに日時をつける

More than 1 year has passed since last update.

awkを使えばvmstatだけではなくなんにでも日時をつけることが出来ます。

vmstatに日時をつける

vmstat 1|awk '{print strftime("%Y/%m/%d %H:%M:%S",systime()) " " $0 }'
2019/06/13 09:27:35 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
2019/06/13 09:27:35  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
2019/06/13 09:27:35  2  0      0 265972  12900 233000    0    0   274   163  511  423 15  2 83  0  0    
2019/06/13 09:27:36  0  0      0 296276  12900 233116    0    0     0  5072  593 2685 31  3 66  0  0    
2019/06/13 09:27:37  0  0      0 296160  12900 233296    0    0     0     0  397  300 14  0 86  0  0    
2019/06/13 09:27:38  0  0      0 296160  12908 233484    0    0     0    28  428  329 14  0 85  0  1    
2019/06/13 09:27:39  0  0      0 296036  12908 233704    0    0     0     0  488  393 14  1 85  0  0    
2019/06/13 09:27:40  0  0      0 295788  12908 233932    0    0     0     0  465  343 14  0 86  0  0    
2019/06/13 09:27:41  1  0      0 295540  12908 234148    0    0     0     0  424  311 13  2 85  0  0    
2019/06/13 09:27:42  0  0      0 295292  12908 234348    0    0     0     0  431  310 14  1 85  0  0    
2019/06/13 09:27:43  0  0      0 295168  12916 234492    0    0     0    12  431  325 13  1 86  0  0    

tail -f したデータに日時をつける

tail -f access_log | awk '{print strftime("%Y/%m/%d %H:%M:%S",systime()) " " $0 }'
2019/06/13 09:31:14 1.2.3.4 - - [13/Jun/2019:09:09:08 +0000] "GET / HTTP/1.1" 200 479 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:56.0) Gecko/20100101 Firefox/56.0 Waterfox/56.2.10"
2019/06/13 09:31:14 1.2.3.4 - - [13/Jun/2019:09:09:08 +0000] "GET /css/demo.css HTTP/1.1" 304 - " "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:56.0) Gecko/20100101 Firefox/56.0 Waterfox/56.2.10"
2019/06/13 09:31:14 1.2.3.4 - - [13/Jun/2019:09:09:08 +0000] "GET /js/jquery.min.js HTTP/1.1" 304 - "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:56.0) Gecko/20100101 Firefox/56.0 Waterfox/56.2.10"

imaiworks
PHP好き好き大好き!やっぱ好き!
ayudante
いつもユーザー中心で技術者とコンサルタントがとことん考え抜く それがアユダンテです
https://ayudante.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした