本文整理汇总了Python中sensors.cleanup函数的典型用法代码示例。如果您正苦于以下问题:Python cleanup函数的具体用法?Python cleanup怎么用?Python cleanup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cleanup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_detected_chips
def _get_detected_chips(): # pragma: no cover
sensors.cleanup()
sensors.init()
chips_detected = list(sensors.iter_detected_chips())
return chips_detected
开发者ID:Bengt,项目名称:AL-FanControl,代码行数:7,代码来源:temperatures.py
示例2: check
def check(self, instance):
## Capture CPU temperature stats
dimensions = self._set_dimensions(None, instance)
sensors.init()
stats ={}
try:
for chip in sensors.iter_detected_chips():
# Only temps from ISA adpters that are deteced by lm_sensors
if (chip.adapter_name == "ISA adapter"):
for feature in chip:
if "Core" in feature.label:
name = feature.label.replace(" ", "_")
name = name.lower()
stats["cpu."+str(chip)+"."+str(name)+"_temperature"] = feature.get_value()
elif "Physical id" in feature.label:
name = feature.label.replace(" ", "_")
name = name.lower()
stats["cpu."+str(chip)+".max_temperature"] = feature.get_value()
finally:
sensors.cleanup()
for key, value in stats.iteritems():
# Writes data to monasca that will go to InfluxDB
self.gauge(key, value, dimensions)
log.debug('Collected {0} cpu temp metrics'.format(len(stats))) 1,1 Top
开发者ID:BU-NU-CLOUD-SP16,项目名称:MOC-Monitoring,代码行数:25,代码来源:temp.py
示例3: get_sensors
def get_sensors(self):
"""
collects the current temperature of CPU
and each core
"""
sensors.init()
added = []
cpu_temp_c = []
try:
for chip in sensors.iter_detected_chips():
for feature in chip:
if feature.name.startswith('temp'):
if ((feature.label.startswith('Physical') or
feature.label.startswith('CPU')) and
feature.label not in added):
self._status.add_cpu_temp(feature.get_value())
elif (feature.label.startswith('Core')
and feature.label not in added):
cpu_temp_c.append(feature.get_value())
added.append(feature.label)
except sensors.SensorsError:
pass
if cpu_temp_c:
try:
self._status.add_cpu_temp_core(cpu_temp_c)
except IndexError:
pass
sensors.cleanup()
开发者ID:ROS-PSE,项目名称:arni,代码行数:29,代码来源:host_statistics_handler.py
示例4: getY
def getY():
sensors.init() # Inicializamos sensores
temperaturas = [] # Guarda todas las tempereturas
#detectadas
suma_total = 0 # Variable de apoyo
try:
# Recorremos todos los sensores detectados
for chip in sensors.iter_detected_chips():
a = chip
b = chip.adapter_name
if b == "PCI adapter":
print "Procesador >", a,
for core in chip:
print "",core.get_value(), "C"
# Agregamos a la lista
temperaturas.append(core.get_value())
total_tempe = len(temperaturas)
suma_total = sum(suma for suma in temperaturas)
prom = int(suma_total) / total_tempe
finally:
sensors.cleanup() # Cerramos los sensores
print "prom =>", prom
print "--------------------------------------"
if SERIAL: ser.write(str(prom)) # Enviamos el prom al arduino
return prom
开发者ID:osvaldojavier14,项目名称:integrador2,代码行数:27,代码来源:tableroSensores.py
示例5: process_temp
def process_temp():
print("-" * 50)
sensors.init()
critical = False
try:
for chip in sensors.ChipIterator():
for feature in sensors.FeatureIterator(chip):
subs = list(sensors.SubFeatureIterator(chip, feature))
critical = None
current = None
for sub in subs:
value = sensors.get_value(chip, sub.number)
if sub.name.endswith(b"input"):
current = value
if sub.name.endswith(b"crit"):
critical_value = value
name = sensors.get_label(chip, feature)
print("Current temp for {}: {} / {}".format(name, current,
critical_value))
if current >= critical_value:
critical = True
if critical:
play_critical()
finally:
sensors.cleanup()
开发者ID:felipelerena,项目名称:voz_cachonda,代码行数:25,代码来源:__init__.py
示例6: get_lmsensor
def get_lmsensor(self):
"""
"""
if self._lmsensor_next_run < datetime.now():
locked = self._lock.acquire(False)
if locked == True:
try:
_lmsensor = {}
pysensors.init(config_filename=self.values["config_filename"].data)
try:
for chip in pysensors.iter_detected_chips():
_lmsensor['%s'%chip] = {}
for feature in chip:
_lmsensor['%s'%chip][feature.label] = feature.get_value()
except Exception:
logger.exception("[%s] - Exception in get_lmsensor", self.__class__.__name__)
finally:
pysensors.cleanup()
for val_id in ['temperature', 'voltage']:
for config in self.values[val_id].get_index_configs():
for chip in _lmsensor:
if config in _lmsensor[chip] :
self.values[val_id].set_data_index(config=config, data=_lmsensor[chip][config])
self._lmsensor_last = True
except Exception:
logger.exception("[%s] - Exception in get_lmsensor", self.__class__.__name__)
self._lmsensor_last = False
finally:
self._lock.release()
min_poll=99999
for val_id in ['temperature_poll', 'voltage_poll']:
if self.values[val_id].data > 0:
min_poll=min(min_poll, self.values[val_id].data)
self._lmsensor_next_run = datetime.now() + timedelta(seconds=min_poll)
开发者ID:bibi21000,项目名称:janitoo_hostsensor_lmsensor,代码行数:34,代码来源:component.py
示例7: metric_init
def metric_init(params):
global descriptors
sensors.init()
corelist = []
try:
for chip in sensors.iter_detected_chips():
if chip.prefix == CORETEMP:
for feature in chip:
if feature.label.startswith('Core'):
corelist.append("%s Temperature" % feature.label)
except:
raise
finally:
sensors.cleanup()
for core in corelist:
print 'name: %s' % core
descriptors.append({'name': core,
'call_back': temp_handler,
'time_max': 90,
'value_type': 'float',
'units': 'Celsius',
'slope': 'both',
'format': '%.2f',
'description': 'Temperature of %s' % core,
'groups': 'Node Health'})
return descriptors
开发者ID:building39,项目名称:pycoretemp,代码行数:29,代码来源:cputemp.py
示例8: serve
def serve(port):
sensors.init()
server = Server("localhost", port)
try:
server.serve_forever()
except KeyboardInterrupt:
server.server_close()
finally:
sensors.cleanup()
开发者ID:nwlunatic,项目名称:sensors-agent,代码行数:9,代码来源:agent.py
示例9: getDictTemp
def getDictTemp():
result = dict()
sensors.init()
try:
for chip in sensors.iter_detected_chips():
for feature in chip:
result[str(feature.label)] = str(feature.get_value())
finally:
sensors.cleanup()
return result
开发者ID:fessoga5,项目名称:zabbix-scripts-sensors,代码行数:10,代码来源:discovery.py
示例10: main
def main():
try:
sensors.init()
log_thread = threading.Thread(target=lambda: run_log(60.0))
log_thread.daemon = True
log_thread.start()
http_viewer.run()
finally:
sensors.cleanup()
开发者ID:fyhuang,项目名称:sensors-log,代码行数:11,代码来源:sensors_log.py
示例11: collect
def collect(self):
if sensors is None:
self.log.error('Unable to import module sensors')
return {}
sensors.init()
try:
for chip in sensors.iter_detected_chips():
for feature in chip:
self.publish(".".join([str(chip), feature.label]), feature.get_value())
finally:
sensors.cleanup()
开发者ID:kippandrew,项目名称:Diamond,代码行数:12,代码来源:lmsensors.py
示例12: temp_handler
def temp_handler(name):
sensors.init()
temp = 0.0
try:
for chip in sensors.iter_detected_chips():
if chip.prefix == CORETEMP:
for feature in chip:
if '%s Temperature' % feature.label == name:
temp = feature.get_value()
finally:
sensors.cleanup()
return temp
开发者ID:building39,项目名称:pycoretemp,代码行数:12,代码来源:cputemp.py
示例13: get_temp
def get_temp():
sensors.init()
temp = 0
try:
for chip in sensors.iter_detected_chips():
for feature in chip:
sensor_temp = feature.get_value()
if sensor_temp > temp:
temp = sensor_temp
finally:
sensors.cleanup()
return temp
开发者ID:Charlyzzz,项目名称:vot.ar,代码行数:13,代码来源:temperature.py
示例14: run
def run(self):
"""
Main program loop. Keep checking the temperature and set fan speed.
"""
while True:
try:
self.check_temperature()
time.sleep(self.poll_time)
except Exception, details:
self.log.error("Main loop ended with exception: %s", details)
self.log.error("Daemon is shutting down...")
sensors.cleanup()
sys.exit(1)
开发者ID:eduardok,项目名称:fanfare,代码行数:13,代码来源:fanfare.py
示例15: getTemp
def getTemp(name):
result = dict()
sensors.init()
try:
for chip in sensors.iter_detected_chips():
for feature in chip:
try:
if feature.label == name:
return feature.get_value()
except:
pass
finally:
sensors.cleanup()
开发者ID:fessoga5,项目名称:zabbix-scripts-sensors,代码行数:13,代码来源:discovery.py
示例16: main
def main():
monitor = Monitor()
updateThread = Thread(target=monitor.update)
sendThread = Thread(target=monitor.send)
updateThread.daemon = True
sendThread.daemon = True
updateThread.start()
sendThread.start()
while (1):
sleep(1000)
sensors.cleanup()
开发者ID:TurBoss,项目名称:TurBoMonitor3000,代码行数:16,代码来源:TurBoMonitor3000.py
示例17: coretemp_handler
def coretemp_handler(name):
sensors.init()
value = 0
try:
for chip in sensors.iter_detected_chips():
if chip.prefix.startswith('coretemp'):
for feature in chip:
if feature.label == name:
value = feature.get_value()
break
except:
print "WTF?!?"
finally:
sensors.cleanup()
return value
开发者ID:building39,项目名称:pycoretemp,代码行数:16,代码来源:coretemp.py
示例18: main
def main():
sensors.init()
try:
for chip in sensors.iter_detected_chips():
print(chip)
print('Adapter:', chip.adapter_name)
for feature in chip:
print('%s (%r): %.1f' % (
feature.name, feature.label, feature.get_value()
))
for subfeature in feature:
print(' %s: %.1f' % (
subfeature.name, subfeature.get_value()
))
print()
finally:
sensors.cleanup()
开发者ID:akaIDIOT,项目名称:python-sensors,代码行数:17,代码来源:cli.py
示例19: collect
def collect(self):
if sensors is None:
self.log.error('Unable to import module sensors')
return {}
sensors.init()
try:
for chip in sensors.iter_detected_chips():
for feature in chip:
label = feature.label.replace(' ', '-')
value = None
try:
value = feature.get_value()
except Exception:
if str_to_bool(self.config['send_zero']):
value = 0
if value is not None:
self.publish(".".join([str(chip), label]), value)
finally:
sensors.cleanup()
开发者ID:Logan2211,项目名称:Diamond,代码行数:21,代码来源:lmsensors.py
示例20: metric_init
def metric_init(params):
global descriptors
metric_group = params.get('metric_group', 'coretemp')
sensors.init()
for chip in sensors.iter_detected_chips():
for feature in chip:
if chip.prefix.startswith('coretemp'):
descriptors.append({
'name': feature.label,
'call_back' : coretemp_handler,
'time_max' : 60,
'units': 'C',
'format' : '%.2f',
'slope' : 'both',
'description' : 'CPU Core Temperature',
'groups' : metric_group,
})
sensors.cleanup()
return descriptors
开发者ID:building39,项目名称:pycoretemp,代码行数:22,代码来源:coretemp.py
注:本文中的sensors.cleanup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论