5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SMARTのそれっぽい値を監視するcronとかに入れておくやつ

Posted at

S.M.A.R.Tとか見ても仕方ないだろうと思ってんたんですがBackblazeさんによると故障率と相関がはっきりしている値も存在するらしい

ということでSMART 5, 187, 188, 197 ,198をチェックして0以外だったらmailが飛んでくるようにスクリプトを書いてcronに登録した。
効果があるかは不明でおまじないというやつ。

sudo ruby -e '["sda", "sdb", "sdc", "sdd"].each{|d| print `smartctl -A /dev/#{d}`}' | ruby -ne 'r = $_.split; [5, 187, 188, 197, 198].each{|n| puts "smart error: #{$_}" if r.first.to_i == n && r.last.to_i != 0 }'

Rubyのコードを整形するとこう

# 1個目
["sda", "sdb", "sdc", "sdd"].each{|d|
  print `smartctl -A /dev/#{d}`
}

# 2個目 (nオプション付きで行単位処理)
$_.split;
[5, 187, 188, 197, 198].each{|n|
  if r.first.to_i == n && r.last.to_i != 0
    puts "smart error: #{$_}"
  end
}
5
6
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
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?