Allow presets for message bodies

This lets users of simple_message_to_bus predefine items which should be
present in all message bodies this way:

export MSGBODY_PRESET="key1=value1 key2=value2"

This doesn't work with spaces in either keys or values, any quotation
will be used verbatim.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2021-09-07 15:09:55 +02:00
parent a3203d29d9
commit cb61463c26
4 changed files with 22 additions and 20 deletions

View file

@ -20,8 +20,8 @@
# not, see <http://www.gnu.org/licenses/>.
export MSGTOPIC_PREFIX=logging.stats
RUN_ID="$(uuidgen -r)"
simple_message_to_bus combinehttplogs.start run_id="$RUN_ID"
export MSGBODY_PRESET="loghost=$(hostname) run_id=$(uuidgen -r)"
simple_message_to_bus combinehttplogs.start
# Some constants / standard paths
LOGDIR=/var/log/hosts
@ -83,9 +83,9 @@ FILES=$( ls -1 ${PROXYLOG}/*access.log.xz | awk '{x=split($0,a,"/"); print a[x]}
for FILE in ${FILES}; do
TEMP=$(echo ${FILE} | sed 's/\.xz$//')
simple_message_to_bus combinehttplogs.logmerge.proxy.start run_id="$RUN_ID" log="$PROXYLOG" file="$FILE" target="$TARGET" temp="$TEMP"
simple_message_to_bus combinehttplogs.logmerge.proxy.start log="$PROXYLOG" file="$FILE" target="$TARGET" temp="$TEMP"
perl ${LOGMERGE} ${PROXYLOG}/${FILE} > ${TARGET}/${TEMP}
simple_message_to_bus combinehttplogs.logmerge.proxy.finish run_id="$RUN_ID" log="$PROXYLOG" file="$FILE" target="$TARGET" temp="$TEMP" result="$?"
simple_message_to_bus combinehttplogs.logmerge.proxy.finish log="$PROXYLOG" file="$FILE" target="$TARGET" temp="$TEMP" result="$?"
done
##
@ -94,9 +94,9 @@ FILES=$( ls -1 ${DL_LOG}/dl*access.log.xz | awk '{x=split($0,a,"/"); print a[x]}
for FILE in ${FILES}; do
TEMP=$(echo ${FILE} | sed 's/\.xz$//')
simple_message_to_bus combinehttplogs.logmerge.download.start run_id="$RUN_ID" proxylog="$DL_LOG" file="$FILE" target="$TARGET" temp="$TEMP"
simple_message_to_bus combinehttplogs.logmerge.download.start proxylog="$DL_LOG" file="$FILE" target="$TARGET" temp="$TEMP"
perl ${LOGMERGE} ${DL_LOG}/${FILE} > ${TARGET}/${TEMP}
simple_message_to_bus combinehttplogs.logmerge.download.finish run_id="$RUN_ID" proxylog="$DL_LOG" file="$FILE" target="$TARGET" temp="$TEMP" result="$?"
simple_message_to_bus combinehttplogs.logmerge.download.finish proxylog="$DL_LOG" file="$FILE" target="$TARGET" temp="$TEMP" result="$?"
done
##
@ -107,9 +107,9 @@ FILES=$( ls -1 ${PEOPLE}/fedora*access.log.xz | awk '{x=split($0,a,"/"); print a
for FILE in ${FILES}; do
TEMP=$(echo ${FILE} | sed 's/\.xz$//')
simple_message_to_bus combinehttplogs.logmerge.people.start run_id="$RUN_ID" proxylog="$PEOPLE" file="$FILE" target="$TARGET" temp="$TEMP"
simple_message_to_bus combinehttplogs.logmerge.people.start proxylog="$PEOPLE" file="$FILE" target="$TARGET" temp="$TEMP"
perl ${LOGMERGE} ${PEOPLE}/${FILE} > ${TARGET}/${TEMP}
simple_message_to_bus combinehttplogs.logmerge.people.finish run_id="$RUN_ID" proxylog="$PEOPLE" file="$FILE" target="$TARGET" temp="$TEMP" result="$?"
simple_message_to_bus combinehttplogs.logmerge.people.finish proxylog="$PEOPLE" file="$FILE" target="$TARGET" temp="$TEMP" result="$?"
done
# Now we link up the files into latest directory
@ -126,4 +126,4 @@ if [[ "$UPDATE_LATEST" && -d ${NFSDIR}/latest ]]; then
done
popd &> /dev/null
fi
simple_message_to_bus combinehttplogs.finish run_id="$RUN_ID"
simple_message_to_bus combinehttplogs.finish