.credentialsIfNotNull(config().get(MesosCluster.MESOS_USERNAME), config().get(MesosCluster.MESOS_PASSWORD)) .poll(HttpPollConfig.forSensor(MEMORY_AVAILABLE) .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), Functions.compose( .onFailureOrException(Functions.constant(-1L))) .poll(HttpPollConfig.forSensor(CPU_AVAILABLE) .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), Functions.compose( .onFailureOrException(Functions.constant(-1d))) .poll(HttpPollConfig.forSensor(DISK_AVAILABLE) .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), Functions.compose( .onFailureOrException(Functions.constant(-1L))) .poll(HttpPollConfig.forSensor(MEMORY_USED) .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), Functions.compose( .onFailureOrException(Functions.constant(-1L))) .poll(HttpPollConfig.forSensor(CPU_USED) .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), Functions.compose(
@Override protected void connectSensors() { super.connectSensors(); ConfigToAttributes.apply(this); HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getHttpPort()); String nodeJsUrl = String.format("http://%s:%d", accessible.getHostText(), accessible.getPort()); if (isHttpMonitoringEnabled()) { LOG.info("Connecting to {}", nodeJsUrl); httpFeed = HttpFeed.builder() .entity(this) .baseUri(nodeJsUrl) .poll(new HttpPollConfig<Boolean>(SERVICE_UP) .suppressDuplicates(true) .suburl(getConfig(NodeJsWebAppService.SERVICE_UP_PATH)) .checkSuccess(Predicates.alwaysTrue()) .onSuccess(HttpValueFunctions.responseCodeEquals(200)) .setOnException(false)) .build(); } else { connectServiceUpIsRunning(); } WebAppServiceMethods.connectWebAppServerPolicies(this); }
@Override public void connectSensors() { super.connectSensors(); HttpFeed.Builder httpFeedBuilder = HttpFeed.builder() .entity(this) .period(2000, TimeUnit.MILLISECONDS) .baseUri(sensors().get(FRAMEWORK_URL)) .credentialsIfNotNull(config().get(MesosCluster.MESOS_USERNAME), config().get(MesosCluster.MESOS_PASSWORD)) .poll(HttpPollConfig.forSensor(MARATHON_APPLICATIONS) .suppressDuplicates(true) .suburl("/v2/apps/") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), JsonFunctions.walk("apps"), JsonFunctions.forEach(JsonFunctions.<String>getPath("id")))) .onFailureOrException(Functions.constant(Arrays.asList(new String[0])))) .poll(HttpPollConfig.forSensor(MARATHON_VERSION) .suppressDuplicates(true) .suburl("/v2/info/") .onSuccess(HttpValueFunctions.jsonContents("version", String.class)) .onFailureOrException(Functions.constant(""))) .poll(HttpPollConfig.forSensor(SERVICE_UP) .suppressDuplicates(true) .suburl("/ping") .onSuccess(HttpValueFunctions.responseCodeEquals(200)) .onFailureOrException(Functions.constant(Boolean.FALSE))); httpFeed = httpFeedBuilder.build(); }
@Override public void connectSensors() { super.connectSensors(); connectServiceUpIsRunning(); HostAndPort hostAndPort = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, sensors().get(DOCKER_REGISTRY_PORT)); sensors().set(Attributes.MAIN_URI, URI.create("https://" + hostAndPort + "/v2")); httpFeed = HttpFeed.builder() .entity(this) .period(Duration.seconds(3)) .baseUri(getAttribute(Attributes.MAIN_URI)) .poll(new HttpPollConfig<Boolean>(Attributes.SERVICE_UP) .onSuccess(Functions.constant(true)) .onFailureOrException(Functions.constant(false))) .poll(new HttpPollConfig<List<String>>(DOCKER_REGISTRY_CATALOG) .suburl("/_catalog") .onSuccess(Functionals.chain( HttpValueFunctions.jsonContents(), JsonFunctions.walk("repositories"), JsonFunctions.forEach(JsonFunctions.cast(String.class)))) .onFailureOrException(Functions.constant(Collections.<String>emptyList()))) .build(); }
.period(getConfig(POLL_PERIOD)) .poll(HttpPollConfig.forMultiple() .suburl("/sensors/current-state") .onSuccess(mirrorSensors) .onFailureOrException(new Function<Object, Void>() {
.credentialsIfNotNull(getConfig(MANAGEMENT_USER), getConfig(MANAGEMENT_PASSWORD)) .poll(new HttpPollConfig<Boolean>(WEB_CONSOLE_ACCESSIBLE) .suburl("/v1/server/healthy") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), JsonFunctions.cast(Boolean.class))) .setOnException(false)) .poll(new HttpPollConfig<ManagementNodeState>(MANAGEMENT_NODE_STATE) .suburl("/v1/server/ha/state") .onSuccess(Functionals.chain(Functionals.chain(HttpValueFunctions.jsonContents(), JsonFunctions.cast(String.class)), Enums.fromStringFunction(ManagementNodeState.class))) .setOnFailureOrException(null))
.credentialsIfNotNull(config().get(MESOS_USERNAME), config().get(MESOS_PASSWORD)) .poll(HttpPollConfig.forSensor(SERVICE_UP) .suburl("/master/health") .onSuccess(HttpValueFunctions.responseCodeEquals(200)) .onFailureOrException(Functions.constant(Boolean.FALSE))) .onFailureOrException(Functions.constant(-1L))) .poll(HttpPollConfig.forSensor(MEMORY_TOTAL_BYTES) .suburl("/system/stats.json") .onSuccess(HttpValueFunctions.jsonContents("mem_total_bytes", Long.class)) .onFailureOrException(Functions.constant(-1L))); .poll(HttpPollConfig.forSensor(MESOS_SLAVE_LIST) .description("Scan Cluster Slaves") .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), JsonFunctions.walk("slaves"), new Function<JsonElement, List<String>>() { @Override
@Override public void connectSensors() { Duration scanInterval = config().get(MesosCluster.SCAN_INTERVAL); HttpFeed.Builder taskScanBuilder = HttpFeed.builder() .entity(this) .period(scanInterval) .baseUri(config().get(MesosCluster.MESOS_URL)) .credentialsIfNotNull(config().get(MesosCluster.MESOS_USERNAME), config().get(MesosCluster.MESOS_PASSWORD)) .poll(HttpPollConfig.forSensor(MESOS_TASK_LIST) .description("Scan Tasks") .suburl("/master/state.json") .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), JsonFunctions.walk("frameworks"), new Function<JsonElement, List<String>>() { @Override public List<String> apply(JsonElement frameworks) { return scanTasks(frameworks.getAsJsonArray()); } })) .onFailureOrException(Functions.<List<String>>constant(null))); taskScan = taskScanBuilder.build(); }