Beispiel #1
0
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()))
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())
        )
    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()))