psutil

Форк
0
/
temperatures.py 
52 строки · 1.5 Кб
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3

4
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
5
# Use of this source code is governed by a BSD-style license that can be
6
# found in the LICENSE file.
7

8
"""A clone of 'sensors' utility on Linux printing hardware temperatures.
9

10
$ python3 scripts/sensors.py
11
asus
12
    asus                 47.0 °C (high = None °C, critical = None °C)
13

14
acpitz
15
    acpitz               47.0 °C (high = 103.0 °C, critical = 103.0 °C)
16

17
coretemp
18
    Physical id 0        54.0 °C (high = 100.0 °C, critical = 100.0 °C)
19
    Core 0               47.0 °C (high = 100.0 °C, critical = 100.0 °C)
20
    Core 1               48.0 °C (high = 100.0 °C, critical = 100.0 °C)
21
    Core 2               47.0 °C (high = 100.0 °C, critical = 100.0 °C)
22
    Core 3               54.0 °C (high = 100.0 °C, critical = 100.0 °C)
23
"""
24

25
from __future__ import print_function
26

27
import sys
28

29
import psutil
30

31

32
def main():
33
    if not hasattr(psutil, "sensors_temperatures"):
34
        sys.exit("platform not supported")
35
    temps = psutil.sensors_temperatures()
36
    if not temps:
37
        sys.exit("can't read any temperature")
38
    for name, entries in temps.items():
39
        print(name)
40
        for entry in entries:
41
            line = "    %-20s %s °C (high = %s °C, critical = %s °C)" % (
42
                entry.label or name,
43
                entry.current,
44
                entry.high,
45
                entry.critical,
46
            )
47
            print(line)
48
        print()
49

50

51
if __name__ == '__main__':
52
    main()
53

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.