import requests


def metric_request(port):
  """
  Sends an http request to a node's jmx endpoint. Returns the parsed json, or None on error.
  """
  try:
    _r = requests.get('http://localhost:%d/jmx' % (port))
  except:
    return None
  if _r.status_code != 200:
    return None
  try:
    return _r.json()
  except ValueError:
    return None