feat(host-events): host events, event channels as log sources, how a service's run ended (NetOrk/netork#2897)
- HostEventsMixin.get_host_events(since=None), declared: the events of a fixed set of kinds a host's own log recorded (unexpected shutdowns, system crashes, hardware errors, disk errors, programs and services that crashed), with HostEventDict, HostEventsDict and host_event(). - LogSourceDict: kind "eventlog" for a Windows event channel, named by the new optional channel field (eventlog_source, LOG_SOURCE_KINDS). - ServiceDict: optional result, exit_code, trigger_start and account; exported.
This commit is contained in:
1 parent
2df46741f2
commit
6c273ea346
10 files changed
+458
-7
No files matched your search
@@ -412,6 +412,31 @@ driver mixes it in and supplies `run_command`.
|
||||
list only when nothing is pending; netOrk keeps "pending since" per package, and an empty
|
||||
list for "don't know" would reset it.
|
||||
|
||||
A Windows host has no journal and no log files a process holds open: its logs are its event
|
||||
channels. A driver for it implements `get_log_sources` itself and lists each channel as a
|
||||
source of kind `"eventlog"` (`eventlog_source(channel, path, size, modified)`, one of
|
||||
`LOG_SOURCE_KINDS`), named by `channel` -- the name a log reader takes (CrowdSec's
|
||||
`event_channel`, Wazuh's `eventchannel`) -- with its `.evtx` file as `path`. `journald` is
|
||||
False there and `forwarding` None.
|
||||
|
||||
`HostEventsMixin` (`get_host_events(since=None)`) only declares: what a host's own log
|
||||
recorded that says something is wrong with it, read from its event log or its journal by the
|
||||
driver. A fixed set of kinds (`HOST_EVENT_KINDS`: an unexpected shutdown, a system crash with
|
||||
its stop code, a fatal or a corrected hardware error, a disk or file system error, a program's
|
||||
or a service's crash), never the log itself; each event with its time, what it is about in
|
||||
words that do not depend on the host's language (`subject`), where it was recorded and the
|
||||
host's message cut to `HOST_EVENT_MESSAGE_CHARS` (`host_event()` builds one). The reading
|
||||
covers `HOST_EVENT_WINDOW_DAYS` days unless the caller names a start; `capped` names the kinds
|
||||
read up to the driver's bound, `unread` those it could not read this time. Whether an event is
|
||||
a problem is the application's to decide.
|
||||
|
||||
`ServiceDict` says, beside whether a service runs, how its last run ended where the driver can
|
||||
tell (all optional): `result` in systemd's `Result` words (`SERVICE_RESULT_SUCCESS`,
|
||||
`SERVICE_RESULT_EXIT_CODE`, `signal` …; None where it has not run since the host started),
|
||||
`exit_code`, `trigger_start` for a service a trigger starts and idleness stops, and the
|
||||
`account` it runs as. A service that is enabled, not running and whose last run did not
|
||||
succeed has failed; one stopped on purpose has not.
|
||||
|
||||
`SystemdServicesMixin` (`get_services`, `manage_service`) is mixed in the same way, by
|
||||
the drivers whose host runs systemd. Listing the services, checking a unit name and
|
||||
reading an action's exit status are the same on every such host, so they are concrete
|
||||
|
||||
Reference in new issue
Block a user