def __init__(self,django_settings,connect_redis=True): self.django_settings = django_settings self.poll_interval = 0.5 self.config_update_interval =120 self.config_last_loading_time = time.time() self.global_monitor_dic = {} self.exit_flag = False if connect_redis: self.redis = redis_conn.redis_conn(django_settings)
def __init__(self,django_settings,connect_redis=True): self.django_settings = django_settings self.poll_interval = 0.5 self.config_update_interval = 120 self.config_last_loading_time = time.time() self.global_monitor_dic = {} self.exit_flag = False if connect_redis: self.redis = redis_conn.redis_conn(django_settings)
def __init__(self,django_settings): self.django_settings = django_settings self.redis = redis_conn.redis_conn(self.django_settings) self.alert_counters ={} #纪录每个action的触发报警次数 alert_counters = { 1: {2:{'counter':0,'last_alert':None}, 4:{'counter':1,'last_alert':None}}, #k是action id, {2:0,3:2}这里面的k是主机id,value是报警次数 #2: {2:0}, }
def __init__(self,django_setting): self.django_settings = django_setting self.redis = redis_conn.redis_conn(self.django_settings) self.alert_counter = {} alert_counters = { 1:{ 2:{'counter':0,'last_alert':None}, 4:{'counter':1,'last_alert':None}, }, }
def __init__(self, django_settings): self.django_settings = django_settings self.redis = redis_conn.redis_conn(self.django_settings) self.alert_counters = {} #纪录每个action的触发报警次数 alert_counters = { 1: { 2: { 'counter': 0, 'last_alert': None }, 4: { 'counter': 1, 'last_alert': None } }, #k是action id, {2:0,3:2}这里面的k是主机id,value是报警次数 #2: {2:0}, }
from django.shortcuts import render, HttpResponse import json from monitor import settings from Robb.backends import redis_conn from Robb.backends import data_processing from Robb.backends import data_optimization from Robb.serializer import ClientHandler, get_host_triggers from django.views.decorators.csrf import csrf_exempt from Robb import models # Create your views here. REDIS_OBJ = redis_conn.redis_conn(settings) def dashboard(request): return render(request, 'Robb/monitor/dashboard.html') def triggers(request): return render(request, 'Robb/monitor/triggers.html') def index(request): return render(request, 'Robb/monitor/index.html') def hosts(request): host_list = models.Host.objects.all() print("hosts:", host_list)
from django.shortcuts import render,HttpResponse import json from Stark import settings from Robb.backends import redis_conn from Robb.backends import data_processing from Robb.backends import data_optimization from Robb.serializer import ClientHandler,get_host_triggers from django.views.decorators.csrf import csrf_exempt from Robb import models # Create your views here. REDIS_OBJ = redis_conn.redis_conn(settings) def client_configs(request,client_id): print("--->",client_id) config_obj = ClientHandler(client_id) config = config_obj.fetch_configs() # 获取服务插件名以及,间隔时间 if config: return HttpResponse(json.dumps(config)) @csrf_exempt def service_data_report(request): if request.method == 'POST': print("---->",request.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'])