PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/sensors.py

"""
Read lm-sensors

.. versionadded:: 2014.1.3
"""

import logging

import salt.utils.path

log = logging.getLogger(__name__)


def __virtual__():
    if salt.utils.path.which("sensors"):
        return True
    return (False, "sensors does not exist in the path")


def sense(chip, fahrenheit=False):
    """
    Gather lm-sensors data from a given chip

    To determine the chip to query, use the 'sensors' command
    and see the leading line in the block.

    Example:

    /usr/bin/sensors

    coretemp-isa-0000
    Adapter: ISA adapter
    Physical id 0:  +56.0°C  (high = +87.0°C, crit = +105.0°C)
    Core 0:         +52.0°C  (high = +87.0°C, crit = +105.0°C)
    Core 1:         +50.0°C  (high = +87.0°C, crit = +105.0°C)
    Core 2:         +56.0°C  (high = +87.0°C, crit = +105.0°C)
    Core 3:         +53.0°C  (high = +87.0°C, crit = +105.0°C)

    Given the above, the chip is 'coretemp-isa-0000'.
    """
    extra_args = ""
    if fahrenheit is True:
        extra_args = "-f"
    sensors = __salt__["cmd.run"](
        f"/usr/bin/sensors {chip} {extra_args}", python_shell=False
    ).splitlines()
    ret = {}
    for sensor in sensors:
        sensor_list = sensor.split(":")
        if len(sensor_list) >= 2:
            ret[sensor_list[0]] = sensor_list[1].lstrip()
    return ret