Esempio n. 1
0
def coretemp():
    rv = {}
    for chip in sensors.ChipIterator():
        chipname = sensors.chip_snprintf_name(chip)
        if "temp" not in chipname:
            continue

        chipdata = {}
        for feature in sensors.FeatureIterator(chip):
            label = sensors.get_label(chip, feature)

            sfs = list(sensors.SubFeatureIterator(chip, feature)) # get a list of all subfeatures
            vals = [sensors.get_value(chip, sf.number) for sf in sfs]
            names = [sf.name[len(feature.name)+1:].decode("utf-8") for sf in sfs]

            data = dict(zip(names, vals))
            # We use the label instead of the name because the name is typically unhelpful.
            chipdata[sanitizeName(label)] = data["input"]
        
        rv[chipname] = chipdata
    
    return rv
Esempio n. 2
0
def get_temp():
    sensors.init()
    temp = 0
    try:
        for chip in sensors.ChipIterator():
            for feature in sensors.FeatureIterator(chip):
                subs = list(sensors.SubFeatureIterator(chip, feature))
                try:
                    sensor_temp = sensors.get_value(chip, subs[0].number)
                    # el 200 es por que en las maquinas de desarrollo devuelve
                    # los RPM de los ventiladores como features. Esta es la
                    # solucion menos compleja para descartar ese valor.
                    if sensor_temp < 200 and sensor_temp > temp:
                        temp = sensor_temp
                except Exception:
                    # alguno de los sensores no se pudo leer. en circunstancias
                    # normales no pasa pero atajamoe el error para que siga con
                    # el resto de las featuras
                    pass
    finally:
        sensors.cleanup()

    return temp
            if minutes > 15:
                rep = 1
                critical_alarm0 = 0
                critical_alarm1 = 0
                critical_alarm2 = 0
                critical_alarm3 = 0
                critical_alarm4 = 0
                critical_alarm5 = 0
    #print("*********************************")
        print "Time :  %f " % time.time()
        cnt = 0
        for chip in sensors.ChipIterator(
        ):  # optional arg like "coretemp-*" restricts iterator
            #print(sensors.chip_snprintf_name(chip)+" ("+sensors.get_adapter_name(chip.bus)+")")
            print("*********************************")
            for feature in sensors.FeatureIterator(chip):
                #print_feature(chip, feature)
                #value = sensors.get_value(chip, feature.number)

                #print(value)
                #print(feature.number)
                if cnt == 1:
                    coretemp[0] = sensors.get_value(chip, 4)
                    coretemp[1] = sensors.get_value(chip, 8)
                    coretemp[2] = sensors.get_value(chip, 12)
                    coretemp[3] = sensors.get_value(chip, 16)
                    coretemp[4] = sensors.get_value(chip, 20)
                    coretemp[5] = sensors.get_value(chip, 24)

                    dateTimeObj = datetime.now()
                    timestampStr = dateTimeObj.strftime(
Esempio n. 4
0
    label = sensors.get_label(chip, feature)

    skip_name = len(feature.name) + 1  # skip common prefix
    values = [sensors.get_value(chip, sf.number) for sf in sfs]

    if feature.type == sensors.Feature.INTRUSION:
        # short path for INTRUSION to demonstrate type usage
        status = "alarm" if int(values[0]) == 1 else "normal"
        print("\t" + label + "\t" + status)
        return

    names = [sf.name[skip_name:].decode("utf-8") for sf in sfs]
    data = list(zip(names, values))

    str_data = ", ".join([e[0] + ": " + str(e[1]) for e in data])
    print("\t" + label + "\t" + str_data)


if __name__ == "__main__":
    sensors.init()  # optionally takes config file

    print("libsensors version: " + sensors.VERSION)

    for c in sensors.ChipIterator():  # optional arg like "coretemp-*" restricts iterator
        print(sensors.chip_snprintf_name(c) + " (" + sensors.get_adapter_name(c.bus) + ")")
        for f in sensors.FeatureIterator(c):
            print_feature(c, f)

    sensors.cleanup()