amdgpu_fan 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab8784cb1b68ab424942a5c7f2b4c11d9b15ef664529d8029b3c1cc03d4c4ffe
4
- data.tar.gz: c2be64896c2d981b6462e4df7ff4e060a78663d55b51ff270f0c6089ec26a855
3
+ metadata.gz: 7f57ebc2011d08efe82baa67964bf75a17dfe7c85a518249a93c7b6eeadf207e
4
+ data.tar.gz: 1e1fa6d5af4f3cecc5346003949eb4a1edeb1c1ef943e60478f09cd8e3600099
5
5
  SHA512:
6
- metadata.gz: db7e5229ca97968edf84e563d0a626777e053922969e3f03a0e801b30ed5108971bc0679fdecc582c9d9920f52ac35e24af9800fd10cf9755a51f3ca222daa9e
7
- data.tar.gz: 963a1876d6ef7b00f3693035bc181d245268c9d528344e4cb1eec1af45c8d85305a6c292d93cc3340b68facc2d85d30df452ee81df882e062c7adbfcdef4b5e0
6
+ metadata.gz: a185688066129ae01860f6dcf15fa75d84b5441f0cf3fbf23df812986c8da194eb6ed00557afe607299d6d3640beed3b5dc60483b1e6155d09d4e40180865793
7
+ data.tar.gz: 2ef75cd3c949fd579eaf855c63ca985a1ddff172e41fceb46dd10b5f1177e0ddaf7f74427e3ce64c26a86ac15da473806f400014abaf428fb7275f075cd79069
data/README.md CHANGED
@@ -75,8 +75,30 @@ Watching Advanced Micro Devices, Inc. [AMD/ATI] Radeon R9 FURY X / NANO every 3
75
75
  And now the watch is ended.
