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


Python Utils.LadDiagnosticUtil类代码示例

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


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

示例1: __generate_mdsd_syslog_config

    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,代码行数:29,代码来源:lad_logging_config.py

示例2: generatePerformanceCounterConfiguration

def generatePerformanceCounterConfiguration(mdsdCfg, includeAI=False):
    perfCfgList = []
    try:
        ladCfg = readPublicConfig("ladCfg")
        perfCfgList = LadUtil.generatePerformanceCounterConfigurationFromLadCfg(ladCfg)
        if not perfCfgList:
            perfCfgList = readPublicConfig("perfCfg")
        if not perfCfgList and not hasPublicConfig("perfCfg"):
            perfCfgList = [
                {
                    "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",
                },
            ]
    except Exception, e:
        hutil.error(
            "Failed to parse performance configuration with exception:{0} {1}".format(e, traceback.format_exc())
        )
开发者ID:karataliu,项目名称:azure-linux-extensions,代码行数:26,代码来源:diagnostic.py

示例3: _update_metric_collection_settings

    def _update_metric_collection_settings(self, ladCfg):
        """
        Update mdsd_config_xml_tree for Azure Portal metric collection. The mdsdCfg performanceCounters element contains
        an array of metric definitions; this method passes each definition to its provider's AddMetric method, which is
        responsible for configuring the provider to deliver the metric to mdsd and for updating the mdsd config as
        required to expect the metric to arrive. This method also builds the necessary aggregation queries (from the
        metrics.metricAggregation array) that grind the ingested data and push it to the WADmetric table.
        :param ladCfg: ladCfg object from extension config
        :return: None
        """
        metrics = LadUtil.getPerformanceCounterCfgFromLadCfg(ladCfg)
        if not metrics:
            return

        counter_to_table = {}
        local_tables = set()

        # Add each metric
        for metric in metrics:
            if metric['type'] == 'builtin':
                local_table_name = BuiltIn.AddMetric(metric)
                if local_table_name:
                    local_tables.add(local_table_name)
                    counter_to_table[metric['counterSpecifier']] = local_table_name

        # Finalize; update the mdsd config to be prepared to receive the metrics
        BuiltIn.UpdateXML(self._mdsd_config_xml_tree)

        # Aggregation is done by <LADQuery> within a <DerivedEvent>. If there are no alternate sinks, the DerivedQuery
        # can send output directly to the WAD metrics table. If there *are* alternate sinks, have the LADQuery send
        # output to a new local table, then arrange for additional derived queries to pull from that.
        intervals = LadUtil.getAggregationPeriodsFromLadCfg(ladCfg)
        sinks = LadUtil.getFeatureWideSinksFromLadCfg(ladCfg, 'performanceCounters')
        for table_name in local_tables:
            for aggregation_interval in intervals:
                if sinks:
                    local_table_name = ProvUtil.MakeUniqueEventName('aggregationLocal')
                    self._add_derived_event(aggregation_interval, table_name,
                                            local_table_name,
                                            'Local', add_lad_query=True)
                    self._handle_alternate_sinks(aggregation_interval, sinks, local_table_name)
                else:
                    self._add_derived_event(aggregation_interval, table_name,
                                            LadConfigAll._wad_table_name(aggregation_interval),
                                            'Central', add_lad_query=True)
开发者ID:SuperScottz,项目名称:azure-linux-extensions,代码行数:45,代码来源:lad_config_all.py

示例4: _update_raw_omi_events_settings

    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,代码行数:57,代码来源:lad_config_all.py

示例5: getSyslogCfg

def getSyslogCfg():
    syslogCfg = ""
    ladCfg = readPublicConfig('ladCfg')
    encodedSyslogCfg = LadUtil.getDiagnosticsMonitorConfigurationElement(ladCfg, 'syslogCfg')
    if not encodedSyslogCfg:
        encodedSyslogCfg = readPublicConfig('syslogCfg')
    if encodedSyslogCfg:
        syslogCfg = base64.b64decode(encodedSyslogCfg)
    return syslogCfg
开发者ID:Rev68,项目名称:azure-linux-extensions,代码行数:9,代码来源:diagnostic.py

示例6: getResourceId

