Unix events are observer objects that run concurrently with commands, scanning connection output line-by-line and firing when a condition is met. Unlike commands, events do not send anything to the connection — they only observe. All Unix events inherit from eitherDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nokia/moler/llms.txt
Use this file to discover all available pages before exploring further.
GenericUnixLineEvent or GenericUnixTextualEvent.
Events return a list of occurrence dicts. Each occurrence contains
line, matched, groups, named_groups, and time. The till_occurs_times parameter controls how many occurrences to collect before the event is considered complete (-1 means run indefinitely).Event list
| Class | Module | What it detects |
|---|---|---|
Wait4prompt | moler.events.unix.wait4prompt | A specific shell prompt regex |
Wait4prompts | moler.events.unix.wait4prompts | One of multiple prompt regexes, returning state name |
PingResponse | moler.events.unix.ping_response | Successful ICMP reply lines |
PingNoResponse | moler.events.unix.ping_no_response | ICMP no-answer / unreachable lines |
LastLogin | moler.events.unix.last_login | Last login: ... from ... |
LastFailedLogin | moler.events.unix.last_failed_login | Last failed login messages |
FailedLoginCounter | moler.events.unix.failed_login_counter | Failed login count lines |
Shutdown | moler.events.unix.shutdown | System shutdown announcement |
WarningDefaultPassword | moler.events.unix.warning_default_password | Default-password warnings |
AdviseToChangeYourPassword | moler.events.unix.advise_to_change_your_password | Password change advisories |
PrivateSystem | moler.events.unix.private_system | Private system / authorised-use notices |
UBootCrtm | moler.events.unix.u_boot_crtm | U-Boot CRTM boot sequence output |
Detailed reference
Wait4prompt — moler.events.unix.wait4prompt
The most commonly used Unix event. Waits for a specific prompt pattern to appear on the connection. Internally delegates to Wait4 with match='any'.
Moler connection to observe.
Regex pattern to match the expected prompt.
How many times the prompt must be seen before the event completes. Default
-1 (run indefinitely).Runner used to execute the event.
| Key | Type | Description |
|---|---|---|
line | str | The full line that matched |
matched | str | The substring matched by the prompt regex |
groups | tuple | Unnamed capture groups from the regex |
named_groups | dict | Named capture groups from the regex |
time | datetime | Timestamp when the match occurred |
Wait4prompts — moler.events.unix.wait4prompts
Like Wait4prompt, but watches for multiple possible prompts simultaneously and returns the prompt’s state name alongside the match. Useful for state-machine-based connection management.
Moler connection to observe.
Mapping of prompt regex (str or compiled) → state name string. E.g.
{r'host:.*#': 'UNIX_ROOT', r'host:.*\$': 'UNIX_USER'}.Number of occurrences before completion. Default
-1.| Key | Type | Description |
|---|---|---|
line | str | Full matched line |
matched | str | Matched substring |
prompt_regex | str | Pattern string of the matching prompt |
state | str | State name from the prompts dict |
time | datetime | Timestamp of the match |
PingResponse — moler.events.unix.ping_response
Fires whenever a successful ICMP reply line ("N bytes from ..." ) appears in the output. Useful for monitoring connectivity while a long-running ping command executes.
Moler connection to observe.
Number of occurrences. Default
-1.r'\d+ bytes from.+'
PingNoResponse — moler.events.unix.ping_no_response
Fires on no answer yet for icmp_seq=N or Destination Host Unreachable lines.
Moler connection to observe.
Number of occurrences. Default
-1.r'(no answer yet for.*)|(.*Destination Host Unreachable)'
LastLogin — moler.events.unix.last_login
Parses Last login: <date> from <host> lines into structured data.
Result list item keys
| Key | Type | Description |
|---|---|---|
time | datetime | Time the event was detected |
host | str | Source host/IP from the login message |
date_raw | str | Raw date string from the message |
date | datetime | Parsed datetime of the last login |
Shutdown — moler.events.unix.shutdown
Detects system shutdown announcements matching system is going down for <reason> at <time>.
Result list item keys: line, matched, groups (tuple of (reason, time_string)), named_groups, time.
Using events with callbacks
Events can be used either synchronously (blocking untiltill_occurs_times is reached) or asynchronously with callbacks: