当前位置: 首页>>代码示例>>Python>>正文


Python LadDiagnosticUtil.getSinkList方法代码示例

本文整理汇总了Python中Utils.LadDiagnosticUtil.getSinkList方法的典型用法代码示例。如果您正苦于以下问题:Python LadDiagnosticUtil.getSinkList方法的具体用法?Python LadDiagnosticUtil.getSinkList怎么用?Python LadDiagnosticUtil.getSinkList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils.LadDiagnosticUtil的用法示例。


在下文中一共展示了LadDiagnosticUtil.getSinkList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __generate_mdsd_syslog_config

# 需要导入模块: from Utils import LadDiagnosticUtil [as 别名]
# 或者: from Utils.LadDiagnosticUtil import getSinkList [as 别名]
    def __generate_mdsd_syslog_config(self):
        """
        Helper method to generate oms_mdsd_syslog_config
        """
        if self._syslog_disabled:
            return ''

        # For basic syslog conf (single dest table): Source name is unified as 'mdsd.syslog' and
        # dest table (eventName) is 'LinuxSyslog'. This is currently the only supported syslog conf scheme.
        syslog_routeevents = mxt.per_RouteEvent_tmpl.format(event_name='LinuxSyslog', opt_store_type='')
        # Add RouteEvent elements for specified "sinks" for "syslogEvents" feature
        # Also add EventStreamingAnnotation for EventHub sinks
        syslog_eh_urls = ''
        for sink_name in LadUtil.getSinkList(self._syslogEvents):
            if sink_name == 'LinuxSyslog':
                raise LadLoggingConfigException("'LinuxSyslog' can't be used as a sink name. "
                    "It's reserved for default Azure Table name for syslog events.")
            routeevent, eh_url = self.__generate_routeevent_and_eh_url_for_extra_sink(sink_name,
                                                                                      syslog_src_name)
            syslog_routeevents += routeevent
            syslog_eh_urls += eh_url

        mdsd_event_source = ''
        if syslog_routeevents:  # Do not add MdsdEventSource element if there's no associated RouteEvent generated.
            mdsd_event_source = mxt.per_MdsdEventSource_tmpl.format(source=syslog_src_name,
                                                                    routeevents=syslog_routeevents)

        return mxt.top_level_tmpl_for_logging_only.format(
            sources=mxt.per_source_tmpl.format(name=syslog_src_name), events=mdsd_event_source, eh_urls=syslog_eh_urls)
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:31,代码来源:lad_logging_config.py

示例2: _update_raw_omi_events_settings

# 需要导入模块: from Utils import LadDiagnosticUtil [as 别名]
# 或者: from Utils.LadDiagnosticUtil import getSinkList [as 别名]
    def _update_raw_omi_events_settings(self, omi_queries):
        """
        Update the mdsd XML tree with the OMI queries provided.
        :param omi_queries: List of dictionaries specifying OMI queries and destination tables. E.g.:
         [
             {"query":"SELECT PercentAvailableMemory, AvailableMemory, UsedMemory, PercentUsedSwap FROM SCX_MemoryStatisticalInformation","table":"LinuxMemory"},
             {"query":"SELECT PercentProcessorTime, PercentIOWaitTime, PercentIdleTime FROM SCX_ProcessorStatisticalInformation WHERE Name='_TOTAL'","table":"LinuxCpu"},
             {"query":"SELECT AverageWriteTime,AverageReadTime,ReadBytesPerSecond,WriteBytesPerSecond FROM  SCX_DiskDriveStatisticalInformation WHERE Name='_TOTAL'","table":"LinuxDisk"}
         ]
        :return: None. The mdsd XML tree member is updated accordingly.
        """
        if not omi_queries:
            return

        def generate_omi_query_xml_elem(omi_query, sink=()):
            """
            Helper for generating OMI event XML element
            :param omi_query: Python dictionary object for the raw OMI query specified as a LAD 3.0 perfCfg array item
            :param sink: (name, type) tuple for this OMI query. Not specified implies default XTable sink
            :return: An XML element object for this OMI event that should be added to the mdsd XML cfg tree
            """
            omi_xml_schema = """
            <OMIQuery cqlQuery="" dontUsePerNDayTable="true" eventName="" omiNamespace="" priority="High" sampleRateInSeconds="" storeType="" />
            """ if sink else """
            <OMIQuery cqlQuery="" dontUsePerNDayTable="true" eventName="" omiNamespace="" priority="High" sampleRateInSeconds="" />
            """
            xml_elem = XmlUtil.createElement(omi_xml_schema)
            xml_elem.set('cqlQuery', omi_query['query'])
            xml_elem.set('eventName', sink[0] if sink else omi_query['table'])
            # Default OMI namespace is 'root/scx'
            xml_elem.set('omiNamespace', omi_query['namespace'] if 'namespace' in omi_query else 'root/scx')
            # Default query frequency is 300 seconds
            xml_elem.set('sampleRateInSeconds', str(omi_query['frequency']) if 'frequency' in omi_query else '300')
            if sink:
                xml_elem.set('storeType', 'local' if sink[1] == 'EventHub' else sink[1])
            return xml_elem

        for omi_query in omi_queries:
            if ('query' not in omi_query) or ('table' not in omi_query and 'sinks' not in omi_query):
                self._logger_log("Ignoring perfCfg array element missing required elements: '{0}'".format(omi_query))
                continue
            if 'table' in omi_query:
                self._add_element_from_element('Events/OMI', generate_omi_query_xml_elem(omi_query))
            for sink_name in LadUtil.getSinkList(omi_query):
                sink = self._sink_configs.get_sink_by_name(sink_name)
                if not sink:
                    raise LadPerfCfgConfigException('Sink name "{0}" is not defined in sinksConfig'.format(sink_name))
                sink_type = sink['type']
                if sink_type != 'JsonBlob' and sink_type != 'EventHub':
                    raise LadPerfCfgConfigException('Sink type "{0}" (for sink name="{1}") is not supported'
                                                    .format(sink_type, sink_name))
                self._add_element_from_element('Events/OMI', generate_omi_query_xml_elem(omi_query, (sink_name, sink_type)))
                if sink_type == 'EventHub':
                    if 'sasURL' not in sink:
                        raise LadPerfCfgConfigException('No sasURL specified for an EventHub sink (name="{0}")'
                                                        .format(sink_name))
                    self._add_streaming_annotation(sink_name, sink['sasURL'])
开发者ID:SuperScottz,项目名称:azure-linux-extensions,代码行数:59,代码来源:lad_config_all.py


注:本文中的Utils.LadDiagnosticUtil.getSinkList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。