summaryrefslogtreecommitdiff
path: root/psutil/_psbsd.py
diff options
context:
space:
mode:
authorAlex Manuskin <amanusk@protonmail.com>2018-12-01 20:14:53 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2018-12-01 19:14:53 +0100
commit459556dd1e2979cdee22177339ced0761caf4c83 (patch)
tree50fc0c6ef3dd355d78220f8c620271ca81a8c03c /psutil/_psbsd.py
parenta3d6a28be2631cae7f78287b0742bba36338a745 (diff)
downloadpsutil-459556dd1e2979cdee22177339ced0761caf4c83.tar.gz
Add CPU frequency support for FreeBSD (#1369)
Add CPU frequency support for FreeBSD (patch by @amanusk)
Diffstat (limited to 'psutil/_psbsd.py')
-rw-r--r--psutil/_psbsd.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index 0727dd2e..d3ce7b5c 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -455,6 +455,32 @@ if FREEBSD:
return ret
+ def cpu_freq():
+ """
+ Return frequency metrics for CPUs. Currently, only CPU 0 is supported
+ by FreeBSD, all other cores match the frequency of CPU 0.
+ """
+ ret = []
+ num_cpus = cpu_count_logical()
+ for cpu in range(num_cpus):
+ try:
+ current, available_freq = cext.cpu_frequency(cpu)
+ except NotImplementedError:
+ continue
+ min_freq = None
+ max_freq = None
+ if available_freq:
+ try:
+ min_freq = int(available_freq.split(" ")[-1].split("/")[0])
+ except(IndexError, ValueError):
+ pass
+ try:
+ max_freq = int(available_freq.split(" ")[0].split("/")[0])
+ except(IndexError, ValueError):
+ pass
+ ret.append(_common.scpufreq(current, min_freq, max_freq))
+ return ret
+
# =====================================================================
# --- other system functions