GithubHelp home page GithubHelp logo

lbovet / jminix Goto Github PK

View Code? Open in Web Editor NEW
119.0 20.0 41.0 367 KB

A lightweight servlet-embedded JMX console

License: Apache License 2.0

Java 29.98% JavaScript 42.89% CSS 23.70% HTML 3.28% Shell 0.08% Dockerfile 0.07%

jminix's People

Contributors

bokysan avatar danlmr2 avatar dhaeb avatar gitomat avatar imsandli avatar kerny3d avatar lbovet avatar michaelknigge avatar mtrovo avatar rwmccro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jminix's Issues

LocalDate not supported

I have a ValueBean with managedAttribute of type LocalDate:

@ManagedAttribute
@Override
public LocalDate getMyDate() {
    return myDate;
}

@ManagedAttribute
public void setMyDate(final LocalDate myDate) {
    this.myDate = myDate;
}

The value in the JMX console is presented in the format yyyy-mm-dd. When I change the value, an exception is thrown:

Internal Server Error (500) - The server encountered an unexpected condition which prevented it from fulfilling the request

//

Caused by: java.lang.RuntimeException: Type java.time.LocalDate is not supported
	at org.jminix.console.resource.ValueParser.parse(ValueParser.java:87)
	at org.jminix.console.resource.AttributeResource.update(AttributeResource.java:191)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
//

NPE in OperationResource.java

stringParams = (String[]) ServletUtils.getRequest(getRequest()).getParameterMap().get("param");

after hitting http://localhost:9997/servers/0/domains/java.lang/mbeans/type%3DMemory/operations/gc()

  • stringParams is a empty String array
  • ServletUtils.getRequest(getRequest()) returns null
  • getRequest().getClass().toString(): class org.restlet.engine.adapter.HttpRequest
  • ((HttpRequest) getRequest()).getHttpCall(): class org.restlet.engine.connector.HttpExchangeCall
  • ((HttpRequest) getRequest()).getHttpCall() instanceof org.restlet.ext.servlet.internal.ServletCall: false

hope it helps

Missing standard MBean in JMinix

I am working in a Spring application with Logback, I would like to use JMinix to enable the online configuration of logging level. However, I can only see MBean as followed, but not the Logback one

image

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
    <property name="autodetect" value="true"/>
    <property name="server" ref="mbeanServer"/>
</bean>

jminix errors out when deploying on tomcat 9

i've followed the instructions in adding a jminix servlet to my web.xml

when loading the jminix page i get an empty browser (all the static files are loaded, but nothing displayed in the tree borwser) and the following javascript error in my firefox console:

Error: dijit.tree.TreeStoreModel: query "" returned undefined items, but must return exactly one item Stack trace: getRoot/<.onComplete<@js/dojotoolkit/dojo/../dijit/tree/TreeStoreModel.js:29:7 dojo.hitch/<@http://localhost:8080/impl-war-1.0-SNAPSHOT/jmx/js/dojotoolkit/dojo/dojo.js:16:15296 fetch/<@js/dojotoolkit/dojo/../dojox/data/ServiceStore.js:113:1

the very last request i see made is to /servers, which returns "0". i can manually browse to /servers/0/ and see contents, so this appears to be a client-side issue?

Support for JMXRP

It'd be nice if there were out of the box support for JMXRP in addition to RMI. TLS / SASL support might be annoying to work in, but it looks like the RMI server has mostly the same code as this example JMXRP code:

package com.example;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.net.ssl.*;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * Dumps info about the specified MBean from the JMXConnectorServer at
 * the specified URL.
 */
public class ConnectorClient {

    static KeyStore trustStore(String type, String name, char[] password) throws Exception {
        KeyStore anchors = KeyStore.getInstance(type);
        anchors.load(new FileInputStream(name), password);
        return anchors;
    }

    static KeyStore.Builder keystore(String type, String filename, char[] password) {
        return KeyStore.Builder.newInstance(type, null, new File(filename), new KeyStore.PasswordProtection(password));
    }

    static  KeyManagerFactory keyManagerFactory(KeyStore.Builder... keystores) throws Exception {
        KeyStoreBuilderParameters ksParams = new KeyStoreBuilderParameters(Arrays.asList(keystores));
        KeyManagerFactory factory = KeyManagerFactory.getInstance("NewSunX509");
        factory.init(ksParams);
        return factory;
    }

