信创国产化替换如何推动企业自主创新与市场竞争力提升
638
2022-11-26
【分布式监控系统】第5章——报警阈值处理程序逻辑解析
代码实现
url(r'client/service/report/$',api_views.service_report),
@csrf_exemptdef service_report(request): print("client data:",request.POST) if request.method == 'POST': #REDIS_OBJ.set("test_alex",'hahaha') try: print('host=%s, service=%s' %(request.POST.get('client_id'),request.POST.get('service_name') ) ) data = json.loads(request.POST['data']) #print(data) #StatusData_1_memory_latest client_id = request.POST.get('client_id') service_name = request.POST.get('service_name') #把数据存下来 data_saveing_obj = data_optimization.DataStore(client_id,service_name,data,REDIS_OBJ) #redis_key_format = "StatusData_%s_%s_latest" %(client_id,service_name) #data['report_time'] = time.time() #REDIS_OBJ.lpush(redis_key_format,json.dumps(data)) #同时触发trigger检查 print("-------触发trigger检查---------") host_obj = models.Host.objects.get(id=client_id) service_triggers = get_host_triggers(host_obj) trigger_handler = data_processing.DataHandler(settings,connect_redis=False) for trigger in service_triggers: trigger_handler.load_service_data_and_calulating(host_obj,trigger,REDIS_OBJ) print("service trigger::",service_triggers) except IndexError as e: print('----->err:',e) return HttpResponse(json.dumps("---report success---"))
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~