Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #147 from caskdata/feature_release/gh144-to-release35
Browse files Browse the repository at this point in the history
CDAP-7660 Use scripts to check status of CDAP Auth Server/Router
  • Loading branch information
wolf31o2 committed Jan 31, 2017
2 parents 2a160c2 + ca10100 commit 2030c41
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 47 deletions.
54 changes: 7 additions & 47 deletions alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,8 @@
"scope": "ANY",
"enabled": true,
"source": {
"type": "WEB",
"uri": {
"http": "{{hostname}}:{{cdap-site/router.bind.port}}/status",
"https": "{{hostname}}:{{cdap-site/router.ssl.bind.port}}/status",
"https_property": "{{cdap-site/ssl.enabled}}",
"https_property_value": "true",
"default_port": 11015,
"connection_timeout": 5.0
},
"reporting": {
"ok": {
"text": "HTTP {0} response in {2:.3f}s"
},
"warning": {
"text": "HTTP {0} response from {1} in {2:.3f}s ({3})",
"value": 1.5
},
"critical": {
"text": "Connection failed to {1} ({3})",
"value": 5.0
}
}
"type": "SCRIPT",
"path": "CDAP/3.6.0-SNAPSHOT/package/alerts/alert_cdap_router_status.py"
}
}
],
Expand Down Expand Up @@ -86,11 +66,11 @@
"source": {
"type": "WEB",
"uri": {
"http": "{{hostname}}:{{cdap-site/dashboard.bind.port}}/status",
"https": "{{hostname}}:{{cdap-site/dashboard.ssl.bind.port}}/status",
"http": "{{hostname}}:{{cdap-site/dashboard.bind.port}}",
"https": "{{hostname}}:{{cdap-site/dashboard.ssl.bind.port}}",
"https_property": "{{cdap-site/ssl.enabled}}",
"https_property_value": "true",
"default_port": 9999,
"default_port": 11011,
"connection_timeout": 5.0
},
"reporting": {
Expand Down Expand Up @@ -118,28 +98,8 @@
"scope": "ANY",
"enabled": true,
"source": {
"type": "WEB",
"uri": {
"http": "{{hostname}}:{{cdap-site/security.auth.server.bind.port}}/status",
"https": "{{hostname}}:{{cdap-site/security.auth.server.ssl.bind.port}}/status",
"https_property": "{{cdap-site/ssl.enabled}}",
"https_property_value": "true",
"default_port": 10009,
"connection_timeout": 5.0
},
"reporting": {
"ok": {
"text": "HTTP {0} response in {2:.3f}s"
},
"warning": {
"text": "HTTP {0} response from {1} in {2:.3f}s ({3})",
"value": 1.5
},
"critical": {
"text": "Connection failed to {1} ({3})",
"value": 5.0
}
}
"type": "SCRIPT",
"path": "CDAP/3.6.0-SNAPSHOT/package/alerts/alert_cdap_auth_server_status.py"
}
}
]
Expand Down
37 changes: 37 additions & 0 deletions package/alerts/alert_cdap_auth_server_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding=utf8
# Copyright © 2016 Cask Data, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

import logging

from resource_management import *

RESULT_STATE_OK = 'OK'
RESULT_STATE_CRITICAL = 'CRITICAL'
RESULT_STATE_UNKNOWN = 'UNKNOWN'

LOGGER_EXCEPTION_MESSAGE = "[Alert] CDAP Auth Server Health on {0} fails:"
logger = logging.getLogger('ambari_alerts')


def execute(configurations={}, parameters={}, host_name=None):
if configurations is None:
return (RESULT_STATE_UNKNOWN, ['There were no configurations supplied to the script.'])
try:
check_cmd = format('service cdap-auth-server status')
Execute(check_cmd, timeout=5)
return(RESULT_STATE_OK, ['Auth Server OK - CDAP Auth Server is running'])
except:
return(RESULT_STATE_CRITICAL, [LOGGER_EXCEPTION_MESSAGE])
37 changes: 37 additions & 0 deletions package/alerts/alert_cdap_router_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding=utf8
# Copyright © 2016 Cask Data, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

import logging

from resource_management import *

RESULT_STATE_OK = 'OK'
RESULT_STATE_CRITICAL = 'CRITICAL'
RESULT_STATE_UNKNOWN = 'UNKNOWN'

LOGGER_EXCEPTION_MESSAGE = "[Alert] CDAP Router Health on {0} fails:"
logger = logging.getLogger('ambari_alerts')


def execute(configurations={}, parameters={}, host_name=None):
if configurations is None:
return (RESULT_STATE_UNKNOWN, ['There were no configurations supplied to the script.'])
try:
check_cmd = format('service cdap-router status')
Execute(check_cmd, timeout=5)
return(RESULT_STATE_OK, ['Router OK - CDAP Router is running'])
except:
return(RESULT_STATE_CRITICAL, [LOGGER_EXCEPTION_MESSAGE])

0 comments on commit 2030c41

Please sign in to comment.