Skip to content

Instantly share code, notes, and snippets.

@subtly
Created February 20, 2020 06:58
Show Gist options
  • Save subtly/c9ec066287fbd95545cc2b0c3b490f8e to your computer and use it in GitHub Desktop.
Save subtly/c9ec066287fbd95545cc2b0c3b490f8e to your computer and use it in GitHub Desktop.
Get disk temperatures in macOS (nvme can get hot)
#!/usr/bin/env ruby
lines = `diskutil list physical|grep dev|awk -F ' ' '{print $1}'`
lines.gsub(/\/dev\//, '').each_line do |line|
out = `smartctl -A -f brief #{line}` if !!(line.gsub!(/\s/,'') =~ /\Adisk\d+\z/)
puts "#{line}: " + out.split("\n").grep(/Temperature:/).first.split(/\s/)[-2]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment