code: def _sge_get_mem(xmlstring, queue_name):
      
      rootxml = ET.fromstring(xmlstring)
      my_machine_dict = {}
      # on some machines rootxml.tag looks like "{...}qhost" where the "{...}" gets prepended to all attributes
      rootTag = rootxml.tag.rstrip("qhost")
      for host in rootxml.findall(rootTag + 'host'):
          # find all hosts supporting queues
          for queues in host.findall(rootTag + 'queue'):
              # if the user specified queue matches that in the xml:
              if not queue_name or any(q in queues.attrib['name'] for q in queue_name.split(",")):
                  my_machine_dict[host.attrib['name']] = {}
                  # values from xml for number of processors and mem_total on each machine
                  for hostvalues in host.findall(rootTag + 'hostvalue'):
                      if('mem_total' == hostvalues.attrib['name']):
                          if hostvalues.text.lower().endswith('g'):
                              multip = 1
                          elif hostvalues.text.lower().endswith('m'):
                              multip = 1 / float(1024)
                          elif hostvalues.text.lower().endswith('t'):
                              multip = 1024
                          else:
                              raise Exception("Unrecognized suffix in mem_tot from SGE")
                          my_machine_dict[host.attrib['name']]['mem_total'] = \
                                  float(hostvalues.text[:-1]) * float(multip)
                  break
      return my_machine_dict
docs: Get memory information from qhost