Do not accidentaly overwrite DATA_FILE

the ollect_rabbitmq_stats.sh file correctly
creates and uses a tempfile, except it writes
the colums headers to DATA_FILE, which is both
non-atomic and overwritten a few lines later with a mv.

Change-Id: I59a9279e67da26b483a0cac539abc8e40da3622b
Closes-Bug: #1806635
This commit is contained in:
Chris MacNaughton 2018-12-04 12:05:53 +01:00
parent 065914d696
commit cdef3f6885
1 changed files with 1 additions and 1 deletions

View File

@ -44,7 +44,7 @@ if [ ! -d $LOG_DIR ]; then
mkdir -p $LOG_DIR
fi
TMP_DATA_FILE=$(mktemp -p ${DATA_DIR})
echo "#Vhost Name Messages_ready Messages_unacknowledged Messages Consumers Memory Time" > $DATA_FILE
echo "#Vhost Name Messages_ready Messages_unacknowledged Messages Consumers Memory Time" > ${TMP_DATA_FILE}
/usr/sbin/rabbitmqctl -q list_vhosts | \
while read VHOST; do
/usr/sbin/rabbitmqctl -q list_queues -p $VHOST name messages_ready messages_unacknowledged messages consumers memory | \