本文整理汇总了Python中sensors.iter_detected_chips函数的典型用法代码示例。如果您正苦于以下问题:Python iter_detected_chips函数的具体用法?Python iter_detected_chips怎么用?Python iter_detected_chips使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iter_detected_chips函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: get_sensors
def get_sensors(self):
sensor_objects = []
sensor_names = []
for chip in sensors.iter_detected_chips():
logger.debug("Found chip %s, adapter %s", chip, chip.adapter_name)
for feature in chip:
sensor_name = feature.label
# Prevent name conflicts across chips
if not sensor_name in sensor_names:
sensor_names.append(sensor_name)
else:
o = sensor_name
idx = 1
while sensor_name in sensor_names:
idx += 1
sensor_name = "%s-%d" % (o, idx)
sensor_names.append(sensor_name)
logger.debug("' %s: %.2f", sensor_name, feature.get_value())
sensor = Sensor(feature.type, sensor_name, float(feature.get_value()))
sensor_objects.append(sensor)
for subfeature in feature:
name = subfeature.name
if name.endswith("_crit"):
sensor.critical = float(subfeature.get_value())
elif name.endswith("_input"):
sensor.value = float(subfeature.get_value())
return sensor_objects
开发者ID:FPar,项目名称:gnome15,代码行数:30,代码来源:sense.py
示例4: _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
示例5: fetch_sensor_data
def fetch_sensor_data():
try:
sensors.init()
data = {}
for chip in sensors.iter_detected_chips():
for feature in chip:
# log stuff we care about
if feature.label not in IGNORE_READINGS:
data[feature.label] = round(feature.get_value(), 3)
sorted_data = collections.OrderedDict(sorted(data.items()))
write_data_file(sorted_data)
if USE_REDIS:
import redis
REDIS_CONNECTION = redis.StrictRedis(host='localhost', port=6379, db=0)
write_data_redis(sorted_data)
if USE_INFLUX:
from influxdb import InfluxDBClient
INFLUX_CLIENT = InfluxDBClient('localhost', 8086, 'root', 'root', 'jarvis')
write_data_influx(sorted_data, INFLUX_CLIENT)
for name, reading in sorted_data.iteritems():
print "{0}: {1}".format(name, reading)
except Exception as exception:
print_exc()
print "Failed to get sensor data: {0}".format(exception.message)
开发者ID:bassdread,项目名称:zeep,代码行数:32,代码来源:read_sensors.py
示例6: 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
示例7: 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
示例8: __init__
def __init__(self):
"""Initialize"""
print("Initialize")
if os.name == "posix":
sensors.init()
self.ser = serial.Serial()
self.ser.baudrate = 9600
self.ser.port = PORT
try:
self.ser.open()
except:
print("no serial port")
if os.name == "posix":
self.chips = [[0 for feature in chip] for chip in sensors.iter_detected_chips()]
self.cores = psutil.cpu_count()
self.cpuTotal = psutil.cpu_percent()
self.cpu = [0 for cores in range(self.cores)]
self.mem = psutil.virtual_memory()
self.disk = psutil.disk_usage('/')
self.netio = psutil.net_io_counters()
self.netup = 0
self.netdw = 0
self.lastnetup = 0
self.lastnetdw = 0
self.interval = 1
开发者ID:TurBoss,项目名称:TurBoMonitor3000,代码行数:30,代码来源:TurBoMonitor3000.py
示例9: __update__
def __update__(self):
"""Update the stats."""
# Reset the list
self.reset()
if self.initok:
for chip in sensors.iter_detected_chips():
for feature in chip:
sensors_current = {}
if feature.name.startswith(b'temp'):
# Temperature sensor
sensors_current['unit'] = SENSOR_TEMP_UNIT
elif feature.name.startswith(b'fan'):
# Fan speed sensor
sensors_current['unit'] = SENSOR_FAN_UNIT
if sensors_current:
try:
sensors_current['label'] = feature.label
sensors_current['value'] = int(feature.get_value())
except SensorsError as e:
logger.debug("Cannot grab sensor stat(%s)" % e)
else:
self.sensors_list.append(sensors_current)
return self.sensors_list
开发者ID:mikepelley,项目名称:glances,代码行数:25,代码来源:glances_sensors.py
示例10: updateLmSensors
def updateLmSensors(self):
for chip in sensors.iter_detected_chips():
if chip.prefix == b'w83627dhg':
for f in chip:
if f.label.startswith('temp'):
# print(f.label)
self.readings[self.aliases[f.label]] = f.get_value()
开发者ID:paulfantom,项目名称:Server-LCD,代码行数:7,代码来源:temperatures.py
示例11: update
def update(_):
indicator.set_label(prefix + str(tempconvert(int(selected.get_value()))) + deg, '00°C')
global chips
chips = []
for chip in sensors.iter_detected_chips():
chips.append(chip)
return True
开发者ID:AdamNiederer,项目名称:sensors_nouveau,代码行数:7,代码来源:sensors_nouveau.py
示例12: update_sensors
def update_sensors(self):
# Temperature sensors
for chip in pysensors.iter_detected_chips():
for feature in chip:
if feature.type == self.__FEATURE_TEMP:
self.append_sensor(
chip.prefix + '_' + feature.name,
feature.label,
'%.1f ºC',
feature.get_value(),
100.0)
# Cpu usage
self.append_sensor(
'cpu',
'CPU usage',
'%.1f %%',
psutil.cpu_percent(interval=1),
95.0)
# Memory usage
vmem = psutil.virtual_memory()
self.append_sensor(
'memory', 'Memory usage', '%.1f %%', vmem.percent, 95.0)
# Swap usage
vswap = psutil.swap_memory()
self.append_sensor(
'swap', 'Swap usage', '%.1f %%', vswap.percent, 95.0)
开发者ID:abbarrasa,项目名称:openbox,代码行数:29,代码来源:sensors-trayicon.py
示例13: 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
示例14: 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
示例15: _get_temp
def _get_temp(self):
import sensors
sensors.init()
for chip in sensors.iter_detected_chips():
if not 'temp' in str(chip):
continue
tot = 0
for i, feature in enumerate(chip):
tot += feature.get_value()
return float(tot) / (i + 1)
return None
开发者ID:phyng,项目名称:desktop-hardware-monitor,代码行数:11,代码来源:cputemp.py
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: get_sensors_temp
def get_sensors_temp():
temp = {}
chips = sensors.iter_detected_chips()
for chip in chips:
features = {}
for feature in chip:
# temperature type is 2
if feature.type == 2:
features[feature.label] = feature.get_value()
if features:
temp[str(chip)] = features
return temp
开发者ID:nwlunatic,项目名称:sensors-agent,代码行数:13,代码来源:server.py
注:本文中的sensors.iter_detected_chips函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论