76
76
  ```
77
77
 
78
+ ```
79
+ ➤ bin/amdgpu_fan watch_avg
80
+ Watching Sapphire Technology Limited Vega 10 XL/XT [Radeon RX Vega 56/64] min, max and averges since
81
+ 2020-06-02 23:05:20 -0400...
82
+ <Press Ctrl-C to exit>
83
+ ⏰ Core clock min: 852 MHz avg: 887.0 MHz max: 1200 MHz now: 852 MHz
84
+ 💾 Memory clk min: 167 MHz avg: 227.1 MHz max: 945 MHz now: 167 MHz
85
+ 🌀 Fan speed min: 1231 RPM avg: 1231.0 RPM max: 1231 RPM now: 1231 RPM
86
+ ⚡ Power usage min: 6.0 W avg: 21.8 W max: 141.0 W now: 6.0 W
87
+ 🌡 Temperature min: 30 °C avg: 31.3 °C max: 35 °C now: 32 °C
88
+ ^C
89
+ And now the watch is ended.
90
+ ```
91
+
78
92
  ## Dependencies
79
93
 
80
94
  - [Ruby](https://www.ruby-lang.org) with [Bundler](https://bundler.io)
81
95
  - [Thor](http://whatisthor.com/) (installed with `bundle install`)
82
96
  - [`lspci`](https://linux.die.net/man/8/lspci) (included with most Linux distributions)
97
+
98
+ ## Building a binary
99
+
100
+ [Ruby Packer](https://github.com/pmq20/ruby-packer) provides a convenient way to compile this into a single executable. For the best results, compile Ruby Packer from source from the lastest master branch.
101
+
102
+ ```sh
103
+ rubyc amdgpu_fan --output amdgpu_fan
104
+ ```
@@ -3,9 +3,12 @@
3
3
  require 'thor'
4
4
 
5
5
  require_relative '../lib/amdgpu_fan'
6
+ require_relative '../lib/amdgpu_fan/version'
6
7
 
7
8
  require_relative '../lib/amdgpu_fan/mixin/cli_output_format'
8
9
  require_relative '../lib/amdgpu_fan/mixin/sys_write'
9
10
 
10
11
  require_relative '../lib/amdgpu_fan/service'
11
12
  require_relative '../lib/amdgpu_fan/cli'
13
+ require_relative '../lib/amdgpu_fan/stat_set'
14
+ require_relative '../lib/amdgpu_fan/watcher'
@@ -0,0 +1,10 @@
1
+ ---
2
+ clock: ⏰
3
+ display: 📺
4
+ fan: 🌀
5
+ gpu: 👾
6
+ load: "⚖ "
7
+ memory: 💾
8
+ power: ⚡
9
+ temp: "🌡 "
10
+ vbios: 📄
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'yaml'
4
+
3
5
  module AmdgpuFan
4
6
  # The command-line interface class
5
7
  class Cli < Thor
6
8
  include CliOutputFormat
7
9
 
10
+ ICONS = YAML.load(File.read(File.join(__dir__, '../../config/icons.yml')))
11
+ .transform_keys(&:to_sym).freeze
8
12
  WATCH_FIELD_SEPARATOR = ' | '
9
13
 
10
14
  desc 'connectors', 'View the status of the display connectors.'
@@ -52,18 +56,23 @@ module AmdgpuFan
52
56
  desc 'status [--logo]', 'View device info, current fan speed, and temperature.'
53
57
  def status(option = nil)
54
58
  puts radeon_logo if option == '--logo'
55
- puts "👾 #{'GPU:'.ljust(9)} #{amdgpu_service.name}",
56
- "📄 #{'vBIOS:'.ljust(9)} #{amdgpu_service.vbios_version}",
57
- "📺 Displays: #{amdgpu_service.connectors.map(&:display_name).compact.join(', ')}",
58
- "⏰ #{'Clocks:'.ljust(9)} #{clock_status}",
59
- "💾 #{'Memory:'.ljust(9)} #{mem_total_mibibyes}",
60
- "🌀 #{'Fan:'.ljust(9)} #{fan_status}",
61
- "🌞 #{'Temp:'.ljust(9)} #{amdgpu_service.temperature}°C",
62
- "⚡ #{'Power:'.ljust(9)} #{amdgpu_service.profile_mode} profile in " \
59
+ puts ICONS[:gpu] + ' GPU:'.ljust(9) + amdgpu_service.name,
60
+ ICONS[:vbios]+ ' vBIOS:'.ljust(9) + amdgpu_service.vbios_version,
61
+ ICONS[:display] + ' Displays:' + amdgpu_service.display_names.join(', '),
62
+ ICONS[:clock] + ' Clocks:'.ljust(9) + clock_status,
63
+ ICONS[:memory] + ' Memory:'.ljust(9) + mem_total_mibibyes,
64
+ ICONS[:fan] + ' Fan:'.ljust(9) + fan_status,
65
+ ICONS[:temp] + ' Temp:'.ljust(9) + "#{amdgpu_service.temperature}°C",
66
+ ICONS[:power] + ' Power:'.ljust(9) + "#{amdgpu_service.profile_mode} profile in " \
63
67
  "#{amdgpu_service.power_dpm_state} mode using " \
64
68
  "#{amdgpu_service.power_draw} / #{amdgpu_service.power_max} Watts "\
65
69
  "(#{amdgpu_service.power_draw_percent}%)",
66
- "⚖ #{'Load:'.ljust(9)} #{percent_meter amdgpu_service.busy_percent, 20}"
70
+ ICONS[:load] + ' Load:'.ljust(9) + percent_meter(amdgpu_service.busy_percent, 20)
71
+ end
72
+
73
+ desc 'version', 'Print the application version.'
74
+ def version
75
+ puts AmdgpuFan::VERSION
67
76
  end
68
77
 
69
78
  desc 'watch [SECONDS]', 'Watch fan speed, load, power, and temperature ' \
@@ -91,6 +100,35 @@ module AmdgpuFan
91
100
  end
92
101
  end
93
102
 
103
+ desc 'watch_avg',
104
+ <<~DOC
105
+ Watch min, max, average, and current stats.
106
+ DOC
107
+ def watch_avg
108
+ puts "Watching #{amdgpu_service.name} min, max and averges since #{Time.now}...",
109
+ ' <Press Ctrl-C to exit>',
110
+ "\n\n\n\n\n"
111
+
112
+ trap 'SIGINT' do
113
+ puts "\nAnd now the watch is ended."
114
+ exit 0
115
+ end
116
+
117
+ watcher = Watcher.new amdgpu_service
118
+
119
+ loop do
120
+ watcher.measure
121
+ 5.times { print "\033[K\033[A" } # move up a line and clear to end of line
122
+
123
+ puts ICONS[:clock] + ' Core clock ' + watcher.core_clock.to_s,
124
+ ICONS[:memory] + ' Memory clk ' + watcher.mem_clock.to_s,
125
+ ICONS[:fan] + ' Fan speed ' + watcher.fan_speed.to_s,
126
+ ICONS[:power] + ' Power usage ' + watcher.power.to_s,
127
+ ICONS[:temp] + ' Temperature ' + watcher.temp.to_s
128
+ sleep 1
129
+ end
130
+ end
131
+
94
132
  desc 'watch_csv [SECONDS]', 'Watch stats in CSV format ' \
95
133
  'refreshed every n seconds defaulting to 1 second.'
96
134
  def watch_csv(seconds = 1)
@@ -37,6 +37,10 @@ module AmdgpuFan
37
37
  clock_from_pp_file "#{base_card_dir}/pp_dpm_sclk"
38
38
  end
39
39
 
40
+ def display_names
41
+ connectors.map(&:display_name).compact
42
+ end
43
+
40
44
  def fan_mode
41
45
  FAN_MODES[File.read(fan_mode_file).strip] || 'unknown'
42
46
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AmdgpuFan
4
+ # A set of stats
5
+ class StatSet < Hash
6
+ attr_accessor :avg, :max, :min, :now
7
+ attr_reader :unit
8
+
9
+ def initialize(unit)
10
+ @unit = unit
11
+ end
12
+
13
+ def stats
14
+ { min: min, avg: avg, max: max, now: now }
15
+ end
16
+
17
+ ##
18
+ # Return a string containing all the stats with units.
19
+ #
20
+ def to_s
21
+ stats.map { |k,v| "#{k}: #{v.to_s.rjust(6)} #{unit.ljust(3)} " }.join
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AmdgpuFan
4
+ # Current version of RSpec Core, in semantic versioning format.
5
+ VERSION = '0.6.0'
6
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'stat_set'
4
+
5
+ module AmdgpuFan
6
+ # Keep track of stats over time.
7
+ class Watcher
8
+ attr_reader :core_clock, :fan_speed, :num_measurements, :mem_clock, :power, :temp
9
+
10
+ def initialize(amdgpu_service)
11
+ @amdgpu_service = amdgpu_service
12
+ @num_measurements = 0
13
+
14
+ @core_clock = StatSet.new 'MHz'
15
+ @mem_clock = StatSet.new 'MHz'
16
+ @fan_speed = StatSet.new 'RPM'
17
+ @power = StatSet.new 'W'
18
+ @temp = StatSet.new '°C'
19
+ end
20
+
21
+ ##
22
+ # Take a new set of measurements and adjust the stats.
23
+ #
24
+ def measure
25
+ @num_measurements += 1
26
+
27
+ @core_clock.now = @amdgpu_service.core_clock.to_i
28
+ @mem_clock.now = @amdgpu_service.memory_clock.to_i
29
+ @fan_speed.now = @amdgpu_service.fan_speed_rpm.to_i
30
+ @power.now = @amdgpu_service.power_draw.to_f
31
+ @temp.now = @amdgpu_service.temperature.to_i
32
+
33
+ [@core_clock, @mem_clock, @fan_speed, @power, @temp].each do |stat_set|
34
+ calculate_stats(stat_set)
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def calculate_stats(stat_set)
41
+ if num_measurements == 1
42
+ stat_set.min = stat_set.now
43
+ stat_set.avg = stat_set.now.to_f
44
+ stat_set.max = stat_set.now
45
+ return
46
+ end
47
+
48
+ stat_set.min = stat_set.now if stat_set.now < stat_set.min
49
+ stat_set.avg =
50
+ ((stat_set.now + stat_set.avg * (num_measurements - 1)) / num_measurements.to_f)
51
+ .round(1)
52
+ stat_set.max = stat_set.now if stat_set.now > stat_set.max
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amdgpu_fan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McCormack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-13 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: A CLI for interacting with the amdgpu Linux driver
14
56
  email: harlemsquirrel@gmail.com
15
57
  executables:
@@ -20,6 +62,7 @@ files:
20
62
  - README.md
21
63
  - bin/amdgpu_fan
22
64
  - config/environment.rb
65
+ - config/icons.yml
23
66
  - lib/amdgpu_fan.rb
24
67
  - lib/amdgpu_fan/cli.rb
25
68
  - lib/amdgpu_fan/connector.rb
@@ -27,6 +70,9 @@ files:
27
70
  - lib/amdgpu_fan/mixin/fan.rb
28
71
  - lib/amdgpu_fan/mixin/sys_write.rb
29
72
  - lib/amdgpu_fan/service.rb
73
+ - lib/amdgpu_fan/stat_set.rb
74
+ - lib/amdgpu_fan/version.rb
75
+ - lib/amdgpu_fan/watcher.rb
30
76
  homepage: https://github.com/HarlemSquirrel/amdgpu-fan-rb
31
77
  licenses:
32
78
  - MIT