@Override public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException { return mbeanServer.getAttributes(name, attributes); }
@Override public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException { return mbeanServer.getAttributes(name, attributes); }
@Override public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException { return mbeanServer.getAttributes(name, attributes); }
@Override public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException { return mbeanServer.getAttributes(name, attributes); }
private ImmutableMap<String, Optional<Object>> getAttributes(Set<String> uniqueColumnNames, String name) throws JMException { ObjectName objectName = new ObjectName(name); String[] columnNamesArray = uniqueColumnNames.toArray(new String[uniqueColumnNames.size()]); ImmutableMap.Builder<String, Optional<Object>> attributes = ImmutableMap.builder(); for (Attribute attribute : mbeanServer.getAttributes(objectName, columnNamesArray).asList()) { attributes.put(attribute.getName(), Optional.ofNullable(attribute.getValue())); } return attributes.build(); }
/** {@inheritDoc} */ @Override public AttributeList getAttributes(ObjectName name, String[] attrs) throws InstanceNotFoundException, ReflectionException { return origin.getAttributes(name, attrs); }
@Override public long[] getFileDecriptorInfo() { MBeanServer mbsc = MBeans.getMBeanServer(); AttributeList attributes; try { attributes = mbsc.getAttributes( new ObjectName("java.lang:type=OperatingSystem"), new String[]{"OpenFileDescriptorCount", "MaxFileDescriptorCount"}); List<Attribute> attrList = attributes.asList(); long openFdCount = (Long)attrList.get(0).getValue(); long maxFdCount = (Long)attrList.get(1).getValue(); long[] fdCounts = { openFdCount, maxFdCount}; return fdCounts; } catch (Exception e) { LogFactory.getLog(SdkMBeanRegistrySupport.class).debug( "Failed to retrieve file descriptor info", e); } return null; }
public static double getProcessCpuLoad() throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = ObjectName.getInstance("java.lang:type=OperatingSystem"); AttributeList list = mbs.getAttributes(name, new String[]{ "ProcessCpuLoad" }); if (list.isEmpty()) return Double.NaN; Attribute att = (Attribute)list.get(0); Double value = (Double)att.getValue(); // usually takes a couple of seconds before we get real values if (value == -1.0) return Double.NaN; // returns a percentage value with 1 decimal point precision return ((int)(value * 1000) / 10.0); }
private AttributeList getAttributes(MetricName metricName, String... attributes) throws Exception { return mBeanServer.getAttributes(objectName(metricName), attributes); }
strAtts[i] = attrs[i].getName(); AttributeList attrList = mbeanServer.getAttributes(obj.getObjectName(), strAtts); String component = obj.getObjectName().toString().substring( obj.getObjectName().toString().indexOf('=') + 1);
private static void fetchExecutorMetrics(long now, MBeanServer mbs, List<Metric> metrics) throws JMException { final ObjectName executorName = new ObjectName("Catalina:type=Executor,*"); final Set<ObjectName> names = mbs.queryNames(executorName, null); if (names == null) { return; } for (ObjectName name : names) { AttributeList list = mbs.getAttributes(name, EXECUTOR_ATTRS); for (Attribute a : list.asList()) { addMetric(metrics, a.getName().equals("completedTaskCount") ? toCounter(now, name, a) : toGauge(now, name, a)); } } }
private static void fetchRequestProcessorMetrics(long now, MBeanServer mbs, List<Metric> metrics) throws JMException { final ObjectName globalName = new ObjectName("Catalina:type=GlobalRequestProcessor,*"); final Set<ObjectName> names = mbs.queryNames(globalName, null); if (names == null) { return; } for (ObjectName name : names) { AttributeList list = mbs.getAttributes(name, GLOBAL_REQ_ATTRS); for (Attribute a : list.asList()) { // the only gauge here is maxTime addMetric(metrics, a.getName().equals("maxTime") ? toGauge(now, name, a) : toCounter(now, name, a)); } } }
private AttributeList getCpuAttributes() { try { String[] names = new String[]{ATTRIBUTE_NAME_ProcessCpuLoad, ATTRIBUTE_NAME_SystemCpuLoad, ATTRIBUTE_NAME_ProcessCpuTime}; AttributeList list = platformMBeanServer.getAttributes(operatingSystemObjectName, names); if (list.size() != names.length) { logger.warn("Failed to get all attributes"); return new AttributeList(); } return list; } catch (Throwable ex) { logger.warn("Failed to get CPU MBean attributes", ex); return null; } } }
try { final List<Object> attributes = mbeanServer.getAttributes(name, attributeNamesArray); for (final Object object : attributes) { final Attribute attribute = (Attribute) object;
private static void fetchThreadPoolMetrics(long now, MBeanServer mbs, List<Metric> metrics) throws JMException { final ObjectName threadPoolName = new ObjectName("Catalina:type=ThreadPool,*"); final Set<ObjectName> names = mbs.queryNames(threadPoolName, null); if (names == null) { return; } for (ObjectName name : names) { AttributeList list = mbs.getAttributes(name, THREAD_POOL_ATTRS); // determine whether the shared threadPool is used boolean isUsed = true; for (Attribute a : list.asList()) { if (a.getName().equals("maxThreads")) { Number v = (Number) a.getValue(); isUsed = v.doubleValue() >= 0.0; break; } } if (isUsed) { // only add the attributes if the metric is used. for (Attribute a : list.asList()) { addMetric(metrics, toGauge(now, name, a)); } } } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { MBeanServer mbs = TransactionExtension.getMBeanServer(context); final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); try { final ObjectName on = LogStoreResource.getObjectName(resource); final ModelNode model = resource.getModel().clone(); AttributeList attributes = mbs.getAttributes(on, LogStoreConstants.PARTICIPANT_JMX_NAMES); for (javax.management.Attribute attribute : attributes.asList()) { String modelName = LogStoreConstants.jmxNameToModelName(LogStoreConstants.MODEL_TO_JMX_PARTICIPANT_NAMES, attribute.getName()); if (modelName != null) { ModelNode aNode = model.get(modelName); Object value = attribute.getValue(); if (aNode != null) aNode.set(value == null ? "" : value.toString()); } } // Replace the model resource.writeModel(model); } catch (Exception e) { throw new OperationFailedException("JMX error: " + e.getMessage()); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
/** {@inheritDoc} */ public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException { return delegate.getAttributes(name, attributes); }
@Override public long[] getFileDecriptorInfo() { MBeanServer mbsc = MBeans.getMBeanServer(); AttributeList attributes; try { attributes = mbsc.getAttributes( new ObjectName("java.lang:type=OperatingSystem"), new String[]{"OpenFileDescriptorCount", "MaxFileDescriptorCount"}); List<Attribute> attrList = attributes.asList(); long openFdCount = (Long)attrList.get(0).getValue(); long maxFdCount = (Long)attrList.get(1).getValue(); long[] fdCounts = { openFdCount, maxFdCount}; return fdCounts; } catch (Exception e) { LogFactory.getLog(SdkMBeanRegistrySupport.class).debug( "Failed to retrieve file descriptor info", e); } return null; }
@Override public AttributeList action() throws ManageActionException { try { ObjectName objectName = _mBean.getObjectName(); MBeanServer mBeanServer = getMBeanServer(); MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName); MBeanAttributeInfo[] mBeanAttributeInfos = mBeanInfo.getAttributes(); String[] attributeNames = new String[mBeanAttributeInfos.length]; for (int i = 0; i < attributeNames.length; i++) { attributeNames[i] = mBeanAttributeInfos[i].getName(); } return mBeanServer.getAttributes(objectName, attributeNames); } catch (Exception e) { throw new ManageActionException(e); } }
private long getOpenFileDecriptorCount() throws Exception { MBeanServer mbsc = getMBeanServer(); AttributeList attributes; attributes = mbsc.getAttributes( new ObjectName("java.lang:type=OperatingSystem"), new String[] { "OpenFileDescriptorCount" }); List<Attribute> attrList = attributes.asList(); return (Long) attrList.get(0).getValue(); }