hardware_information 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hardware_information might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +65 -0
- data/bin/hardware_information +12 -0
- data/doc/README.gen +25 -0
- data/hardware_information.gemspec +44 -0
- data/lib/hardware_information/class/colours.rb +82 -0
- data/lib/hardware_information/class/constants.rb +145 -0
- data/lib/hardware_information/class/hardware_information.rb +32 -0
- data/lib/hardware_information/class/initialize.rb +24 -0
- data/lib/hardware_information/class/make_line.rb +55 -0
- data/lib/hardware_information/class/menu.rb +52 -0
- data/lib/hardware_information/class/misc.rb +275 -0
- data/lib/hardware_information/class/obtain.rb +255 -0
- data/lib/hardware_information/class/reset.rb +54 -0
- data/lib/hardware_information/class/run.rb +48 -0
- data/lib/hardware_information/css/project.css +3 -0
- data/lib/hardware_information/gui/gtk2/purchased_hardware/purchased_hardware.rb +34 -0
- data/lib/hardware_information/gui/gtk2/show_input_devices/show_input_devices.rb +34 -0
- data/lib/hardware_information/gui/gtk3/mounted_harddiscs/mounted_harddiscs.rb +103 -0
- data/lib/hardware_information/gui/gtk3/purchased_hardware/purchased_hardware.rb +34 -0
- data/lib/hardware_information/gui/gtk3/show_input_devices/show_input_devices.rb +34 -0
- data/lib/hardware_information/gui/libui/mounted_harddiscs/mounted_harddiscs.rb +88 -0
- data/lib/hardware_information/gui/shared_code/mounted_harddiscs/mounted_harddiscs_module.rb +107 -0
- data/lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb +291 -0
- data/lib/hardware_information/gui/shared_code/show_input_devices/show_input_devices_module.rb +187 -0
- data/lib/hardware_information/misc/purchased_hardware/README.md +7 -0
- data/lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb +169 -0
- data/lib/hardware_information/monitor/README.md +6 -0
- data/lib/hardware_information/monitor/monitor.rb +36 -0
- data/lib/hardware_information/project/project.rb +29 -0
- data/lib/hardware_information/version/version.rb +19 -0
- data/lib/hardware_information/www/embeddable_interface.rb +52 -0
- data/lib/hardware_information/www/my_hardware.cgi +7 -0
- data/lib/hardware_information/www/my_hardware.rb +462 -0
- data/lib/hardware_information/www/my_hardware_for_sinatra.rb +65 -0
- data/lib/hardware_information/yaml/colours_for_the_hardware_information_project.yml +30 -0
- data/lib/hardware_information/yaml/usb_errors/usb_errors.yml +2 -0
- data/lib/hardware_information.rb +7 -0
- metadata +95 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
class HardwareInformation
|
6
|
+
|
7
|
+
# ========================================================================= #
|
8
|
+
# === set_run_already
|
9
|
+
# ========================================================================= #
|
10
|
+
def set_run_already(i)
|
11
|
+
@run_already = i
|
12
|
+
end
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === pad?
|
16
|
+
# ========================================================================= #
|
17
|
+
def pad?
|
18
|
+
@default_padding
|
19
|
+
end
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === append_newline
|
23
|
+
# ========================================================================= #
|
24
|
+
def append_newline
|
25
|
+
add N
|
26
|
+
end
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === report_result
|
30
|
+
# ========================================================================= #
|
31
|
+
def report_result
|
32
|
+
e string?
|
33
|
+
end
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === string?
|
37
|
+
# ========================================================================= #
|
38
|
+
def string?
|
39
|
+
@string
|
40
|
+
end; alias string string? # === string
|
41
|
+
|
42
|
+
# ========================================================================= #
|
43
|
+
# === set_commandline_mode
|
44
|
+
# ========================================================================= #
|
45
|
+
def set_commandline_mode
|
46
|
+
@mode = :commandline
|
47
|
+
end
|
48
|
+
|
49
|
+
# ========================================================================= #
|
50
|
+
# === set_web_mode
|
51
|
+
# ========================================================================= #
|
52
|
+
def set_web_mode
|
53
|
+
@mode = :web
|
54
|
+
end
|
55
|
+
|
56
|
+
# ========================================================================= #
|
57
|
+
# === default_ljust
|
58
|
+
# ========================================================================= #
|
59
|
+
def default_rjust(i)
|
60
|
+
if i.is_a? Array # We do not handle Arrays.
|
61
|
+
i
|
62
|
+
else
|
63
|
+
i.to_s.rjust(MAIN_DEFAULT_RJUST)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# ========================================================================= #
|
68
|
+
# === _ (_ tag)
|
69
|
+
#
|
70
|
+
# This method, as a shortcut, makes use of the method called add(),
|
71
|
+
# but it will also append a newline to the given input and support
|
72
|
+
# colours (if given as argument).
|
73
|
+
# ========================================================================= #
|
74
|
+
def _(i, optional_colour = nil)
|
75
|
+
if optional_colour and use_colours? # Add colours only if needed.
|
76
|
+
if optional_colour.is_a? Symbol
|
77
|
+
i = ::Colours.send(optional_colour, i)
|
78
|
+
else
|
79
|
+
i = optional_colour+i+rev
|
80
|
+
end
|
81
|
+
end
|
82
|
+
add i+N # We try it with mandatory newline for now.
|
83
|
+
end
|
84
|
+
|
85
|
+
# ========================================================================= #
|
86
|
+
# === add_title
|
87
|
+
# ========================================================================= #
|
88
|
+
def add_title
|
89
|
+
optional_colour = nil
|
90
|
+
if use_colours?
|
91
|
+
if Object.const_defined? :Colours # User has the colours gem installed.
|
92
|
+
optional_colour = :mediumslateblue
|
93
|
+
else
|
94
|
+
optional_colour = green?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
_ N+'Hardware Information'+N, optional_colour
|
98
|
+
end
|
99
|
+
|
100
|
+
# ========================================================================= #
|
101
|
+
# === colourize_filesize_of_the_harddisc
|
102
|
+
# ========================================================================= #
|
103
|
+
def colourize_filesize_of_the_harddisc(i)
|
104
|
+
Colours.send(
|
105
|
+
@hash_use_these_colours[:filesize_of_the_harddisc],
|
106
|
+
i
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# ========================================================================= #
|
111
|
+
# === colourize_file_system_type
|
112
|
+
# ========================================================================= #
|
113
|
+
def colourize_file_system_type(i)
|
114
|
+
Colours.send(
|
115
|
+
@hash_use_these_colours[:file_system_type],
|
116
|
+
i
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
# ========================================================================= #
|
121
|
+
# === colourize_n_percent_occupied
|
122
|
+
# ========================================================================= #
|
123
|
+
def colourize_n_percent_occupied(i)
|
124
|
+
Colours.send(
|
125
|
+
@hash_use_these_colours[:n_percent_occupied],
|
126
|
+
i
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
# ========================================================================= #
|
131
|
+
# === colourize_highlighted_content
|
132
|
+
# ========================================================================= #
|
133
|
+
def colourize_highlighted_content(i)
|
134
|
+
Colours.send(
|
135
|
+
@hash_use_these_colours[:highlighted_content],
|
136
|
+
i
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
# ========================================================================= #
|
141
|
+
# === colourize_via_regular_colour
|
142
|
+
#
|
143
|
+
# Do note that this is presently hardcoded to the "thistle" colour.
|
144
|
+
# Unsure whether to allow the user more customization here, so for
|
145
|
+
# the time being this remains hardcoded.
|
146
|
+
# ========================================================================= #
|
147
|
+
def colourize_via_regular_colour(i)
|
148
|
+
Colours.send(
|
149
|
+
:thistle,
|
150
|
+
i
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# ========================================================================= #
|
155
|
+
# === append_output_generated_via_lsblk
|
156
|
+
#
|
157
|
+
# Typical output generated via lsblk may be like this:
|
158
|
+
#
|
159
|
+
# NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
160
|
+
# sda 8:0 0 2.7T 0 disk
|
161
|
+
# ├─sda1 8:1 0 1M 0 part
|
162
|
+
# └─sda2 8:2 0 2.7T 0 part /
|
163
|
+
# sr0 11:0 1 1024M 0 rom
|
164
|
+
#
|
165
|
+
# ========================================================================= #
|
166
|
+
def append_output_generated_via_lsblk
|
167
|
+
_ = ''.dup
|
168
|
+
# ======================================================================== #
|
169
|
+
# Next we will display/obtain more information, via df.
|
170
|
+
# ======================================================================== #
|
171
|
+
extended_information = `df -T`.split(N)
|
172
|
+
result = `lsblk`.strip.split(N).map {|line| " #{line}" }
|
173
|
+
result.each {|entry|
|
174
|
+
# ===================================================================== #
|
175
|
+
# Modify the input.
|
176
|
+
# ===================================================================== #
|
177
|
+
if entry.include? ' /'
|
178
|
+
# =================================================================== #
|
179
|
+
# These entries will be colourized. Note that the first part may
|
180
|
+
# look like this: "└─sda2"
|
181
|
+
#
|
182
|
+
# " └─sda2 8:2 0 2.7T 0 part /"
|
183
|
+
#
|
184
|
+
# =================================================================== #
|
185
|
+
splitted = entry.split(' ')
|
186
|
+
# =================================================================== #
|
187
|
+
# The root_entry may look like this:
|
188
|
+
#
|
189
|
+
# /dev/sda2 ext4 2883218608 529813416 2206875608 20% /
|
190
|
+
#
|
191
|
+
# =================================================================== #
|
192
|
+
selection = extended_information.select {|line|
|
193
|
+
last = line.split(' ').last
|
194
|
+
last == '/' or last.include?('USB')
|
195
|
+
}
|
196
|
+
if selection
|
197
|
+
selection = selection.select {|inner_line|
|
198
|
+
inner_line.end_with? splitted[-1]
|
199
|
+
}
|
200
|
+
if selection.is_a?(Array) and selection.first
|
201
|
+
selection = selection.first.split(' ')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
splitted[-1] = colourize_highlighted_content(splitted[-1].ljust(12)) # ← The last part.
|
205
|
+
splitted[0] = colourize_highlighted_content(" #{splitted[0]}") # ← The first part.
|
206
|
+
splitted[1] = colourize_via_regular_colour(splitted[1].strip.ljust(4).rjust(6))
|
207
|
+
splitted[2] = colourize_via_regular_colour(" #{splitted[2].strip.rjust(2)}")
|
208
|
+
splitted[3] = colourize_filesize_of_the_harddisc(splitted[3].strip.rjust(5).ljust(6)) # ← The size of the harddisc.
|
209
|
+
splitted[4] = colourize_via_regular_colour(splitted[4].strip.ljust(2).rjust(3))
|
210
|
+
splitted[5] = colourize_via_regular_colour(splitted[5].strip)
|
211
|
+
file_system_type = selection[1]
|
212
|
+
n_percent_occupied = selection[5]
|
213
|
+
# =================================================================== #
|
214
|
+
# /dev/sda2 ext4 2883218608 529753916 2206935108 20% /"]
|
215
|
+
# =================================================================== #
|
216
|
+
splitted = splitted.join(' ')
|
217
|
+
unless entry.include? '/boot/' # ← Don't show information for /boot/ entries.
|
218
|
+
splitted << colourize_file_system_type(" (#{file_system_type})")
|
219
|
+
splitted << colourize_n_percent_occupied(" (#{n_percent_occupied} used)")
|
220
|
+
end
|
221
|
+
entry = splitted
|
222
|
+
else # Else we only do a slightly simpler colourization-part.
|
223
|
+
splitted = entry.split(' ')
|
224
|
+
splitted[0] = colourize_via_regular_colour(" #{splitted[0].ljust(6)}") # ← The first part.
|
225
|
+
splitted[1] = colourize_via_regular_colour(splitted[1].strip.ljust(4).rjust(6))
|
226
|
+
splitted[2] = colourize_via_regular_colour(" #{splitted[2].strip.rjust(2)}")
|
227
|
+
splitted[3] = colourize_filesize_of_the_harddisc(splitted[3].strip.rjust(5).ljust(6)) # ← The size of the harddisc.
|
228
|
+
splitted[4] = colourize_via_regular_colour(splitted[4].strip.ljust(2).rjust(3))
|
229
|
+
splitted[5] = colourize_via_regular_colour(splitted[5].strip)
|
230
|
+
if splitted[6] and (splitted[6] == '[SWAP]')
|
231
|
+
splitted[6] = royalblue(splitted[6])
|
232
|
+
end
|
233
|
+
entry = splitted.join(' ')
|
234
|
+
entry = colourize_via_regular_colour(entry)
|
235
|
+
end
|
236
|
+
_ << "#{entry}\n" # Now we can append this.
|
237
|
+
}
|
238
|
+
# ======================================================================= #
|
239
|
+
# Add two newlines too, for slightly more readable output.
|
240
|
+
# ======================================================================= #
|
241
|
+
_ << "#{N}#{N}"
|
242
|
+
add _
|
243
|
+
end
|
244
|
+
|
245
|
+
# ========================================================================= #
|
246
|
+
# === default_ljust
|
247
|
+
# ========================================================================= #
|
248
|
+
def default_ljust(i)
|
249
|
+
i.to_s.ljust(15)
|
250
|
+
end
|
251
|
+
|
252
|
+
# ========================================================================= #
|
253
|
+
# === add_audio_information (audio tag)
|
254
|
+
# ========================================================================= #
|
255
|
+
def add_audio_information
|
256
|
+
audio_device = `aplay -l`.scan(/card.+$/).first
|
257
|
+
make_line(pad?+'Audio Device', N+(pad? * 2)+audio_device.to_s)
|
258
|
+
end
|
259
|
+
|
260
|
+
# ========================================================================= #
|
261
|
+
# === find_out_the_amount_of_processors
|
262
|
+
# ========================================================================= #
|
263
|
+
def find_out_the_amount_of_processors
|
264
|
+
data = CPUINFO.scan(/cpu cores\t: (\d+)\n/).flatten.map(&:to_i).sum.to_i
|
265
|
+
make_line(' Processors', data) { :slateblue }
|
266
|
+
end
|
267
|
+
|
268
|
+
# ========================================================================= #
|
269
|
+
# === add (add tag)
|
270
|
+
# ========================================================================= #
|
271
|
+
def add(i)
|
272
|
+
@string << i
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'hardware_information/class/obtain.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
class HardwareInformation
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === obtain_virtualization
|
11
|
+
#
|
12
|
+
# This method call may fail, depending on the output of the LSCPU
|
13
|
+
# command, hence why this check has to be a bit more complicated.
|
14
|
+
# ========================================================================= #
|
15
|
+
def obtain_virtualization
|
16
|
+
result = LSCPU.grep(/Virtualization:/)
|
17
|
+
if result
|
18
|
+
result = result.first.split(':').last.strip
|
19
|
+
make_line(' Virtualization', result) { :mediumseagreen }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'hardware_information/monitor/monitor.rb'
|
24
|
+
# ========================================================================= #
|
25
|
+
# === obtain_information_about_the_monitor
|
26
|
+
# ========================================================================= #
|
27
|
+
def obtain_information_about_the_monitor
|
28
|
+
make_line(
|
29
|
+
' Monitor resolution',
|
30
|
+
::HardwareInformation.return_the_monitor_resolution
|
31
|
+
) { :mediumspringgreen }
|
32
|
+
end
|
33
|
+
|
34
|
+
# ========================================================================= #
|
35
|
+
# === obtain_information_about_the_GPU
|
36
|
+
# ========================================================================= #
|
37
|
+
def obtain_information_about_the_GPU
|
38
|
+
make_line(
|
39
|
+
' GPU',
|
40
|
+
return_information_about_the_GPU
|
41
|
+
) { :mediumpurple }
|
42
|
+
end
|
43
|
+
|
44
|
+
# ========================================================================= #
|
45
|
+
# === return_information_about_the_GPU
|
46
|
+
#
|
47
|
+
# This method will return information about the GPU in use on the given
|
48
|
+
# computer system.
|
49
|
+
#
|
50
|
+
# This may be similar to a String such as:
|
51
|
+
#
|
52
|
+
# GPU: AMD ATI Radeon R7 Graphics
|
53
|
+
#
|
54
|
+
# ========================================================================= #
|
55
|
+
def return_information_about_the_GPU
|
56
|
+
result = `lspci #{ERROR_LINE}`.strip
|
57
|
+
if result and result.include?('VGA compatible controller')
|
58
|
+
result = result.split(N).select {|line|
|
59
|
+
line.include? 'VGA compatible controller'
|
60
|
+
}.first
|
61
|
+
# ===================================================================== #
|
62
|
+
# Work on:
|
63
|
+
#
|
64
|
+
# VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics]"
|
65
|
+
#
|
66
|
+
# ===================================================================== #
|
67
|
+
result = result.split('. [').last.
|
68
|
+
delete('[]').tr('/',' ')
|
69
|
+
end
|
70
|
+
return result
|
71
|
+
end
|
72
|
+
|
73
|
+
# ========================================================================= #
|
74
|
+
# === obtain_firmware_information
|
75
|
+
#
|
76
|
+
# Note that this functionality depends on the binary called "lshw".
|
77
|
+
# ========================================================================= #
|
78
|
+
def obtain_firmware_information
|
79
|
+
result = `lshw 2>&1`
|
80
|
+
if result
|
81
|
+
# ===================================================================== #
|
82
|
+
# See: https://rubular.com/r/Uf4XqmbZW3atCy
|
83
|
+
# ===================================================================== #
|
84
|
+
regex =
|
85
|
+
/description: Motherboard\s+product: (.+)\s+vendor: (.+)\s+[.:0-9a-zA-Z\n ]+\*-firmware[.:0-9a-zA-Z\n ]+version: (\d{0,4}[0-9.]+)\s+date: (\d{1,2}.+)/
|
86
|
+
result =~ regex
|
87
|
+
motherboard = $1.to_s.dup
|
88
|
+
motherboard_vendor = $2.to_s.dup
|
89
|
+
bios_version = $3.to_s.dup
|
90
|
+
bios_release = $4.to_s.dup
|
91
|
+
# ===================================================================== #
|
92
|
+
# Show some more information next, in particular the BIOS.
|
93
|
+
# ===================================================================== #
|
94
|
+
make_line(' Motherboard vendor', motherboard_vendor)
|
95
|
+
make_line(' Motherboard', motherboard)
|
96
|
+
make_line(' BIOS version', bios_version)
|
97
|
+
make_line(' BIOS released on', bios_release)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# ========================================================================= #
|
102
|
+
# === obtain_vendor_id
|
103
|
+
# ========================================================================= #
|
104
|
+
def obtain_vendor_id
|
105
|
+
result = LSCPU.grep(/Vendor ID:/).first.split(':').last.strip
|
106
|
+
make_line(' Vendor ID', result) { :mediumseagreen }
|
107
|
+
end
|
108
|
+
|
109
|
+
# ========================================================================= #
|
110
|
+
# === obtain_n_cores
|
111
|
+
#
|
112
|
+
# Return how many cores that machine has.
|
113
|
+
# ========================================================================= #
|
114
|
+
def obtain_n_cores
|
115
|
+
make_line(
|
116
|
+
' n CPU cores',
|
117
|
+
`nproc --all`.strip
|
118
|
+
) { :lightgreen }
|
119
|
+
end
|
120
|
+
|
121
|
+
# ========================================================================= #
|
122
|
+
# === obtain_ram (ram tag)
|
123
|
+
# ========================================================================= #
|
124
|
+
def obtain_ram
|
125
|
+
make_line(' RAM (max)', RAM_AVAILABLE) { :orangered }
|
126
|
+
end
|
127
|
+
|
128
|
+
# ========================================================================= #
|
129
|
+
# === obtain_ram_free
|
130
|
+
# ========================================================================= #
|
131
|
+
def obtain_ram_free
|
132
|
+
make_line(' RAM (free)', RAM_AVAILABLE_FREE) { :orangered }
|
133
|
+
end
|
134
|
+
|
135
|
+
# ========================================================================= #
|
136
|
+
# === obtain_swap_size (swap tag)
|
137
|
+
# ========================================================================= #
|
138
|
+
def obtain_swap_size
|
139
|
+
_ = DATASET_FROM_PROC_MEMINFO.grep(/SwapTotal:/).first.
|
140
|
+
split(' ').last.strip.upcase
|
141
|
+
make_line(' SwapTotal', _) { :springgreen }
|
142
|
+
end
|
143
|
+
|
144
|
+
# ========================================================================= #
|
145
|
+
# === obtain_system_bogomips
|
146
|
+
#
|
147
|
+
# BogoMIPS measure CPU speed.
|
148
|
+
# ========================================================================= #
|
149
|
+
def obtain_system_bogomips
|
150
|
+
make_line ' BogoMIPS',
|
151
|
+
SPLITTED_CPUINFO.select {|line|
|
152
|
+
line.include? 'bogomips'
|
153
|
+
}.first.split(':')[1].strip
|
154
|
+
end
|
155
|
+
|
156
|
+
# ========================================================================= #
|
157
|
+
# === obtain_pci_information
|
158
|
+
# ========================================================================= #
|
159
|
+
def obtain_pci_information
|
160
|
+
array_fetch_these_types = %w(
|
161
|
+
SMBus Audio IDE VGA
|
162
|
+
Memory Controller
|
163
|
+
)
|
164
|
+
results = []
|
165
|
+
if LSPCI
|
166
|
+
LSPCI.split(N).each {|line|
|
167
|
+
array_fetch_these_types.each { |inner_line|
|
168
|
+
results << line if line.include? inner_line
|
169
|
+
}
|
170
|
+
}
|
171
|
+
make_line ' PCI Devices', results
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# ========================================================================= #
|
176
|
+
# === obtain_chip_mhz
|
177
|
+
# ========================================================================= #
|
178
|
+
def obtain_chip_mhz
|
179
|
+
make_line ' Chip MHzx',
|
180
|
+
SPLITTED_CPUINFO.select {|line|
|
181
|
+
line.include? 'cpu MHz'
|
182
|
+
}.first.split(':')[1].strip
|
183
|
+
end
|
184
|
+
|
185
|
+
# ========================================================================= #
|
186
|
+
# === obtain_cache_size
|
187
|
+
# ========================================================================= #
|
188
|
+
def obtain_cache_size
|
189
|
+
make_line ' Cache Size',
|
190
|
+
SPLITTED_CPUINFO.select {|line|
|
191
|
+
line.include? 'cache size'
|
192
|
+
}.first.split(':')[1].strip
|
193
|
+
end
|
194
|
+
|
195
|
+
# ========================================================================= #
|
196
|
+
# === obtain_cpu_model
|
197
|
+
# ========================================================================= #
|
198
|
+
def obtain_cpu_model
|
199
|
+
result = SPLITTED_CPUINFO.select {|line|
|
200
|
+
line.include? 'model name'
|
201
|
+
}.first.split(':')[1].strip
|
202
|
+
make_line ' Model', result
|
203
|
+
end
|
204
|
+
|
205
|
+
# ========================================================================= #
|
206
|
+
# === obtain_byte_order
|
207
|
+
# ========================================================================= #
|
208
|
+
def obtain_byte_order
|
209
|
+
result = LSCPU.grep(/Byte Order:/).first.split(':').last.strip
|
210
|
+
make_line ' Byte Order', result
|
211
|
+
end
|
212
|
+
|
213
|
+
# ========================================================================= #
|
214
|
+
# === obtain_cpu_family
|
215
|
+
# ========================================================================= #
|
216
|
+
def obtain_cpu_family
|
217
|
+
result = LSCPU.grep(/CPU family:/).first.split(':').last.strip
|
218
|
+
make_line ' CPU family', result
|
219
|
+
end
|
220
|
+
|
221
|
+
# ========================================================================= #
|
222
|
+
# === obtain_model
|
223
|
+
# ========================================================================= #
|
224
|
+
def obtain_model
|
225
|
+
result = LSCPU.grep(/Model:/).first.split(':').last.strip
|
226
|
+
make_line ' Model', result
|
227
|
+
end
|
228
|
+
|
229
|
+
# ========================================================================= #
|
230
|
+
# === obtain_cpu_op_modes
|
231
|
+
# ========================================================================= #
|
232
|
+
def obtain_cpu_op_modes
|
233
|
+
result = LSCPU.grep(/CPU op-mode/).first.split(':').last.strip
|
234
|
+
make_line(' CPU op-mode(s)', result)
|
235
|
+
end
|
236
|
+
|
237
|
+
# ========================================================================= #
|
238
|
+
# === obtain_linux_kernel_version
|
239
|
+
#
|
240
|
+
# This method should return a String, such as '4.14.4'.
|
241
|
+
# ========================================================================= #
|
242
|
+
def obtain_linux_kernel_version
|
243
|
+
result = `uname -r`.strip
|
244
|
+
make_line(' Linux kernel version', result)
|
245
|
+
end
|
246
|
+
|
247
|
+
# ========================================================================= #
|
248
|
+
# === obtain_architecture
|
249
|
+
# ========================================================================= #
|
250
|
+
def obtain_architecture
|
251
|
+
result = LSCPU.grep(/Architecture:/).first.split(':').last.strip
|
252
|
+
make_line(' Architecture', result) { :violet }
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'hardware_information/class/reset.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
class HardwareInformation
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === reset (reset tag)
|
11
|
+
# ========================================================================= #
|
12
|
+
def reset
|
13
|
+
# ======================================================================= #
|
14
|
+
# === @string
|
15
|
+
# ======================================================================= #
|
16
|
+
@string = ''.dup
|
17
|
+
# ======================================================================= #
|
18
|
+
# === @default_colour
|
19
|
+
# ======================================================================= #
|
20
|
+
@default_colour = green?
|
21
|
+
# ======================================================================= #
|
22
|
+
# === @default_padding
|
23
|
+
#
|
24
|
+
# This variable denotes the leading padding. That padding will be
|
25
|
+
# prepended to the output.
|
26
|
+
# ======================================================================= #
|
27
|
+
@default_padding = ' '.dup # 1 space.
|
28
|
+
# ======================================================================= #
|
29
|
+
# === @use_colours
|
30
|
+
# ======================================================================= #
|
31
|
+
@use_colours = true # If true we use ANSI colours.
|
32
|
+
# ======================================================================= #
|
33
|
+
# === @use_colon_as_delimiter
|
34
|
+
# ======================================================================= #
|
35
|
+
@use_colon_as_delimiter = true # If true we use colon as delimiter.
|
36
|
+
# ======================================================================= #
|
37
|
+
# === @hash_use_these_colours
|
38
|
+
#
|
39
|
+
# Next we will load the internal .yml file, if it exists.
|
40
|
+
# ======================================================================= #
|
41
|
+
@hash_use_these_colours = {}
|
42
|
+
if File.exist? FILE_COLOURS_FOR_THE_HARDWARE_PROJECT
|
43
|
+
require 'yaml'
|
44
|
+
@hash_use_these_colours.update(
|
45
|
+
YAML.load_file(FILE_COLOURS_FOR_THE_HARDWARE_PROJECT)
|
46
|
+
)
|
47
|
+
else # else use a hardcoded approach.
|
48
|
+
@hash_use_these_colours[:filesize_of_the_harddisc] = :orchid
|
49
|
+
@hash_use_these_colours[:file_system_type] = :steelblue
|
50
|
+
end
|
51
|
+
set_commandline_mode # Default.
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'hardware_information/class/run.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
class HardwareInformation
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === run
|
11
|
+
# ========================================================================= #
|
12
|
+
def run
|
13
|
+
add_title
|
14
|
+
obtain_architecture # === Architecture
|
15
|
+
obtain_cpu_model # === The CPU model, such as "AMD"
|
16
|
+
obtain_cpu_op_modes # === CPU op-modes
|
17
|
+
obtain_n_cores # === n CPU cores
|
18
|
+
find_out_the_amount_of_processors # === Amount of processors
|
19
|
+
obtain_vendor_id # === Vendor ID
|
20
|
+
obtain_virtualization # === Virtualization
|
21
|
+
obtain_linux_kernel_version # === The Linux kernel version
|
22
|
+
obtain_ram # === Amount of RAM
|
23
|
+
obtain_ram_free
|
24
|
+
obtain_swap_size # === SwapTotal
|
25
|
+
obtain_chip_mhz # === Chip MHzx
|
26
|
+
obtain_cache_size
|
27
|
+
obtain_system_bogomips # === BogoMIPS
|
28
|
+
obtain_byte_order
|
29
|
+
obtain_cpu_family
|
30
|
+
obtain_model # === Model
|
31
|
+
obtain_information_about_the_GPU # === Show the GPU in use
|
32
|
+
obtain_firmware_information # === Firmware Information
|
33
|
+
obtain_pci_information
|
34
|
+
add_audio_information # === Show the audio device
|
35
|
+
obtain_information_about_the_monitor # === Gather information about the monitor
|
36
|
+
append_newline
|
37
|
+
append_output_generated_via_lsblk
|
38
|
+
report_result if @run_already # Last but not least, report the result.
|
39
|
+
end
|
40
|
+
|
41
|
+
# ========================================================================= #
|
42
|
+
# === HardwareInformation.run
|
43
|
+
# ========================================================================= #
|
44
|
+
def self.run
|
45
|
+
self.new
|
46
|
+
end; self.instance_eval { alias report run } # === HardwareInformation.report
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === HardwareInformation::GUI::Gtk::PurchasedHardware
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'hardware_information/gui/gtk2/purchased_hardware/purchased_hardware.rb'
|
8
|
+
# HardwareInformation::GUI::Gtk::PurchasedHardware.new
|
9
|
+
# =========================================================================== #
|
10
|
+
require 'gtk_paradise/require_gtk2'
|
11
|
+
|
12
|
+
class HardwareInformation
|
13
|
+
|
14
|
+
module GUI
|
15
|
+
|
16
|
+
module Gtk
|
17
|
+
|
18
|
+
class PurchasedHardware < ::Gtk::VBox
|
19
|
+
|
20
|
+
require 'hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb'
|
21
|
+
include ::HardwareInformation::GUI::Gtk::PurchasedHardwareModule
|
22
|
+
|
23
|
+
# ========================================================================= #
|
24
|
+
# === HardwareInformation::GUI::Gtk::PurchasedHardware.run
|
25
|
+
# ========================================================================= #
|
26
|
+
def self.run
|
27
|
+
::HardwareInformation::GUI::Gtk::PurchasedHardwareModule.run
|
28
|
+
end
|
29
|
+
|
30
|
+
end; end; end; end
|
31
|
+
|
32
|
+
if __FILE__ == $PROGRAM_NAME
|
33
|
+
HardwareInformation::GUI::Gtk::PurchasedHardware.run
|
34
|
+
end
|