Zabbix SMS Alert
Alert Script (CoolSMS/Python)
http://www.coolsms.com 에서 가입 후 APIKEY, APISECRET 생성
CoolSMS 의 환경설정-> Sender Number, Sender IP 등록
vi /usr/lib/zabbix/alertscripts/send-sms.sh
#!/usr/bin/python # -*- coding: utf-8 -*- """ Zabbix SMS Alert Script """ import sys from sdk.api.message import Message from sdk.exceptions import CoolsmsException ## @brief This sample code demonstrate how to send sms through CoolSMS Rest API PHP if __name__ == "__main__": #parameters to = sys.argv[1] content = sys.argv[2] # set api key, api secret api_key = "Your key" api_secret = "your secret" ## 4 params(to, from, type, text) are mandatory. must be filled params = dict() params['type'] = 'sms' # Message type ( sms, lms, mms, ata ) params['to'] = to # Recipients Number '01000000000,01000000001' params['from'] = '010XXXXYYYY' # Sender number params['text'] = content # Message print(to) print(content) cool = Message(api_key, api_secret) try: response = cool.send(params) print("Success Count : %s" % response['success_count']) print("Error Count : %s" % response['error_count']) print("Group ID : %s" % response['group_id']) if "error_list" in response: print("Error List : %s" % response['error_list']) except CoolsmsException as e: print("Error Code : %s" % e.code) print("Error Message : %s" % e.msg) sys.exit() |
/usr/lib/zabbix 와 Shell Script 의 소유자 확인 (zabbix.zabbix)
아래 그림과 같이 Administration - Media Types 에서 media 등록