sonic-buildimage/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils/show_thresholds

44 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env python
import os
import commands
def fantype_detect():
refpgaTMC_path = "/sys/devices/pci0000:00/0000:00:1c.0/0000:0f:00.0/refpga-tmc.15"
AFO = "1"
AFI = "0"
#default fan type is AFI
default_fantype = 0
for filename in os.listdir(refpgaTMC_path):
if filename.endswith('_type'):
fantype_path = os.path.join(refpgaTMC_path, filename)
cat_string = "cat "
fantype_string = cat_string + fantype_path
status,fan_type=commands.getstatusoutput(fantype_string)
if ((fan_type == AFO) or (fan_type == AFI)):
return fan_type
else:
pass
return default_fantype
def main():
AFO_value = "1"
fan_type = fantype_detect()
if fan_type == AFO_value:
temp_thres_file = open("/usr/local/bin/temperature_thresholds_AFO.txt", "r+")
print temp_thres_file.read()
else:
temp_thres_file = open("/usr/local/bin/temperature_thresholds_AFI.txt", "r+")
print temp_thres_file.read()
temp_thres_file.close()
if __name__ == "__main__":
main()