123123

Posted storm1018

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了123123相关的知识,希望对你有一定的参考价值。

# encoding=UTF-8

import logging
import sys
sys.path.append(".")
import Collector
import logging
import logging.handlers
import datetime
import os
import json

class emailMonitor_Mtrs(Collector.Collector):
    collect_datas = []
    _app_list = []

    def __init__(self):
        self.setMetricsKey("emailMonitor")
        self.__init_collect_datas()

    def __init_collect_datas(self):
        self.collect_datas = [
            {
                ‘showDetails‘: ‘false‘,
                ‘emailSendTimeCostAvg‘: 0,
                ‘emailSendTimeCostMax‘: 6000,
                ‘emailServerApiTimeCostAvg‘: 3000,
                ‘emailSendSucceedCount‘: 0,
                ‘emailSendFailedCount‘: 0,
                ‘unavailableServerNumber‘: 0,
                ‘tenantId‘: ‘‘
            }
        ]

    def collect(self, process_filter):
        self.execute("curl -k http://sgbeta.owsgo.com:%s/heartbeat.jsp?monitorNames=emailMonitor" % self.app)

        try:
            result_json_str = self.parse(r‘\s*(\{[\s\S]*\})\s*‘)
            result_dict = json.loads(result_json_str)
            emailMonitorResultCode = int(result_dict[‘monitorResultMap‘][‘emailMonitor‘][‘resultCode‘])
        except Exception, ex:
            logging.exception(ex)
        try:
            detailResult = result_dict[‘monitorResultMap‘][‘emailMonitor‘][‘detailResult‘]
            emailSendTimeCostMax = int(detailResult[‘emailSendTimeCostMax‘])
        except Exception, ex:
            logging.exception(ex)
        try:
            timeCostToWriteESMax = int(detailResult[‘timeCostToWriteESMax‘])
        except Exception, ex:
            logging.exception(ex)

        locals_dict = locals()
        for each_data in self.collect_datas:
            name = each_data["name"]
            if locals_dict.has_key(name):
                each_data["total_value"] += locals_dict[name]
                each_data["total_count"] += 1
            else:
                each_data["total_value"] += each_data["exception_value"]
                each_data["total_count"] += 1


if __name__ == "__main__":
    monitor = emailMonitor_Mtrs()
    monitor.collect("")

    print monitor.collect_datas
# encoding=UTF-8
#name:liveQueryMonitor_Mtrs.py

import sys
import json
import logging

sys.path.append(".")
import Collector


class LiveQueryMonitor_Mtrs(Collector.Collector):
    
    def __init__(self):
        self.setMetricsKey("LiveQueryMonitor")
        self.__init_collect_datas()
        
    #指令执行的超时时间,默认为15秒
    def getTimeout(self):
        return 30
        
    def __init_collect_datas(self):
        self.collect_datas = [
            {
                ‘unit‘: ‘Count‘,
                ‘total_value‘: 0,
                ‘total_count‘: 0,
                ‘exception_value‘: 10000,
                ‘divide_value‘: 1,
                ‘name‘: ‘topicMessageReceiveDelayMax‘
            },{
                ‘unit‘: ‘Count‘,
                ‘total_value‘: 0,
                ‘total_count‘: 0,
                ‘exception_value‘: 10000,
                ‘divide_value‘: 1,
                ‘name‘: ‘liveDataPushDelayMax‘
            }
        ]
        
    # 指令执行的超时时间
    def getTimeout(self):
        return 20
        
    def collect(self, process_filter):

        # LiveQueryMonitor
        try:
            self.execute("curl -k http://127.0.0.1:%s/livequery/heartbeat.jsp?monitorNames=LiveQueryMonitor" % self.tomcat_port)
            result_json_str = self.parse(r‘\s*(\{[\s\S]*\})\s*‘)
            result_dict = json.loads(result_json_str)
        except Exception, ex:
            logging.exception(ex)

        # 从binlogreader发送Topic消息到消息接收延迟(liveTable收到jms相对发的时延) 
        try: 
            LiveQueryDetailResult = result_dict[‘monitorResultMap‘][‘LiveQueryMonitor‘][‘detailResult‘]
            topicMessageReceiveDelayMax = int(LiveQueryDetailResult[‘topicMessageReceiveDelayMax‘])
        except Exception, ex:
            logging.exception(ex)
            
        # JMS消息收到到准备推送的延迟(向前台推送的相对收到jms的时延)
        try: 
            liveDataPushDelayMax = int(LiveQueryDetailResult[‘liveDataPushDelayMax‘])
        except Exception, ex:
            logging.exception(ex)
            
            
        locals_dict = locals()
        for each_data in self.collect_datas:
            name = each_data["name"]
            if locals_dict.has_key(name):
                each_data["total_value"] += locals_dict[name]
                each_data["total_count"] += 1
            else:
                each_data["total_value"] += each_data["exception_value"]
                each_data["total_count"] += 1
            
            
            
                     
if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    monitor = CanalMonitor_Mtrs()    
    monitor.collect("")
    print monitor.collect_datas
    
     
     
            
        

 

以上是关于123123的主要内容,如果未能解决你的问题,请参考以下文章

EditPlus排列数据。 如何将一段数据例如:10000,123123,566自动按位数排列成为566,10000,123123

kafkakafka 启动 Version `123123` is not a valid version

123123

123123

CSS3技巧巧妙使用:not(:last-of-type)简化你的css代码

C语言过滤相同行算法