diff options
author | Alex Manuskin <amanusk@protonmail.com> | 2018-11-03 16:06:13 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2018-11-03 07:06:13 -0700 |
commit | bb5d032be76980a9e110f03f1203bd35fa85a793 (patch) | |
tree | 8341ee50730726aaaf86ca116e92c1f6fa7839e2 /psutil/_psbsd.py | |
parent | 648d8ba39eff4867d461a45a77d1245e2a909234 (diff) | |
download | psutil-bb5d032be76980a9e110f03f1203bd35fa85a793.tar.gz |
FreeBSD adding temperature sensors (WIP) (#1350)
FreeBSD: add temperature sensors
Diffstat (limited to 'psutil/_psbsd.py')
-rw-r--r-- | psutil/_psbsd.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index c2896cb7..0727dd2e 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -11,6 +11,7 @@ import os import xml.etree.ElementTree as ET from collections import namedtuple from socket import AF_INET +from collections import defaultdict from . import _common from . import _psposix @@ -437,6 +438,23 @@ if FREEBSD: secsleft = minsleft * 60 return _common.sbattery(percent, secsleft, power_plugged) + def sensors_temperatures(): + "Return CPU cores temperatures if available, else an empty dict." + ret = defaultdict(list) + num_cpus = cpu_count_logical() + for cpu in range(num_cpus): + try: + current, high = cext.sensors_cpu_temperature(cpu) + if high <= 0: + high = None + name = "Core %s" % cpu + ret["coretemp"].append( + _common.shwtemp(name, current, high, high)) + except NotImplementedError: + pass + + return ret + # ===================================================================== # --- other system functions |