parameters: (request)
return_statement: return HttpResponse(json.dumps(content, ensure_ascii=False, indent=4), content_type="application/json")
docstring: 监控及脚本探测api
      :param request:
      :return:
docstring_summary: 监控及脚本探测api
      :param request:
      :return:
docstring_tokens: 监控及脚本探测api : param request : : return :
function: def FaultApi(request):
      """
      监控及脚本探测api
      :param request:
      :return:
      """
      date_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
      if request.method == "POST":
          source = request.GET.get("source", False)
          if source:
              if source == "zabbix" or source == "nagios" or source == "cacti":
                  data = zabbix_from(request.POST)
                  if data.is_valid():
                      zw = data.save(commit=False)
                      zw.source = source
                      zw.starttime = date_time
                      zw.scantime = date_time
                      zw.save()
                      content = {"status": 200, "msg": u"ok"}
                      return HttpResponse(json.dumps(content, ensure_ascii=False, indent=4))
  
              if source == "smokeping":
                  data = smokeping_from(request.POST)
                  print data
                  if data.is_valid():
                      zw = data.save(commit=False)
                      zw.source = source
                      zw.starttime = date_time
                      zw.scantime = date_time
                      zw.save()
                      content = {"status": 200, "msg": u"ok"}
                      return HttpResponse(json.dumps(content, ensure_ascii=False, indent=4))
  
              if source == u'监控脚本':
                  data = script_from(request.POST)
                  if data.is_valid():
                      zw = data.save(commit=False)
                      zw.source = source
                      zw.starttime = date_time
                      zw.scantime = date_time
                      zw.save()
                      content = {"status": 200, "msg": u"ok"}
                  return HttpResponse(json.dumps(content, ensure_ascii=False, indent=4))
  
          content = {"status": 403, "msg": u"参数不完整"}
          return HttpResponse(json.dumps(content, ensure_ascii=False, indent=4))
  
      content = {"status": 403, "msg": u"禁止get提交"}
      return HttpResponse(json.dumps(content, ensure_ascii=False, indent=4), content_type="application/json")
function_tokens: def FaultApi ( request ) : date_time = time . strftime ( '%Y-%m-%d %H:%M:%S' , time . localtime ( time . time ( ) ) ) if request . method == "POST" : source = request . GET . get ( "source" , False ) if source : if source == "zabbix" or source == "nagios" or source == "cacti" : data = zabbix_from ( request . POST ) if data . is_valid ( ) : zw = data . save ( commit = False ) zw . source = source zw . starttime = date_time zw . scantime = date_time zw . save ( ) content = { "status" : 200 , "msg" : u"ok" } return HttpResponse ( json . dumps ( content , ensure_ascii = False , indent = 4 ) ) if source == "smokeping" : data = smokeping_from ( request . POST ) print data if data . is_valid ( ) : zw = data . save ( commit = False ) zw . source = source zw . starttime = date_time zw . scantime = date_time zw . save ( ) content = { "status" : 200 , "msg" : u"ok" } return HttpResponse ( json . dumps ( content , ensure_ascii = False , indent = 4 ) ) if source == u'监控脚本': data = script_from ( request . POST ) if data . is_valid ( ) : zw = data . save ( commit = False ) zw . source = source zw . starttime = date_time zw . scantime = date_time zw . save ( ) content = { "status" : 200 , "msg" : u"ok" } return HttpResponse ( json . dumps ( content , ensure_ascii = False , indent = 4 ) ) content = { "status" : 403 , "msg" : u"参数不完整"} return HttpResponse ( json . dumps ( content , ensure_ascii = False , indent = 4 ) ) content = { "status" : 403 , "msg" : u"禁止get提交"} return HttpResponse ( json . dumps ( content , ensure_ascii = False , indent = 4 ) , content_type = "application/json" )