metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickal...@apache.org
Subject metron git commit: METRON-1260 Include Alerts UI in Ambari Service Check (nickwallen) closes apache/metron#804
Date Sat, 21 Oct 2017 12:11:40 GMT
Repository: metron
Updated Branches:
  refs/heads/master ad9851aff -> b4aa0859a


METRON-1260 Include Alerts UI in Ambari Service Check (nickwallen) closes apache/metron#804


Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/b4aa0859
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/b4aa0859
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/b4aa0859

Branch: refs/heads/master
Commit: b4aa0859a2a8f7b53d52c7332e5975d443a77ca2
Parents: ad9851a
Author: nickwallen <nick@nickallen.org>
Authored: Sat Oct 21 08:10:48 2017 -0400
Committer: nickallen <nickallen@apache.org>
Committed: Sat Oct 21 08:10:48 2017 -0400

----------------------------------------------------------------------
 .../package/scripts/alerts_ui_commands.py       | 38 +++++++++++++++++
 .../CURRENT/package/scripts/alerts_ui_master.py |  7 +---
 .../package/scripts/management_ui_commands.py   | 44 +++++++++++++-------
 .../package/scripts/management_ui_master.py     |  2 +-
 .../CURRENT/package/scripts/metron_service.py   | 16 +++++++
 .../CURRENT/package/scripts/rest_commands.py    | 30 ++++++++++++-
 .../CURRENT/package/scripts/service_check.py    |  6 +++
 7 files changed, 120 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_commands.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_commands.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_commands.py
index eabdbcb..92ddcf9 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_commands.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_commands.py
@@ -21,6 +21,8 @@ limitations under the License.
 from resource_management.core.logger import Logger
 from resource_management.core.resources.system import Execute, File
 
+import metron_service
+
 # Wrap major operations and functionality in this class
 class AlertsUICommands:
     __params = None
@@ -31,16 +33,52 @@ class AlertsUICommands:
         self.__params = params
 
     def start_alerts_ui(self):
+        """
+        Start the Alerts UI
+        :param env: Environment
+        """
         Logger.info('Starting Alerts UI')
         Execute("service metron-alerts-ui start")
         Logger.info('Done starting Alerts UI')
 
     def stop_alerts_ui(self):
+        """
+        Stop the Alerts UI
+        :param env: Environment
+        """
         Logger.info('Stopping Alerts UI')
         Execute("service metron-alerts-ui stop")
         Logger.info('Done stopping Alerts UI')
 
     def restart_alerts_ui(self, env):
+        """
+        Restart the Alerts UI
+        :param env: Environment
+        """
         Logger.info('Restarting the Alerts UI')
         Execute('service metron-alerts-ui restart')
         Logger.info('Done restarting the Alerts UI')
+
+    def status_alerts_ui(self, env):
+        """
+        Performs a status check for the Alerts UI
+        :param env: Environment
+        """
+        Logger.info('Status check the Alerts UI')
+        metron_service.check_http(
+          self.__params.hostname,
+          self.__params.metron_alerts_ui_port,
+          self.__params.metron_user)
+
+    def service_check(self, env):
+        """
+        Performs a service check for the Alerts UI
+        :param env: Environment
+        """
+        Logger.info('Checking connectivity to Alerts UI')
+        metron_service.check_http(
+          self.__params.hostname,
+          self.__params.metron_alerts_ui_port,
+          self.__params.metron_user)
+
+        Logger.info("Alerts UI service check completed successfully")

http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_master.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_master.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_master.py
index adf05a7..85c3be3 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_master.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/alerts_ui_master.py
@@ -67,11 +67,8 @@ class AlertsUIMaster(Script):
     def status(self, env):
         from params import status_params
         env.set_params(status_params)
-        cmd = format('curl --max-time 3 {hostname}:{metron_alerts_ui_port}')
-        try:
-            get_user_call_output(cmd, user=status_params.metron_user)
-        except ExecutionFailed:
-            raise ComponentIsNotRunning()
+        commands = AlertsUICommands(status_params)
+        commands.status_alerts_ui(env)
 
     def restart(self, env):
         from params import params

http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_commands.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_commands.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_commands.py
index 7427046..0f9194f 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_commands.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_commands.py
@@ -20,10 +20,11 @@ limitations under the License.
 
 from resource_management.core.logger import Logger
 from resource_management.core.resources.system import Execute, File
-from resource_management.core.exceptions import ComponentIsNotRunning
 from resource_management.core.exceptions import ExecutionFailed
 from resource_management.libraries.functions.get_user_call_output import get_user_call_output
 
+import metron_service
+
 # Wrap major operations and functionality in this class
 class ManagementUICommands:
     __params = None
@@ -34,39 +35,52 @@ class ManagementUICommands:
         self.__params = params
 
     def start_management_ui(self):
+        """
+        Starts the Management UI
+        :param env: Environment
+        """
         Logger.info('Starting Management UI')
         Execute("service metron-management-ui start")
         Logger.info('Done starting Management UI')
 
     def stop_management_ui(self):
+        """
+        Stops the Management UI
+        :param env: Environment
+        """
         Logger.info('Stopping Management UI')
         Execute("service metron-management-ui stop")
         Logger.info('Done stopping Management UI')
 
     def restart_management_ui(self, env):
+        """
+        Restarts the Management UI
+        :param env: Environment
+        """
         Logger.info('Restarting the Management UI')
         Execute('service metron-management-ui restart')
         Logger.info('Done restarting the Management UI')
 
-    def check_status(self, env):
+    def status_management_ui(self, env):
+        """
+        Performs a status check for the Management UI
+        :param env: Environment
+        """
         Logger.info('Status check the Management UI')
