protected void connectSensors() {
    setAttribute(
        DATASTORE_URL,
        String.format(
            "postgresql://%s:%s/", getAttribute(HOSTNAME), getAttribute(POSTGRESQL_PORT)));

    Maybe<SshMachineLocation> machine = Locations.findUniqueSshMachineLocation(getLocations());

    if (machine.isPresent()) {
      feed =
          SshFeed.builder()
              .entity(this)
              .machine(machine.get())
              .poll(
                  new SshPollConfig<Boolean>(SERVICE_UP)
                      .command("ps -ef | grep [p]ostgres")
                      .setOnSuccess(true)
                      .setOnFailureOrException(false))
              .build();
    } else {
      LOG.warn(
          "Location(s) {} not an ssh-machine location, so not polling for status; setting serviceUp immediately",
          getLocations());
    }
  }
  public static HostAndPort getBrooklynAccessibleAddress(Entity entity, int port) {
    String host;

    // look up port forwarding
    PortForwardManager pfw = entity.getConfig(PORT_FORWARDING_MANAGER);
    if (pfw != null) {
      Collection<Location> ll = entity.getLocations();
      Maybe<SupportsPortForwarding> machine =
          Machines.findUniqueElement(ll, SupportsPortForwarding.class);
      if (machine.isPresent()) {
        synchronized (BrooklynAccessUtils.class) {
          // TODO finer-grained synchronization

          HostAndPort hp = pfw.lookup((MachineLocation) machine.get(), port);
          if (hp != null) return hp;

          Location l = (Location) machine.get();
          if (l instanceof SupportsPortForwarding) {
            Cidr source = entity.getConfig(MANAGEMENT_ACCESS_CIDR);
            if (source != null) {
              log.debug(
                  "BrooklynAccessUtils requesting new port-forwarding rule to access "
                      + port
                      + " on "
                      + entity
                      + " (at "
                      + l
                      + ", enabled for "
                      + source
                      + ")");
              // TODO discuss, is this the best way to do it
              // (will probably _create_ the port forwarding rule!)
              hp = ((SupportsPortForwarding) l).getSocketEndpointFor(source, port);
              if (hp != null) return hp;
            } else {
              log.warn(
                  "No "
                      + MANAGEMENT_ACCESS_CIDR.getName()
                      + " configured for "
                      + entity
                      + ", so cannot forward port "
                      + port
                      + " "
                      + "even though "
                      + PORT_FORWARDING_MANAGER.getName()
                      + " was supplied");
            }
          }
        }
      }
    }

    host = entity.getAttribute(Attributes.HOSTNAME);
    if (host != null) return HostAndPort.fromParts(host, port);

    throw new IllegalStateException(
        "Cannot find way to access port "
            + port
            + " on "
            + entity
            + " from Brooklyn (no host.name)");
  }