-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsmctrace.py
executable file
·95 lines (84 loc) · 1.85 KB
/
smctrace.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/python
import os
import time
import signal
from subprocess import check_output as call
known_ones = {
'A': 'Ambient',
'C': 'CPU',
'N': 'Northbridge',
'G': 'GPU',
'M': 'Memory',
}
wheres = {
'P': 'Proximity',
'V': 'Vent',
'H': 'Heatsink',
'D': 'Die',
'C': 'Core',
'R': 'Rail',
}
fan_where = {
'Ac': 'Current',
'Tg': 'Target',
'Mn': 'Min',
'Mx': 'Max',
'Sf': 'Safe',
}
def key2header(key):
if key[0] == 'F': # Fan
if key[2:4] in fan_where:
where = fan_where[key[2:4]]
else:
where = key[2:4]
s = "Fan_%s_%s_RPM"%(key[1], where)
else:
if key[1] in known_ones:
who = known_ones[key[1]]
else:
who = key[1]
if key[3] in wheres:
where = wheres[key[3]]
else:
where = key[3]
s = "%s_%s_%s_%s"%(key[0], who, key[2], where)
return s
DEFAULT_LIST = [
'F0Ac', 'F0Tg',
'TA0P', 'TA0V',
'TA1P', 'TA2P',
'TC0P', 'TC0c',
'TC1c', 'TC2c', 'TC3c', 'TCXc',
'TG0P', 'TG1P',
'TG0r', 'TG1r',
'PC0C', 'PC0S',
'PCPC', 'PCPT', 'PCTR',
'PG0C', 'PG0S', 'PG0R',
'PG1C', 'PG1S', 'PG1R',
'VC0C', 'VC0S',
'VCTR',
'VG0C', 'VG0S', 'VG0R',
'VG1C', 'VG1S', 'VG1R',
'VH0R', 'VI1R',
'IC0C', 'IC0S',
'ICTR', 'ICTX',
'IG0C', 'IG0S', 'IG0R',
'IG1C', 'IG1S', 'IG1R',
'IH0R', 'II0R',
]
exit_requested = False
def ctrlc_handler(signum, frame):
global exit_requested
exit_requested = True
def main():
mypath = os.path.dirname(os.path.realpath(__file__))
signal.signal(signal.SIGINT, ctrlc_handler)
a = DEFAULT_LIST
headers = [key2header(x) for x in a]
print ','.join(['time'] + headers)
start = time.time()
while True and not exit_requested:
s = call(['%s/smcprint'%mypath] + a)
print "%f,%s"%(time.time()-start, s.strip())
time.sleep(.5)
main()