summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-02-13 18:45:21 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-02-13 18:45:21 +0100
commitf1005a37a05652a230d6c36f3f22e774ae8c1274 (patch)
treea5cd27213d3483f4c0bafe05c97b154dea8a2b0f /scripts
parent02d6bdba0463e35d8560560323b61f1d31982645 (diff)
downloadpsutil-f1005a37a05652a230d6c36f3f22e774ae8c1274.tar.gz
#974 sensors_fans(): add example script, return dict and named tuple instead of dict + tuple; give CREDITS
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fans.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/fans.py b/scripts/fans.py
new file mode 100755
index 00000000..e302aec5
--- /dev/null
+++ b/scripts/fans.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+# 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.
+
+"""
+Show fans information.
+
+$ python fans.py
+asus
+ cpu_fan 3200 RPM
+"""
+
+from __future__ import print_function
+import sys
+
+import psutil
+
+
+def main():
+ if not hasattr(psutil, "sensors_fans"):
+ return sys.exit("platform not supported")
+ fans = psutil.sensors_fans()
+ if not fans:
+ return sys.exit("no fans detected")
+ for name, entries in fans.items():
+ print(name)
+ for entry in entries:
+ print(" %-20s %s RPM" % (entry.label or name, entry.current))
+ print()
+
+
+if __name__ == '__main__':
+ main()