OSADispatcherLog - file /var/log/rhn/osa-dispatcher.log

class insights.parsers.osa_dispatcher_log.OSADispatcherLog(context)[source]

Bases: LogFileOutput

Reads the OSA dispatcher log. Based on the LogFileOutput class.

Note

Please refer to its super-class insights.core.LogFileOutput

Works a bit like the XMLRPC log but the IP address always seems to be 0.0.0.0 and the module is always ‘osad’ - it’s more like what produced the log.

Sample log data:

2015/12/23 04:40:58 -04:00 28307 0.0.0.0: osad/jabber_lib.__init__
2015/12/23 04:40:58 -04:00 28307 0.0.0.0: osad/jabber_lib.setup_connection('Connected to jabber server', u'example.com')
2015/12/23 04:40:58 -04:00 28307 0.0.0.0: osad/osa_dispatcher.fix_connection('Upstream notification server started on port', 1290)
2015/12/23 04:40:58 -04:00 28307 0.0.0.0: osad/jabber_lib.process_forever
2015/12/27 22:48:50 -04:00 28307 0.0.0.0: osad/jabber_lib.main('ERROR', 'Error caught:')
2015/12/27 22:48:50 -04:00 28307 0.0.0.0: osad/jabber_lib.main('ERROR', 'Traceback (most recent call last)')

Example

>>> osa = shared[OSADispatcherLog]
>>> osa.get('__init__')
[{'raw_message': '2015/12/23 04:40:58 -04:00 28307 0.0.0.0: osad/jabber_lib.__init__',
 'timestamp': '2015/12/23 04:40:58 -04:00',
 'datetime': datetime.datetime(2015, 12, 23, 4, 40, 58),
 'pid': '28307', 'client_ip': '0.0.0.0', 'module': 'osad',
 'function': 'jabber_lib.__init__', 'info': None}
]
>>> osa.last()
{'raw_message': "2015/12/27 22:48:50 -04:00 28307 0.0.0.0: osad/jabber_lib.main('ERROR', 'Traceback (most recent call last)')",
 'timestamp': '2015/12/27 22:48:50 -04:00',
 'datetime': datetime.datetime(2015, 12, 27, 22, 48, 50), 'pid': '28307',
 'client_ip': '0.0.0.0', 'module': 'osad', 'function': 'jabber_lib.main',
 'info': "'ERROR', 'Traceback (most recent call last)'"}
>>> from datetime import datetime
>>> len(list(osa.get_after(datetime(2015, 12, 27, 22, 48, 0))))
2
last()[source]

Finds the last complete log line in the file. It looks for a line with a client IP address and parses the line to a dictionary.

Returns:

(dict) the last complete log line parsed to a dictionary.

time_format = '%Y/%m/%d %H:%M:%S'

The timestamp format assumed for the log files. A subclass can override this for files that have a different timestamp format. This can be:

  • A string in strptime() format.

  • A list of strptime() strings.

  • A dictionary with each item’s value being a strptime() string. This allows the item keys to provide some form of documentation.

  • A None value when there is no timestamp info in the log file