private JMXConnector initJMXConnector(String svcName)
      throws IOException, AttachNotSupportedException, AgentLoadException,
          AgentInitializationException {
    int pid = PlatformUtils.getServicePid(svcName);
    log.info("{} service pid {}", svcName, pid);

    VirtualMachine vm = VirtualMachine.attach(String.valueOf(pid));
    try {
      String connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
      if (connectorAddress == null) {
        String agent =
            Strings.join(
                File.separator,
                vm.getSystemProperties().getProperty("java.home"),
                "lib",
                "management-agent.jar");
        vm.loadAgent(agent);

        connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
      }

      JMXServiceURL serviceURL = new JMXServiceURL(connectorAddress);
      return JMXConnectorFactory.connect(serviceURL);
    } finally {
      vm.detach();
    }
  }
  @POST
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Path("/natcheck")
  public VdcNatCheckResponse checkIfBehindNat(
      VdcNatCheckParam checkParam, @HeaderParam("X-Forwarded-For") String clientIp) {
    if (checkParam == null) {
      log.error("checkParam is null, X-Forwarded-For is {}", clientIp);
      throw GeoException.fatals.invalidNatCheckCall("(null)", clientIp);
    }

    String ipv4Str = checkParam.getIPv4Address();
    String ipv6Str = checkParam.getIPv6Address();
    log.info(
        String.format(
            "Performing NAT check, client address connecting to VIP: %s. Client reports its IPv4 = %s, IPv6 = %s",
            clientIp, ipv4Str, ipv6Str));

    InetAddress ipv4Addr = parseInetAddress(ipv4Str);
    InetAddress ipv6Addr = parseInetAddress(ipv6Str);
    InetAddress directAddr = parseInetAddress(clientIp);
    if (directAddr == null || ipv4Addr == null && ipv6Addr == null) {
      String ipAddrsStr = Strings.join("|", ipv4Str, ipv6Addr);
      log.error("checkParam is {}, X-Forwarded-For is {}", ipAddrsStr, clientIp);
      throw GeoException.fatals.invalidNatCheckCall(ipAddrsStr, clientIp);
    }

    VdcNatCheckResponse resp = new VdcNatCheckResponse();
    resp.setSeenIp(clientIp);
    resp.setBehindNAT(!directAddr.equals(ipv4Addr) && !directAddr.equals(ipv6Addr));

    return resp;
  }