List of usage examples for javax.management ObjectName ObjectName
public ObjectName(String name) throws MalformedObjectNameException
From source file:fr.xebia.ws.travel.antifraud.v1_0.AntiFraudServiceDispatchingImpl.java
@Override public ObjectName getObjectName() throws MalformedObjectNameException { return new ObjectName(Monitoring.JMX_DOMAIN + ":type=AntiFraudService,name=" + beanName); }
From source file:com.proofpoint.jmx.MBeanResource.java
@GET @Produces(MediaType.APPLICATION_JSON)// w w w . j a va 2 s. c o m public List<MBeanRepresentation> getMBeans() throws JMException { ImmutableList.Builder<MBeanRepresentation> mbeans = ImmutableList.builder(); for (ObjectName objectName : mbeanServer.queryNames(new ObjectName("*:*"), null)) { mbeans.add(new MBeanRepresentation(mbeanServer, objectName, objectMapper)); } return mbeans.build(); }
From source file:com.atolcd.alfresco.audit.web.scripts.DatabaseInfoGet.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { try {/*from w ww .j ava2 s.co m*/ // Map that will be passed to the template Map<String, Object> model = new HashMap<String, Object>(); // Copy server object in a local object "MBeanProxy" ObjectName dbName = new ObjectName("Alfresco:Name=DatabaseInformation"); MBeanServer mbs = getMBeanServer(dbName); model.put("DatabaseProductName", mbs.getAttribute(dbName, "DatabaseProductName")); model.put("DatabaseProductVersion", mbs.getAttribute(dbName, "DatabaseProductVersion")); model.put("DriverName", mbs.getAttribute(dbName, "DriverName")); model.put("DriverVersion", mbs.getAttribute(dbName, "DriverVersion")); model.put("URL", mbs.getAttribute(dbName, "URL")); model.put("UserName", mbs.getAttribute(dbName, "UserName")); return model; } catch (Exception e) { throw new WebScriptException("[DatabaseInfoGet] Error in executeImpl function : \n" + e.getMessage()); } }
From source file:com.appdynamics.monitors.muleesb.JMXUtil.java
public static Set<ObjectInstance> queryMbeans(MBeanServerConnection connection, String mbeanMatcher) throws IOException, MalformedObjectNameException { Set<ObjectInstance> mBeans = connection.queryMBeans(new ObjectName(mbeanMatcher), null); return mBeans; }
From source file:com.atolcd.alfresco.audit.web.scripts.ContentStoreInfoGet.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { try {/*w w w. jav a 2s .com*/ // Map that will be passed to the template Map<String, Object> model = new HashMap<String, Object>(); ObjectName query = new ObjectName("Alfresco:Name=ContentStore,Type=*,Root=*"); MBeanServer mbs = getMBeanServerWithQuery(query); Set<ObjectName> storesName = mbs.queryNames(query, null); List<ContentStore> contentStores = new ArrayList<ContentStore>(); for (ObjectName storeName : storesName) { Object writeSupported = mbs.getAttribute(storeName, "WriteSupported"); Object totalSize = mbs.getAttribute(storeName, "SpaceUsed"); contentStores.add(new ContentStore(storeName.getKeyProperty("Root"), String.valueOf(writeSupported), String.valueOf(totalSize))); } model.put("contentStores", contentStores); return model; } catch (Exception e) { throw new WebScriptException("[ContentStoreInfoGet] Error in executeImpl function"); } }
From source file:com.atolcd.alfresco.audit.web.scripts.SystemPropertiesGet.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { try {//w w w. j av a 2 s . c o m // Map that will be passed to the template Map<String, Object> model = new HashMap<String, Object>(); // Copy server object in a local object "MBeanProxy" ObjectName systemName = new ObjectName("Alfresco:Name=SystemProperties"); MBeanServer mbsc = getMBeanServer(systemName); model.put("AlfrescoHome", mbsc.getAttribute(systemName, "alfresco.jmx.dir")); model.put("CatalinaHome", mbsc.getAttribute(systemName, "catalina.home")); model.put("HibernateDialect", mbsc.getAttribute(systemName, "hibernate.dialect")); model.put("JavaClassPath", mbsc.getAttribute(systemName, "java.class.path")); model.put("JavaHome", mbsc.getAttribute(systemName, "java.home")); model.put("JavaRuntimeName", mbsc.getAttribute(systemName, "java.runtime.name")); model.put("JavaRuntimeVersion", mbsc.getAttribute(systemName, "java.runtime.version")); model.put("JavaVersion", mbsc.getAttribute(systemName, "java.version")); model.put("OsArch", mbsc.getAttribute(systemName, "os.arch")); model.put("OsName", mbsc.getAttribute(systemName, "os.name")); model.put("OsVersion", mbsc.getAttribute(systemName, "os.version")); model.put("UserCountry", mbsc.getAttribute(systemName, "user.country")); model.put("UserLanguage", mbsc.getAttribute(systemName, "user.language")); model.put("UserTimezone", mbsc.getAttribute(systemName, "user.timezone")); return model; } catch (Exception e) { throw new WebScriptException("[SystemPropertiesGet] Error in executeImpl function"); } }
From source file:com.atolcd.alfresco.audit.web.scripts.LuceneIndexesInfoGet.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { try {/*from www . j av a2 s. com*/ // Map that will be passed to the template Map<String, Object> model = new HashMap<String, Object>(); ObjectName query = new ObjectName("Alfresco:Name=LuceneIndexes,*"); MBeanServer mbs = getMBeanServerWithQuery(query); Set<ObjectName> luceneIndexesName = mbs.queryNames(query, null); List<LuceneIndex> luceneIndexes = new ArrayList<LuceneIndex>(); for (ObjectName luceneIndexName : luceneIndexesName) { luceneIndexes.add(new LuceneIndex(luceneIndexName.getKeyProperty("Index"), String.valueOf(mbs.getAttribute(luceneIndexName, "ActualSize")), String.valueOf(mbs.getAttribute(luceneIndexName, "NumberOfDocuments")), String.valueOf(mbs.getAttribute(luceneIndexName, "NumberOfFields")), String.valueOf(mbs.getAttribute(luceneIndexName, "NumberOfIndexedFields")), String.valueOf(mbs.getAttribute(luceneIndexName, "UsedSize")))); } model.put("luceneIndexes", luceneIndexes); return model; } catch (Exception e) { throw new WebScriptException( "[LuceneIndexesInfosGet] Error in executeImpl function : \n" + e.getMessage()); } }
From source file:cc.kune.kunecli.JMXUtils.java
public static Object doOperation(final String objectName, final String operation) { final List<VirtualMachineDescriptor> vms = VirtualMachine.list(); try {// w ww. j a v a 2 s.c om for (final VirtualMachineDescriptor vmd : vms) { final String id = vmd.id(); LOG.debug("VM id: " + id); final JMXServiceURL url = getURLForPid(id.trim()); final JMXConnector jmxc = JMXConnectorFactory.connect(url, null); final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); final ObjectName mbeanName = new ObjectName(objectName); MBeanInfo beanInfo; try { beanInfo = mbsc.getMBeanInfo(mbeanName); for (final MBeanOperationInfo currentOp : beanInfo.getOperations()) { if (currentOp.getName().equals(operation)) { LOG.debug("Doing operation '" + operation + "' over mbean: '" + objectName + "' with id: '" + id + "'."); final Object invoke = mbsc.invoke(mbeanName, currentOp.getName(), new Object[] {}, new String[] {}); return invoke; } } } catch (final InstanceNotFoundException e) { // Ok, operation not found in this VM or domain } } throw new RuntimeException("JMX operation not found"); } catch (final Exception e) { LOG.error("Error in jmx connection", e); } throw new RuntimeException("JMX operation failed"); }
From source file:io.fabric8.mq.util.BrokerJmxUtils.java
public static ObjectName getRoot(J4pClient client) throws Exception { String type = "org.apache.activemq:*,type=Broker"; String attribute = "BrokerName"; ObjectName objectName = new ObjectName(type); J4pResponse<J4pReadRequest> response = client.execute(new J4pReadRequest(objectName, attribute)); JSONObject jsonObject = response.getValue(); JSONObject nameObject = (JSONObject) jsonObject.values().iterator().next(); String name = nameObject.values().iterator().next().toString(); return new ObjectName("org.apache.activemq:type=Broker,brokerName=" + name); }
From source file:org.apache.camel.example.management.ManagementExampleTest.java
@Test public void testManagementExample() throws Exception { // Give it a bit of time to run Thread.sleep(2000);//from w w w .j a v a 2 s . c o m MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer(); // Find the endpoints Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=endpoints,*"), null); // now there is no managed endpoint for the dead queue // CAMEL-7076 there is no spring-event:default endpoint any more assertEquals(4, set.size()); // Find the routes set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null); assertEquals(3, set.size()); // Stop routes for (ObjectName on : set) { mbeanServer.invoke(on, "stop", null, null); } }