[root@zabbixdbm1-ctc-bj-10-254-64-xx include]# cat sendsms_api.py
#!/bin/env python
#-*-coding:utf-8-*-
import os
import sys
import time
import string
reload(sys) 
sys.setdefaultencoding('utf8')
import ConfigParser
import requests

def send_sms(sms_to_list,sms_msg,db_type,application,host,port,level,alarm_item,alarm_value,message):
    '''
    sms_to_list:发给谁
    sms_msg:短信内容
    sms_msg='['+level+'] '+db_type+'-'+tags+'-'+server+' '+message+' Time:'+create_time.strftime('%Y-%m-%d %H:%M:%S')
    '''
    '''
    sms_to_list_comma:多个短信接收者,用逗号拼接
    sms_to_list_semicolon:多个短信接收者,用分号拼接
    '''
    sms_to_list_comma = ",".join(sms_to_list)
    sms_to_list_semicolon = ";".join(sms_to_list)
    try:
        ######### you send sms code here ##############
        url = 'http://admin.aiwaly.com/SmsGroup/sendSms/'
        messages = sms_msg[0:70]
        for mobile in sms_to_list:
            #print mobile
            #mobile="13522875075"
            payload = {"mobile":mobile, "content":messages}
            r = requests.get(url, params=payload)
        #return r.tex
        ###############################################
        #return True
    except Exception, e:
        print str(e)
        return False
文档更新时间: 2019-06-14 13:38   作者:月影鹏鹏