Last active
August 29, 2015 14:07
-
-
Save ross-nordstrom/e3e65209852aac74fe4b to your computer and use it in GitHub Desktop.
Get a breakdown of CPU temperatures. Requires `sudo apt-get install lm-sensors && sudo sensors-detect`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
temps = `sensors` | |
tempLines = temps.split("\n").select{|l| l.include?('Core') } | |
max = 0 | |
tempData = tempLines.map{|l| [ l.split(':')[0].split(' ').join(''), l.split('+')[1].split('C')[0][0..-2] ] }.reduce({}) do |acc, l| | |
acc[l[0]] = l[1].to_f | |
max = [acc[l[0]], max].max | |
acc | |
end | |
tempData['max'] = max | |
puts tempData.to_json.gsub(/"/, "'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment