mirror of
https://github.com/lkddi/dell-fans-controller-docker.git
synced 2026-04-03 09:55:11 +08:00
提示词全部改为中文
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
| 温度(℃) | 风扇转速(%) |
|
||||
|-------|--------------------|
|
||||
| 0-50 | 10 |
|
||||
| 0-50 | 15 |
|
||||
| 50-55 | 20 |
|
||||
| 55-60 | 30 |
|
||||
| 60-65 | 40 |
|
||||
|
||||
@@ -13,15 +13,15 @@ class FanController:
|
||||
self.ipmi = IpmiTool(self.host, self.username, self.password)
|
||||
|
||||
def set_fan_speed(self, speed: int):
|
||||
logger.info(f'Set fan speed: {speed}%')
|
||||
logger.info(f'设置风扇速度: {speed}%')
|
||||
self.ipmi.set_fan_speed(speed)
|
||||
|
||||
def run(self):
|
||||
temperature: int = max(self.ipmi.temperature())
|
||||
logger.info(f'Current maximum temperature: {temperature}')
|
||||
logger.info(f'当前最高温度: {temperature}')
|
||||
|
||||
if 0 < temperature <= 50:
|
||||
self.set_fan_speed(10)
|
||||
self.set_fan_speed(15)
|
||||
elif 50 < temperature <= 55:
|
||||
self.set_fan_speed(20)
|
||||
elif 55 < temperature <= 60:
|
||||
@@ -29,5 +29,5 @@ class FanController:
|
||||
elif 60 < temperature <= 65:
|
||||
self.set_fan_speed(40)
|
||||
else:
|
||||
logger.info(f'Switch fan control to auto mode')
|
||||
logger.info(f'切换风扇控制到自动模式')
|
||||
self.ipmi.switch_fan_mode(auto=True)
|
||||
|
||||
@@ -15,21 +15,21 @@ class IpmiTool:
|
||||
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(
|
||||
f'execute command {cmd} failed:{result.stderr}'
|
||||
f'执行命令 {cmd} 失败:{result.stderr}'
|
||||
)
|
||||
|
||||
return result.stdout
|
||||
|
||||
def mc_info(self) -> str:
|
||||
"""
|
||||
execute ipmitool command mc info
|
||||
执行 ipmitool 命令 mc info
|
||||
:return:
|
||||
"""
|
||||
return self.run_cmd(cmd='mc info')
|
||||
|
||||
def sensor(self) -> str:
|
||||
"""
|
||||
execute ipmitool command sensor
|
||||
执行 ipmitool 命令 sensor
|
||||
:return:
|
||||
"""
|
||||
return self.run_cmd(cmd='sensor')
|
||||
|
||||
8
start.py
8
start.py
@@ -12,13 +12,13 @@ if __name__ == '__main__':
|
||||
password = os.getenv('PASSWORD')
|
||||
|
||||
if host is None:
|
||||
raise RuntimeError('HOST environment variable not set')
|
||||
raise RuntimeError('HOST 环境变量未设置')
|
||||
|
||||
if username is None:
|
||||
raise RuntimeError('USERNAME environment variable not set')
|
||||
raise RuntimeError('USERNAME 环境变量未设置')
|
||||
|
||||
if password is None:
|
||||
raise RuntimeError('PASSWORD environment variable not set')
|
||||
raise RuntimeError('PASSWORD 环境变量未设置')
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -27,5 +27,5 @@ if __name__ == '__main__':
|
||||
time.sleep(60)
|
||||
except Exception as err:
|
||||
logger.error(
|
||||
f'run controller failed {err}. {traceback.format_exc()}'
|
||||
f'运行控制器失败 {err}. {traceback.format_exc()}'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user