def getResourceId():
    ladCfg = readPublicConfig('ladCfg')
    resourceId = LadUtil.getResourceIdFromLadCfg(ladCfg)
    if not resourceId:
        encodedXmlCfg = readPublicConfig('xmlCfg').strip()
        if encodedXmlCfg:
            xmlCfg = base64.b64decode(encodedXmlCfg)
            resourceId = XmlUtil.getXmlValue(XmlUtil.createElement(xmlCfg),'diagnosticMonitorConfiguration/metrics','resourceId')
# Azure portal uses xmlCfg which contains WadCfg which is pascal case, Currently we will support both casing and deprecate one later
            if not resourceId:
                resourceId = XmlUtil.getXmlValue(XmlUtil.createElement(xmlCfg),'DiagnosticMonitorConfiguration/Metrics','resourceId')
    return resourceId
开发者ID:arunjvs,项目名称:azure-linux-extensions,代码行数:12,代码来源:diagnostic.py

示例7: setEventVolume

def setEventVolume(mdsdCfg,ladCfg):
    eventVolume = LadUtil.getEventVolumeFromLadCfg(ladCfg)
    if eventVolume:
        hutil.log("Event volume found in ladCfg: " + eventVolume)
    else:
        eventVolume = readPublicConfig("eventVolume")
        if eventVolume:
            hutil.log("Event volume found in public config: " + eventVolume)
        else:
            eventVolume = "Medium"
            hutil.log("Event volume not found in config. Using default value: " + eventVolume)
            
    XmlUtil.setXmlValue(mdsdCfg,"Management","eventVolume",eventVolume)
开发者ID:Rev68,项目名称:azure-linux-extensions,代码行数:13,代码来源:diagnostic.py

示例8: get_syslog_config

 def get_syslog_config(self):
     """
     Get syslog config from LAD extension settings.
     First look up 'ladCfg' section's 'syslogCfg' and use it. If none, then use 'syslogCfg' at the top level
     of public settings. Base64-encoded rsyslogd conf content is currently supported for 'syslogCfg' in either
     section.
     :return: rsyslogd configuration content string (base64-decoded 'syslogCfg' setting)
     """
     syslog_cfg = ''
     lad_cfg = self.read_public_config('ladCfg')
     encoded_syslog_cfg = LadUtil.getDiagnosticsMonitorConfigurationElement(lad_cfg, 'syslogCfg')
     if not encoded_syslog_cfg:
         encoded_syslog_cfg = self.read_public_config('syslogCfg')
     if encoded_syslog_cfg:
         syslog_cfg = base64.b64decode(encoded_syslog_cfg)
     return syslog_cfg
开发者ID:vityagi,项目名称:azure-linux-extensions,代码行数:16,代码来源:lad_ext_settings.py

示例9: get_file_monitoring_config

 def get_file_monitoring_config(self):
     """
     Get rsyslog file monitoring (imfile module) config from LAD extension settings.
     First look up 'ladCfg' and use it if one is there. If not, then get 'fileCfg' at the top level
     of public settings.
     :return: List of dictionaries specifying files to monitor and Azure table names for the destinations
     of the monitored files. E.g.:
     [
       {"file":"/var/log/a.log", "table":"aLog"},
       {"file":"/var/log/b.log", "table":"bLog"}
     ]
     """
     lad_cfg = self.read_public_config('ladCfg')
     file_cfg = LadUtil.getFileCfgFromLadCfg(lad_cfg)
     if not file_cfg:
         file_cfg = self.read_public_config('fileCfg')
     return file_cfg
开发者ID:vityagi,项目名称:azure-linux-extensions,代码行数:17,代码来源:lad_ext_settings.py

示例10: get_resource_id

 def get_resource_id(self):
     """
     Try to get resourceId from LadCfg. If not present, try to fetch from xmlCfg.
     """
     lad_cfg = self.read_public_config('ladCfg')
     resource_id = LadUtil.getResourceIdFromLadCfg(lad_cfg)
     if not resource_id:
         encoded_xml_cfg = self.read_public_config('xmlCfg').strip()
         if encoded_xml_cfg:
             xml_cfg = base64.b64decode(encoded_xml_cfg)
             resource_id = XmlUtil.getXmlValue(XmlUtil.createElement(xml_cfg),
                                               'diagnosticMonitorConfiguration/metrics', 'resourceId')
             # Azure portal uses xmlCfg which contains WadCfg which is pascal case
             # Currently we will support both casing and deprecate one later
             if not resource_id:
                 resource_id = XmlUtil.getXmlValue(XmlUtil.createElement(xml_cfg),
                                                   'DiagnosticMonitorConfiguration/Metrics', 'resourceId')
     return resource_id
