Skip to content

Commit

Permalink
Added more HMC log messages; Added debug flag for unknown
Browse files Browse the repository at this point in the history
Details:

* Added all HMC log messages. At this point, all log messages that ever occurred
  in dal13-01 or in wdc04-05 have been added.

* Added a debug flag DEBUG_CADF_ONLY_UNKNOWN that allows suppressing any
  log messages that are known, in order to surface those that are
  still unknown.
  This helps in completing the log message file.

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Nov 27, 2019
1 parent 9934d74 commit 8c70f42
Show file tree
Hide file tree
Showing 2 changed files with 842 additions and 69 deletions.
29 changes: 19 additions & 10 deletions zhmc_log_forwarder/zhmc_log_forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
# Debug flag: Include full HMC log record in CADF output
DEBUG_CADF_INCLUDE_FULL_RECORD = False

# Debug flag: Output only unknown HMC log messages in CADF output
DEBUG_CADF_ONLY_UNKNOWN = False


try:
textwrap.indent
Expand Down Expand Up @@ -1319,25 +1322,29 @@ def output_entries(self, log_entries, console):
dest_stream = getattr(sys, dest)
for row in sorted_table:
out_str = self.out_str(row, console)
print(out_str, file=dest_stream)
dest_stream.flush()
if out_str:
print(out_str, file=dest_stream)
dest_stream.flush()
else:
assert dest == 'syslog'
for row in sorted_table:
out_str = self.out_str(row, console)
try:
self.logger.info(out_str)
except Exception as exc:
raise ConnectionError(
"Cannot write log entry to syslog server at "
"{host}, port {port}/{porttype}: {msg}".
format(host=self.syslog_host, port=self.syslog_port,
porttype=self.syslog_porttype, msg=str(exc)))
if out_str:
try:
self.logger.info(out_str)
except Exception as exc:
raise ConnectionError(
"Cannot write log entry to syslog server at "
"{host}, port {port}/{porttype}: {msg}".
format(host=self.syslog_host, port=self.syslog_port,
porttype=self.syslog_porttype, msg=str(exc)))

def out_str(self, row, console):
"""
Return an output string for the specified row that fits the specified
output format.
If the row is not to be output, None is returned.
"""
format = self.fwd_parms['format']
if format == 'line':
Expand All @@ -1363,6 +1370,8 @@ def out_str(self, row, console):
target_type=None,
target_class=None
)
if DEBUG_CADF_ONLY_UNKNOWN and msg_info.action != 'unknown':
return None
msg_id = uuid.uuid4().urn.lstrip('urn:uuid:')
out_dict = OrderedDict([
("id", "zhmc_log_forwarder:{}".format(msg_id)),
Expand Down
Loading

0 comments on commit 8c70f42

Please sign in to comment.