Documentation
¶
Overview ¶
Package unitmon lists the units a systemd manager reports failed and tells when any unit's ActiveState may have changed, over D-Bus. One Monitor watches one manager: the system manager on the system bus or the user manager on the session bus. Policy (notify, clear, log) is the caller's: this package only reports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor lists one systemd manager's failed units and reports when a unit's ActiveState may have changed. It is safe for concurrent use.
func Absent ¶
func Absent() *Monitor
Absent returns a Monitor for a manager that is not watched (no bus, the monitor disabled, or the manager not running): Present is false, Failed is empty, neither returns an error, and Changed never fires.
func New ¶
New watches the systemd manager on conn, a bus connection the caller keeps open and closes. It adds match rules for unit ActiveState changes and UnitRemoved, then calls Manager.Subscribe, without which systemd emits no unit signal. Changes that happen before New returns are not reported: list them with Failed after New.
A failed match rule or Subscribe is logged once at WARN naming the bus name and leaves Changed silent; Present and Failed still work. A Subscribe refused because nothing owns the name (the manager is absent) logs nothing, so the caller's own report of the absence is the only line. Nothing else is ever logged. The caller passes log.With("manager", ...) so the WARN names the manager. A nil log discards.
func (*Monitor) Changed ¶
func (m *Monitor) Changed() <-chan struct{}
Changed fires after the manager reports a unit ActiveState change or an unloaded unit. Changes that arrive before the receiver reads coalesce into one. The channel is closed when the bus connection is lost (or closed by the caller); it is never closed by Absent or after a failed setup, where it simply never fires.