DEV/ETC
Zabbix 에서 알람 설정 -- SMS 연동 및 라인(line)연동
초록매실원액
2018. 1. 26. 13:17
zabbix 에서 sms 및 line 연동
아래와 같이 미디어 타입에서 타입을 생성한다.
스크립트 이름은 생성할 파일의 이름이다.
zabbix가 설치된 경로에서 해당 파일을 생성한다.
AlertScriptsPath 설정경로는 zabbix_server.conf 에서 설정하면된다.
필자의 경우 아래와 같다.
zabbix_server.conf 파일에서 "AlertScriptsPath" 부분을 찾는다
1 2 3 4 5 6 7 8 9 10 11 | ### Option: AlertScriptsPath # Full path to location of custom alert scripts. # Default depends on compilation options. # # Mandatory: no # Default: # AlertScriptsPath=${datadir}/zabbix/alertscripts #AlertScriptsPath=/usr/bin AlertScriptsPath=/home/zabbix/zabbix/share/zabbix/alertscripts | cs |
스크립트를 생성할 경로에 가서 send_sms.py 를 작성한다.
파일을 작성하고 실행권한을 준다.
chmod +x send_sms.py
필자는 후이즈 SMS를 사용하고있는데
후이즈의 경우 php , asp , jsp 샘플 코드를 제공해주고있습니다.
후이즈의 경우 xmlrcp 서버를 사용
파이썬을 통해 ( 후이즈 SMS사용 )를 연동하도록하겠습니다.
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 | import xmlrpclib import sys def connectService(url): try: s = xmlrpclib.ServerProxy(url) s.system.listMethods() return s finally: pass def main(): xrs = None url = 'http://www.whoisweb.net/emma/API/EmmaSend_JSP.php' try: xrs = connectService(url) result = xrs.EmmaSend('[계정ID]','[비밀번호]','[수신번호],'[발신번호]','[내용]','0','','') except xmlrpc.client.Fault as err: print("A fault occurred") print("Fault code: %d" % err.faultCode) print("Fault string: %s" % err.faultString) finally: pass print result if __name__ == '__main__': main() | cs |
참고로
아래문구를 추가하면 셀처럼 바로 실행이 가능하다.
1 | #!/usr/bin/env python | cs |
라인연동은 아래 URL을 참조하시면 됩니다.
참고 URL : http://manual.oplab.co.kr/doku.php/manual/config/notifications/media/line