RTFM · Healthchecks
lb.saphira.sendexpect.tcp: the custom-protocol escape hatch
For every protocol nobody wrote a check for: send exact bytes, demand a matching answer. Binary or text, fixed or hex, with a configurable pause between connect and send; this is the check you write against in an afternoon.
What it proves
Whatever transaction you define: the check connects to real:$4, sends your payload, accumulates the response, and is healthy only when the response matches your regex within the timeout. The regex runs over the accumulated buffer (latin-1, dot-matches-newline), so multi-packet answers work naturally.
How it works
The probe engine's sendexpect probe in TCP mode. Payload sources, in priority order: LB_SAPHIRA_SEND (text), LB_SAPHIRA_SEND_HEX (hex, spaces and colons ignored), LB_SAPHIRA_SEND_FILE (raw file; the escape hatch's escape hatch for long binary frames). LB_SAPHIRA_DELAY sleeps between connect and send for protocols that need the server to speak first.
Waiting for a banner? Leave SEND unset and use the ssh-style banner probe via saphira-lb-probe banner, or just set EXPECT and SEND together for a full conversation.
Configuration
| Variable | Default | Meaning |
|---|---|---|
| LB_SAPHIRA_SEND / SEND_HEX / SEND_FILE | (required) | The payload: one of the three |
| LB_SAPHIRA_EXPECT | (required) | Regex the accumulated response must match |
| LB_SAPHIRA_DELAY | 0 | Seconds between connect and send |
| LB_SAPHIRA_TIMEOUT | 3 | Whole-exchange deadline |
| (target port) | $4, else $2 | Any TCP port |
Wiring it up
# ldirectord.cf - legacy ERP listener
virtual = 203.0.113.10:7777
protocol = tcp
scheduler = lc
real = 192.168.20.140:7777 gate 1
checktype = external
checkcommand = "/var/lib/lb/saphira/lb.saphira.sendexpect.tcp"
# /etc/saphira/lb-healthchecks.d/sendexpect.tcp/erp.conf
LB_SAPHIRA_SEND_HEX=01 00 00 00
LB_SAPHIRA_EXPECT=^ACK
Run it by hand
LB_SAPHIRA_SEND='PING' LB_SAPHIRA_EXPECT='PONG' \
/var/lib/lb/saphira/lb.saphira.sendexpect.tcp erp 7777 192.168.20.140 7777
echo $?
# 0 = reply matched
# 1 = connect refused, timeout, or reply never matched
# 2 = payload or expect not configured
Failure modes
- Timeout mid-exchange: the server accepted and went quiet: the payload may be wrong for the dialect
- Never matched: right service, wrong regex: debug with saphira-lb-probe sendexpect directly and watch the reply
- exit 2: missing payload or expect: the check refuses to guess
Did we miss something?
If this page left something unanswered, found an error, or there is another subject you would like documented, tell us. Saphira’s documentation grows from real problems people need to solve.
Send feedback or request a new section →
Prefer not to do it yourself?
Everything needed to do the work yourself is documented here and remains free; we charge for human time, not for withholding knowledge. Sometimes the missing resource is simply time. The same people who build Saphira can provide paid professional help with implementation, migration, troubleshooting and administration.