开发者ID:vityagi,项目名称:azure-linux-extensions,代码行数:18,代码来源:lad_ext_settings.py

示例11: _apply_perf_cfgs

    def _apply_perf_cfgs(self, include_app_insights=False):
        """
        Extract the 'perfCfg' settings from ext_settings and apply them to mdsd config XML root.
        :param include_app_insights: Indicates whether perf counter settings for AppInsights should be included or not.
        :return: None. Changes are applied directly to the mdsd config XML tree member.
        """
        assert self._mdsd_config_xml_tree is not None

        perf_cfgs = []
        default_perf_cfgs = [
                        {"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"}
                      ]
        try:
            # First try to get perf cfgs from the new 'ladCfg' setting.
            lad_cfg = self._ext_settings.read_public_config('ladCfg')
            perf_cfgs = LadUtil.generatePerformanceCounterConfigurationFromLadCfg(lad_cfg)
            # If none, try the original 'perfCfg' setting.
            if not perf_cfgs:
                perf_cfgs = self._ext_settings.read_public_config('perfCfg')
            # If none, use default (3 OMI queries)
            if not perf_cfgs and not self._ext_settings.has_public_config('perfCfg'):
                perf_cfgs = default_perf_cfgs
        except Exception as e:
            self._logger_error("Failed to parse performance configuration with exception:{0}\n"
                               "Stacktrace: {1}".format(e, traceback.format_exc()))

        try:
            self._update_perf_counters_settings(perf_cfgs)
            if include_app_insights:
                self._update_perf_counters_settings(perf_cfgs, True)
        except Exception as e:
            self._logger_error("Failed to create perf config. Error:{0}\n"
                         "Stacktrace: {1}".format(e, traceback.format_exc()))
开发者ID:vityagi,项目名称:azure-linux-extensions,代码行数:41,代码来源:config_mdsd_rsyslog.py

示例12: _set_event_volume

    def _set_event_volume(self, lad_cfg):
        """
        Set event volume in mdsd config. Check if desired event volume is specified,
        first in ladCfg then in public config. If in neither then default to Medium.
        :param lad_cfg: 'ladCfg' Json object to look up for the event volume setting.
        :return: None. The mdsd config XML tree's eventVolume attribute is directly updated.
        :rtype: str
        """
        assert self._mdsd_config_xml_tree is not None

        event_volume = LadUtil.getEventVolumeFromLadCfg(lad_cfg)
        if event_volume:
            self._logger_log("Event volume found in ladCfg: " + event_volume)
        else:
            event_volume = self._ext_settings.read_public_config("eventVolume")
            if event_volume:
                self._logger_log("Event volume found in public config: " + event_volume)
            else:
                event_volume = "Medium"
                self._logger_log("Event volume not found in config. Using default value: " + event_volume)
        XmlUtil.setXmlValue(self._mdsd_config_xml_tree, "Management", "eventVolume", event_volume)
开发者ID:SuperScottz,项目名称:azure-linux-extensions,代码行数:21,代码来源:lad_config_all.py

示例13: test_bogus_config

 def test_bogus_config(self):
     self.assertIsNone(LadUtil.getDiagnosticsMonitorConfigurationElement(self.bogus_config, "dummy"))
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:2,代码来源:test_LadDiagnosticUtil.py

示例14: test_getEventVolumeFromLadCfg

 def test_getEventVolumeFromLadCfg(self):
     self.assertEqual(LadUtil.getEventVolumeFromLadCfg(self.valid_config), "Large")
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:2,代码来源:test_LadDiagnosticUtil.py

示例15: test_entry_is_present

 def test_entry_is_present(self):
     self.assertEqual(LadUtil.getDiagnosticsMonitorConfigurationElement(self.valid_config, "foo"), "bar")
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:2,代码来源:test_LadDiagnosticUtil.py


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