![]() |
You can reformat the output value from Mbeans in JMX by way of the Custom Format Masks. This option leverages on Java's built-in string manipulation and functions. You will need to build a Java code and compile it before it becomes useful in JMX. Documentation Link: Custom Format Masks |
![]() |
Here's an example to render numerical field values into a floating point and output the value with two decimal places. Here's how to do it: You will need to build this Java program on your system, so having a Java SDK package is necessary. Copy the following code and save it as "geneosFormat.java" on your system: package com.itrsgroup.jmx.masks; public class geneosFormat implements Mask { public String get(Object data, String[] args) throws MaskException { String r; try { r = String.format(args[ 0 ], Float.parseFloat((String) data)); } catch (Exception e) { throw new MaskException( "Error!" ); } return r; } }
javac -d . -classpath .. /geneos-plugins .jar geneosFormat.java *kindly ensure the directory structures and location of the geneos-plugins.jar from where you execute this command; the geneos-plugins.jar is bundled with the Netprobe. Once compiled, it will create a hierarchy in the current direct, e.g. com/itrsgroup/jmx/masks, and generate a 'geneosFormat.class' file in there. Now build a .jar file using jar cvf custom-masks.jar com/ you can delete the com/ directory once you have the jar file. rm -r com/
The sample XML for the plugin is as follows: < plugin > < jmx-server > < connection > < generic > < serviceURL > < data >service:jmx:rmi:///jndi/rmi://</ data > < var ref = "JMX" ></ var > < data >/jmxrmi</ data > </ serviceURL > </ generic > </ connection > < aliases > < alias > < name >$1</ name > < value > < data >java.lang:type=Memory</ data > </ value > < attributePath > < data >HeapMemoryUsage</ data > </ attributePath > </ alias > </ aliases > < columns > < column > < label >Committed in MB</ label > < rowTemplate > < data >$1.committed / 1000000</ data > </ rowTemplate > < mask > < data >geneosFormat(%.2fMB)</ data > </ mask > </ column > < column > < label >Used in MB</ label > < rowTemplate > < data >$1.used / 1000000</ data > </ rowTemplate > < mask > < data >geneosFormat(%.2fMB)</ data > </ mask > </ column > < column > < label >% Used</ label > < rowTemplate > < data > 100 * $1.used / $1.committed</ data > </ rowTemplate > < mask > < data >geneosFormat(%.2f'%')</ data > </ mask > </ column > </ columns > < idAttributes ></ idAttributes > </ jmx-server > </ plugin > |
-
Tags:
Comments
0 comments
Please sign in to leave a comment.