    static TrustManagerFactory trustManagerFactory(KeyStore anckors) throws Exception {
        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
        tmf.init(anckors);
        return tmf;
    }

    static SSLSocketFactory socketFactory(KeyManagerFactory kmf, TrustManagerFactory tmf) throws Exception {
        SSLParameters sslParams = new SSLParameters();
        sslParams.setEndpointIdentificationAlgorithm("HTTPS");
        SSLContext ctx = SSLContext.getInstance("TLSv1.2");

        ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
        SSLSocketFactory ssf = ctx.getSocketFactory();
        return ssf;
    }

    static MBeanServerConnection mbsc = null;
    static public void main(String[] sa) throws Exception {
        String urlString = "service:jmx:jmxmp://localhost:9999";
        String beanId = "com.example:type=Hello";

        KeyManagerFactory kmf = keyManagerFactory(keystore("JKS", "src/universal/conf/certs/client.jks", "changeit".toCharArray()));
        TrustManagerFactory tmf = trustManagerFactory(trustStore("JKS", "src/universal/conf/certs/exampletrust.jks", "changeit".toCharArray()));
        SSLSocketFactory socketFactory = socketFactory(kmf, tmf);

        Map env = new HashMap();
        env.put("jmx.remote.profiles", "TLS");
        env.put("jmx.remote.tls.enabled.protocols", "TLSv1.2");
        env.put("jmx.remote.tls.enabled.cipher.suites", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256");
        env.put("jmx.remote.tls.socket.factory", socketFactory);

        JMXConnector c =
                JMXConnectorFactory.connect(new JMXServiceURL(urlString), env);
        // If you aren't setting a profile or any other options, you can use
        // null for the second connect() parameter, instead of an empty list.
        try {
            mbsc = c.getMBeanServerConnection();

            // For this example, I chose to not expose the Adaptor as an
            // MBean, which is sometimes a good thing to do for security.
            // Therefore, I use it as a normal Java Object.
            System.err.println("Info on '" + beanId + "' is:");
            javax.management.MBeanAttributeInfo[] aa =
                    mbsc.getMBeanInfo(new ObjectName(beanId)).getAttributes();
            for (int i = 0; i < aa.length; i++)
                System.err.println(aa[i].getName());
        } finally {
            if (c != null) c.close();
        }
        System.exit(0);
    }
}

https://www.javaworld.com/article/2072256/remote-jmx--connectors-and-adapters.html?page=2

RuntimeException with null cause thrown by JMX method causes NPE in JminiX

model.put(VALUE_MODEL_ATTRIBUTE, e.getTargetException().getCause().getMessage());

Scenario:

