10
8

More than 5 years have passed since last update.

vmstatとかiostatを見やすくtailしたい

Posted at

トラブル時に忘れるのでメモ。

vmstatは横に長いです。特に複数サーバのvmstatを一括で見たいときには邪魔なので、以下のようなワンライナーを使っています。

vmstat.sh
$ vmstat 1 | egrep --line-buffered "^ +[0-9]" | awk '{OFS=""; print "r=",$1," us=",$13," sy=",$14; fflush()}'

r=2 us=0 sy=0
r=0 us=1 sy=0
r=0 us=1 sy=1
r=0 us=1 sy=0

いっそそのままCSVにしちゃってもよいでしょう。

vmstatcsv.sh
$ echo "r,us,sy"; vmstat 1 | egrep --line-buffered "^ +[0-9]" | awk '{OFS=","; print $1,$13,$14; fflush()}'

r,us,sy
2,0,0
0,1,0
0,1,1

iostatは縦にも横にも長いです。特定デバイスのr/s, w/sだけ見たいときには、以下のようにやっています。

iostat.sh
$ iostat -xd 1 | egrep --line-buffered "Device|xvda[0-9]" | awk '{OFS=""; ORS=""; if ($1=="Device:") print "\n"; else print $1,"=",$4,"|",$5," "; fflush()}'

xvda1=0.00|0.00 xvda2=0.00|0.00 xvda3=0.36|14.02
xvda1=0.00|0.00 xvda2=0.00|0.00 xvda3=0.00|0.00
xvda1=0.00|0.00 xvda2=0.00|0.00 xvda3=0.00|20.00
xvda1=0.00|0.00 xvda2=0.00|0.00 xvda3=0.00|0.00
xvda1=0.00|0.00 xvda2=0.00|0.00 xvda3=0.00|0.00
10
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8