Example #1
0
 def __init__(self, django_settings, connect_redis=True):
     self.django_settings = django_settings
     self.global_monitor_dic = {}  # 提取主机的监控和指标信息
     self.config_last_loading_time = time.time()  # 主机更新时间
     self.exit_flag = False
     self.config_update_interval = 12  # 每120s重新从数据库加载一次配置数据
     self.poll_interval = 3  # 每3秒进行一次全局轮训
     if connect_redis:
         self.redis = redis_conn.redis_conn(django_settings)
Example #2
0
# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.shortcuts import render
from . import models
from django.views.decorators.csrf import csrf_exempt
from app.serializer import ClientHandler, get_host_triggers, StatusSerializer
import json
from . import graphs
from zabbix import settings
from app.backends import data_optimization, data_processing
from app.backends import redis_conn

# Create your views here.
REDIS_OBJ = redis_conn.redis_conn(settings)


def client_configs(request, client_id):
    """
    客户端请求返回最新服务监控数据
    :param request:
    :param client_id: 服务器 assed_id
    :return:
    """
    config_obj = ClientHandler(client_id)
    config = config_obj.fetch_configs()
    if config:
        return HttpResponse(json.dumps(config))


@csrf_exempt
def service_data_report(request):
Example #3
0
 def __init__(self):
     self.q_man = queue_handle.QueueMan()
     self.redis = redis_conn.redis_conn(settings)
Example #4
0
 def __init__(self, django_settings):
     self.django_settings = django_settings
     self.redis = redis_conn.redis_conn(self.django_settings)
     self.alert_counters = {}  # 纪录每个action的触发报警次数
     '''
Example #5
0
 def __init__(self, django_settings, connect_redis=True):
     self.django_settings = django_settings
     if connect_redis:
         self.redis = redis_conn.redis_conn(django_settings)