  • a user JMX attribute getter throws RuntimeException with null getCause() (for whatever reason; it is permitted by the exception contract).
  • it is picked up by the cited catch inside JMiniX. It is correctly logged by this line: log.warn("Error accessing attribute", e);
  • But the next line (referenced above) incorrectly assumes getCause() is always not null and causes NPE on calling getMessage().
  • So the user sees not the original error in browser, but overwritten stack trace, this time with NPE, logged by org.restlet.resource.ServerResource#doCatch (getLogger().log(level, "Exception or error caught in server resource", throwable);)

It makes it hard to debug jmx method failures in browser (you see the irrelevant NPE in causedBy section), you have to go to the app logs to find the original causedBy exception.

POST parameters not recognized

I deployed the console embedded and I face the problem that I cannot send commands (operations in language of jmx).

Debugging shows, that stringParams here https://github.com/lbovet/jminix/blob/master/src/main/java/org/jminix/console/resource/OperationResource.java#L79 has no value.

The params are available though. The console is working right with the following patch

Map<String, String[]> parameterMap = ((ServletCall) ((HttpRequest) ((OperationResource) this).getRequest()).getHttpCall()).getRequest().getParameterMap();
String[] params = parameterMap.get("param");
stringParams = params;

I try to find out if I have a problem with my configuration, but without success. Does anyone has a hint what the problem could be?

Cheers
Stefku

My configuration for spring boot

<dependency>
    <groupId>org.jminix</groupId>
    <artifactId>jminix</artifactId>
    <version>1.2.0</version>
</dependency>
@Configuration
public class JMinixConfig {
    @Bean
    public ServletRegistrationBean jminixServlet() {
        ServletRegistrationBean servletBean = new ServletRegistrationBean();
        servletBean.addUrlMappings("/admin/jminix/*");
        servletBean.setServlet(new org.jminix.console.servlet.MiniConsoleServlet());
        return servletBean;
    }
}

ContentFilter for Operations

I have an application which relies heavily on JMX operations for ops reports and I'm needing the same kind of functionality that attributeFilter provides but for the operation return value.

For example I have several operations which queries with certain parameters and return a HTML string as a value, I would like to see this content served as HTML, not as plain text.

Jminix doesn't work in websphere, but working fine in Jboss

I have used the jminix artifact in my application and It is working in Jboss Application server. I have deployed the same application in Websphere and i see that all the MiniConsoleApplication is getting initialized, but finally its giving 404.
Did anyone tried using jminix and deployed in websphere?

Boolean attributes should use a checkbox

When editing boolean attributes in the UI, currently you have to enter true/false into a text box. Be nice if there was a checkbox instead, or some true/false link/buttons to fast-fill the text box.

Encoding issues

Received once upon a time...
Check if this is still needed.

I got the same issue as listed in 6,7,8,10,15,16 not "able to handle special characters". It needed a small fix that I could figure : Encoding the $ref attribute in JSON response. This is some thing that is already there, but is not working. Below is the existing code. The first two "if clauses" never come true as item is comming an instance of String Class, so I added the url encode in the else clause. It worked for me, but we need to find out in which cases the first two cases will become true.

AbstractTemplateResource.java

if (item instanceof MBeanAttributeInfo)
{
ref.put("$ref", encoderBean.encode(((MBeanAttributeInfo) item).getName()) + "/");
}
else if (item instanceof Map && ((Map) item).containsKey("declaration"))
{
ref.put("$ref", ((Map) item).get("declaration").toString());
}
else
{
ref.put("$ref",encoderBean.encode(item.toString()) + "/"); // This is the fix I added
}

Please find the patch attached and the compiled jar for a quick test.
I think the following defects 6,7,8,10,15,16 are refering to same issue. So all of them can tryout this fix I think

Index: main/java/org/jminix/console/resource/AbstractTemplateResource.java
===================================================================
--- main/java/org/jminix/console/resource/AbstractTemplateResource.java	(revision 103)
+++ main/java/org/jminix/console/resource/AbstractTemplateResource.java	(working copy)
@@ -215,6 +215,8 @@
                     itemCollection = Arrays.asList(items);
                 }
                 List<Map<String, String>> children = new ArrayList<Map<String, String>>();
+                
+                EncoderBean encoderBean = new EncoderBean();
                 for (Object item : itemCollection)
                 {
 
@@ -222,7 +224,7 @@
 
                     if (item instanceof MBeanAttributeInfo)
                     {
-                        ref.put("$ref", new EncoderBean().encode(((MBeanAttributeInfo) item).getName()) + "/");
+                        ref.put("$ref", encoderBean.encode(((MBeanAttributeInfo) item).getName()) + "/");
                     }
                     else if (item instanceof Map && ((Map) item).containsKey("declaration"))
                     {
@@ -230,7 +232,7 @@
                     }
                     else
                     {
-                        ref.put("$ref", item.toString() + "/");
+                	ref.put("$ref",encoderBean.encode(item.toString()) + "/");   
                     }
                     children.add(ref);
                 }

Notification support

Unfortunately, at the moment there is no way to see the available notifications:

image

Is it possible to view available notifications? Is it possible in this case to subscribe to all or only certain notifications?
For example, as it is implemented in JConsole:

image

Standalone App - No Data

Hi,

I've used your standalone edition on previous projects with no issues, however in my latest project when browsing the web interface there is no data.

I can see the MBean groups/data in jconsole using the same server connection string, but in jminix I just get a blank list. Its not throwing any errors, is there any logging i can turn on to find out whats up?

Example of what i'm seeing:
Image

Thanks,
James.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.