Dec-29-2017, 11:31 AM
OK, this is what I expected as output
so, this will print fan and temp status - OK/Fail and Cool/Hot respectively
and this will print RPM and degrees instead of OK/Fail and Cool/Hot
so, this will print fan and temp status - OK/Fail and Cool/Hot respectively
#!/usr/bin/python from easysnmp import Session community = 'public' with open('zyxeldslam.txt') as ipfile: for sr_no, line in enumerate(ipfile, start=1): ip = line.strip() try: # Create an SNMP session to be used for all our requests session = Session(hostname=ip, community=community, version=2) # You may retrieve an individual OID using an SNMP GET fan_oids_templ = '1.3.6.1.4.1.890.1.5.13.1.2.1.1.2.0.{}' temp_oids_templ = '1.3.6.1.4.1.890.1.5.13.1.2.3.1.2.0.0.{}' fans_oids = [fan_oids_templ.format(i) for i in range(1,4)] temps_oids = [temp_oids_templ.format(i) for i in range(1,4)] fans_status = ['Fail' if int(fan.value) < 2000 else 'Ok' for fan in session.get(fans_oids)] temp_status = ['Cool' if int(temp.value) < 50 else 'Hot' for temp in session.get(temps_oids)] data = fans_status data.extend(temp_status) print('{} {} {} {} {} {} {} {}'.format(sr_no, ip, *data)) except Exception as excp: print('Something went wrong!') print(excp)
and this will print RPM and degrees instead of OK/Fail and Cool/Hot
#!/usr/bin/python from easysnmp import Session community = 'public' with open('zyxeldslam.txt') as ipfile: for sr_no, line in enumerate(ipfile, start=1): ip = line.strip() try: # Create an SNMP session to be used for all our requests session = Session(hostname=ip, community=community, version=2) # You may retrieve an individual OID using an SNMP GET fan_oids_templ = '1.3.6.1.4.1.890.1.5.13.1.2.1.1.2.0.{}' temp_oids_templ = '1.3.6.1.4.1.890.1.5.13.1.2.3.1.2.0.0.{}' fans_oids = [fan_oids_templ.format(i) for i in range(1,4)] temps_oids = [temp_oids_templ.format(i) for i in range(1,4)] fans_status = [fan.value for fan in session.get(fans_oids)] temp_status = [temp.value for temp in session.get(temps_oids)] data = [str(sr_no), ip] data.extend(fans_status) data.extend(temp_status) print(' '.join(data)) except Exception as excp: print('Something went wrong!') print(excp)