-
Notifications
You must be signed in to change notification settings - Fork 0
/
throttle.py
executable file
·30 lines (24 loc) · 925 Bytes
/
throttle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python2
import subprocess
GET_THROTTLED_CMD = 'vcgencmd get_throttled'
MESSAGES = {
0: 'Under-voltage!',
1: 'ARM frequency capped!',
2: 'Currently throttled!',
16: 'Under-voltage has occurred since last reboot.',
17: 'Throttling has occurred since last reboot.',
18: 'ARM frequency capped has occurred since last reboot.'
}
print("Checking for throttling issues since last reboot...")
throttled_output = subprocess.check_output(GET_THROTTLED_CMD, shell=True)
throttled_binary = bin(int(throttled_output.split('=')[1], 0))
warnings = 0
for position, message in MESSAGES.iteritems():
# Check for the binary digits to be "on" for each warning message
if len(throttled_binary) > position and throttled_binary[0 - position - 1] == '1':
print(message)
warnings += 1
if warnings == 0:
print("Looking good!")
else:
print("Houston, we may have a problem!")