Skip to content

Commit 649ed06

Browse files
author
Konstantin Wolff
committed
adapted setup.py to new classnames, fixed bug in probehealth sensor
1 parent a6381ef commit 649ed06

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

miniprobe/sensors/probehealth.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,13 @@ def read_temp(self):
210210
data = []
211211
chandata = []
212212
try:
213-
temp = open("/sys/class/thermal/thermal_zone0/temp", "r")
214-
lines = temp.readlines()
215-
temp.close()
216-
temp_string = lines[0]
213+
if os.path.exists("/sys/class/thermal/thermal_zone0/temp"):
214+
temp = open("/sys/class/thermal/thermal_zone0/temp", "r")
215+
lines = temp.readlines()
216+
temp.close()
217+
temp_string = lines[0]
218+
else:
219+
return chandata
217220
except OSError:
218221
logging.debug("Could not read temp file, no data will be returned")
219222
return chandata
@@ -238,13 +241,16 @@ def read_probe_health(self, config):
238241
data = []
239242
chandata = []
240243
try:
241-
temp = open("/sys/class/thermal/thermal_zone0/temp", "r")
242-
lines = temp.readlines()
243-
temp.close()
244-
temp_float = float(lines[0]) / 1000.0
245-
if temp_float > config['maxtemp']:
246-
health -= 25
247-
logging.debug("Current Health: %s percent" % health)
244+
if os.path.exists("/sys/class/thermal/thermal_zone0/temp"):
245+
temp = open("/sys/class/thermal/thermal_zone0/temp", "r")
246+
lines = temp.readlines()
247+
temp.close()
248+
temp_float = float(lines[0]) / 1000.0
249+
if temp_float > config['maxtemp']:
250+
health -= 25
251+
logging.debug("Current Health: %s percent" % health)
252+
else:
253+
return chandata
248254
except OSError:
249255
logging.debug("Health not changed, no temperature available")
250256
pass

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def init_script(self, script_path, user):
138138
return init_script_tpl.read() % (script_path, user)
139139

140140
def write_load_list(self, ds18b20_sensors, other_sensors):
141-
default_sensors = "Ping,HTTP,Port,SNMPCustom,CPULoad,Memory,Diskspace,SNMPTraffic,CPUTemp,Probehealth,External_IP,aDNS,APT,NMAP"
141+
default_sensors = "Ping,HTTP,Port,SNMPCustom,CPULoad,Memory,Diskspace,SNMPTraffic,CPUTemp,Probehealth,ExternalIP,ADNS,APT,NMAP"
142142
if not (other_sensors == ""):
143143
default_sensors = default_sensors + "," + other_sensors
144144
f=open("./miniprobe/sensors/__init__.py","a")

0 commit comments

Comments
 (0)