Exemple #1
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()
    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()
Exemple #3
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()