-        cmd = "curl --max-time 3 {0}:{1}"
-        try:
-          Execute(
-            cmd.format(self.__params.hostname, self.__params.metron_management_ui_port),
-            tries=3,
-            try_sleep=5,
-            logoutput=False,
-            user=self.__params.metron_user)
-        except:
-          raise ComponentIsNotRunning()
+        metron_service.check_http(
+          self.__params.hostname,
+          self.__params.metron_management_ui_port,
+          self.__params.metron_user)
 
     def service_check(self, env):
         """
         Performs a service check for the Management UI
         :param env: Environment
         """
-        from params import status_params
-        env.set_params(status_params)
-        self.check_status(env)
+        Logger.info('Checking connectivity to Management UI')
+        metron_service.check_http(
+          self.__params.hostname,
+          self.__params.metron_management_ui_port,
+          self.__params.metron_user)
+
         Logger.info("Management UI service check completed successfully")

http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_master.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_master.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_master.py
index 15bcd94..dad8f12 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_master.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/management_ui_master.py
@@ -73,7 +73,7 @@ class ManagementUIMaster(Script):
         from params import status_params
         env.set_params(status_params)
         commands = ManagementUICommands(status_params)
-        commands.check_status(env)
+        commands.status_management_ui(env)
 
     def restart(self, env):
         from params import params

http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/metron_service.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/metron_service.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/metron_service.py
index 2ae0b08..d8b8b10 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/metron_service.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/metron_service.py
@@ -20,12 +20,14 @@ import subprocess
 
 from datetime import datetime
 from resource_management.core.logger import Logger
+from resource_management.core.exceptions import ComponentIsNotRunning
 from resource_management.core.exceptions import Fail
 from resource_management.core.resources.system import Directory, File
 from resource_management.core.resources.system import Execute
 from resource_management.core.source import InlineTemplate
 from resource_management.libraries.functions import format as ambari_format
 from resource_management.libraries.functions.get_user_call_output import get_user_call_output
+
 from metron_security import kinit
 
 
@@ -443,3 +445,17 @@ def check_kafka_acl_groups(params, groups, user=None):
         cmd = template.format(params.kafka_bin_dir, params.zookeeper_quorum, group, user)
         err_msg = "Missing Kafka group access; group={0}, user={1}".format(group, user)
         execute(cmd, user=params.kafka_user, err_msg=err_msg)
+
+def check_http(host, port, user):
+    """
+    Check for a valid HTTP response.
+    :param hostname: The hostname.
+    :param port: The port number.
+    :param user: Execute the HTTP request as.
+    """
+    cmd = "curl -sS --max-time 3 {0}:{1}".format(host, port)
+    Logger.info('Checking HTTP connectivity; host={0}, port={1}, user={2} cmd={3}'.format(host,
port, user, cmd))
+    try:
+      Execute(cmd, tries=3, try_sleep=5, logoutput=False, user=user)
+    except:
+      raise ComponentIsNotRunning()

http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py
index 542fc08..0828e3a 100755
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py
@@ -77,6 +77,9 @@ class RestCommands:
         metron_service.init_kafka_acl_groups(self.__params, groups)
 
     def start_rest_application(self):
+        """
+        Start the REST application
+        """
         Logger.info('Starting REST application')
 
         if self.__params.security_enabled:
@@ -110,6 +113,9 @@ class RestCommands:
         Logger.info('Done starting REST application')
 
     def stop_rest_application(self):
+        """
+        Stop the REST application
+        """
         Logger.info('Stopping REST application')
 
         # Get the pid associated with the service
@@ -153,21 +159,41 @@ class RestCommands:
         Logger.info('Done stopping REST application')
 
     def restart_rest_application(self, env):
+        """
+        Restart the REST application
+        :param env: Environment
+        """
         Logger.info('Restarting the REST application')
         self.stop_rest_application()
         self.start_rest_application()
         Logger.info('Done restarting the REST application')
 
+    def status_rest_application(self, env):
+        """
+        Performs a status check for the REST application
+        :param env: Environment
+        """
+        Logger.info('Status check the REST application')
+        metron_service.check_http(
+            self.__params.hostname,
+            self.__params.metron_rest_port,
+            self.__params.metron_user)
+
     def service_check(self, env):
         """
-        Performs a service check for the Metron API.
+        Performs a service check for the REST application
         :param env: Environment
         """
+        Logger.info('Checking connectivity to REST application')
+        metron_service.check_http(
+            self.__params.hostname,
+            self.__params.metron_rest_port,
+            self.__params.metron_user)
+
         Logger.info('Checking Kafka topics for the REST application')
         metron_service.check_kafka_topics(self.__params, self.__get_topics())
 
         if self.__params.security_enabled:
-
             Logger.info('Checking Kafka topic ACL for the REST application')
             metron_service.check_kafka_acls(self.__params, self.__get_topics())
 

http://git-wip-us.apache.org/repos/asf/metron/blob/b4aa0859/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/service_check.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/service_check.py
index 1aebecb..2007f36 100755
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/service_check.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/service_check.py
@@ -28,6 +28,7 @@ from indexing_commands import IndexingCommands
 from profiler_commands import ProfilerCommands
 from rest_commands import RestCommands
 from management_ui_commands import ManagementUICommands
+from alerts_ui_commands import AlertsUICommands
 
 class ServiceCheck(Script):
 
@@ -64,6 +65,11 @@ class ServiceCheck(Script):
         mgmt_cmds = ManagementUICommands(params)
         mgmt_cmds.service_check(env)
 
+        # check the alerts UI
+        Logger.info("Performing Alerts UI service check")
+        alerts_cmds = AlertsUICommands(params)
+        alerts_cmds.service_check(env)
+
         Logger.info("Metron service check completed successfully")
         exit(0)
 


Mime
View raw message