mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-19 21:02:57 +02:00
Work towards full completion of the module’s interface as it exits PoC. The new name senderid (formerly: template) matches intent (identify a sender, not an output format) and avoids confusion. Also make state persistence safer via atomic writes. Merged a bit pre-completion in order to get a static analyzer fix into the main code base. Some additional cleanup PR will follow. State is much cleaner now than in PoC. Impact: Configs must use senderid=; statefile is now required. Tests and docs updated. Before/After: action(... template="name") -> action(... senderid="name"). Technical details: - Replace the config parameter and instance field; drop legacy template parsing in parseSelectorAct. The module now reads only senderid=. - Enforce required statefile (descriptor + runtime) and cache a temp path "<statefile>.tmp" to ensure rename() is atomic. Provide a one-time fallback build if the cache is missing (e.g., reload flow). - Add built-in template "StdOmSenderTrack-senderid" yielding "%fromhost-ip%" and use it as the default senderid template. - Improve memory ownership (free cached temp path/default template) and keep existing locking/queue semantics unchanged. - Update tests to use senderid= and prune PoC doc note accordingly. see also: https://github.com/rsyslog/rsyslog/issues/5599
32 lines
983 B
Bash
Executable File
32 lines
983 B
Bash
Executable File
#!/bin/bash
|
|
. ${srcdir:=.}/diag.sh init
|
|
export NUMMESSAGES=2
|
|
export QUEUE_EMPTY_CHECK_FUNC=wait_file_lines
|
|
|
|
cat > $RSYSLOG_DYNNAME.sendertrack <<'JSON'
|
|
[
|
|
{"sender":"sender1.example.net","messages":5,"firstseen":1600000000,"lastseen":1600000000}
|
|
]
|
|
JSON
|
|
|
|
generate_conf
|
|
add_conf '
|
|
module(load="../plugins/omsendertrack/.libs/omsendertrack")
|
|
|
|
template(name="hostname" type="string" string="%hostname%")
|
|
template(name="outfmt" type="string" string="%msg:F,58:2%\n")
|
|
action(type="omsendertrack" senderid="hostname" statefile="'$RSYSLOG_DYNNAME'.sendertrack")
|
|
:msg, contains, "msgnum:" action(type="omfile" template="outfmt" file="'$RSYSLOG_OUT_LOG'")
|
|
'
|
|
|
|
startup
|
|
injectmsg_literal '<167>Mar 1 01:00:00 sender1.example.net tag msgnum:00000000:'
|
|
injectmsg_literal '<167>Mar 1 01:00:00 sender1.example.net tag msgnum:00000001:'
|
|
shutdown_when_empty
|
|
wait_shutdown
|
|
|
|
grep '"sender":"sender1.example.net"' $RSYSLOG_DYNNAME.sendertrack
|
|
grep '"messages":7' $RSYSLOG_DYNNAME.sendertrack
|
|
|
|
exit_test
|