def snmp_get_oid(a_device, oid='.1.3.6.1.2.1.1.1.0', display_errors=False):
 (a_host, community_string, snmp_port) = a_device
 snmp_target = (a_host, snmp_port)
 cmd_gen = cmdgen.CommandGenerator()
 (error_detected, error_status, error_index, snmp_data) = cmd_gen.getCmd(cmdgen.CommunityData(community_string), cmdgen.UdpTransportTarget(snmp_target), oid, lookupNames=True, lookupValues=True)
 if (not error_detected):
  return snmp_data
 else:
  if display_errors:
   print('ERROR DETECTED: ')
   print(('    %-16s %-60s' % ('error_message', error_detected)))
   print(('    %-16s %-60s' % ('error_status', error_status)))
   print(('    %-16s %-60s' % ('error_index', error_index)))
  return None

def snmp_get_oid ( a_device , oid = '.1.3.6.1.2.1.1.1.0' , display_errors = False ) : ( a_host , community_string , snmp_port ) = a_device snmp_target = ( a_host , snmp_port ) cmd_gen = cmdgen . CommandGenerator ( ) ( error_detected , error_status , error_index , snmp_data ) = cmd_gen . getCmd ( cmdgen . CommunityData ( community_string ) , cmdgen . UdpTransportTarget ( snmp_target ) , oid , lookupNames = True , lookupValues = True ) if ( not error_detected ) : return snmp_data else : if display_errors : print ( 'ERROR DETECTED: ' ) print ( ( '    %-16s %-60s' % ( 'error_message' , error_detected ) ) ) print ( ( '    %-16s %-60s' % ( 'error_status' , error_status ) ) ) print ( ( '    %-16s %-60s' % ( 'error_index' , error_index ) ) ) return None
retrieve the given oid default oid is mib2 .