summaryrefslogtreecommitdiff
path: root/scripts/temperatures.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-02-01 16:29:02 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-02-01 16:29:02 +0100
commitcba54bcfd8c0e618d087e5079f33b6be7d518a37 (patch)
tree5413de9acc21bb81c9547e166b150ef74a5eae1a /scripts/temperatures.py
parentc019b2ecc9207327922c6b8b591fa358418bd186 (diff)
downloadpsutil-cba54bcfd8c0e618d087e5079f33b6be7d518a37.tar.gz
update HISTORY / README
Diffstat (limited to 'scripts/temperatures.py')
-rwxr-xr-xscripts/temperatures.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/temperatures.py b/scripts/temperatures.py
new file mode 100755
index 00000000..4b14180e
--- /dev/null
+++ b/scripts/temperatures.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+A clone of 'sensors' utility on Linux printing hardware temperatures.
+
+$ python scripts/sensors.py
+asus
+ asus 47.0 °C (high = None °C, critical = None °C)
+
+acpitz
+ acpitz 47.0 °C (high = 103.0 °C, critical = 103.0 °C)
+
+coretemp
+ Physical id 0 54.0 °C (high = 100.0 °C, critical = 100.0 °C)
+ Core 0 47.0 °C (high = 100.0 °C, critical = 100.0 °C)
+ Core 1 48.0 °C (high = 100.0 °C, critical = 100.0 °C)
+ Core 2 47.0 °C (high = 100.0 °C, critical = 100.0 °C)
+ Core 3 54.0 °C (high = 100.0 °C, critical = 100.0 °C)
+"""
+
+from __future__ import print_function
+import sys
+
+import psutil
+
+
+def main():
+ if not hasattr(psutil, "sensors_temperatures"):
+ sys.exit("platform not supported")
+ temps = psutil.sensors_temperatures()
+ for name, entries in temps.items():
+ print(name)
+ for entry in entries:
+ print(" %-20s %s °C (high = %s °C, critical = %s °C)" % (
+ entry.label or name, entry.current, entry.high,
+ entry.critical))
+ print()
+
+
+if __name__ == '__main__':
+ main()