2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-10-20 14:45:45 +00:00

Say when a named log source answered with nothing

An ipmi node named no source at all, so -s dropped every event, and a
log with no entries can never be named by one.
This commit is contained in:
Markus Hilger
2026-08-15 13:00:52 +02:00
parent 9cdcbe4046
commit c13a434246
3 changed files with 22 additions and 1 deletions
+11 -1
View File
@@ -201,10 +201,20 @@ elif wantsources is not None:
for node in nodes:
found = set(x.lower() for x in sources_seen.get(node, ()))
missing = wantsources - found
if missing and found:
if not missing:
continue
if found:
sys.stderr.write('{0}: no such log source: {1}, this node has {2}\n'
.format(node, ','.join(sorted(missing)),
','.join(sorted(sources_seen[node]))))
else:
# A log that holds no entries names no source, so an empty answer
# here is as often a quiet platform as a wrong name. Either way
# saying nothing would look like the log simply had nothing in it.
sys.stderr.write(
'{0}: no entries from any log source, so nothing could match '
'{1}\n'.format(node, ','.join(sorted(missing))))
exitcode |= 1
if options.lines and not listmode:
for node in nodes:
@@ -15,6 +15,11 @@ noisier than others. Reading gathers every log the platform describes as an
event log, wherever it keeps them, and `-s` narrows the output to the ones
asked for. `-s list` names the logs a node offers rather than showing entries.
A source is named by the entries that come from it, so a log that holds no
entries is not among them, and a node whose logs are all empty names none. An
ipmi managed node keeps its events in the one log the spec gives it, which is
reported as `SEL`.
Clearing is deliberately narrower than reading: it only touches the logs the
platform's own manager publishes, so a log that only a read reaches is never
destroyed by one. A selection cannot be cleared, so `-s` and `clear` are
@@ -39,6 +44,8 @@ refused together.
only show entries from the named logs, comma delimited and matched without
regard to case. `-s list` names the logs the node offers instead of showing
entries. A platform that named a log "list" would be shadowed by that.
Asking for a log the node named nothing from is reported on stderr and
exits non-zero, rather than looking like an empty log.
* `-h`, `--help`:
Show help message and exit
@@ -933,6 +933,10 @@ class IpmiHandler:
await self.output.put(msg.EventCollection(eventout, name=self.node))
def pyghmi_event_to_confluent(self, event):
# An ipmi platform keeps its events in one place and the spec has a
# name for it, so say so rather than leaving the source blank and
# having a caller asking for a named log get nothing back
event.setdefault('log_id', 'SEL')
event['severity'] = _str_health(event.get('severity', 'unknown'))
if 'event_data' in event:
event['event'] = '{0} - {1}'.format(