SlideShare a Scribd company logo
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 1
JMX
Java Management Extensions (JMX) is a Java technology that supplies tools
for managing and monitoring java based applications, system objects,
devices and service oriented networks. Those resources are represented by
objects called MBeans (for Managed Bean).
What is JMX ?
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 2
JMX Agent & Remote
Management
JMX
JMX Agent
The main component of a JMX agent is the MBean server. This is a core
managed object server in which MBeans are registered. A JMX agent also
includes a set of services for handling MBeans. JMX agents directly control
resources and make them available to remote management agents.
Remote Management
Protocol adaptors and standard connectors make a JMX agent accessible
from remote management applications outside the agent’s Java Virtual
Machine (Java VM) using the JMX URL
(Sample URL : service:jmx:rmi://192.168.7.46:12345/jndi/rmi://192.168.7.46:12345/jmxrmi)
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 3
JMX architecture
JMX
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 4
Enabling JMX on Tomcat
JMX
CATALINA_OPTS="${CATALINA_OPTS}
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=4447
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"
1. Go to folder /usr/share/tomcat6/bin (this may differ based on the tomcat version)
2. Create a setenv.sh file with below contents (or add to it if one already exists).
#!/bin/sh
export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4447 -
Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false“
Note: You can alternatively put this into catalina.sh
3. Save file and restart Tomcat as root user : service tomcat6 restart (this may differ based on the tomcat version)
Ref : https://tomcat.apache.org/tomcat-6.0-doc/monitoring.html#Enabling_JMX_Remote
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 5
Campaign Portal – JMX Integration
JMX
Mbean interface:
(../WebPortal/vsdp-jmx/src/main/java/com/verizon/vsdp/jmx/VsdpManagementMBean.java)
public interface VsdpManagementMBean {
public int getNewCampaignsStat();
public int getCampaignsBudgetStat();
}
Note: By convention, an MBean interface takes the name of the Java class that implements it, with the suffix MBean added.
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 6
Campaign Portal – JMX Integration (Continued..)
JMX
Mbean Implementation:
(../WebPortal/vsdp-jmx/src/main/java/com/verizon/vsdp/jmx/VsdpJmxManagement.java)
public class VsdpJmxManagement extends NotificationBroadcasterSupport implements VsdpManagementMBean {
….
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName cusPortal = new ObjectName("VSDP:type=Customer Portal");
mbs.registerMBean(this, cusPortal);
int newCampaignsStatVal=0;
public void incrementNewCampaignsStat() {
newCampaignsStatVal ++;
}
….
@Override
public int getNewCampaignsStat() {
return newCampaignsStatVal;
}
….
public void sendNotification(String notificationTitle, String notificationMsg, String notificationOldMsg){
Notification n = new AttributeChangeNotification(this, sequenceNumber++, System.currentTimeMillis(),
notificationTitle, "Message", "String", notificationOldMsg, notificationMsg);
sendNotification(n);
}
}
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 7
Campaign Portal – JMX Integration (Continued..)
JMX
JMX stats call:
(../WebPortal/vsdp/src/main/java/com/verizon/vsdp/controller/ServiceController.java)
public String createService (@RequestBody CreateUpdateServiceRequest req,
@RequestParam(value=TokenUtils.VSDP_TOKEN, required=true) String token,
@RequestParam(value=TokenUtils.USER, required=true) String userName,
HttpServletRequest request, HttpServletResponse response) throws TfdsCampaignException {
….
String codeSnippet = scmService.createService(req.getService(), req.getRatings(), userName);
if (codeSnippet == null)
throw new TfdsCampaignException("tfdsCampaignCreationError");
else {
….
VsdpJmxManagement.getInstance().incrementNewCampaignsStat();
return sendSuccessResponse(response, "{"codesnippetid":"" + codeSnippet + ""}");
}
….
}
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 8
Campaign Portal – JMX Integration (Continued..)
JMX
JMX notification call:
(../WebPortal/vsdp/src/main/java/com/verizon/vsdp/service/SvcService.java)
private final String CD_JMX_NOTFN_TITLE = "Campaign Director connection issue";
public CampaignDirectorResponse invokeRestTemplate(Object service, String event) throws Exception {
...
try {
...
CampaignDirectorResponse cdResposne = responseEntity.getBody();
return cdResposne;
} catch (Exception exc){
logger.error("CD transaction ID {} with Exception {}", uuid,exc.getMessage());
//VPCMS call : Raise an alarm if the exception is due to CD connection loss
if (exc.getMessage().contains("java.net.ConnectException")) {
VsdpJmxManagement.getInstance().sendNotification(CD_JMX_NOTFN_TITLE, exc.getMessage(), "");
}
}
return null;
}
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 9
JConsole
Using JConsole for verification
JConsole is a graphical monitoring tool to monitor Java Virtual Machine (JVM) and Java applications both on
a local or remote machine. JConsole uses underlying features of Java Virtual Machine to provide information
on performance and resource consumption of applications running on the Java platform using Java
Management Extensions (JMX) technology. JConsole comes as part of Java Development Kit (JDK) and the
graphical console can be started using "jconsole" command.
Using Jconsole:
1. Download JDK to your laptop / desktop.
2. Start JConsole
3. Enable JMX on tomcat and start the tomcat process
4. Enter process url as “service:jmx:rmi:///jndi/rmi://192.168.7.46:4447/jmxrmi” (Replace the IP with your tomcat IP)
5. Click on “Insecure” button on the next screen if prompted.
6. Click on “MBeans” tab in the next screen after which you should see a screen as shown in fig. 1
7. The applications exposing MBeans would be shown in the console listing the attributes
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 10
Jconsole- Fig. 1
Using JConsole for verification

More Related Content

Similar to JMX_vcms

Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
Prasad Mukhedkar
 
An MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected ContentAn MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected Content
Alpen-Adria-Universität
 
Pandora FMS: Jboss monitoring
Pandora FMS: Jboss monitoring Pandora FMS: Jboss monitoring
Pandora FMS: Jboss monitoring
Pandora FMS
 
Up is Down, Black is White: Using SCCM for Wrong and Right
Up is Down, Black is White: Using SCCM for Wrong and RightUp is Down, Black is White: Using SCCM for Wrong and Right
Up is Down, Black is White: Using SCCM for Wrong and Right
enigma0x3
 
Scmad Chapter11
Scmad Chapter11Scmad Chapter11
Scmad Chapter11
Marcel Caraciolo
 
_Hackercool - September 2021.pdf
_Hackercool - September 2021.pdf_Hackercool - September 2021.pdf
_Hackercool - September 2021.pdf
ssuser5e1b13
 
Reversing & malware analysis training part 12 rootkit analysis
Reversing & malware analysis training part 12   rootkit analysisReversing & malware analysis training part 12   rootkit analysis
Reversing & malware analysis training part 12 rootkit analysis
Abdulrahman Bassam
 
Jboss Exploit
Jboss ExploitJboss Exploit
Jboss Exploit
drkimsky
 
Windows Command Line Tools
Windows Command Line ToolsWindows Command Line Tools
Windows Command Line Tools
love4upratik
 
Temadag om-java-jamaica car-2013-09
Temadag om-java-jamaica car-2013-09Temadag om-java-jamaica car-2013-09
Temadag om-java-jamaica car-2013-09
InfinIT - Innovationsnetværket for it
 
Micro services from scratch - Part 1
Micro services from scratch - Part 1Micro services from scratch - Part 1
Micro services from scratch - Part 1
Azrul MADISA
 
How to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatHow to monitor and manage Apache Tomcat
How to monitor and manage Apache Tomcat
Egnyte
 
Android Nâng cao-Bài 9-Debug in Android Application Development
Android Nâng cao-Bài 9-Debug in Android Application Development Android Nâng cao-Bài 9-Debug in Android Application Development
Android Nâng cao-Bài 9-Debug in Android Application Development
Phuoc Nguyen
 
web services using java
web services using javaweb services using java
web services using java
Riza Prapascatama Agusdin
 
Architecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVCArchitecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVC
marcocasario
 
Android workshop
Android workshopAndroid workshop
Android workshop
Nikola Kapraljevic Nixa
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Virus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing GatekeeperVirus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing Gatekeeper
Synack
 
Jms queues
Jms queuesJms queues
Jms queues
Karnam Karthik
 
Manual of the CSS Alarm Handler (Beast)
Manual of the CSS Alarm Handler (Beast)Manual of the CSS Alarm Handler (Beast)
Manual of the CSS Alarm Handler (Beast)
Robert-Emmanuel Mayssat
 

Similar to JMX_vcms (20)

Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
 
An MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected ContentAn MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected Content
 
Pandora FMS: Jboss monitoring
Pandora FMS: Jboss monitoring Pandora FMS: Jboss monitoring
Pandora FMS: Jboss monitoring
 
Up is Down, Black is White: Using SCCM for Wrong and Right
Up is Down, Black is White: Using SCCM for Wrong and RightUp is Down, Black is White: Using SCCM for Wrong and Right
Up is Down, Black is White: Using SCCM for Wrong and Right
 
Scmad Chapter11
Scmad Chapter11Scmad Chapter11
Scmad Chapter11
 
_Hackercool - September 2021.pdf
_Hackercool - September 2021.pdf_Hackercool - September 2021.pdf
_Hackercool - September 2021.pdf
 
Reversing & malware analysis training part 12 rootkit analysis
Reversing & malware analysis training part 12   rootkit analysisReversing & malware analysis training part 12   rootkit analysis
Reversing & malware analysis training part 12 rootkit analysis
 
Jboss Exploit
Jboss ExploitJboss Exploit
Jboss Exploit
 
Windows Command Line Tools
Windows Command Line ToolsWindows Command Line Tools
Windows Command Line Tools
 
Temadag om-java-jamaica car-2013-09
Temadag om-java-jamaica car-2013-09Temadag om-java-jamaica car-2013-09
Temadag om-java-jamaica car-2013-09
 
Micro services from scratch - Part 1
Micro services from scratch - Part 1Micro services from scratch - Part 1
Micro services from scratch - Part 1
 
How to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatHow to monitor and manage Apache Tomcat
How to monitor and manage Apache Tomcat
 
Android Nâng cao-Bài 9-Debug in Android Application Development
Android Nâng cao-Bài 9-Debug in Android Application Development Android Nâng cao-Bài 9-Debug in Android Application Development
Android Nâng cao-Bài 9-Debug in Android Application Development
 
web services using java
web services using javaweb services using java
web services using java
 
Architecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVCArchitecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVC
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
 
Virus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing GatekeeperVirus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing Gatekeeper
 
Jms queues
Jms queuesJms queues
Jms queues
 
Manual of the CSS Alarm Handler (Beast)
Manual of the CSS Alarm Handler (Beast)Manual of the CSS Alarm Handler (Beast)
Manual of the CSS Alarm Handler (Beast)
 

JMX_vcms

  • 1. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 1 JMX Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring java based applications, system objects, devices and service oriented networks. Those resources are represented by objects called MBeans (for Managed Bean). What is JMX ?
  • 2. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 2 JMX Agent & Remote Management JMX JMX Agent The main component of a JMX agent is the MBean server. This is a core managed object server in which MBeans are registered. A JMX agent also includes a set of services for handling MBeans. JMX agents directly control resources and make them available to remote management agents. Remote Management Protocol adaptors and standard connectors make a JMX agent accessible from remote management applications outside the agent’s Java Virtual Machine (Java VM) using the JMX URL (Sample URL : service:jmx:rmi://192.168.7.46:12345/jndi/rmi://192.168.7.46:12345/jmxrmi)
  • 3. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 3 JMX architecture JMX
  • 4. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 4 Enabling JMX on Tomcat JMX CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4447 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" 1. Go to folder /usr/share/tomcat6/bin (this may differ based on the tomcat version) 2. Create a setenv.sh file with below contents (or add to it if one already exists). #!/bin/sh export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4447 - Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false“ Note: You can alternatively put this into catalina.sh 3. Save file and restart Tomcat as root user : service tomcat6 restart (this may differ based on the tomcat version) Ref : https://tomcat.apache.org/tomcat-6.0-doc/monitoring.html#Enabling_JMX_Remote
  • 5. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 5 Campaign Portal – JMX Integration JMX Mbean interface: (../WebPortal/vsdp-jmx/src/main/java/com/verizon/vsdp/jmx/VsdpManagementMBean.java) public interface VsdpManagementMBean { public int getNewCampaignsStat(); public int getCampaignsBudgetStat(); } Note: By convention, an MBean interface takes the name of the Java class that implements it, with the suffix MBean added.
  • 6. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 6 Campaign Portal – JMX Integration (Continued..) JMX Mbean Implementation: (../WebPortal/vsdp-jmx/src/main/java/com/verizon/vsdp/jmx/VsdpJmxManagement.java) public class VsdpJmxManagement extends NotificationBroadcasterSupport implements VsdpManagementMBean { …. MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName cusPortal = new ObjectName("VSDP:type=Customer Portal"); mbs.registerMBean(this, cusPortal); int newCampaignsStatVal=0; public void incrementNewCampaignsStat() { newCampaignsStatVal ++; } …. @Override public int getNewCampaignsStat() { return newCampaignsStatVal; } …. public void sendNotification(String notificationTitle, String notificationMsg, String notificationOldMsg){ Notification n = new AttributeChangeNotification(this, sequenceNumber++, System.currentTimeMillis(), notificationTitle, "Message", "String", notificationOldMsg, notificationMsg); sendNotification(n); } }
  • 7. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 7 Campaign Portal – JMX Integration (Continued..) JMX JMX stats call: (../WebPortal/vsdp/src/main/java/com/verizon/vsdp/controller/ServiceController.java) public String createService (@RequestBody CreateUpdateServiceRequest req, @RequestParam(value=TokenUtils.VSDP_TOKEN, required=true) String token, @RequestParam(value=TokenUtils.USER, required=true) String userName, HttpServletRequest request, HttpServletResponse response) throws TfdsCampaignException { …. String codeSnippet = scmService.createService(req.getService(), req.getRatings(), userName); if (codeSnippet == null) throw new TfdsCampaignException("tfdsCampaignCreationError"); else { …. VsdpJmxManagement.getInstance().incrementNewCampaignsStat(); return sendSuccessResponse(response, "{"codesnippetid":"" + codeSnippet + ""}"); } …. }
  • 8. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 8 Campaign Portal – JMX Integration (Continued..) JMX JMX notification call: (../WebPortal/vsdp/src/main/java/com/verizon/vsdp/service/SvcService.java) private final String CD_JMX_NOTFN_TITLE = "Campaign Director connection issue"; public CampaignDirectorResponse invokeRestTemplate(Object service, String event) throws Exception { ... try { ... CampaignDirectorResponse cdResposne = responseEntity.getBody(); return cdResposne; } catch (Exception exc){ logger.error("CD transaction ID {} with Exception {}", uuid,exc.getMessage()); //VPCMS call : Raise an alarm if the exception is due to CD connection loss if (exc.getMessage().contains("java.net.ConnectException")) { VsdpJmxManagement.getInstance().sendNotification(CD_JMX_NOTFN_TITLE, exc.getMessage(), ""); } } return null; }
  • 9. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 9 JConsole Using JConsole for verification JConsole is a graphical monitoring tool to monitor Java Virtual Machine (JVM) and Java applications both on a local or remote machine. JConsole uses underlying features of Java Virtual Machine to provide information on performance and resource consumption of applications running on the Java platform using Java Management Extensions (JMX) technology. JConsole comes as part of Java Development Kit (JDK) and the graphical console can be started using "jconsole" command. Using Jconsole: 1. Download JDK to your laptop / desktop. 2. Start JConsole 3. Enable JMX on tomcat and start the tomcat process 4. Enter process url as “service:jmx:rmi:///jndi/rmi://192.168.7.46:4447/jmxrmi” (Replace the IP with your tomcat IP) 5. Click on “Insecure” button on the next screen if prompted. 6. Click on “MBeans” tab in the next screen after which you should see a screen as shown in fig. 1 7. The applications exposing MBeans would be shown in the console listing the attributes
  • 10. Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 10 Jconsole- Fig. 1 Using JConsole for verification