@Override protected void connectSensors() { String queue = String.format("org.apache.activemq:type=Broker,brokerName=%s,destinationType=Queue,destinationName=%s", getBrokerName(), getName()); jmxFeed = JmxFeed.builder() .entity(this) .helper(jmxHelper) .pollAttribute(new JmxAttributePollConfig<Integer>(QUEUE_DEPTH_MESSAGES) .objectName(queue) .attributeName("QueueSize")) .build(); }
@Override protected void connectSensors() { String queue = format("org.apache.qpid:type=VirtualHost.Queue,VirtualHost=\"%s\",name=\"%s\"", virtualHost, getName()); jmxFeed = JmxFeed.builder() .entity(this) .helper(jmxHelper) .pollAttribute(new JmxAttributePollConfig<Integer>(QUEUE_DEPTH_BYTES) .objectName(queue) .attributeName("QueueDepth")) .pollAttribute(new JmxAttributePollConfig<Integer>(QUEUE_DEPTH_MESSAGES) .objectName(queue) .attributeName("MessageCount")) .build(); }
@Override public JmxFeed call() throws Exception { JmxHelper helper = new JmxHelper(entity); JmxFeed feed = JmxFeed.builder() .entity(entity) .period(period) .helper(helper) .pollAttribute(new JmxAttributePollConfig<T>(sensor) .objectName(objectName) .attributeName(attribute) .suppressDuplicates(Boolean.TRUE.equals(suppressDuplicates)) .onFailureOrException(Functions.<T>constant((T) defaultValue))) .build(); entity.addFeed(feed); return feed; } })
@Override public void start(Collection<? extends Location> locs) { // TODO Auto-generated method stub super.start(locs); sensors().set(Attributes.HOSTNAME, "localhost"); sensors().set(UsesJmx.JMX_PORT, LocalhostMachineProvisioningLocation.obtainPort(PortRanges.fromString("40123+"))); // only supports no-agent, at the moment config().set(UsesJmx.JMX_AGENT_MODE, JmxAgentModes.NONE); sensors().set(UsesJmx.RMI_REGISTRY_PORT, -1); // -1 means to use the JMX_PORT only ConfigToAttributes.apply(this, UsesJmx.JMX_CONTEXT); JmxFeed.Builder feedBuilder = JmxFeed.builder() .entity(this) .pollAttribute(new JmxAttributePollConfig<String>(SENSOR_STRING) .objectName(OBJECT_NAME) .period(50) .attributeName(JMX_ATTRIBUTE_NAME)); if (getConfig(PRE_CREATE_JMX_HELPER)) { JmxHelper jmxHelper = new JmxHelper(this); feedBuilder.helper(jmxHelper); } addFeed(feedBuilder.build()); } }