Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

Tutorial: Implementing a Notification Application

$
0
0

This tutorial is to help you configure an example notification scenario. The scenario includes a custom application that notifies you of critical metrics via email or SMS, and the application undertakes actions to fix issues as a result of these critical metrics.

Prerequisites

  • To test the whole scenario, you need accounts on SAP HANA Cloud Platform in two data centers (EU and US East).
  • To retrieve the metrics of Java applications according to this scenario, you need four deployed and running Java applications.

    Note: If a Java application is not started yet, the notification application will trigger the start process.

  • To use the console commands, you need to set up the console client.

    For more information, see Setting Up the Console Client.

Context

According to this tutorial, you implement a notification application that requests metrics of the following Java applications running on SAP HANA Cloud Platform:

  • app1 located in a1 account and EU data center
  • app2 located in a2 account and EU data center
  • app3 located in b1 account and US East data center
  • app4 located in b1 account and US East data center

Note: Because the requests are sent to four applications only, the Maven project that you import in Eclipse spawns only four threads. However, you can update this number in the MetricsWatcher class, where the ScheduledThreadPoolExecutor (4) method is called. Furthermore, if you decide to update the list of applications, you also need to correct it in the Demo class of the imported project.

When the notification application receives the Java application metrics, it checks for critical ones. The application then sends an email or SMS according to that if the metrics are received as critical once or three times. In addition, the application restarts the Java application when the metrics are detected as critical three times.

Procedure

  1. Download the cloud-metricswatcher project as a ZIP file.
  2. Extract the files into a local folder and import the folder in Eclipse as an existing Maven project.

    Note: You can also upload your project by copying the URL from GitHub and pasting it as a Git repository path or URI after you switch to the Git perspective. Don't forget to switch back to a Java perspective.

  3. Open the Demo.java class and update the following information: your email and SMS addresses, your logon credentials, your Java applications and their accounts and data centers.
  4. Open the Mailsender.java class and update your email account settings.
  5. Test your scenario.
    1. Open SAP HANA Cloud Platform cockpit and find your Java applications.
    2. Configure your Java applications to return critical metrics.

      To do this, you can create a JMX check with a very low critical threshold for HeapMemoryUsage so that the check will always be received in a critical state.

      Example: neo create-jmx-check -a myaccount -b demo -u p1234567 -n "JMX Check Test - Heap Memory" -O java.lang:type=Memory -A HeapMemoryUsage -K used -U B -C 20000000 -h hana.ondemand.com

    3. Run your notification application in Eclipse and check the following:
      • You receive an email with subject A metric has reached a critical state. and body Metric HeapMemoryUsage for application app1 has reached а critical state. when a critical metric is received.
      • You receive an SMS with text Metric HeapMemoryUsage for application app1 has reached a critical state 3 times. The application will be restarted. when a critical metric is received three times.

        You can follow the status of your Java applications in the SAP HANA Cloud Platform cockpit.

More Information

create-jmx-check

Landscape Hosts


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>