Exemplo 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
Exemplo n.º 2
0
    sfs = list(sensors.SubFeatureIterator(chip, feature)) # get a list of all subfeatures

    label = sensors.get_label(chip, feature)

    skipname = len(feature.name)+1 # skip common prefix
    vals = [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(vals[0]) == 1 else "normal"
        print("\t"+label+"\t"+status)
        return

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

    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 chip in sensors.ChipIterator(): # optional arg like "coretemp-*" restricts iterator
        print(sensors.chip_snprintf_name(chip)+" ("+sensors.get_adapter_name(chip.bus)+")")
        for feature in sensors.FeatureIterator(chip):
            print_feature(chip, feature)

    sensors.cleanup()
Exemplo n.º 3
0
    skipname = len(feature.name) + 1  # skip common prefix
    vals = [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(vals[0]) == 1 else "normal"
        print("\t" + label + "\t" + status)
        return

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

    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 chip in sensors.ChipIterator(
    ):  # optional arg like "coretemp-*" restricts iterator
        print(
            sensors.chip_snprintf_name(chip) + " (" +
            sensors.get_adapter_name(chip.bus) + ")")
        for feature in sensors.FeatureIterator(chip):
            print_feature(chip, feature)

    sensors.cleanup()
Exemplo n.º 4
0
    names = [sf.name[skipname:].decode("utf-8") for sf in sfs]
    data = list(zip(names, vals))

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

    if vals[2] > value_max[label]:
        print("\tCheck "+src[label]+"\tFAILED! "+str(vals[2])+" > "+str(value_max[label])+")")
        return False

    if vals[1] < value_min[label]:
        print("\tCheck "+src[label]+"\tFAILED! "+str(vals[1])+" < "+str(value_min[label])+")")
        return False

    print("\tCheck "+src[label]+"\t"+"\t("+str(vals[0])+") ....OK")
    return True

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

    print("Checking board voltage:")

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

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

    sensors.cleanup()