/
githubmirror
/
rsyslog
Обзор
Документация
Войти
/
githubmirror
/
rsyslog
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/template-jsonf-nested.sh
40 строк
1 KB
Rainer Gerhards
template: add jsonftree option for nested jsonf output
24 сен 2025, 19:12
Не верифицирован
24 сен 2025, 19:12
e9d4857
Код
Авторство
О чём код?
#!/bin/bash # added by AI agent to verify nested jsonf output; Released under ASL 2.0 . ${srcdir:=.}/diag.sh init generate_conf add_conf ' template(name="nested" type="list" option.jsonftree="on") { constant(outname="host.hostname" value="testhost" format="jsonf") constant(outname="host.ip" value="127.0.0.1" format="jsonf") constant(outname="event.dataset.name" value="syslog" format="jsonf") property(outname="event.original" name="msg" format="jsonf") } local4.* action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="nested") ' startup injectmsg 0 1 shutdown_when_empty wait_shutdown export EXPECTED_JSON='{"host": {"hostname": "testhost", "ip": "127.0.0.1"}, "event": {"dataset": {"name": "syslog"}, "original":" msgnum:00000000:"}}' python3 - "$RSYSLOG_OUT_LOG" <<'PY' import json import os import sys expected = json.loads(os.environ['EXPECTED_JSON']) with open(sys.argv[1], 'r', encoding='utf-8') as fh: actual = json.loads(fh.read()) if actual != expected: print('invalid response generated') print('################# actual JSON is:') print(json.dumps(actual, indent=2, sort_keys=True)) print('################# expected JSON was:') print(json.dumps(expected, indent=2, sort_keys=True)) sys.exit(1) PY exit_test