rpi-cpu-led 0.0.0
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.
- data/bin/rpi-cpu-led +43 -0
- metadata +63 -0
data/bin/rpi-cpu-led
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# LED CPU monitor for raspberry pi
|
3
|
+
#
|
4
|
+
# LED on : CPU frequency is above 700mHz"
|
5
|
+
# LED off : CPU frequency is 700mHz or below"
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'wiringpi'
|
9
|
+
|
10
|
+
def help
|
11
|
+
puts "usage: leddrive [wiringpi_gpio_pin_number] (debug:optional)\n\n"
|
12
|
+
exit 0
|
13
|
+
end
|
14
|
+
|
15
|
+
help if not ARGV[0]
|
16
|
+
led_power_pin = ARGV[0].to_i
|
17
|
+
DEBUG = 0 if not ARGV[1]
|
18
|
+
DEBUG = 1 if ARGV[1] == "debug"
|
19
|
+
base_status = 0
|
20
|
+
|
21
|
+
begin
|
22
|
+
io = WiringPi::GPIO.new
|
23
|
+
io.write(led_power_pin,LOW)
|
24
|
+
while true
|
25
|
+
cpu_freque = File.open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", 'r')
|
26
|
+
cpu_freque.each do |cpu_freq|
|
27
|
+
if cpu_freq.to_i > 700000 and base_status == 0 # turn on led when cpu spikes #
|
28
|
+
base_status = 1
|
29
|
+
date = Time.now if DEBUG == 1
|
30
|
+
puts "[#{date}] - led switched on" if DEBUG == 1
|
31
|
+
io.write(led_power_pin,HIGH)
|
32
|
+
elsif cpu_freq.to_i <= 700000 and base_status == 1 # turn off led when cpu is back to normal #
|
33
|
+
base_status = 0
|
34
|
+
date = Time.now if DEBUG == 1
|
35
|
+
puts "[#{date}] - led switched off" if DEBUG == 1
|
36
|
+
io.write(led_power_pin,LOW)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
cpu_freque.close
|
40
|
+
sleep 0.5
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rpi-cpu-led
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Samer Abdel-Hafez
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-05-12 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: turn off/on LED based on CPU frequency
|
22
|
+
email:
|
23
|
+
- sam@arahant.net
|
24
|
+
executables:
|
25
|
+
- rpi-cpu-led
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files: []
|
31
|
+
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://github.com/nopedial/rpi-cpu-led
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- bin
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
requirements: []
|
56
|
+
|
57
|
+
rubyforge_project: rpi-cpu-led
|
58
|
+
rubygems_version: 1.3.6
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: cpu frequency led based monitoring
|
62
|
+
test_files: []
|
63
|
+
|