-
Notifications
You must be signed in to change notification settings - Fork 0
/
GpuTempSetter.rb
74 lines (65 loc) · 1.95 KB
/
GpuTempSetter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env ruby
#require 'yaml'
class GpuTempSetter
def self.countCards()
puts "Counting cards ..."
sInfo = `nvclock -s`.split("\n")
cards = {}
sInfo.each_with_index do | sInfoLine, i |
if (sInfoLine =~ /Card number/)
cardNumber = sInfoLine.split(" ")[-1]
cardName = sInfo[i - 1].split(":")[-1].strip()
puts "\tCard #{cardNumber}: #{cardName}"
cards[cardNumber] = cardName
end
end
puts "... done."
puts "---"
return cards
end
def initialize()
@wantedTabs = 3
@grepStrings = {}
@grepStrings["Core temperature"] = "GPU temperature:"
@grepStrings["Board temperature"] = "Board temperature:"
@grepStrings["Fan speed, RPM"] = "Fanspeed:"
@grepStrings["Fan speed, percent"] = "PWM duty cycle:"
@cards = GpuTempSetter::countCards()
end
def autoTemp
@cards.keys.each do | cardID |
`nvclock -c#{cardID} -f -F auto`
end
end
def getInfo
# initialize()
allCardsInfo = {}
@cards.keys.each do | cardID |
rawInfo = `nvclock -i`.split("\n")
cardInfo = {}
@grepStrings.each do | infoKey, infoGrepString |
infoStr = "#{(rawInfo.grep(/#{infoGrepString}/))}".split(" ")
# puts "infoStr: #{infoStr.inspect()}"
# print "grep:\n"
numGrep = "#{infoStr.grep(/[0-9]+/)}" # (/[0-9]*\.?[0.9]/)}"
# puts numGrep
# puts numGrep.to_f();
# puts "---"
cardInfo[infoKey] = numGrep.to_f() # "#{rawInfo.grep(/#{infoGrepString}/)}".to_f()
end
allCardsInfo[cardID] = cardInfo
end
return allCardsInfo
end
def printInfo
allCardsInfo = self.getInfo()
allCardsInfo.each do | cardID, info |
puts "Card #{cardID} (#{@cards[cardID]}) info: "
info.keys.sort.each do | infoKey |
tabStops = infoKey.length / 8
puts "#{infoKey}:#{"\t" * [0, (@wantedTabs - tabStops)].max()}#{info[infoKey]}"
end
puts "---"
end
end
end