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 __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)
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)
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'])
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
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
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)
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
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
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
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()))
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)
def test_getEventVolumeFromLadCfg(self): self.assertEqual(LadUtil.getEventVolumeFromLadCfg(self.valid_config), "Large")
def test_getDefaultSampleRateFromLadCfg(self): self.assertEqual(LadUtil.getDefaultSampleRateFromLadCfg(self.valid_config), 60)
def test_entry_is_present(self): self.assertEqual(LadUtil.getDiagnosticsMonitorConfigurationElement(self.valid_config, "foo"), "bar")
def setUp(self): """ Create LadLoggingConfig objects for use by test cases """ # "syslogEvents" LAD config example syslogEvents_json_ext_settings = """ { "sinks": "SyslogJsonBlob,SyslogEventHub", "syslogEventConfiguration": { "LOG_LOCAL0": "LOG_CRIT", "LOG_USER": "******" } } """ # "fileLogs" LAD config example fileLogs_json_ext_settings = """ [ { "file": "/var/log/mydaemonlog1", "table": "MyDaemon1Events", "sinks": "Filelog1JsonBlob,FilelogEventHub" }, { "file": "/var/log/mydaemonlog2", "table": "MyDaemon2Events", "sinks": "Filelog2JsonBlob" } ] """ # "sinksConfig" LAD config example sinksConfig_json_ext_settings = """ { "sink": [ { "name": "SyslogEventHub", "type": "EventHub", "sasURL": "https://fake&sas%url;for_syslog_eh" }, { "name": "SyslogJsonBlob", "type": "JsonBlob" }, { "name": "FilelogEventHub", "type": "EventHub", "sasURL": "https://fake&sas%url;for_filelog_eh" }, { "name": "Filelog1JsonBlob", "type": "JsonBlob" }, { "name": "Filelog2JsonBlob", "type": "JsonBlob" } ] } """ sinksConfig = LadUtil.SinkConfiguration() sinksConfig.insert_from_config( json.loads(sinksConfig_json_ext_settings)) syslogEvents = json.loads(syslogEvents_json_ext_settings) mock_pkey_path = "/waagent/dir/mock_pkey.prv" mock_cert_path = "/waagent/dir/mock_cert.crt" self.cfg_syslog = LadLoggingConfig(syslogEvents, None, sinksConfig, mock_pkey_path, mock_cert_path, mock_encrypt_secret) fileLogs = json.loads(fileLogs_json_ext_settings) self.cfg_filelog = LadLoggingConfig(None, fileLogs, sinksConfig, mock_pkey_path, mock_cert_path, mock_encrypt_secret) self.cfg_none = LadLoggingConfig(None, None, sinksConfig, mock_pkey_path, mock_cert_path, mock_encrypt_secret) # XPaths representations of expected XML outputs, for use with xmlunittests package self.oms_syslog_expected_xpaths = ( './Sources/Source[@name="mdsd.syslog" and @dynamic_schema="true"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.syslog"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.syslog"]/RouteEvent[@dontUsePerNDayTable="true" and @eventName="LinuxSyslog" and @priority="High"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.syslog"]/RouteEvent[@dontUsePerNDayTable="true" and @eventName="SyslogJsonBlob" and @priority="High" and @storeType="JsonBlob"]', './EventStreamingAnnotations/EventStreamingAnnotation[@name="mdsd.syslog"]/EventPublisher/Key', # TODO Perform CDATA validation ) self.oms_filelog_expected_xpaths = ( './Sources/Source[@name="mdsd.filelog.var.log.mydaemonlog1" and @dynamic_schema="true"]', './Sources/Source[@name="mdsd.filelog.var.log.mydaemonlog2" and @dynamic_schema="true"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.filelog.var.log.mydaemonlog1"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.filelog.var.log.mydaemonlog1"]/RouteEvent[@dontUsePerNDayTable="true" and @eventName="MyDaemon1Events" and @priority="High"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.filelog.var.log.mydaemonlog1"]/RouteEvent[@dontUsePerNDayTable="true" and @eventName="Filelog1JsonBlob" and @priority="High" and @storeType="JsonBlob"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.filelog.var.log.mydaemonlog2"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.filelog.var.log.mydaemonlog2"]/RouteEvent[@dontUsePerNDayTable="true" and @eventName="MyDaemon2Events" and @priority="High"]', './Events/MdsdEvents/MdsdEventSource[@source="mdsd.filelog.var.log.mydaemonlog2"]/RouteEvent[@dontUsePerNDayTable="true" and @eventName="Filelog2JsonBlob" and @priority="High" and @storeType="JsonBlob"]', './EventStreamingAnnotations/EventStreamingAnnotation[@name="mdsd.filelog.var.log.mydaemonlog1"]/EventPublisher/Key', # TODO Perform CDATA validation )
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'])
def getFileCfg(): ladCfg = readPublicConfig('ladCfg') fileCfg = LadUtil.getFileCfgFromLadCfg(ladCfg) if not fileCfg: fileCfg = readPublicConfig('fileCfg') return fileCfg
def test_getPerformanceCounterCfgFromLadCfg(self): definitions = LadUtil.getPerformanceCounterCfgFromLadCfg(self.valid_config) self.assertEqual(1, len(definitions)) metric = definitions[0] self.assertIn('counterSpecifier', metric) self.assertEqual('/builtin/Processor/PercentIdleTime', metric['counterSpecifier'])
def test_getAggregationPeriodsFromLadCfg(self): periods = LadUtil.getAggregationPeriodsFromLadCfg(self.valid_config) self.assertEqual(len(periods), 2) self.assertIn('PT5M', periods) self.assertIn('PT1H', periods)
def test_getDefaultSampleRateFromLadCfg(self): self.assertEqual( LadUtil.getDefaultSampleRateFromLadCfg(self.valid_config), 60)
def test_entry_is_present(self): self.assertEqual( LadUtil.getDiagnosticsMonitorConfigurationElement( self.valid_config, "foo"), "bar")
def test_bogus_config(self): self.assertIsNone(LadUtil.getDiagnosticsMonitorConfigurationElement(self.bogus_config, "dummy"))
def test_entry_not_present(self): self.assertIsNone(LadUtil.getDiagnosticsMonitorConfigurationElement(self.missing_from_config, "dummy"))
def test_getResourceIdFromLadCfg(self): self.assertIsNone(LadUtil.getResourceIdFromLadCfg(self.missing_from_config)) res_id = LadUtil.getResourceIdFromLadCfg(self.valid_config) self.assertIsNotNone(res_id) self.assertIn("1111-2222-3333-4444", res_id)
def test_getFeatureWideSinksFromLadCfg(self): self.assertEqual(LadUtil.getFeatureWideSinksFromLadCfg(self.valid_config, 'syslogEvents'), ['sink2']) self.assertEqual(LadUtil.getFeatureWideSinksFromLadCfg(self.valid_config, 'performanceCounters'), ['sink1'])
def get_syslogEvents_setting(self): """ Get 'ladCfg/syslogEvents' setting from LAD 3.0 public settings. :return: A dictionary of syslog facility and minSeverity to monitor/ Refer to README.md for more details. """ return LadUtil.getDiagnosticsMonitorConfigurationElement(self.read_public_config('ladCfg'), 'syslogEvents')