2 -- License: Public domain
3 -- Last Changed: Unknown
9 -- Use the key "cpufreq_[KMG]" to get the current CPU frequency in
10 -- K/M/GHz, according to /sys/devices/system/cpu/cpuX/cpufreq/. (This
11 -- has the advantage of being a much "rounder" number than the one in
12 -- /proc/cpuinfo, as provided by statusd_cpuspeed.lua.)
14 -- The "cpu" option to the statusd settings for cpufreq modifies which
17 local defaults
={ update_interval
=2*1000, cpu
=0 }
18 local settings
=table.join(statusd
.get_config("cpufreq"), defaults
)
20 function get_cpufreq()
21 local f
=io
.open('/sys/devices/system/cpu/cpu'.. settings
.cpu
..'/cpufreq/scaling_cur_freq')
22 local cpufreq_K
= f
:read('*a')
25 local cpufreq_M
= cpufreq_K
/ 1000
26 local cpufreq_G
= cpufreq_M
/ 1000
28 return tostring(cpufreq_K
), tostring(cpufreq_M
), tostring(cpufreq_G
)
31 function update_cpufreq()
32 local cpufreq_K
, cpufreq_M
, cpufreq_G
= get_cpufreq()
33 statusd
.inform("cpufreq_K", cpufreq_K
)
34 statusd
.inform("cpufreq_M", cpufreq_M
)
35 statusd
.inform("cpufreq_G", cpufreq_G
)
36 cpufreq_timer
:set(settings
.update_interval
, update_cpufreq
)
39 cpufreq_timer
= statusd
.create_timer()