dstat_thermal.py (dstat-0.7.3) | : | dstat_thermal.py (dstat-0.7.4) | ||
---|---|---|---|---|
### Author: Dag Wieers <dag@wieers.com> | ### Author: Dag Wieers <dag@wieers.com> | |||
class dstat_plugin(dstat): | class dstat_plugin(dstat): | |||
def __init__(self): | def __init__(self): | |||
self.name = 'thermal' | self.name = 'thermal' | |||
self.type = 'd' | self.type = 'd' | |||
self.width = 3 | self.width = 3 | |||
self.scale = 20 | self.scale = 20 | |||
if os.path.exists('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zone/'): | if os.path.exists('/sys/devices/virtual/thermal/'): | |||
self.nick = [] | ||||
self.vars = [] | ||||
for zone in os.listdir('/sys/devices/virtual/thermal/'): | ||||
zone_split=zone.split("thermal_zone") | ||||
if len(zone_split) == 2: | ||||
self.vars.append(zone) | ||||
name="".join(["tz",zone_split[1]]) | ||||
self.nick.append(name) | ||||
elif os.path.exists('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zone/'): | ||||
self.vars = os.listdir('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zo ne/') | self.vars = os.listdir('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zo ne/') | |||
self.nick = [] | self.nick = [] | |||
for name in self.vars: | for name in self.vars: | |||
self.nick.append(name.lower()) | self.nick.append(name.lower()) | |||
elif os.path.exists('/proc/acpi/ibm/thermal'): | elif os.path.exists('/proc/acpi/ibm/thermal'): | |||
self.namelist = ['cpu', 'pci', 'hdd', 'cpu', 'ba0', 'unk', 'ba1', 'u nk'] | self.namelist = ['cpu', 'pci', 'hdd', 'cpu', 'ba0', 'unk', 'ba1', 'u nk'] | |||
self.nick = [] | self.nick = [] | |||
for line in dopen('/proc/acpi/ibm/thermal'): | for line in dopen('/proc/acpi/ibm/thermal'): | |||
l = line.split() | l = line.split() | |||
skipping to change at line 34 | skipping to change at line 44 | |||
self.vars = self.nick | self.vars = self.nick | |||
elif os.path.exists('/proc/acpi/thermal_zone/'): | elif os.path.exists('/proc/acpi/thermal_zone/'): | |||
self.vars = os.listdir('/proc/acpi/thermal_zone/') | self.vars = os.listdir('/proc/acpi/thermal_zone/') | |||
# self.nick = [name.lower() for name in self.vars] | # self.nick = [name.lower() for name in self.vars] | |||
self.nick = [] | self.nick = [] | |||
for name in self.vars: | for name in self.vars: | |||
self.nick.append(name.lower()) | self.nick.append(name.lower()) | |||
else: | else: | |||
raise Exception, 'Needs kernel ACPI or IBM-ACPI support' | raise Exception('Needs kernel thermal, ACPI or IBM-ACPI support') | |||
def check(self): | def check(self): | |||
if not os.path.exists('/proc/acpi/ibm/thermal') and \ | if not os.path.exists('/proc/acpi/ibm/thermal') and \ | |||
not os.path.exists('/proc/acpi/thermal_zone/') and \ | not os.path.exists('/proc/acpi/thermal_zone/') and \ | |||
not os.path.exists('/sys/devices/virtual/thermal/') and \ | ||||
not os.path.exists('/sys/bus/acpi/devices/LNXTHERM:00/thermal_zone/') : | not os.path.exists('/sys/bus/acpi/devices/LNXTHERM:00/thermal_zone/') : | |||
raise Exception, 'Needs kernel ACPI or IBM-ACPI support' | raise Exception('Needs kernel thermal, ACPI or IBM-ACPI support') | |||
def extract(self): | def extract(self): | |||
if os.path.exists('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zone/'): | if os.path.exists('/sys/devices/virtual/thermal/'): | |||
for zone in self.vars: | ||||
for line in dopen('/sys/devices/virtual/thermal/'+zone+'/temp'). | ||||
readlines(): | ||||
l = line.split() | ||||
self.val[zone] = int(l[0]) | ||||
elif os.path.exists('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zone/'): | ||||
for zone in self.vars: | for zone in self.vars: | |||
if os.path.isdir('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zone /'+zone) == False: | if os.path.isdir('/sys/bus/acpi/devices/LNXTHERM:01/thermal_zone /'+zone) == False: | |||
for line in dopen('/sys/bus/acpi/devices/LNXTHERM:01/thermal _zone/'+zone).readlines(): | for line in dopen('/sys/bus/acpi/devices/LNXTHERM:01/thermal _zone/'+zone).readlines(): | |||
l = line.split() | l = line.split() | |||
if l[0].isdigit() == True: | if l[0].isdigit() == True: | |||
self.val[zone] = int(l[0]) | self.val[zone] = int(l[0]) | |||
else: | else: | |||
self.val[zone] = 0 | self.val[zone] = 0 | |||
elif os.path.exists('/proc/acpi/ibm/thermal'): | elif os.path.exists('/proc/acpi/ibm/thermal'): | |||
for line in dopen('/proc/acpi/ibm/thermal'): | for line in dopen('/proc/acpi/ibm/thermal'): | |||
End of changes. 5 change blocks. | ||||
4 lines changed or deleted | 21 lines changed or added |