-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChangeMetastoreWriteDbMonitor.py
44 lines (36 loc) · 2.1 KB
/
ChangeMetastoreWriteDbMonitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
#!/usr/bin/env python
#
# 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. See accompanying LICENSE file.
#
import httplib, urllib, urllib2, logging, os, time, sys
baseHome = os.path.abspath(sys.path[0] + '/..')
alertModes1 = {"mail": "http://bigdata0.photo.163.org:8080/sentry/sendmail2.jsp", "sms": "http://bigdata0.photo.163.org:8080/sentry/sendsms.jsp"}
alertModes = {"mail": "http://172.16.87.242:8080/omnew/alert/sendMultiAlert", "sms": "http://bigdata0.photo.163.org:8080/sentry/sendsms.jsp"}
receivers2 = {"mail": "[email protected]", "sms": "13777495757"}
receivers = {"mail": "[email protected],[email protected],[email protected]", "sms": "13777495757,13867471941,15558132155"}
def sendAlert(alertType, subject, body):
url = alertModes[alertType]
body_value = {"account": receivers[alertType] ,"subject": subject, "mobile": receivers["sms"], "emailMsg": body, "popoMsg": body, "mobileMsg": body, "product":"holmes_alarm", "type":7}
print(body_value)
# body_value = urllib.urlencode(body_value)
request = urllib2.Request(url, str(body_value))
request.add_header("Content-type", "application/json")
request.add_header("Accept", "text/plain")
resp = urllib2.urlopen(request )
logging.info( "send alters to " + receivers[alertType] + " by "+ alertType + ". Got response code " + bytes(resp.getcode()))
'''subject = "testAlertFunction"
body = "get alert from hadoop707"
to = receivers["mail"]
sendAlert("mail", subject, body)'''
sendAlert("mail", "YX MetaStoreChangeWriteDb error!", "YX MetaStoreChangeWriteDb error!")